3v4l.org

run code in 300+ PHP versions simultaneously
<?php session_start(); require_once "_mysql_utilities.php"; $operation_id = isset( $_REQUEST['op'] ) ? strval( trim( $_REQUEST['op'] ) ) : 'none'; $category_id = ( isset( $_REQUEST['cat'] ) && trim( $_REQUEST['cat'] ) != "" ) ? intval( $_REQUEST['cat'] ) : null; $search_phrases = isset( $_REQUEST['kq'] ) ? strval( trim( $_REQUEST['kq'] ) ) : null; $metadata_phrases = isset( $_REQUEST['mq'] ) ? strval( trim( $_REQUEST['mq'] ) ) : null; $page_index = isset( $_REQUEST['p'] ) ? intval( $_REQUEST['p'] ) : 0; $items_per_page = isset( $_REQUEST['items_per_page'] ) ? intval( $_REQUEST['items_per_page'] ) : 50; $baseURL = $_SERVER['REQUEST_URI']; $baseURL .= "?cat=".urlencode( $category_id ); $baseURL .= "&kq=".urlencode( $search_phrases ); $baseURL .= "&mq=".urlencode( $metadata_phrases ); $conditionList = array("1"); // "1" always evaluates as true in MySQL $queryBase = <<<BaseQuery FROM image_gallery AS i WHERE BaseQuery; if ( $category_id !== null ) { $conditionList[] = "i.category = {$category_id}"; } if ( $search_phrases !== null ) { $phraseList = explode(",", $search_phrases ); foreach( $phraseList as $searchPhrase ) { $conditionList[] = "i.keywords LIKE '%".mysql_escape_mimic( trim( $searchPhrase ) )."%'"; } } if ( $metadata_phrases !== null ) { $phraseList = explode(",", $metadata_phrases ); foreach( $phraseList as $searchPhrase ) { $conditionList[] = "i.metadata LIKE '%".mysql_escape_mimic( trim( $searchPhrase ) )."%'"; } } include "config.php"; switch( $operation_id ) { case "delete" : if ( ! $isAdmin ) die("Access Error: You are not allowed to perform this action!" ); $imageID = isset( $_REQUEST['image_id'] ) ? intval( $_REQUEST['image_id'] ) : 0; if ( $imageID != 0 ) { $deleteSQL = "DELETE FROM image_gallery WHERE id = {$imageID} LIMIT 1"; if ( mysql_query( $deleteSQL ) === false || mysql_affected_rows() != 1 ) { // This shouldn't happen unless the user refreshes a page with a delete operation in its URL } } break; } $queryConditions = implode(" AND ", $conditionList ); $resultCount = mysql_query_scalar( "SELECT COUNT(*) $queryBase $queryConditions" ); $resultData = array(); if ( $resultCount > 0 ) { $offset = intval( $page_index * $items_per_page ); $pageCount = intval( $resultCount / $items_per_page ) - 1; $resultData = mysql_query_assoc( "SELECT * $queryBase $queryConditions LIMIT $items_per_page OFFSET $offset", 'id' ); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/text.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>IP Callison Intranet - Image Gallery</title> <!-- InstanceEndEditable --> <link rel="stylesheet" href="css/reset.css" type="text/css"> <link rel="stylesheet" href="css/standard.css" type="text/css"> <link rel="stylesheet" href="css/text-page.css" type="text/css"> <!--[if IE]> <link href="css/ie.css" rel="stylesheet" type="text/css"> <![endif]--> <!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable --> </head> <body> <div id="container"> <div class="page-header"> <img src="images/ipc_logo_new.png" /> </div> <div> <a href="index.html"><img src="images/back_dark.gif" id="back_button" /></a> </div> <div id="picture-gallery"> <h1><span class="header">Image Gallery</span></h1> <p>Click an image to view larger and download. <?php if ( $isAdmin ) /* see config.php and login.php */ { ?> You are logged in as an administrative user, so you will be able to delete images by clicking the 'X' button below each. <?php } ?> </p> <!--<h2>Field Images</h2>--> <div class="picture-section"> <div id="sidebar" style="height:auto;" > <div id="picture_gallery_search"> <form name="gallery_search" action="gallery.php" method="get"> <div class="row"> <label for="kq">Filter by summary:</label> <input type="text" name="kq" id="kq" value="<?php echo $search_phrases;?>" /> </div> <div class="row"> <label for="mq">Filter by metadata:</label> <input type="text" name="mq" id="mq" value="<?php echo $metadata_phrases;?>" /> </div> <div class="row"> <label for="cat">Filter by category:</label> <select name="cat" id="cat"> <option value="" <?php if ( $category_id === null ) { echo "selected"; } ?>>Any</option> <?php $optionList = mysql_query_assoc( "SELECT * FROM image_gallery_categories", 'id' ); foreach( $optionList as $optionID => $optionInfo ) { $optionName = $optionInfo['category']; $selected = ""; if ( $category_id !== null && $category_id == $optionID ) $selected = "selected"; ?> <option value="<?php echo $optionID;?>" <?php echo $selected;?>><?php echo $optionName;?></option> <?php } ?> </select> </div> <div class="items-per-page"> <label for="items_per_page">Items per page:</label> <select name="items_per_page" id="items_per_page"> <?php $itemsPerPageOptions = array( 10, 15, 25, 50, 100 ); foreach ( $itemsPerPageOptions as $ippValue ) { $selected = $ippValue == $items_per_page ? "selected" : ""; echo "<option value=\"{$ippValue}\" {$selected}>{$ippValue}</option>"; } ?> </select> </div> <input type="image" src="images/search_button.gif" name="submit" /> <?php if ( $isAdmin ) { ?> <p>You can also <a href="gallery_admin_add.php">add new images here</a>.</p> <?php } ?> </form> <?php if(isset($_SESSION["error_message"]) && $_SESSION["error_message"] != "") { echo "<div class='error_message'>" . $_SESSION["error_message"] . "</div>"; $_SESSION["error_message"] = ""; } ?> </div> </div> <?php if ( $resultCount == 0 ) { ?> <p><i>There are no image results that match your criteria.</i></p> <?php } else { $imageIndex = 0; foreach( $resultData as $imageID => $imageInfo ) { $keywords = $imageInfo['keywords']; $imageURL = $imageInfo['ph_xxsmall']; $linkURL = "gallery_image.php?image_id={$imageID}&return_url=".urlencode( $baseURL."&p={$page_index}" ); $frameClass = "image-frame"; $title = str_replace( '-Large', '', array_pop( explode("/", $imageInfo['ph_large'] ) ) ); // a terrible but effective way of extricating the original filename (or an approximation thereof) from the upload path if ( $imageIndex == 1 || ( $imageIndex >= 6 && ( $imageIndex - 6 ) % 4 == 0 ) ) $frameClass .= " last"; /* This is a hack to make images wrap around the search sidebar */ ?> <div class="<?php echo $frameClass;?>"> <?php if ( $isAdmin ) { $deleteURL = $baseURL."&p={$page_index}&op=delete&image_id={$imageID}"; ?> <div class="image-admin-overlay"> <a href="<?php echo $deleteURL;?>" onclick="return confirm('Are you sure you want to delete this image from the gallery? This action cannot be undone.' );"><img src="images/icon-delete-24px.png" alt="Delete" /></a> </div> <?php } ?> <a href="/<?php echo $linkURL;?>"><img src="/<?php echo $imageURL;?>" alt="Image Result" /></a> <p><strong><?php echo $title;?></strong></p> <?php if ( ! empty( $keywords ) ) { ?> <div class="keywords"> <?php echo $keywords;?> </div> <?php } ?> </div> <?php $imageIndex++; } ?> <div class="pagination"> <label>Pages:</label> <?php // I dislike finding PHP functions buried inside of markup. However, needs must as the devil drives. function _emitPageLink( $baseURL, $i, $currentPageIndex ) { static $lastPageIndex = -1; if ( $i <= $lastPageIndex ) return; $pageNumber = $i + 1; $url = $baseURL."&p=$i"; $class = "page-link"; if ( $i == $currentPageIndex ) $class .= " current"; if ( abs( $i - $lastPageIndex ) > 1 ) { echo "&nbsp;..."; } echo "<a href=\"{$url}\" title=\"Page {$pageNumber}\" class=\"{$class}\">{$pageNumber}</a>"; $lastPageIndex = $i; } for ( $i = 0; $i < min( 5, $pageCount ); $i++ ) { _emitPageLink( $baseURL, $i, $page_index ); } $midStart = $page_index - 4; $midStop = $page_index + 5; for ( $i = $midStart; $i <= min( $midStop, $pageCount ); $i++ ) { _emitPageLink( $baseURL, $i, $page_index ); } $endStart = $pageCount - 5; for ( $i = $endStart; $i <= $pageCount; $i++ ) { _emitPageLink( $baseURL, $i, $page_index ); } ?> </div> <?php } ?> </div> <br class="clearfloat" /> </div> <!-- InstanceEndEditable --></div> </body> <!-- InstanceEnd --></html>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0130.01018.55
8.3.50.0140.00322.00
8.3.40.0090.00618.95
8.3.30.0150.00019.25
8.3.20.0040.00420.46
8.3.10.0040.00421.92
8.3.00.0000.00822.33
8.2.180.0150.00416.75
8.2.170.0110.00722.96
8.2.160.0060.00920.89
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0080.00017.63
8.2.110.0030.00622.24
8.2.100.0070.00419.58
8.2.90.0040.00419.30
8.2.80.0060.00318.16
8.2.70.0120.00317.25
8.2.60.0030.00618.05
8.2.50.0060.00318.07
8.2.40.0040.00418.47
8.2.30.0040.00418.13
8.2.20.0000.00817.94
8.2.10.0050.00317.85
8.2.00.0000.00817.96
8.1.280.0060.00925.92
8.1.270.0050.00322.43
8.1.260.0050.00326.35
8.1.250.0030.00528.09
8.1.240.0000.00823.82
8.1.230.0060.00619.18
8.1.220.0030.00517.89
8.1.210.0000.00818.77
8.1.200.0070.00317.47
8.1.190.0030.00617.63
8.1.180.0060.00318.10
8.1.170.0000.00818.78
8.1.160.0000.01222.16
8.1.150.0030.00520.43
8.1.140.0080.00017.53
8.1.130.0060.00317.91
8.1.120.0120.00017.47
8.1.110.0030.00617.44
8.1.100.0040.00417.55
8.1.90.0040.00417.57
8.1.80.0000.00717.57
8.1.70.0030.00317.60
8.1.60.0080.00017.73
8.1.50.0030.00517.68
8.1.40.0000.00817.72
8.1.30.0050.00317.87
8.1.20.0060.00317.91
8.1.10.0040.00417.73
8.1.00.0060.00317.70
8.0.300.0030.00618.77
8.0.290.0030.00617.55
8.0.280.0040.00418.60
8.0.270.0050.00217.40
8.0.260.0000.00717.04
8.0.250.0030.00517.32
8.0.240.0060.00317.17
8.0.230.0080.00017.32
8.0.220.0000.00717.16
8.0.210.0030.00517.23
8.0.200.0000.00817.17
8.0.190.0000.00717.14
8.0.180.0000.00817.19
8.0.170.0030.00517.29
8.0.160.0040.00417.13
8.0.150.0040.00417.14
8.0.140.0040.00417.23
8.0.130.0000.00613.68
8.0.120.0000.00817.23
8.0.110.0030.00617.15
8.0.100.0040.00417.25
8.0.90.0040.00417.21
8.0.80.0130.00917.17
8.0.70.0000.00817.21
8.0.60.0040.00417.21
8.0.50.0030.00517.16
8.0.30.0110.01317.21
8.0.20.0100.00917.40
8.0.10.0050.00317.01
8.0.00.0070.01616.97
7.4.330.0050.00015.13
7.4.320.0030.00316.72
7.4.300.0000.00616.73
7.4.290.0000.00816.80
7.4.280.0030.00316.80
7.4.270.0000.00716.65
7.4.260.0040.00416.62
7.4.250.0030.00616.75
7.4.240.0040.00416.75
7.4.230.0050.00216.71
7.4.220.0140.00616.74
7.4.210.0070.00816.82
7.4.200.0040.00416.54
7.4.190.0040.00416.85
7.4.160.0160.00016.49
7.4.150.0160.01017.40
7.4.140.0080.01117.86
7.4.130.0100.00716.69
7.4.120.0120.00716.71
7.4.110.0060.01216.77
7.4.100.0120.00616.41
7.4.90.0100.01016.70
7.4.80.0150.00319.39
7.4.70.0120.00616.81
7.4.60.0070.01016.77
7.4.50.0050.00516.48
7.4.40.0070.01022.77
7.4.30.0160.00616.74
7.4.10.0030.01315.26
7.4.00.0060.01115.08
7.3.330.0030.00313.46
7.3.320.0030.00313.40
7.3.310.0030.00316.50
7.3.300.0030.00316.45
7.3.290.0150.00016.44
7.3.280.0100.00716.46
7.3.270.0070.01017.40
7.3.260.0210.00316.29
7.3.250.0110.00916.45
7.3.240.0040.01516.48
7.3.230.0050.01416.71
7.3.210.0110.00616.52
7.3.200.0080.00919.39
7.3.190.0060.01216.49
7.3.180.0080.00816.39
7.3.170.0090.00916.43
7.3.160.0100.00616.52
7.3.130.0090.00615.03
7.3.120.0120.00514.88
7.3.110.0060.01015.02
7.3.100.0050.01114.88
7.3.90.0060.01114.91
7.3.80.0080.00814.84
7.3.70.0060.00714.88
7.3.60.0050.00814.93
7.3.50.0020.01014.95
7.3.40.0090.00514.96
7.3.30.0050.00714.89
7.3.20.0080.00316.59
7.3.10.0030.01016.55
7.3.00.0090.00216.51
7.2.330.0150.00616.77
7.2.320.0090.00916.47
7.2.310.0130.01016.82
7.2.300.0040.01416.59
7.2.290.0030.01516.73
7.2.260.0110.00315.09
7.2.250.0100.00715.00
7.2.240.0080.00815.08
7.2.230.0080.00715.16
7.2.220.0050.01114.88
7.2.210.0050.01015.05
7.2.200.0080.00815.10
7.2.190.0040.01115.18
7.2.180.0070.00715.19
7.2.170.0030.01315.05
7.2.160.0030.00614.96
7.2.150.0070.01316.96
7.2.140.0030.01216.82
7.2.130.0000.01116.87
7.2.120.0000.01116.94
7.2.110.0070.00716.54
7.2.100.0070.01116.71
7.2.90.0070.00416.69
7.2.80.0030.01016.68
7.2.70.0110.00416.69
7.2.60.0060.00616.73
7.2.50.0100.00016.68
7.2.40.0040.00716.81
7.2.30.0000.01616.75
7.2.20.0110.00416.52
7.2.10.0000.01216.73
7.2.00.0060.00918.02
7.1.330.0040.01015.64
7.1.320.0040.01115.82
7.1.310.0090.00615.72
7.1.300.0030.01015.80
7.1.290.0070.00615.64
7.1.280.0040.01015.80
7.1.270.0020.01115.48
7.1.260.0070.00615.77
7.1.250.0100.00315.70
7.1.240.0050.00315.63
7.1.230.0040.01115.86
7.1.220.0040.00715.50
7.1.210.0040.00815.72
7.1.200.0060.00915.74
7.1.190.0100.00315.74
7.1.180.0090.00315.55
7.1.170.0030.01015.68
7.1.160.0000.01115.48
7.1.150.0000.01715.63
7.1.140.0040.01115.86
7.1.130.0030.00915.71
7.1.120.0030.01015.36
7.1.110.0030.01315.69
7.1.100.0050.01016.72
7.1.90.0070.00715.87
7.1.80.0070.00715.63
7.1.70.0040.00816.54
7.1.60.0030.00916.58
7.1.50.0050.01416.29
7.1.40.0070.01015.71
7.1.30.0030.00915.59
7.1.20.0060.00615.81
7.1.10.0100.00615.41
7.1.00.0070.03618.99
7.0.330.0060.00615.13
7.0.320.0070.00715.25
7.0.310.0090.00314.96
7.0.300.0060.00615.29
7.0.290.0040.00715.46
7.0.280.0040.00415.50
7.0.270.0000.01015.37
7.0.260.0090.00615.27
7.0.250.0090.00315.46
7.0.240.0030.00715.43
7.0.230.0080.00415.23
7.0.220.0030.01015.21
7.0.210.0030.00615.49
7.0.200.0050.00715.89
7.0.190.0000.00815.30
7.0.180.0030.01015.32
7.0.170.0030.00615.49
7.0.160.0090.00615.21
7.0.150.0040.01115.30
7.0.140.0060.03518.60
7.0.130.0060.00614.99
7.0.120.0030.01015.52
7.0.110.0060.00615.42
7.0.100.0350.04017.76
7.0.90.0270.04417.82
7.0.80.0280.04217.68
7.0.70.0250.04417.48
7.0.60.0240.04817.51
7.0.50.0260.03818.03
7.0.40.0060.04016.55
7.0.30.0090.03216.73
7.0.20.0070.04216.72
7.0.10.0150.03616.81
7.0.00.0080.04316.66
5.6.400.0070.01114.50
5.6.390.0150.00014.33
5.6.380.0030.00714.45
5.6.370.0060.00614.07
5.6.360.0000.00914.31
5.6.350.0130.00314.43
5.6.340.0070.00714.19
5.6.330.0000.00914.35
5.6.320.0040.00414.35
5.6.310.0100.00314.37
5.6.300.0040.01114.45
5.6.290.0060.00614.16
5.6.280.0080.03617.68
5.6.270.0030.00914.43
5.6.260.0040.01514.05
5.6.250.0050.04817.50
5.6.240.0080.03317.52
5.6.230.0030.04717.52
5.6.220.0080.02517.49
5.6.210.0080.04817.36
5.6.200.0100.04217.74
5.6.190.0080.04217.78
5.6.180.0080.04317.59
5.6.170.0080.04217.79
5.6.160.0050.04717.52
5.6.150.0100.04317.72
5.6.140.0040.04617.79
5.6.130.0050.04917.71
5.6.120.0100.04017.71
5.6.110.0060.04317.72
5.6.100.0090.04617.66
5.6.90.0120.04017.67
5.6.80.0030.04817.14
5.6.70.0060.04017.26
5.6.60.0080.04117.30
5.6.50.0060.02217.19
5.6.40.0050.04617.35
5.6.30.0080.04117.23
5.6.20.0020.04817.27
5.6.10.0080.03717.31
5.6.00.0120.03217.32
5.5.380.0070.04217.28
5.5.370.0080.04217.24
5.5.360.0070.02417.29
5.5.350.0100.04317.35
5.5.340.0060.04317.29
5.5.330.0030.04517.58
5.5.320.0030.04117.51
5.5.310.0020.03217.53
5.5.300.0090.04017.44
5.5.290.0070.04217.47
5.5.280.0050.04617.47
5.5.270.0060.03817.44
5.5.260.0080.04517.63
5.5.250.0090.03817.31
5.5.240.0030.02317.05
5.5.230.0030.04017.20
5.5.220.0070.03217.16
5.5.210.0020.04617.19
5.5.200.0070.04117.19
5.5.190.0120.03717.31
5.5.180.0050.03317.08
5.5.170.0060.00913.93
5.5.160.0120.03317.19
5.5.150.0070.04017.05
5.5.140.0070.04517.27
5.5.130.0070.04117.14
5.5.120.0070.03817.15
5.5.110.0010.04817.10
5.5.100.0070.02717.03
5.5.90.0080.04017.13
5.5.80.0060.03817.06
5.5.70.0080.04017.15
5.5.60.0080.04117.05
5.5.50.0050.04217.01
5.5.40.0060.03816.98
5.5.30.0070.04417.07
5.5.20.0040.04417.13
5.5.10.0050.04517.08
5.5.00.0050.04517.04
5.4.450.0080.04315.43
5.4.440.0080.04015.43
5.4.430.0080.02715.44
5.4.420.0110.02315.48
5.4.410.0100.03815.30
5.4.400.0050.04015.20
5.4.390.0090.02015.20
5.4.380.0000.04515.32
5.4.370.0060.02115.37
5.4.360.0050.02815.27
5.4.350.0070.04115.23
5.4.340.0070.04015.33
5.4.330.0000.00711.50
5.4.320.0070.04315.31
5.4.310.0050.04015.27
5.4.300.0070.04115.20
5.4.290.0110.03315.36
5.4.280.0040.02615.32
5.4.270.0050.04115.18
5.4.260.0100.03615.19
5.4.250.0030.03915.20
5.4.240.0030.03515.27
5.4.230.0030.03715.27
5.4.220.0050.02515.33
5.4.210.0050.03615.27
5.4.200.0050.03815.27
5.4.190.0030.04115.19
5.4.180.0110.03515.31
5.4.170.0110.04015.19
5.4.160.0120.03315.33
5.4.150.0150.03015.17
5.4.140.0100.03413.98
5.4.130.0030.04213.97
5.4.120.0040.03713.96
5.4.110.0020.04413.92
5.4.100.0030.03913.95
5.4.90.0070.03914.07
5.4.80.0100.03613.95
5.4.70.0030.04213.94
5.4.60.0050.03913.94
5.4.50.0050.03714.02
5.4.40.0050.04313.93
5.4.30.0050.04014.02
5.4.20.0070.02313.98
5.4.10.0070.03914.01
5.4.00.0000.03813.68
5.3.290.0000.04613.15
5.3.280.0020.03713.05
5.3.270.0050.04513.16
5.3.260.0080.02213.08
5.3.250.0080.02013.05
5.3.240.0050.02413.06
5.3.230.0050.04013.04
5.3.220.0050.02413.09
5.3.210.0040.04213.07
5.3.200.0080.03513.06
5.3.190.0080.04113.03
5.3.180.0050.04413.08
5.3.170.0080.03813.07
5.3.160.0080.02313.10
5.3.150.0050.04113.11
5.3.140.0110.02813.07
5.3.130.0030.04513.03
5.3.120.0070.04013.13
5.3.110.0110.03513.13
5.3.100.0050.03512.83
5.3.90.0020.02712.84
5.3.80.0030.02712.77
5.3.70.0030.04312.76
5.3.60.0060.04212.77
5.3.50.0020.04012.77
5.3.40.0020.04212.78
5.3.30.0030.02612.77
5.3.20.0070.03212.63
5.3.10.0030.03612.62
5.3.00.0020.04112.63

preferences:
39.77 ms | 401 KiB | 5 Q