discourse-legacysite-perl/site/slowtwitch.com/www/tick/pics_add.php
2024-06-17 22:30:36 +10:00

58 lines
1.5 KiB
PHP

<?require ("global.php");?>
<?php
$ID = 0;
list($msec, $sec) = explode(" ", microtime());
$stamp = date("Ymdhis") . substr($msec, 4);
$filename = "";
$path = "";
$complete = "";
$url = "";
$sql = "";
if (isset($_POST['ID'])) { $ID = $_POST['ID']; }
if (isset($_FILES['pic']['name']) && $_FILES['pic']['name'] != "")
{
$path = "$DOCUMENT_ROOT/tick/images/gallery/";
$pieces = preg_split('/\./', basename($_FILES['pic']['name']));
$filename = $stamp . "." . $pieces[1];
$complete = $path . $filename;
move_uploaded_file($_FILES['pic']['tmp_name'], $complete);
chmod($complete, 0755);
$s = "/var/home/slowtwitch/slowtwitch.com/www/tick/scripts/pics.pl $filename --- 640";
exec("$s 2>&1", $updw);
$s = "/var/home/slowtwitch/slowtwitch.com/www/tick/scripts/pics.pl $filename t_ 130";
exec("$s 2>&1", $updw);
$url = "/tick/images/gallery/";
$sql = "fullname = '" . $filename . "', fullurl = '" . $url . "', ";
}
if ($ID != 0)
{
$query = "UPDATE pics SET "
. $sql
. "caption = '" . myaddslashes($_POST['caption']) . "',"
. "courtesy_of = '" . myaddslashes($_POST['courtesy_of']) . "' "
. "WHERE ID = '$ID'";
$result = mysql_query($query, $db);
}
else
{
$query = "INSERT INTO pics (stageID,fullname,fullurl,caption,courtesy_of,default_flag) VALUES ('"
. $_POST['stageID'] . "','"
. $filename . "','"
. $url . "','"
. myaddslashes($_POST['caption']) . "','"
. myaddslashes($_POST['courtesy_of']) . "','"
. "no')";
$result = mysql_query($query, $db);
}
header("Location: /tick/pics.php");
?>