Smart Image Processor PHP 2 Support Product Page
Solved
Error in Dreamweaver
Reported 07 Aug 2012 06:33:50
1
has this problem
07 Aug 2012 06:33:50 student 101 posted:
Can't upload an image but something about pure php upload or SIP not being detected.What exactly should the order of this code be?
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "99,98";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php require_once('../Connections/cngreg.php'); ?>
<?php require_once('../ScriptLibrary/incPureUpload.php'); ?>
<?php require_once('../ScriptLibrary/cGraphicMediator.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
require_once('config.php');
?>
<?php
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
// Pure PHP Upload 2.1.12
$ppu = new pureFileUpload();
$ppu->path = "../images";
$ppu->extensions = "GIF,JPG,JPEG,PNG";
$ppu->formName = "frm_insert";
$ppu->storeType = "file";
$ppu->sizeLimit = "";
$ppu->nameConflict = "uniq";
$ppu->nameToLower = false;
$ppu->requireUpload = false;
$ppu->minWidth = "";
$ppu->minHeight = "";
$ppu->maxWidth = "";
$ppu->maxHeight = "";
$ppu->saveWidth = "";
$ppu->saveHeight = "";
$ppu->timeout = "600";
$ppu->progressBar = "";
$ppu->progressWidth = "";
$ppu->progressHeight = "";
$ppu->redirectURL = "";
$ppu->checkVersion("2.1.12");
$ppu->doUpload();
// Smart Image Processor PHP 2.0.9
if (isset($_GET['GP_upload'])) {
$sipp1 = new cGraphicMediator("upload", $ppu, "imgmain");
$sipp1->setComponent("Auto");
$sipp1->setMatteColor("#FFFFFF");
$sipp1->resizeEx(300, 300, true, false);
$sipp1->overwrite = false;
$sipp1->saveJPEG(80);
$sipp1->process();
}
?>
<?php
// Smart Image Processor PHP 2.0.9
if (isset($_GET['GP_upload'])) {
$sipp2 = new cGraphicMediator("upload", $ppu, "imgmain");
$sipp2->setComponent("Auto");
$sipp2->setMatteColor("#FFFFFF");
$sipp2->resizeEx(170, 170, true, false);
$sipp2->overwrite = false;
$sipp2->setMask("../images/thumb/##name##.jpg");
$sipp2->saveJPEG(80);
$sipp2->process();
}
?>
<?php
if (isset($editFormAction)) {
if (isset($_SERVER['QUERY_STRING'])) {
if (!preg_match("/GP_upload=true/i", $_SERVER['QUERY_STRING'])) {
$editFormAction .= "&GP_upload=true";
}
} else {
$editFormAction .= "?GP_upload=true";
}
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "frm_insert")) {
$insertSQL = sprintf("INSERT INTO tblimg (imgid, imgtext, imgmain, imgthumb, prjid, mainimg, imgtype) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['imgid'], "int"),
GetSQLValueString($_POST['imgtext'], "text"),
GetSQLValueString($_POST['imgmain'], "text"),
GetSQLValueString($_POST['imgmain'], "text"),
GetSQLValueString($_POST['prjid'], "int"),
GetSQLValueString(isset($_POST['mainimg']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['imgtype'], "text"));
mysql_select_db($database_cngreg, $cngreg);
$Result1 = mysql_query($insertSQL, $cngreg) or die(mysql_error());
$insertGoTo = "projects.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<?php
$colname_rspr = "-1";
if (isset($_GET['prjid'])) {
$colname_rspr = $_GET['prjid'];
}
mysql_select_db($database_cngreg, $cngreg);
$query_rspr = sprintf("SELECT tblprojects.id, tblprojects.prjname, tblimg.imgtext, tblimg.imgid, tblimg.imgmain, tblimg.imgthumb, tblimg.prjid, tblimg.mainimg, tblimg.imgtype FROM tblprojects , tblimg WHERE tblprojects.id = tblimg.prjid AND tblimg.prjid = %s ORDER BY tblprojects.sortid ASC", GetSQLValueString($colname_rspr, "int"));
$rspr = mysql_query($query_rspr, $cngreg) or die(mysql_error());
$row_rspr = mysql_fetch_assoc($rspr);
$totalRows_rspr = mysql_num_rows($rspr);
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="../img/favicon.ico" />
<title><?php echo $sitename." - ";?>Content Management System</title>
<link href="style/style.css" rel="stylesheet" type="text/css" />
<style media="screen" type="text/css">
</style>
<!--[if lt IE 7]>
<style media="screen" type="text/css">
#container {
height:100%;
}
</style>
<![endif]-->
<script type="text/javascript">
function tmt_confirm(msg){
document.MM_returnValue=(confirm(unescape(msg)));
}
</script>
<script language='JavaScript' src='../ScriptLibrary/incPureUpload.js' type="text/javascript"></script>
</head>
<body>
<div id="container">
<div id="header">
<?php require_once('header.php'); ?>
<?php require_once('menu.php'); ?>
</div>
<div id="body">
<div id="wr">
<div id="cnt">
<?php if ((isset($_GET["addnew"])) && ($_GET["addnew"] == "Y")) {?>
<p class="pt">Upload images for <span style="color:#666;"><?php echo $row_rspr['prjname']; ?></span></p>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="frm_insert" id="frm_insert" onsubmit="checkFileUpload(this,'GIF,JPG,JPEG,PNG',false,'','','','','','','');return document.MM_returnValue"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="menuframe"><tr><td class="formhead" align="left">Upload image</td></tr><tr>
<td><table width="100%" border="0" cellpadding="2" cellspacing="2"><tr>
<td nowrap="nowrap" class="lightblue">Upload an image:</td>
<td colspan="3" class="lightblue"><input name="imgmain" type="file" id="imgmain" onchange="checkOneFileUpload(this,'GIF,JPG,JPEG,PNG',false,'','','','','','','')"></td></tr>
<tr>
<td class="lightblue">Image text: </td>
<td colspan="3" class="lightblue"><textarea name="imgtext" id="imgtext" cols="50" rows="8"><?php if (isset($_POST['imgtext'])){ echo $_POST['imgtext']; }?></textarea></td>
</tr>
<tr>
<td class="lightblue">Visible:</td>
<td colspan="3" class="lightblue"><input name="mainimg" type="checkbox" id="mainimg" checked="checked" /></td>
</tr>
<tr>
<td class="lightblue"><p>Visable on:</p></td>
<td colspan="3" class="lightblue">
<select name="imgtype" id="imgtype">
<option value="all">All</option>
<option value="home">Home</option>
<option value="projects">projects</option>
<option value="none">none</option>
</select>
</td>
</tr>
</table></td></tr><tr>
<td class="loginfoot">
<input name="imgid" type="hidden" id="imgid" value="<?php // echo $lastid; ?>" />
<input name="prjid" type="hidden" id="prjid" value="<?php echo $_GET['prjid']; ?>" />
<input name="Submit" type="submit" id="btn_insert" value="insert" />
</td></tr></table>
<input type="hidden" name="MM_insert" value="frm_insert" />
</form>
<?php }else{?>
<p class="pt">Edit images for <span style="color:#666;"><?php echo $row_rspr['prjname']; ?></span></p>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="frm_edit" id="frm_edit"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="menuframe"><tr><td class="formhead" align="left">Upload image</td></tr><tr>
<td><table width="100%" border="0" cellpadding="2" cellspacing="2"><tr>
<td nowrap="nowrap" class="lightblue">Upload an image:</td>
<td colspan="3" class="lightblue"><input name="imgmain" type="file" id="imgmain"></td></tr>
<tr>
<td class="lightblue">Image text: </td>
<td colspan="3" class="lightblue"><textarea name="imgtext" id="imgtext" cols="50" rows="8"><?php if (isset($_POST['imgtext'])){ echo $_POST['imgtext']; }?></textarea></td>
</tr>
<tr>
<td class="lightblue">Visible:</td>
<td colspan="3" class="lightblue"><input name="mainimg" type="checkbox" id="mainimg" checked="checked" /></td>
</tr>
<tr>
<td class="lightblue"><p>Visable on:</p></td>
<td colspan="3" class="lightblue">
<select name="imgtype" id="imgtype">
<option value="all">All</option>
<option value="home">Home</option>
<option value="projects">projects</option>
<option value="none">none</option>
</select>
</td>
</tr>
</table></td></tr><tr>
<td class="loginfoot">
<input name="imgid" type="hidden" id="imgid" value="<?php // echo $lastid; ?>" />
<input name="prjid" type="hidden" id="prjid" value="<?php echo $_GET['prjid']; ?>" />
<input name="Submit" type="submit" id="btn_edit" value="Edit" />
</td></tr></table>
<input type="hidden" name="MM_update" value="frm_edit" />
</form>
<?php }?>
<p> </p>
<p>
<?php do { ?>
[img]images/thumb/<?php echo $row_rspr['imgthumb']; ?>" alt="" name="<?php echo $row_rspr['imgthumb']; ?>" title="<?php echo $row_rspr['imgthumb']; ?>" width="72" />
<?php } while ($row_rspr = mysql_fetch_assoc($rspr)); ?>
</p>
</div>
</div>
</div>
<?php require_once('footer.php'); ?>
</div>
</body>
</html>
<?php
mysql_free_result($rspr);
?>
Replies
Replied 08 Aug 2012 07:04:50
08 Aug 2012 07:04:50 Teodor Kuduschiev replied:
Hello,
Can you tell us what exactly do you mean by:
" but something about pure php upload or SIP not being detected"
Your code seems to be well ordered.
Can you tell us what exactly do you mean by:
" but something about pure php upload or SIP not being detected"
Your code seems to be well ordered.
Replied 08 Aug 2012 07:11:17
08 Aug 2012 07:11:17 student 101 replied:
A tiny mission uploading the error in image format here.
Anyway here's the error msg...
Anyway here's the error msg...
Replied 08 Aug 2012 08:37:14
08 Aug 2012 08:37:14 student 101 replied:
Quick fix!
Add this:
// Pure PHP Upload 2.1.12
..rest of PHP Upload code only.
Before this:
if (!function_exists("GetSQLValueString"
) {
function GetSQLValueString
Add this:
// Pure PHP Upload 2.1.12
..rest of PHP Upload code only.
Before this:
if (!function_exists("GetSQLValueString"
function GetSQLValueString
Replied 09 Aug 2012 06:37:08
09 Aug 2012 06:37:08 Teodor Kuduschiev replied:
Hello,
Did the last change solve your issue?
Did the last change solve your issue?
Replied 09 Aug 2012 07:26:18
09 Aug 2012 07:26:18 student 101 replied:
Yes thx!

