Location: PHPKode > projects > WorkOrder TS > workorder-ts/include/upload_img.php
<html><head> <title>Image Uploader</title> </head> <body> <?PHP if( isset($_POST['TicketID']) ) { $TicketID=addslashes($_POST['TicketID']);} else { die("This script can not be called directly");} if( isset($_POST['SSID']) ) { $SSID=addslashes($_POST['SSID']);} else { die("This script can not be called directly");} if( isset($_POST['ImageName']) ) { $_jL0i6=addslashes($_POST['ImageName']);} else { $_jL0i6="Unnamed";} $inc_dir="./";$_Il6fL=NULL;$_j06tj=True;$_j06LI=30;require $inc_dir.'workorder_function_general.inc.php';require $inc_dir.'workorder_function_upload.php';$CONF=_OFB10($inc_dir);require_once $inc_dir.'workorder_function_isuserauthenticated.inc.php';if( _L00CR($SSID,$inc_dir,$_Il6fL,$CONF)=="FAILED" ) { die('Not Authenticated, please login first');} require $inc_dir.'config-guest.inc.php';require $inc_dir.'conn-string-guest.inc.php';$_jL1tf="../".stripslashes($CONF['UploadTargetPath'])."/";$_jLQ0o=stripslashes($CONF['ImageTicketFilesPerDir']);$TableTicketImages=$CONF['TableNameTicketImages'];$_jLQ10=$CONF['ImageTicketSubDir'];$_jLQll=end(explode('.',$_FILES['uploadedfile']['name']));$_jLIl6=explode(',',$CONF['ImageTicketEXT']);$_jLjiJ=False;foreach( $_jLIl6 AS $_jLJO6 ) { $_jLQll=strtolower($_jLQll);$_jLJO6=strtolower($_jLJO6);if( $_jLJO6==$_jLQll ) { $_jLjiJ=True;} } if( $_jLjiJ==False ) { die("File Type not allowed");} if( file_exists("$inc_dir/pro/calendar.php")==False ) { $sql="SELECT COUNT(*) FROM $TableTicketImages WHERE TicketID = \"$TicketID\"";$res=mysql_query($sql,$conn) or die("Unable to get total count Error:xchv4<br /> $sql");$row=mysql_fetch_array($res);$_jL60J=$row['COUNT(*)'];if( $_jL60J >=2 ) { die("The Pro Edition allows unlimited uploads.");} } $sql="SELECT COUNT(*) FROM $TableTicketImages WHERE SubDir = \"$_jLQ10\"";$res=mysql_query($sql,$conn) or die("Unable to get total count Error:xcv4<br /> $sql");$row=mysql_fetch_array($res);$_jL6C6=$row['COUNT(*)'];if( $_jLQ0o <=($_jL6C6-1) ) { $_jLf68=explode( '-',$_jLQ10);$_jLfoj=$_jLf68[0]."-".($_jLf68[1]+1);$TableConfig=$CONF['TableNameConfig'];_OF6BA($inc_dir,$TableConfig,'config_value="'.$_jLfoj.'"','config_name="ImageTicketSubDir"');$CONF=_OFB10($inc_dir);$_jLQ10=$CONF['ImageTicketSubDir'];$_jL1tf="../".stripslashes($CONF['UploadTargetPath'])."/";$_jLQ0o=stripslashes($CONF['ImageTicketFilesPerDir']);$TableTicketImages=$CONF['TableNameTicketImages'];$sql="SELECT COUNT(*) FROM $TableTicketImages WHERE SubDir = \"$_jLQ10\"";$res=mysql_query($sql,$conn) or die("Unable to get total count Error:xcv4<br /> $sql");$row=mysql_fetch_array($res);$_jL6C6=$row['COUNT(*)'];} if( file_exists("$inc_dir/pro/calendar.php")==False ) { $sql="SELECT COUNT(*) FROM $TableTicketImages WHERE TicketID = \"$TicketID\"";$res=mysql_query($sql,$conn) or die("Unable to get total count Error:xchv4<br /> $sql");$row=mysql_fetch_array($res);$_jL60J=$row['COUNT(*)'];if( $_jL60J >=2 ) { die("The Pro Edition allows unlimited uploads.");} } $_jL8tj=$_jL1tf;$_jL1tf=$_jL1tf.$_jLQ10."/";$_jLt1o=_OFFRJ(25);$_jLtIj=$_jLt1o.".".$_jLQll;$_jLO0Q=0;while( $_j06tj==True && $_jLO0Q < $_j06LI ) { if( is_dir($_jL1tf)==False ) { if( @mkdir($_jL1tf,0755)==False ) { die("<p>Unable to create a directory: $_jL1tf <br /> Please make sure that the upload directory is writable Error:Write10a</p>");} } _L0LB1($_jL8tj);_L0LB1($_jL1tf);if( file_exists("$inc_dir/pro/calendar.php")==False ) { $sql="SELECT COUNT(*) FROM $TableTicketImages WHERE TicketID = \"$TicketID\"";$res=mysql_query($sql,$conn) or die("Unable to get total count Error:xchv4<br /> $sql");$row=mysql_fetch_array($res);$_jL60J=$row['COUNT(*)'];if( $_jL60J >=2 ) { die("The Pro Edition allows unlimited uploads.");} } $_jLOQL=$_jL1tf.$_jLtIj;if( file_exists($_jLOQL)==True ) { $_jL6C6++;$_jLt1o=_OFFRJ(25);$_jLtIj=$_jLt1o.".".$_jLQll;} else { $_j06tj=False;if( is_writable($_jLOQL)==False) { if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$_jLOQL)) { _OFROQ($inc_dir,$TableTicketImages,'FileName,SubDir,TicketID,FileDesc','"'.$_jLtIj.'","'.$_jLQ10.'","'.$TicketID.'","'.$_jL0i6.'"');echo ("The file ".basename( $_FILES['uploadedfile']['name'])." has been uploaded");echo ('<p><a href="upload_img_ui.php?TicketID='.$TicketID.'&SSID='.$SSID.'">Upload More</a> &nbsp;&nbsp;&nbsp;&nbsp; <a href="javascript:window.close();">Close Window</a>');} else{ $_jLo0J=$CONF['UploadMaxSizeb'];$_jLojl=$_FILES['uploadedfile']['error'];switch ($_FILES['uploadedfile']["error"]) { case UPLOAD_ERR_OK:break;case UPLOAD_ERR_INI_SIZE:die("The uploaded file exceeds the upload_max_filesize directive (".ini_get("upload_max_filesize").") in php.ini.");break;case UPLOAD_ERR_FORM_SIZE:die("The uploaded file exceeds the MAX_FILE_SIZE(".round(($_jLo0J / 1024),2)."KB) directive that was specified in the HTML form.");break;case UPLOAD_ERR_PARTIAL:die("The uploaded file was only partially uploaded.");break;case UPLOAD_ERR_NO_FILE:die("No file was uploaded.");break;case UPLOAD_ERR_NO_TMP_DIR:die("Missing a temporary folder.");break;case UPLOAD_ERR_CANT_WRITE:die("Failed to write file to disk");break;default:die("Unknown File Error");} echo "There was an error uploading the file, please try again! PHP error: $_jLojl max file size is ".($_jLo0J / 1024)."KB";} } else { die("File already exists: $_jLtIj UNHANDLED, please email the developer: Error UNHANDLED:45656fdgd");} $_j06tj=False;} $_jLO0Q++;} ?> </body></html>
Return current item: WorkOrder TS