@ 2014-04-18T21:50:14Z <?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 " ...";
}
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>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Warning: require_once(): open_basedir restriction in effect. File(_mysql_utilities.php) is not within the allowed path(s): (/tmp:/in:/etc) in /in/h9ANJ on line 5
Warning: require_once(_mysql_utilities.php): Failed to open stream: Operation not permitted in /in/h9ANJ on line 5
Fatal error: Uncaught Error: Failed opening required '_mysql_utilities.php' (include_path='.:') in /in/h9ANJ:5
Stack trace:
#0 {main}
thrown in /in/h9ANJ on line 5
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
50.71 ms | 402 KiB | 8 Q