Viewing file: index.php (20.43 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/********************************************************************************
- MemHT Portal -
Copyright (C) 2007-2008 by Miltenovik Manojlo
http://www.memht.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your opinion) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, see <http://www.gnu.org/licenses/> (GPLv2)
or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA02110-1301, USA.
********************************************************************************/
if (!defined("_LOAD_PAGE_")) {
die("<table style='padding: 2px; border: 1px solid #999; background-color: #EEE; font-family: Verdana; font-size: 10px;' align='center'><tr><td><b>Error:</b> This file cannot be opened directly!</td></tr></table>");
}
$cfgrow = mysql_fetch_assoc(mysql_query("SELECT * FROM memht_imageup_config"));
$guests = intval($cfgrow['guests']);
$maxfilesize_user = intval($cfgrow['maxfilesize_user']);
$maxfilesize_guest = intval($cfgrow['maxfilesize_guest']);
$max_thumb_w = intval($cfgrow['max_thumb_w']);
$max_thumb_h = intval($cfgrow['max_thumb_h']);
if (isSet($_GET['op'])) { $op = inCode($_GET['op']); } else { $op = ""; }
if (isSet($_GET['start'])) { $start = inCode($_GET['start']); } else { $start = ""; }
if (isSet($_GET['file'])) { $file = inCode($_GET['file']); } else { $file = ""; }
if (isSet($_GET['ok'])) { $ok = inCode($_GET['ok']); } else { $ok = false; }
if (isSet($_GET['pg'])) { $pg = inCode($_GET['pg']); } else { $pg = 1; }
$ofsppg = 40; //Items per page
$ofsbgn = ($pg*$ofsppg)-$ofsppg;
function main() {
global $user,$guests,$maxfilesize_user,$maxfilesize_guest;
if (isUser($user)) {
$maxfilesize = $maxfilesize_user;
$note = "";
} else {
$maxfilesize = $maxfilesize_guest;
if ($maxfilesize_user!=$maxfilesize_guest) {
$more = " "._UPTO_." ".strSize($maxfilesize_user)." "._INSTEADOF_." ".strSize($maxfilesize_guest)." "._PERFILE_;
} else { $more = ""; }
$username = "Guest";
$note = "<a href='index.php?page=users' title='"._LOGIN_."'><b>"._LOGIN_."</b></a> "._OR_." <a href='index.php?page=users&op=register' title='"._REGISTER_."'><b>"._REGISTER_."</b></a> "._ANDGETYOURPRSALBUM_."<br><br>"._ASREGUSERYOUABLETO_;
if ($guests>0) { $note .= "$more"; }
$note .= _MANAGEYOURFILES_;
}
echo "<table border='0' align='center'>";
if ($note!="") {
echo "<tr><td>$note</td></tr>";
echo "<tr><td> </td></tr>";
}
if (isUser($user) OR $guests==1) {
echo "<tr><td>";
echo "<form action='index.php?page=imageup&op=uploadFile' method='post' enctype='multipart/form-data' name='form'>";
echo "<div id='small'>"._SELECTIMAGE_."</div>";
echo "<input name='MAX_FILE_SIZE' type='hidden' value='$maxfilesize'>";
echo "<input name='image' type='file' size='40'>";
echo "<div id='small'>"._ACCEPTEDFILES_.": <b>jpg, gif, png, tiff, bmp</b><br>";
echo _MAXFILEDIM_.": <b>".strSize($maxfilesize)."</b></div><br>";
echo "<input type='submit' name='Submit' value='"._UPLOAD_."'>";
echo "</form>";
echo "</td></tr>";
}
echo "</table>";
}
function uploadFile() {
global $page,$siteConfig,$user,$guests,$maxfilesize_user,$maxfilesize_guest,$max_thumb_w,$max_thumb_h;
if (isUser($user) OR $guests==1) {
if (isUser($user)) {
$maxfilesize = $maxfilesize_user;
$username = $user;
} else {
$maxfilesize = $maxfilesize_guest;
$username = "Guest";
}
$msg = "<div align='center' color='#006600'><b>"._FILEUPLOADED_."</b></div>";
require_once("inc/class/uploadFile.class.php");
$upload = new uploadFile();
$upload->show_errors = false;
$upload->mime = array('image/gif','image/pjpeg','image/jpeg','image/png','image/tiff','image/bmp');
$upload->path = "pages/$page/uploads/$username/";
$upload->max_size = $maxfilesize;
$upload->field = "image";
if (!file_exists("pages/$page/uploads/$username")) {
if (!@mkdir("pages/$page/uploads/$username",0777)) { mem_ftp_mkdir("pages/$page/uploads/",$username,777); }
if (!@chmod("pages/$page/uploads/$username",0777)) { mem_ftp_chmod("pages/$page/uploads/$username",777); }
}
if ($filename = $upload->upload()) {
$okup = true;
} else {
$okup = false;
$msg = $upload->error;
}
if ($okup) {
$imagesize=@getimagesize($upload->path.$filename);
$img_w= $imagesize[0];
$img_h= $imagesize[1];
@$ratio = $img_w/$img_h;
if ($img_w>$max_thumb_w) {
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/prototype.js'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/scriptaculous.js?load=effects'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/lightbox.js'></script>\n";
echo "<link rel='stylesheet' href='".$siteConfig['site_url']."/inc/javascript/gallery/css/lightbox.css' type='text/css'>\n";
$th_w = $max_thumb_w;
$th_h = $th_w/$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/".$upload->path.$filename."' rel='lightbox' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else if ($img_h>$max_thumb_h) {
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/prototype.js'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/scriptaculous.js?load=effects'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/lightbox.js'></script>\n";
echo "<link rel='stylesheet' href='".$siteConfig['site_url']."/inc/javascript/gallery/css/lightbox.css' type='text/css'>\n";
$th_h = $max_thumb_h;
$th_w = $th_h*$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/".$upload->path.$filename."' rel='lightbox' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else {
$th_h = $img_h;
$th_w = $img_w;
$view = "";
}
echo "<table border='0' align='center'>";
echo "<tr><td>$msg</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td>";
echo "<table border='0' align='center'>";
echo "<tr><td align='center' colspan='2'>";
echo "<table border='0' align='center' bgcolor='#FFFFFF' cellspacing='0' cellpadding='4'><tr align='center'><td>";
echo "<img src='".$siteConfig['site_url']."/".$upload->path.$filename."' width='$th_w' height='$th_h'>";
echo "</td></tr>";
echo "</table>";
echo "$view";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='right'><b>"._FILENAME_.":</b> </td><td>".$filename."</td></tr>";
echo "<tr><td align='right'><b>"._DIMENSION_.":</b> </td><td>".strSize(filesize($upload->path.$filename))."</td></tr>";
echo "<tr><td align='right'><b>"._SIZE_.":</b> </td><td>$img_w x $img_h</td></tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<form>";
echo "<tr align='right'><td><b>"._LINKEDIMAGE_.":</b> <input type='text' name='path_link' size='30' value='<a href=\"".$siteConfig['site_url']."\" title=\"".$siteConfig['site_name']."\" target=\"_blank\"><img src=\"".$siteConfig['site_url']."/".$upload->path.$filename."\" border=\"0\"></a>'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_link.focus();this.form.path_link.select();'></td></tr>";
echo "<tr align='right'><td><b>"._ORIGINALPATH_.":</b> <input type='text' name='path_orig' size='30' value='".$siteConfig['site_url']."/".$upload->path.$filename."'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_orig.focus();this.form.path_orig.select();'></td></tr>";
echo "<tr align='right'><td><b>HTML:</b> <input type='text' name='path_html' size='30' value='<img src=\"".$siteConfig['site_url']."/".$upload->path.$filename."\" border=\"0\">'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_html.focus();this.form.path_html.select();'></td></tr>";
echo "<tr align='right'><td><b>"._BBCODE_.":</b> <input type='text' name='path_forums' size='30' value='"."["."img"."]"."".$siteConfig['site_url']."/".$upload->path.$filename."["."/img"."]"."'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_forums.focus();this.form.path_forums.select();'></td></tr>";
echo "</form>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='center' colspan='2'>";
echo "<div align='center'><a href='index.php?page=imageup&op=main'>"._UPLOADANOTHER_."</a></div>";
echo "</td></tr>";
echo "</table>";
} else {
echo "<div align='center' id='errorText'><b>$msg</b></div>";;
}
} else {
echo "<div align='center' id='errorText'><b>"._ACCESSDENIED_."</b></div>";
}
}
function myFiles($ofsbgn,$ofsppg,$pg) {
global $user,$page,$siteConfig;
if (isUser($user)) {
$path = "pages/$page/uploads/$user/";
unset($filelist);
$handle = @opendir($path);
while (false !== ($file = @readdir($handle))) {
if ($file != "." AND $file != ".." AND !eregi("html",$file) AND $file!="Thumbs.db") {
$filelist[] = $file;
}
}
@closedir($handle);
$n_file = @sizeof($filelist);
if ($n_file>0) {
sort($filelist);
reset($filelist);
}
if ($n_file>0) {
echo "<table width='100%' align='center' border='0' cellspacing='0' cellpadding='1'>";
echo "<tr><td><b>"._FILENAME_."</b></td><td align='right'><b>"._DIMENSION_."</b></td><td align='center'><b>"._SIZE_."</b></td><td></td></tr>";
$ofsend = $ofsbgn + $ofsppg;
if ($ofsend<=$n_file) {
$n_file = $ofsend;
}
for($i=$ofsbgn;$i<$n_file;$i++) {
$file = $filelist[$i];
@$imagesize=getimagesize($path.htmlspecialchars($file));
$img_w= $imagesize[0];
$img_h= $imagesize[1];
echo "<tr><td><img src='pages/imageup/images/img.png' width='16' height='16' border='0' align='left'> <a href='index.php?page=imageup&op=viewDetails&file=".htmlspecialchars($file)."' title='"._VIEWDETAILS_."'>".htmlspecialchars($file)."</a></td><td align='right'>".strSize(filesize($path."/".htmlspecialchars($file)))."</td><td align='center'>$img_w x $img_h</td><td align='right'><a href='index.php?page=imageup&op=viewDetails&file=".htmlspecialchars($file)."' title='"._VIEWDETAILS_."'><img src='images/view.gif' width='14' height='14' border='0'></a> <a href='index.php?page=imageup&op=delete&file=".htmlspecialchars($file)."' title='"._DELETE_."'><img src='images/delete.gif' width='14' height='14' border='0'></a></td></tr>";
}
echo "</table>";
//Pages
$num = @sizeof($filelist);
$pages = ceil($num/$ofsppg);
if ($pages>1) {
echo "<div id='box'>";
echo "<table align='center'>\n";
echo "<tr><td align='center' colspan='2' id='info'>";
$sxpg = $pg-1;
$dxpg = $pg+1;
if ($sxpg>0) {
echo "<a href='index.php?page=imageup&op=myFiles&pg=$sxpg' title='"._PREVIOUS_PAGE_."'><img src='images/left.gif' border='0'></a> ";
}
for ($pgs=1;$pgs<=$pages;$pgs++) {
echo "<a href='index.php?page=imageup&op=myFiles&pg=$pgs' title='"._PAGE_." $pgs'>";
if ($pg==$pgs) {
echo "<b>$pgs</b>";
} else {
echo "$pgs";
}
echo "</a> ";
}
if ($dxpg<=$pages) {
echo "<a href='index.php?page=imageup&op=myFiles&pg=$dxpg' title='"._NEXT_PAGE_."'><img src='images/right.gif' border='0'></a> ";
}
echo "</td></tr>";
echo "</table>\n";
echo "</div>";
}
} else {
echo "<div align='center' id='errorText'><b>"._EMPTY_."</b></div>";
}
} else {
echo "<meta http-equiv='refresh' content='0;URL=".$siteConfig['site_url']."/index.php?page=imageup'>";
}
}
function viewDetails($filedet) {
global $user,$page,$siteConfig,$max_thumb_w,$max_thumb_h;
$path = "pages/$page/uploads/$user";
if (isUser($user) AND file_exists($path."/".urlencode($filedet))) {
$imagesize=@getimagesize($siteConfig['site_url']."/$path/".urlencode($filedet));
$img_w= $imagesize[0];
$img_h= $imagesize[1];
@$ratio = $img_w/$img_h;
if ($img_w>$max_thumb_w) {
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/prototype.js'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/scriptaculous.js?load=effects'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/lightbox.js'></script>\n";
echo "<link rel='stylesheet' href='".$siteConfig['site_url']."/inc/javascript/gallery/css/lightbox.css' type='text/css'>\n";
$th_w = $max_thumb_w;
$th_h = $th_w/$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' rel='lightbox' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else if ($img_h>$max_thumb_h) {
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/prototype.js'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/scriptaculous.js?load=effects'></script>\n";
echo "<script type='text/javascript' src='".$siteConfig['site_url']."/inc/javascript/gallery/js/lightbox.js'></script>\n";
echo "<link rel='stylesheet' href='".$siteConfig['site_url']."/inc/javascript/gallery/css/lightbox.css' type='text/css'>\n";
$th_h = $max_thumb_h;
$th_w = $th_h*$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' rel='lightbox' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else {
$th_h = $img_h;
$th_w = $img_w;
$view = "";
}
echo "<table border='0' align='center'>";
echo "<tr><td>";
echo "<table border='0' align='center'>";
echo "<tr><td align='center' colspan='2'>";
echo "<table border='0' align='center' bgcolor='#FFFFFF' cellspacing='0' cellpadding='4'><tr align='center'><td>";
echo "<img src='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' width='$th_w' height='$th_h'>";
echo "</td></tr>";
echo "</table>";
echo "$view";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='right'><b>"._FILENAME_.":</b> </td><td>".urlencode($filedet)."</td></tr>";
echo "<tr><td align='right'><b>"._DIMENSION_.":</b> </td><td>".strSize(filesize($path."/".htmlspecialchars($filedet)))."</td></tr>";
echo "<tr><td align='right'><b>"._SIZE_.":</b> </td><td>$img_w x $img_h</td></tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<form>";
echo "<tr align='right'><td><b>"._LINKEDIMAGE_.":</b> <input type='text' name='path_link' size='30' value='<a href=\"".$siteConfig['site_url']."\" title=\"".$siteConfig['site_name']."\" target=\"_blank\"><img src=\"".$siteConfig['site_url']."/$path/".urlencode($filedet)."\" border=\"0\"></a>'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_link.focus();this.form.path_link.select();'></td></tr>";
echo "<tr align='right'><td><b>"._ORIGINALPATH_.":</b> <input type='text' name='path_orig' size='30' value='".$siteConfig['site_url']."/$path/".urlencode($filedet)."'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_orig.focus();this.form.path_orig.select();'></td></tr>";
echo "<tr align='right'><td><b>HTML:</b> <input type='text' name='path_html' size='30' value='<img src=\"".$siteConfig['site_url']."/$path/".urlencode($filedet)."\" border=\"0\">'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_html.focus();this.form.path_html.select();'></td></tr>";
echo "<tr align='right'><td><b>"._BBCODE_.":</b> <input type='text' name='path_forums' size='30' value='"."["."img"."]"."".$siteConfig['site_url']."/$path/" .$filedet."["."/img"."]"."'> <input type='button' value='"._SELECT_."' onClick='javascript:this.form.path_forums.focus();this.form.path_forums.select();'></td></tr>";
echo "</form>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='center' colspan='2'><a href='javascript:history.back();'><img src='images/left.gif' border='0'> "._BACK_."</a></td></tr>";
echo "</table>";
} else {
echo "<meta http-equiv='refresh' content='0;URL=".$siteConfig['site_url']."/index.php?page=imageup'>";
}
}
function delete($filedet,$ok=false) {
global $user,$page,$siteConfig,$max_thumb_w,$max_thumb_h;
$path = "pages/$page/uploads/$user";
if (isUser($user) AND file_exists($path."/".urlencode($filedet))) {
$imagesize=@getimagesize($siteConfig['site_url']."/$path/".urlencode($filedet));
$img_w= $imagesize[0];
$img_h= $imagesize[1];
@$ratio = $img_w/$img_h;
if ($img_w>$max_thumb_w) {
$th_w = $max_thumb_w;
$th_h = $th_w/$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else if ($img_h>$max_thumb_h) {
$th_h = $max_thumb_h;
$th_w = $th_h*$ratio;
$view = "<tr><td align='center' colspan='2'><a href='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' target='_blank'><img src='images/view.gif' border='0'></a></td></tr>";
} else {
$th_h = $img_h;
$th_w = $img_w;
$view = "";
}
echo "<table border='0' align='center'>";
echo "<tr><td>";
echo "<table border='0' align='center'>";
echo "<tr><td align='center' colspan='2'>";
echo "<table border='0' align='center' bgcolor='#FFFFFF' cellspacing='0' cellpadding='4'><tr align='center'><td>";
echo "<img src='".$siteConfig['site_url']."/$path/".urlencode($filedet)."' width='$th_w' height='$th_h'>";
echo "</td></tr>";
echo "</table>";
echo "$view";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='right'><b>"._FILENAME_.":</b> </td><td>".urlencode($filedet)."</td></tr>";
echo "<tr><td align='right'><b>"._DIMENSION_.":</b> </td><td>".strSize(filesize($path."/".htmlspecialchars($filedet)))."</td></tr>";
echo "<tr><td align='right'><b>"._SIZE_.":</b> </td><td>$img_w x $img_h</td></tr>";
echo "</table>";
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td>";
if ($ok) {
unlink($path."/".urlencode($filedet));
echo "<meta http-equiv='refresh' content='0;URL=".$siteConfig['site_url']."/index.php?page=imageup&op=myFiles'>";
} else {
echo "<div align='center'><b>"._SUREDELETE_."</b><br><a href='index.php?page=imageup&op=delete&file=".urlencode($filedet)."&ok=true' title='"._YES_."'>"._YES_."</a> - <a href='index.php?page=imageup&op=viewDetails&file=".urlencode($filedet)."' title='"._NO_."'>"._NO_."</a></div>";
}
echo "</td></tr>";
echo "<tr><td> </td></tr>";
echo "<tr><td align='center' colspan='2'><a href='javascript:history.back();'><img src='images/left.gif' border='0'> "._BACK_."</a></td></tr>";
echo "</table>";
} else {
echo "<meta http-equiv='refresh' content='0;URL=".$siteConfig['site_url']."/index.php?page=imageup'>";
}
}
$pagerow = $dblink->get_row("SELECT * FROM memht_pagine WHERE nome='$page'");
$fullScreen = intval($pagerow['fullscreen']);
require_once("inc/inc_header.php");
if (isset($_GET['page'])) { page_title($page); }
openTable();
echo "<div align='center' class='box'><a href='index.php?page=imageup&op=main'>"._MAIN_."</a>";
if (isUser($user)) {
echo " - <a href='index.php?page=imageup&op=myFiles'>"._MYFILES_."</a>";
}
echo "</div>";
closeTable();
openTable();
switch($op) {
case "uploadFile":
uploadFile();
break;
case "myFiles":
myFiles($ofsbgn,$ofsppg,$pg);
break;
case "viewDetails":
viewDetails($file);
break;
case "delete":
delete($file,$ok);
break;
case "main":
default:
main();
break;
}
closeTable();
require_once("inc/inc_footer.php");
?>
|