Add SearchPostgres.php
[lhc/web/wiklou.git] / profileinfo.php
index 91e6589..c7305b3 100644 (file)
@@ -21,7 +21,6 @@
      OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      SOFTWARE.
 
-     $Id$
 -->
 <html>
 <head>
 $wgDBadminuser = $wgDBadminpassword = $wgDBserver = $wgDBname = $wgEnableProfileInfo = false;
 
 define("MEDIAWIKI", 1);
+if ( isset( $_REQUEST['GLOBALS'] ) ) {
+       print $GLOBALS;
+       echo '<a href="http://www.hardened-php.net/index.76.html">$GLOBALS overwrite vulnerability</a>';
+       die( -1 );
+}
 
 require_once("./includes/Defines.php");
 require_once("./LocalSettings.php");
 require_once("./AdminSettings.php");
 
-if (!$wgEnableProfileInfo)
-       die("disabled");
+if (!$wgEnableProfileInfo) {
+       wfDie("disabled");
+}
 
 foreach (array("wgDBadminuser", "wgDBadminpassword", "wgDBserver", "wgDBname") as $var)
        if ($$var === false)
-               die("AdminSettings.php not correct");
+               wfDie("AdminSettings.php not correct");
 
 $expand = array();
 if (isset($_REQUEST['expand']))
@@ -152,13 +157,13 @@ if (isset($_REQUEST['sort']) && in_array($_REQUEST['sort'], $sorts))
        $sort = $_REQUEST['sort'];
 
 $dbh = mysql_connect($wgDBserver, $wgDBadminuser, $wgDBadminpassword)
-       or die("mysql server failed: " . mysql_error());
-mysql_select_db($wgDBname, $dbh) or die(mysql_error($dbh));
+       or wfDie("mysql server failed: " . mysql_error());
+mysql_select_db($wgDBname, $dbh) or wfDie(mysql_error($dbh));
 $res = mysql_query("
        SELECT pf_count, pf_time, pf_name
        FROM profiling
        ORDER BY pf_name ASC
-", $dbh) or die("query failed: " . mysql_error());
+", $dbh) or wfDie("query failed: " . mysql_error());
 
 if (isset($_REQUEST['filter']))
        $filter = $_REQUEST['filter'];
@@ -196,6 +201,8 @@ function makeurl($_filter = false, $_sort = false, $_expand = false) {
 }
 
 $points = array();
+$queries = array();
+$sqltotal = 0.0;
 
 $last = false;
 while (($o = mysql_fetch_object($res)) !== false) {
@@ -208,9 +215,19 @@ while (($o = mysql_fetch_object($res)) !== false) {
                }
        }
        $last = $next;
-       $points[] = $next;
+       if (preg_match("/^query: /", $next->name())) {
+               $sqltotal += $next->time();
+               $queries[] = $next;
+       } else {
+               $points[] = $next;
+       }
 }
 
+$s = new profile_point("SQL Queries", 0, $sqltotal);
+foreach ($queries as $q)
+       $s->add_child($q);
+$points[] = $s;
+
 usort($points, "compare_point");
 
 foreach ($points as $point) {
@@ -230,4 +247,4 @@ mysql_close($dbh);
 
 ?>
 </body>
-</html:
+</html>