Advertisement
Guest User

NES_stats.php

a guest
Dec 12th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.64 KB | None | 0 0
  1. <?php
  2.  
  3. if (!mysql_connect('**', '***', '***'))
  4.     die(mysql_errno() . ': ' . mysql_error());
  5. if (!mysql_select_db('***'))
  6.     die(mysql_errno() . ': ' . mysql_error());
  7.  
  8. function db_escape($values, $htmlspecialchars = false) {
  9.     if (is_array($values)) {
  10.         foreach ($values as $key => $value) {
  11.             $values[$key] = db_escape($value, $htmlspecialchars);
  12.         }
  13.     }
  14.     else if ($values === null) {
  15.         $values = '0';
  16.     }
  17.     else if (is_bool($values)) {
  18.         $values = $values ? 1 : 0;
  19.     }
  20.     else if (!is_numeric($values)) {
  21.         $values = mysql_real_escape_string(($htmlspecialchars ? htmlspecialchars($values, ENT_QUOTES) : $values));
  22.         $values = "'" . $values . "'";
  23.     }
  24.     return $values;
  25. }
  26.  
  27. if (!isset($_GET['NES'])) {
  28.     if (isset($_GET['PNG'])) {
  29.         $addLinkToPostReference = 0;
  30.         $showPostOnMouseOverReference = 0;
  31.         $showPostOnMouseOverReferenceLeft = 0;
  32.         $showPostOnMouseOverReferenceMini = 0;
  33.         $improvedQuoteSetting = 0;
  34.         $applyTargetBlank = 0;
  35.         $applyTargetBlankOnlyOutgoing = 0;
  36.         $fixFailTagsSetting = 0;
  37.         $showUrlImages = 0;
  38.         $embedYouTubeUrls = 0;
  39.         $embedYouTubeUrlsNotInQuote = 0;
  40.         $narrowSite = 0;
  41.        
  42.         //Include phpMyGraph class
  43.         require_once('phpMyGraph5.0.php');
  44.        
  45.         if (!$query = mysql_query('SELECT * FROM `NES_stats`'))
  46.             die(mysql_errno() . ': ' . mysql_error());
  47.        
  48.         $total = mysql_num_rows($query);
  49.        
  50.         while ($row = mysql_fetch_array($query)) {
  51.             $addLinkToPostReference += $row['addLinkToPostReference'];
  52.             $showPostOnMouseOverReference += $row['showPostOnMouseOverReference'];
  53.             $showPostOnMouseOverReferenceLeft += $row['showPostOnMouseOverReferenceLeft'];
  54.             $showPostOnMouseOverReferenceMini += $row['showPostOnMouseOverReferenceMini'];
  55.             $improvedQuoteSetting += $row['improvedQuoteSetting'];
  56.             $applyTargetBlank += $row['applyTargetBlank'];
  57.             $applyTargetBlankOnlyOutgoing += $row['applyTargetBlankOnlyOutgoing'];
  58.             $fixFailTagsSetting += $row['fixFailTagsSetting'];
  59.             $showUrlImages += $row['showUrlImages'];
  60.             $embedYouTubeUrls += $row['embedYouTubeUrls'];
  61.             $embedYouTubeUrlsNotInQuote += $row['embedYouTubeUrlsNotInQuote'];
  62.             $narrowSite += $row['narrowSite'];
  63.         }
  64.        
  65.         //Create data array for graph
  66.         $data = array
  67.         (
  68.             'a'=> round($addLinkToPostReference / $total * 100),
  69.             'b'=> round($showPostOnMouseOverReference / $total * 100),
  70.             'c'=> round($showPostOnMouseOverReferenceLeft / $total * 100),
  71.             'd'=> round($showPostOnMouseOverReferenceMini / $total * 100),
  72.             'e'=> round($improvedQuoteSetting / $total * 100),
  73.             'f'=> round($applyTargetBlank / $total * 100),
  74.             'g'=> round($applyTargetBlankOnlyOutgoing / $total * 100),
  75.             'h'=> round($fixFailTagsSetting / $total * 100),
  76.             'i'=> round($showUrlImages / $total * 100),
  77.             'j'=> round($embedYouTubeUrls / $total * 100),
  78.             'k'=> round($embedYouTubeUrlsNotInQuote / $total * 100),
  79.             'l'=> round($narrowSite / $total * 100)
  80.         );
  81.        
  82.         $cfg['title'] = 'Angivet i %';
  83.         $cfg['average-line-visible'] = 0;
  84.        
  85.         //Create new graph
  86.         $graph = new phpMyGraph();
  87.        
  88.         Header("Content-Type: image/png");
  89.        
  90.         //Parse vertical line graph
  91.         $graph->parseVerticalColumnGraph($data, $cfg);
  92.     } else {
  93.         ?>
  94.         <img src="http://d9projects.com/NES_stats.php?PNG"><br>
  95.         a - addLinkToPostReference<br>
  96.         b - showPostOnMouseOverReference<br>
  97.         c - showPostOnMouseOverReferenceLeft<br>
  98.         d - showPostOnMouseOverReferenceMini<br>
  99.         e - improvedQuoteSetting<br>
  100.         f - applyTargetBlank<br>
  101.         g - applyTargetBlankOnlyOutgoing<br>
  102.         h - fixFailTagsSetting<br>
  103.         i - showUrlImages<br>
  104.         j - embedYouTubeUrls<br>
  105.         k - embedYouTubeUrlsNotInQuote<br>
  106.         l - narrowSite
  107.         <?
  108.     }
  109. } else {
  110.     $hash = db_escape($_GET['hash']);
  111.    
  112.     if (!$query = mysql_query('SELECT * FROM `NES_stats` WHERE `hash` = ' . $hash))
  113.         die(mysql_errno() . ': ' . mysql_error());
  114.    
  115.     if (mysql_num_rows($query) == 0) {
  116.         $hash = md5(uniqid());
  117.         if (!mysql_query('INSERT INTO `NES_stats` (hash) VALUES (\'' . $hash . '\')'))
  118.             die(mysql_errno() . ': ' . mysql_error());
  119.         die('localStorage["NES_statHash2"] = \'' . $hash . '\'; uploadStatistik();');
  120.     }
  121.    
  122.     $addLinkToPostReference = db_escape($_GET['addLinkToPostReference']);
  123.     $showPostOnMouseOverReference = db_escape($_GET['showPostOnMouseOverReference']);
  124.     $showPostOnMouseOverReferenceLeft = db_escape($_GET['showPostOnMouseOverReferenceLeft']);
  125.     $showPostOnMouseOverReferenceMini = db_escape($_GET['showPostOnMouseOverReferenceMini']);
  126.     $improvedQuoteSetting = db_escape($_GET['improvedQuoteSetting']);
  127.     $applyTargetBlank = db_escape($_GET['applyTargetBlank']);
  128.     $applyTargetBlankOnlyOutgoing = db_escape($_GET['applyTargetBlankOnlyOutgoing']);
  129.     $fixFailTagsSetting = db_escape($_GET['fixFailTagsSetting']);
  130.     $showUrlImages = db_escape($_GET['showUrlImages']);
  131.     $embedYouTubeUrls = db_escape($_GET['embedYouTubeUrls']);
  132.     $embedYouTubeUrlsNotInQuote = db_escape($_GET['embedYouTubeUrlsNotInQuote']);
  133.     $narrowSite = db_escape($_GET['narrowSite']);
  134.    
  135.     if (!$query = mysql_query(
  136. <<<CakeIsNigh
  137. UPDATE `NES_stats` SET
  138. addLinkToPostReference=$addLinkToPostReference,
  139. showPostOnMouseOverReference=$showPostOnMouseOverReference,
  140. showPostOnMouseOverReferenceLeft=$showPostOnMouseOverReferenceLeft,
  141. showPostOnMouseOverReferenceMini=$showPostOnMouseOverReferenceMini,
  142. improvedQuoteSetting=$improvedQuoteSetting,
  143. applyTargetBlank=$applyTargetBlank,
  144. applyTargetBlankOnlyOutgoing=$applyTargetBlankOnlyOutgoing,
  145. fixFailTagsSetting=$fixFailTagsSetting,
  146. showUrlImages=$showUrlImages,
  147. embedYouTubeUrls=$embedYouTubeUrls,
  148. embedYouTubeUrlsNotInQuote=$embedYouTubeUrlsNotInQuote,
  149. narrowSite=$narrowSite
  150. WHERE `hash` = $hash
  151. CakeIsNigh
  152.     ))
  153.         die(mysql_errno() . ': ' . mysql_error());
  154. }
  155. ?>
  156.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement