Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // $pMySQL-ExecuteSQL() function
- public function ExecuteSQL( $sSQLQuery ) {
- $this->sLastQuery = $sSQLQuery;
- $this->aResult = mysql_query( $sSQLQuery, $this->pDBLink );
- if( $this->aResult ) {
- $this->iRecords = @mysql_num_rows( $this->aResult );
- $this->iAffected = @mysql_affected_rows( $this->pDBLink );
- return true;
- } else {
- $this->sLastError = mysql_error( $this->pDBLink );
- return false;
- }
- }
- // GetLanguageByLCID()
- function GetLanguageByLCID( $nLCID ) {
- global $pMySQL;
- if ( !is_int( $nLCID ) )
- return 'Unknown';
- if ( $pMySQL->Select( 'Locales', array( 'LCID' => $nLCID ), '', '0,1' ) )
- return $pMySQL->aArrayedResult['DisplayName'];
- return 'Unknown';
- }
- $aLanguageChartData = array();
- $nLangTotal = 0;
- $sSQLQuery = "SELECT s.*, u.* FROM `".$pMySQL->sPrefix."Sessions` AS s, `".$pMySQL->sPrefix."UniqueUsers` AS u ";
- $sSQLQuery .= "WHERE s.UniqueUserId = u.UniqueUserId ";
- $sSQLQuery .= "AND s.ApplicationId = '".$sAppId."' " . ( ( $sAppVer != "all" ) ? ( "AND s.ApplicationVersion = '".$sAppVer."' " ) : ( "" ) );
- $sSQLQuery .= "AND s.StartApp BETWEEN '".$nStartTime."' AND '".$nEndTime."' ";
- $pMySQL->ExecuteSQL( $sSQLQuery );
- $aLanguagesTotal = array();
- if ( $pMySQL->iRecords == 1 )
- $aLanguagesTotal[] = $pMySQL->ArrayResult();
- else if ( $pMySQL->iRecords > 1 )
- $aLanguagesTotal = $pMySQL->ArrayResults();
- foreach ( $aLanguagesTotal as $aLanguageRow ) {
- $nLCID = intval( $aLanguageRow['LangID'] );
- if ( !array_key_exists( $nLCID, $aLanguageChartData ) ) {
- $aLanguageChartData[$nLCID] = array(
- 'total' => 0,
- 'unique' => 0
- );
- }
- $aLanguageChartData[$nLCID]['total']++;
- $nLangTotal++;
- }
- $sSQLQuery = "SELECT s.*, u.* FROM `".$pMySQL->sPrefix."Sessions` AS s, `".$pMySQL->sPrefix."UniqueUsers` AS u ";
- $sSQLQuery .= "WHERE s.UniqueUserId = u.UniqueUserId ";
- $sSQLQuery .= "AND s.ApplicationId = '".$sAppId."' " . ( ( $sAppVer != "all" ) ? ( "AND s.ApplicationVersion = '".$sAppVer."' " ) : ( "" ) );
- $sSQLQuery .= "AND s.StartApp BETWEEN '".$nStartTime."' AND '".$nEndTime."' ";
- $sSQLQuery .= "GROUP BY s.UniqueUserId";
- $pMySQL->ExecuteSQL( $sSQLQuery );
- $aLanguagesUnique = array();
- if ( $pMySQL->iRecords == 1 )
- $aLanguagesUnique[] = $pMySQL->ArrayResult();
- else if ( $pMySQL->iRecords > 1 )
- $aLanguagesUnique = $pMySQL->ArrayResults();
- foreach ( $aLanguagesUnique as $aLanguageRow ) {
- $nLCID = intval( $aLanguageRow['LangID'] );
- $aLanguageChartData[$nLCID]['unique']++;
- }
- ?>
- // How the data is outputted in HTML
- <table style="width: 100%" class="datatable">
- <thead>
- <tr>
- <th>Language</th>
- <th>Executions</th>
- <th>Unique</th>
- <th>Percentage of Executions</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach ( $aLanguageChartData as $nLCID => $aData ) :
- $sLanguage = GetLanguageByLCID( $nLCID ); // Another SQL Query, see function at top
- $sPercentTotal = CalculatePercent( $aData['total'], $nLangTotal ) . '%';
- ?>
- <tr>
- <td><?php echo $sLanguage ?></td>
- <td><?php echo $aData['total'] ?></td>
- <td><?php echo $aData['unique'] ?></td>
- <td><div style="width: 85%" class="usagebox left"><div style="width: <?php echo $sPercentTotal ?>" class="lowbar"></div></div><span style="padding: 8px" class="right"><?php echo $sPercentTotal ?></span></td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement