| Current Path : /var/www/html/mmishra/indem/Parisarnews/ |
| Current File : /var/www/html/mmishra/indem/Parisarnews/uploads.php |
<?php
//checkadmin($role);
checkLogin($webid, $user);
$tbl = 'webpages'; //insert orphan page
$gallery = $_POST["gallery"];
$sharing = $_POST["sharing"];
$rfile = $_REQUEST["rfile"];
if ($_POST["submit"] == 'UPLOAD') {
$maxsize = 90998860800;
$uploadfile = basename($_FILES['userfile']['name']);
$tempfile = $_FILES['userfile']['tmp_name'];
$filesize = $_FILES["userfile"]["size"];
$uploadfile = str_replace(" ","-",$uploadfile);
$uploadfile = str_replace("'","",$uploadfile);
$uploadfile = str_replace('"',"",$uploadfile);
$uploadfile = str_replace('(',"",$uploadfile);
$uploadfile = strtolower(str_replace(')',"",$uploadfile));
if ($uploadfile && $filesize < $maxsize) {
$filename = explode(".", $uploadfile);
$ext = $filename[count($filename)-1];
if ($ext == 'jpg' || $ext == 'gif' || $ext == 'tif' || $ext == 'png') {
if ($gallery == 1) {
$aPath = absolutePath($webid,'gallery');
$rPath = relativePath($webid,'gallery');
} else {
$aPath = absolutePath($webid, 'images');
$rPath = relativePath($webid, 'images');
}
$filetype = 'Image';
} else if ($ext == 'mp3' || $ext == 'avi' || $ext == 'wav' || $ext == 'wma') {
$aPath = absolutePath($webid, 'multimedia');
$rPath = relativePath($webid, 'multimedia');
$filetype = 'Multimedia';
} else {
$aPath = absolutePath($webid, 'documents');
$rPath = relativePath($webid, 'documents');
$filetype = 'Document';
}
//echo (move_uploaded_file($tempfile, "$uPath/$uploadfile"));
if (move_uploaded_file($tempfile, "$aPath/$uploadfile")) {
shell_exec("chmod -R 755 $aPath");
//echo "<div>Thanks! $uploadfile file has successfully been uploaded.</div>";
if ($sharing == 1) $parentid = 99991;
else $parentid = 99992;
mysql_query("insert into $tbl(webid,hypertext,parentid,pagetitle,pagetype,pagecontent,datecreation,userid)
values('$webid','$uploadfile',$parentid,'$filetype','file','$uploadfile',now(),'$user')");
echo "<h2>$uploadfile uploaded.</h2>";
} else {
echo "<h2>$uploadfile upload failed.</h2>";
}
} else {
echo "<h2>$uploadfile upload error.</h2>";
}
}
//echo upload($webid, $gallery);
$rdPath = relativePath($webid,'documents');
$riPath = relativePath($webid,'images');
$rgPath = relativePath($webid,'gallery');
$rmPath = relativePath($webid,'multimedia');
$adPath = absolutePath($webid,'documents');
$aiPath = absolutePath($webid,'images');
$agPath = absolutePath($webid,'gallery');
$amPath = absolutePath($webid,'multimedia');
if ($rfile) shell_exec("rm -f $rfile");
?>
<p>
Please select file to upload on server. Here image files will be uploaded in "<?php echo $riPath; ?>" folder
multimedia files will be "<?php echo $rmPath; ?>" folder and
other files will be uploaded in "<?php echo $rdPath; ?>" folder. File at wrong place may cause access problem.
<br><br>
Select file <input type='file' name='userfile' size='40'><br>
Add to [<input type='checkbox' name='gallery' value='1'> Photo Gallery
<input type='checkbox' name='sharing' value='1'> Interstation sharing]
<input type='submit' name='submit' value='UPLOAD' style='width:80px'>
</p>
<p>
Only images can be added to the photo gallery. Please upload pdf/jpg/gif files to achieve better performance.<br>
Uploaded files can be referenced by their names.
</p>
<p>
List of files in <a href='<?php echo $rdPath; ?>/' target='_blank'>documents</a>,
<a href='<?php echo $riPath; ?>/' target='_blank'>images</a> &
<a href='<?php echo $rmPath; ?>/' target='_blank'>multimedia</a> folders.
</p>
<p>
<?php
$dots = 50;
$files = $_REQUEST["files"];
if (!$files) $files = 'gallery';
if ($files == 'gallery') {
echo "<b>Photo Files:</b><ol>";
$ufiles = scandir($agPath);
foreach ($ufiles as $filename) {
if (strlen($filename) > 2) {
$fsize = number_format(filesize("$agPath/$filename")/1024,2);
echo "<li><a href='$rgPath/$filename'>$filename</a> ";
//mysql_query("insert into $tbl(webid,hypertext,parentid,pagetitle,pagetype,pagecontent,datecreation,userid)
//values('$webid','$filename',99990,'Gallery','file','$filename',now(),'$user')");
echo "($fsize KB)";
for ($i = strlen($filename); $i<$dots; $i++) {
echo '-';
}
if ($role == 'admin') echo "[<a href='$PHP_SELF?conf=$conf&files=gallery&rfile=$agPath/$filename'>Delete</a>]</li>";
}
}
echo "</ol>";
} else
echo "<b><a href='admin.php?conf=$conf&files=gallery'>Photo Files</a></b><br>";
if ($files == 'document') {
echo "<b>Document Files:</b><ol>";
$ufiles = scandir($adPath);
foreach ($ufiles as $filename) {
if (strlen($filename) > 2) {
$fsize = number_format(filesize("$adPath/$filename")/1024,2);
echo "<li><a href='$rdPath/$filename'>$filename</a> ";
//mysql_query("insert into $tbl(webid,hypertext,parentid,pagetitle,pagetype,pagecontent,datecreation,userid)
//values('$webid','$filename',99990,'Document','file','$filename',now(),'$user')");
echo "($fsize KB)";
for ($i = strlen($filename); $i<$dots; $i++) {
echo '-';
}
if ($role == 'admin') echo "[<a href='$PHP_SELF?conf=$conf&files=document&rfile=$adPath/$filename'>Delete</a>]</li>";
}
}
echo "</ol>";
} else
echo "<b><a href='admin.php?conf=$conf&files=document'>Document Files</a></b><br>";
if ($files == 'image') {
echo "<b>Image Files:</b><ol>";
$ufiles = scandir($aiPath);
foreach ($ufiles as $filename) {
if (strlen($filename) > 2) {
$fsize = number_format(filesize("$aiPath/$filename")/1024,2);
echo "<li><a href='$riPath/$filename'>$filename</a> ";
//mysql_query("insert into $tbl(webid,hypertext,parentid,pagetitle,pagetype,pagecontent,datecreation,userid)
//values('$webid','$filename',99990,'Image','file','$filename',now(),'$user')");
echo "($fsize KB)";
for ($i = strlen($filename); $i<$dots; $i++) {
echo '-';
}
if ($role == 'admin') echo "[<a href='$PHP_SELF?conf=$conf&files=image&rfile=$aiPath/$filename'>Delete</a>]</li>";
}
}
echo "</ol>";
} else
echo "<b><a href='admin.php?conf=$conf&files=image'>Image Files</a></b><br>";
if ($files == 'multimedia') {
echo "<b>Multimedia Files:</b><ol>";
$ufiles = scandir($amPath);
foreach ($ufiles as $filename) {
if (strlen($filename) > 2) {
$fsize = number_format(filesize("$amPath/$filename")/1024,2);
echo "<li><a href='$rmPath/$filename'>$filename</a> ";
//mysql_query("insert into $tbl(webid,hypertext,parentid,pagetitle,pagetype,pagecontent,datecreation,userid)
//values('$webid','$filename',99990,'Multimedia','file','$filename',now(),'$user')");
echo "($fsize KB)";
for ($i = strlen($filename); $i<$dots; $i++) {
echo '-';
}
if ($role == 'admin') echo "[<a href='$PHP_SELF?conf=$conf&files=multimedia&rfile=$amPath/$filename'>Delete</a>]</li>";
}
}
echo "</ol>";
} else
echo "<b><a href='admin.php?conf=$conf&files=multimedia'>Multimedia Files</a></b><br>";
?>
</ol>
</p>