\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } function HTMLfooter() { echo "
\n"; echo ""; } function HTML404() { global $Titles; HTMLheader(); echo "

",$Titles[404],"

\n"; HTMLfooter(); } if (ParsedURI()[0]=="index") { HTMLheader(); echo "

",$Titles[Head],"


\n"; echo " $Titles[IndexRegister]",MainURL(),"register
\n"; echo " $Titles[IndexGet]",MainURL(),"get/pastedfileID
\n"; echo " $Titles[IndexEdit]",MainURL(),"edit/pastedfileID
\n"; echo " $Titles[IndexPut]
\n"; echo "
",$Titles[SampleCurlPart1],MainURL(),$Titles[SampleCurlPart2],"
\n"; echo " ",$Titles[MaximumFIleSize],$SettingMaxFileSizeBytes," ",$Titles[Bytes],"
\n"; echo " ",$Titles[DefaultMIME],$DefaultMIMEtype,"
\n"; echo " ",$Titles[StoragePeriod],$SettingExpireDays," ",$Titles[Days],"
\n"; HTMLfooter(); } else if (ParsedURI()[0]=="get") { if (!ParsedURI()[1]) HTML404(); else { $URIid=ParsedURI()[1]; $dbconnection=mysqli_connect($mySQL[host],$mySQL[user],$mySQL[password],$mySQL[dbname]); mysqli_query($dbconnection,"SET CHARACTER SET 'utf8'"); $paste=mysqli_fetch_object(mysqli_query($dbconnection,"SELECT * FROM `$mySQL[table]` WHERE BINARY `id`='$URIid';")); if ($paste->data) { $viewheader="Content-type: ".$paste->mime; header($viewheader); echo $paste->data; } else HTML404(); } } else if (ParsedURI()[0]=="put") { $URIid=ParsedURI()[1]; $dbconnection=mysqli_connect($mySQL[host],$mySQL[user],$mySQL[password],$mySQL[dbname]); mysqli_query($dbconnection,"SET CHARACTER SET 'utf8'"); $paste=mysqli_fetch_object(mysqli_query($dbconnection,"SELECT * FROM `".$mySQL[table]."` WHERE `id` = '$URIid';")); $URIparam=explode('=',ParsedURI()[param][1]); if ($URIid===$paste->id) if (($URIparam[0]=="password")&&($URIparam[1]===$paste->password)) { header("Content-type: text/plain"); if ($_FILES['filedata']['size']<1) echo $Titles[ErrorDataTrans],"\n"; if ($_FILES['filedata']['size']>$SettingMaxFileSizeBytes) echo $Titles[ErrorDataTrans],". ",$Titles[MaximumSize],$SettingMaxFileSizeBytes,$Titles[Bytes],"\n"; if ($_FILES['filedata']['error']>0) echo $Titles[ErrorDataErrNo],$_FILES['filedata']['error'],")\n"; else { if ($SettingMaxFileSizeBytes>$_FILES['filedata']['size']&&$_FILES['filedata']['size']>0) { echo $Titles[SuccFileSize],$_FILES['filedata']['size'],$Titles[SuccFileBytes],"\n"; $filedata=addslashes(fread(fopen($_FILES['filedata']['tmp_name'],"rb"),filesize($_FILES['filedata']['tmp_name']))); mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `data` = '$filedata' WHERE `$mySQL[table]`.`id` = '$URIid';"); mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `modified` = NOW( ) WHERE `$mySQL[table]`.`id` = '$URIid';"); } } } else HTML404(); else HTML404(); } else if (ParsedURI()[0]=="register") { session_start(); HTMLheader(); if($_POST['submit']) { $_SESSION['formpasteid']=$_POST['pasteid']; $UncorrectPasteIDorPassword=0; if(!$_POST['pasteid']) echo "",$Titles[ReqPasteID],"
\n
\n"; if((!$_POST['password'])||(!$_POST['password2'])) echo "",$Titles[ReqPassword],"
\n
\n"; else if($_POST['password']!=$_POST['password2']) echo "",$Titles[WrongPassword],"
\n
\n"; if(($_POST['pasteid'])&&(!ereg("^[a-zA-Z0-9_\.-]+$",$_POST['pasteid']))) $UncorrectPasteIDorPassword=1; if(($_POST['password'])&&(!ereg("^[a-zA-Z0-9_\.-]+$",$_POST['password']))) $UncorrectPasteIDorPassword=1; if(!$_POST['captcha']) echo "",$Titles[ReqCaptcha],"
\n
\n"; if (($_POST['captcha'])&&!($_POST["captcha"]==$_SESSION["captcha"])) echo "",$Titles[WrongCaptcha],"
\n
\n"; if ($UncorrectPasteIDorPassword==1) echo "",$Titles[WrongSymbols],"
\n
\n"; else { if ((($_POST['captcha'])&&($_POST["captcha"]==$_SESSION["captcha"]))&&(($_POST['pasteid'])&&($_POST['password']))&&($_POST['password']===$_POST['password2'])) { $dbconnection=mysqli_connect($mySQL[host],$mySQL[user],$mySQL[password],$mySQL[dbname]); mysqli_query($dbconnection,"SET CHARACTER SET 'utf8'"); mysqli_query($dbconnection,"INSERT INTO `".$mySQL[table]."` (`id`,`password`,`data`,`modified`,`expire`,`mime`) VALUES ('".$_POST['pasteid']."','".$_POST['password']."',NULL,CURRENT_TIMESTAMP ,'".date("Y-m-d h:i:s", $_SESSION['expiretimestamp'])."','".$DefaultMIMEtype."');"); if (mysqli_errno($dbconnection)==1062) echo "",$Titles[WrongPasteID],"
\n
\n"; else if (mysqli_errno($dbconnection)==0) { $CorrectPasteID="true"; echo $Titles[addDone],"
\n"; $_SESSION['formpasteid']=""; if ($SettingMaxFileSizeBytes>$_FILES['filedata']['size']&&$_FILES['filedata']['size']>0) { $filedata=addslashes(fread(fopen($_FILES['filedata']['tmp_name'],"rb"),filesize($_FILES['filedata']['tmp_name']))); mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `data` = '$filedata' WHERE `$mySQL[table]`.`id` = '".$_POST['pasteid']."';"); } } else echo "",$Titles[ErrorAdd],mysqli_error($dbconnection),"
\n
\n"; } } } if (!($_POST['submit'])||!($CorrectPasteID)) { $captchanumber1=rand(1, 50); $captchanumber2=rand(1, 49); $_SESSION['captcha']=$captchanumber1+$captchanumber2; $_SESSION['expiretimestamp']=(time()+$SettingExpireDays*24*60*60); echo "

",$Titles[registerNew],"

\n"; echo "
\n"; echo " ",$Titles[PasteID],":
\n"; echo " ",$Titles[Password],":
\n"; echo " ",$Titles[Password],": (",$Titles[Check],")
\n"; echo " ",$Titles[CheckSymbols],"
\n"; echo " ",$Titles[UploadFile],": (",$Titles[NotNecessary],")
\n"; echo " ",$Titles[MaximumSize],$SettingMaxFileSizeBytes,$Titles[Bytes],"
\n"; echo " ",$Titles[Expire],": ",date("Y m d", $_SESSION['expiretimestamp']),"
\n"; echo " ",$Titles[MIMEtype],": ",$DefaultMIMEtype," (",$Titles[CanBeChanged],")
\n"; echo " ",$Titles[Captcha],": $captchanumber1 ",$Titles[Plus]," $captchanumber2 = ?
\n"; echo " \n"; echo "
\n"; } HTMLfooter(); } else if (ParsedURI()[0]=="edit") { if (ParsedURI()[1]) { $URIid=ParsedURI()[1]; $dbconnection=mysqli_connect($mySQL[host],$mySQL[user],$mySQL[password],$mySQL[dbname]); mysqli_query($dbconnection,"SET CHARACTER SET 'utf8'"); $paste=mysqli_fetch_object(mysqli_query($dbconnection,"SELECT * FROM `".$mySQL[table]."` WHERE `id` = '$URIid';")); if ($URIid===$paste->id) { session_start(); HTMLheader(); if($_POST['submit']) { if ($_POST['password']===$paste->password) $_SESSION['editstatus']=$paste->id; else echo "",$Titles[WrongPassword],"
\n
\n"; } if($_POST['exit']) $_SESSION['editstatus']=""; if($_POST['submit2']) { $editerror=""; if ($SettingMaxFileSizeBytes>$_FILES['filedata']['size']&&$_FILES['filedata']['size']>0) { $filedata=addslashes(fread(fopen($_FILES['filedata']['tmp_name'],"rb"),filesize($_FILES['filedata']['tmp_name']))); mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `data` = '$filedata' WHERE `$mySQL[table]`.`id` = '".$paste->id."';"); mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `modified` = NOW( ) WHERE `$mySQL[table]`.`id` = '".$paste->id."';"); } if ($_POST['mime']!=$paste->mime) { if(!ereg("^[a-zA-Z0-9\./+-]+$",$_POST['mime'])) $editerror=$editerror."".$Titles[WrongSymbolsMIME]."

\n"; else mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `mime` = '".$_POST['mime']."' WHERE `$mySQL[table]`.`id` = '".$paste->id."';"); } if($_POST['password']||$_POST['password2']) { if($_POST['password']===$_POST['password2']) { if(!ereg("^[a-zA-Z0-9_\.-]+$",$_POST['password'])) $editerror=$editerror."".$Titles[WrongSymbols]."

\n"; else { mysqli_query($dbconnection,"UPDATE `$mySQL[table]` SET `password` = '".$_POST['password']."' WHERE `$mySQL[table]`.`id` = '".$paste->id."';"); $editerror=$editerror."".$Titles[PasswordUpdated]."

\n"; } } else $editerror=$editerror."".$Titles[WrongPassword]."

\n"; } $paste=mysqli_fetch_object(mysqli_query($dbconnection,"SELECT * FROM `".$mySQL[table]."` WHERE `id` = '$URIid';")); } if($_SESSION['editstatus']==$URIid) { echo "
\n"; echo "

",$Titles[PasteID],": ",$paste->id,"


\n"; echo " ",$editerror; echo " ",$Titles[Data],": "; if (strlen($paste->data)>0) echo "id,"\">",strlen($paste->data),$Titles[Bytes],"
\n"; else echo "0",$Titles[Bytes],"
\n"; echo " ",$Titles[Modified],": ",$paste->modified,"
\n"; echo " ",$Titles[Expire],": ",$paste->expire,"
\n"; echo " ",$Titles[UploadFile],":
\n"; echo " ",$Titles[MIMEtype],": mime,"\" maxlength=255>
\n"; echo " ",$Titles[NewPassword],":
\n"; echo " ",$Titles[NewPassword],": (",$Titles[Check],")
\n"; echo "

\n"; echo " \n"; echo "
\n"; } else { echo "
\n"; echo " ",$Titles[Password],":
\n"; echo " \n"; echo "
\n"; } HTMLheader(); } else HTML404(); } else HTML404(); } else HTML404(); ?>