add_image.php is part of the source code for OpenPhotoVR. The contents of it is below:
<?php
$tmp_name = "";
$url = $_REQUEST['url'];
if ($url && preg_match('/^http:\/\//', $url))
{
$tmp_name = tempnam("./data/", "tmp");
copy($url, $tmp_name);
} else {
$tmp_name = $_FILES['userfile']['tmp_name'];
}
if (!$info = getimagesize($tmp_name) or $info[2] != IMAGETYPE_JPEG)
{
exit;
}
$width = (int)$info[0];
$height = (int)$info[1];
$id = "";
$chars = "abchefghjkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for ($i = 0; $i < 8; $i++)
$id .= substr($chars, rand() % strlen($chars), 1);
mkdir("data/$id");
$fh = fopen("./data/$id/nav.js", "w");
$info = array("id" => $id, "width" => $width, "height" => $height, "links" => array());
fwrite($fh, "nav(" . json_encode($info) . ");");
fclose($fh);
$levels = 1;
$tw = $width;
$th = $height;
while (($tw > 256) || ($th > 256))
{
$tw = ceil($tw/2);
$th = ceil($th/2);
$levels += 1;
}
$to_unlink = Array();
while (true)
{
array_push($to_unlink, $tmp_name);
`convert -crop 256x256 $tmp_name ./data/$id/$levels-%d.jpg`;
if ($levels == 1)
break;
$levels -= 1;
$new_tmp_name = tempnam("./temp", $id) . ".jpg";
`convert -resize 50%x50% $tmp_name $new_tmp_name`;
$tmp_name = $new_tmp_name;
}
foreach ($to_unlink as $name)
unlink($name); <----LINE 55
`convert -resize 50%x50% ./data/$id/1-0.jpg ./data/$id/thumbnail.jpg`;
header("Location: ./?edit=true&id=$id");
?>