codes****@googl*****
codes****@googl*****
2008年 9月 9日 (火) 21:45:52 JST
Author: tsuchi000 Date: Tue Sep 9 05:43:45 2008 New Revision: 445 Added: trunk/plugins/filemgmt/ trunk/plugins/filemgmt/admin/ trunk/plugins/filemgmt/admin/index.php trunk/plugins/filemgmt/admin/install.php trunk/plugins/filemgmt/config.php trunk/plugins/filemgmt/filemgmt.php trunk/plugins/filemgmt/functions.inc trunk/plugins/filemgmt/history trunk/plugins/filemgmt/language/ trunk/plugins/filemgmt/language/english.php trunk/plugins/filemgmt/public_html/ trunk/plugins/filemgmt/public_html/brokenfile.php trunk/plugins/filemgmt/public_html/downloadhistory.php trunk/plugins/filemgmt/public_html/images/ trunk/plugins/filemgmt/public_html/images/Thumbs.db (contents, props changed) trunk/plugins/filemgmt/public_html/images/arrow.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/bul1a.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/bul42.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/button.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/counter.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/decs.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/delete.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/dl.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/dot1.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/down.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/download.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/editicon.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/filemgmt.jpg (contents, props changed) trunk/plugins/filemgmt/public_html/images/floder.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/home.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/newred.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/platform.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/pop.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/screenshoticon.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/size.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/speck.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/time.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/up.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/update.gif (contents, props changed) trunk/plugins/filemgmt/public_html/images/ver.gif (contents, props changed) trunk/plugins/filemgmt/public_html/include/ trunk/plugins/filemgmt/public_html/include/dlformat.php trunk/plugins/filemgmt/public_html/include/errorhandler.php trunk/plugins/filemgmt/public_html/include/functions.php trunk/plugins/filemgmt/public_html/include/header.php trunk/plugins/filemgmt/public_html/include/textsanitizer.php trunk/plugins/filemgmt/public_html/include/xoopstree.php trunk/plugins/filemgmt/public_html/index.php trunk/plugins/filemgmt/public_html/ratefile.php trunk/plugins/filemgmt/public_html/singlefile.php trunk/plugins/filemgmt/public_html/submit.php trunk/plugins/filemgmt/public_html/viewcat.php trunk/plugins/filemgmt/public_html/visit.php trunk/plugins/filemgmt/readme.htm trunk/plugins/filemgmt/sql/ trunk/plugins/filemgmt/sql/filemgmt_sql_install.php trunk/plugins/filemgmt/templates/ trunk/plugins/filemgmt/templates/admin.html trunk/plugins/filemgmt/templates/admin.txt trunk/plugins/filemgmt/templates/blank.html trunk/plugins/filemgmt/templates/filelisting.thtml trunk/plugins/filemgmt/templates/filelisting_category.thtml trunk/plugins/filemgmt/templates/filelisting_record.thtml trunk/plugins/filemgmt/templates/filelisting_subcategory.thtml trunk/plugins/filemgmt/templates/index.html trunk/plugins/filemgmt/templates/index.txt trunk/plugins/filemgmt/templates/install.thtml trunk/plugins/filemgmt/templates/install.txt trunk/plugins/filemgmt/templates/sortmenu.thtml Log: filemgmt_1.5.3_1.4.1 オリジナル Added: trunk/plugins/filemgmt/admin/index.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/admin/index.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,1446 @@ +<?php + +/* Reminder: always indent with 4 spaces (no tabs). */ +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// | File: index.php | +// | Main admin script | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// +-------------------------------------------------------------------------+ +// | | +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +require_once("../../../lib-common.php"); +include_once($_CONF[path_html]."filemgmt/include/header.php"); +include_once($_CONF[path_html]."filemgmt/include/functions.php"); +include_once($_CONF[path_html]."filemgmt/include/xoopstree.php"); +include_once($_CONF[path_html]."filemgmt/include/textsanitizer.php"); +include_once($_CONF[path_html]."filemgmt/include/errorhandler.php"); +include_once($_CONF[path]."system/classes/navbar.class.php"); + +$op = COM_applyFilter($_REQUEST['op']); +$display = ''; +if (!SEC_hasRights('filemgmt.edit')) { + if ($op != 'comment') { + $display .= COM_siteHeader('menu'); + $display .= COM_startBlock(_GL_ERRORNOACCESS); + $display .= _MD_USER." ".$_USER['username']. " " ._GL_NOUSERACCESS; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; + exit; + } +} + +function filemgmt_navbar($selected='') { + global $_CONF,$LANG_FM02,$_FM_TABLES; + + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_brokenlinks']}"); + list($totalbrokendownloads) = DB_fetchARRAY($result); + if($totalbrokendownloads > 0){ + $totalbrokendownloads = "<font color=\"#ff0000\"><b>$totalbrokendownloads</b></font>"; + } + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE status=0"); + list($totalnewdownloads) = DB_fetchARRAY($result); + if($totalnewdownloads > 0){ + $totalnewdownloads = "<font color=\"#ff0000\"><b>$totalnewdownloads</b></font>"; + } + + $navbar = new navbar; + $navbar->add_menuitem($LANG_FM02['nav1'],$_CONF['site_admin_url'] .'/plugins/filemgmt/index.php?op=filemgmtConfigAdmin'); + $navbar->add_menuitem($LANG_FM02['nav2'],$_CONF['site_admin_url'] .'/plugins/filemgmt/index.php?op=categoryConfigAdmin'); + $navbar->add_menuitem($LANG_FM02['nav3'],$_CONF['site_admin_url'] .'/plugins/filemgmt/index.php?op=newfileConfigAdmin'); + $navbar->add_menuitem(sprintf($LANG_FM02['nav4'],$totalnewdownloads),$_CONF['site_admin_url'] .'/plugins/filemgmt/index.php?op=listNewDownloads'); + $navbar->add_menuitem(sprintf($LANG_FM02['nav5'],$totalbrokendownloads),$_CONF['site_admin_url'] .'/plugins/filemgmt/index.php?op=listBrokenDownloads'); + + if ($selected == $LANG_FM02['nav4']) { + $navbar->set_selected(sprintf($LANG_FM02['nav4'],$totalnewdownloads)); + } elseif ($selected == $LANG_FM02['nav5']) { + $navbar->set_selected(sprintf($LANG_FM02['nav5'],$totalbrokendownloads)); + } else { + $navbar->set_selected($selected); + } + + return $navbar->generate(); + +} + +$myts = new MyTextSanitizer; +$mytree = new XoopsTree($_DB_name,$_FM_TABLES['filemgmt_cat'],"cid","pid"); +$eh = new ErrorHandler; + +function mydownloads() { + global $_CONF,$LANG_FM02,$_FM_TABLES; + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + + $display .= filemgmt_navbar(); + + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE status > 0"); + list($numrows) = DB_fetchARRAY($result); + $display .= "<br><br><div style=\"text-align:center;padding:10px;\">"; + $display .= sprintf(_MD_THEREARE,$numrows); + $display .= "</div>"; + $display .= "<br>"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + +function listNewDownloads(){ + global $_CONF,$_TABLES,$_FM_TABLES,$myts,$eh,$mytree,$filemgmt_FileStoreURL,$filemgmt_FileSnapURL,$LANG_FM02; + + // List downloads waiting for validation + $sql = "SELECT lid, cid, title, url, homepage, version, size, logourl, submitter, comments, platform "; + $sql .= "FROM {$_FM_TABLES['filemgmt_filedetail']} where status=0 ORDER BY date DESC"; + $result = DB_query($sql); + $numrows = DB_numROWS($result); + $display = COM_siteHeader('menu'); + $display .= COM_startBlock('<b>'._MD_ADMINTITLE.'</b>'); + $display .= filemgmt_navbar($LANG_FM02['nav4']); + + $i = 1; + if ($numrows > 0) { + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td width="100%" class="pluginHeader" style="padding:5px;">' . _MD_DLSWAITING. " ($numrows)</td></tr>"; + while(list($lid, $cid, $title, $url, $homepage, $version, $size, $logourl, $submitter, $comments, $tmpnames) = DB_fetchARRAY($result)) { + $result2 = DB_query("SELECT description FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid='$lid'"); + list($description) = DB_fetchARRAY($result2); + $title = $myts->makeTboxData4Edit($title); + $url = rawurldecode($myts->makeTboxData4Edit($url)); + $logourl = rawurldecode($myts->makeTboxData4Edit($logourl)); + $homepage = $myts->makeTboxData4Edit($homepage); + $version = $myts->makeTboxData4Edit($version); + $size = $myts->makeTboxData4Edit($size); + $description = $myts->makeTareaData4Edit($description); + $tmpfilenames = explode(";",$tmpnames); + $tempfileurl = $filemgmt_FileStoreURL . 'tmp/' .$tmpfilenames[0]; + if (isset($tmpfilenames[1]) and $tmpfilenames[1] != '') { + $tempsnapurl = $filemgmt_FileSnapURL . 'tmp/' .$tmpfilenames[1]; + } else { + $tempsnapurl = ''; + } + $display .= '<tr><td>'; + $display .= '<form action="index.php" method="post" enctype="multipart/form-data" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td align="right" nowrap>'._MD_SUBMITTER.'</td><td>'; + $display .= '<a href="'. $_CONF['site_url'] . '/users.php?mode=profile&uid='. $submitter. '">'.COM_getDisplayName ($submitter).'</a>'; + $display .= '</td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_FILETITLE.'</td><td>'; + $display .= '<input type="text" name="title" size="50" maxlength="100" value="'.$title.'">'; + $display .= '</td></tr><tr><td align="right" nowrap>'._MD_DLFILENAME.'</td><td>'; + $display .= '<input type="text" name="url" size="50" maxlength="250" value="'.$url.'">'; + $display .= '</td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_CATEGORYC.'</td><td>'; + $display .= $mytree->makeMySelBox('title', 'title', $cid); + $display .= '</td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_HOMEPAGEC.'</td><td>'; + $display .= '<input type="text" name="homepage" size="50" maxlength="100" value="'.$homepage.'"></td></tr>'; + $display .= '<tr><td align="right">'._MD_VERSIONC.'</td><td>'; + $display .= '<input type="text" name="version" size="10" maxlength="10" value="'.$version.'"></td></tr>'; + $display .= '<tr><td align="right">'._MD_FILESIZEC.'</td><td>'; + $display .= '<input type="text" name="size" size="10" maxlength="8" value="'.$size.'"> '._MD_BYTES.'</td></tr>'; + $display .= '<tr><td align="right" valign="top" nowrap>'._MD_DESCRIPTIONC.'</td><td>'; + $display .= '<textarea name=description cols="60" rows="5">'.$description.'</textarea>'; + $display .= '</td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_SHOTIMAGE.'</td><td>'; + $display .= '<input type="text" name="logourl" size="50" maxlength="250" value="'.$logourl.'">'; + if ($tempsnapurl != '') { + $display .= '<span style="padding-left:20px;"><a href="' . $tempsnapurl . '">Preview</a></span>'; + } + $display .= '</td></tr>'; + $display .= '<tr><td></td><td>'; + $display .= '</td></tr><tr><td nowrap align="right">'._MD_COMMENTOPTION.'</td><td>'; + if ($comments) { + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="1" CHECKED> ' ._MD_YES.' </INPUT>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="0" > ' ._MD_NO.' </INPUT>'; + } else { + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="1" > ' ._MD_YES.' </INPUT>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="0" CHECKED> ' ._MD_NO.' </INPUT>'; + } + $display .= '</td></tr>'; + $display .= '<tr><td style="text-align:right;padding:10px;">'; + $display .= '<input type="submit" onClick=\'this.form.op.value="delNewDownload"\' value="Delete"></input>'; + $display .= '<input type="hidden" name="op" value=""></input>'; + $display .= '<input type="hidden" name="lid" value="'.$lid.'"></input>'; + $display .= '<span style="padding-left:10px;">'; + $display .= '<input type="submit" value="'._MD_APPROVE.'" onClick=\'this.form.op.value="approve"\'></input></span>'; + $display .= '</td><td style="padding:10px;">Download to preview: <a href="' . $tempfileurl . '">tempfile</a></td></tr>'; + if ($numrows > 1 and $i < $numrows ) { + $i++; + } + $display .= '</table></form></td></tr>'; + } + $display .= '</table>'; + } else { + $display .= '<div style="padding:20px">' . _MD_NOSUBMITTED .'</div>'; + } + + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + + +function categoryConfigAdmin(){ + global $_CONF, $_TABLES, $LANG_FM02, $_FM_TABLES, $myts, $eh, $mytree; + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= filemgmt_navbar($LANG_FM02['nav2']); + $display .= '<table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%">'; + $display .= '<form action="index.php" method="post" enctype="multipart/form-data" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_ADDMAIN . '</td></tr>'; + $display .= '<tr><td>' . _MD_TITLEC. '</td><td><input type=text name=title size=30 maxlength=50></td></tr>'; + $display .= '<tr><td>' . _MD_CATSEC. '</td><td><select name="sel_access">'; + $display .= COM_optionList($_TABLES['groups'], "grp_id,grp_name") . '</select></td></tr>'; + $display .= '<tr><td>'. _MD_ADDCATEGORYSNAP . '<br><span style="text-size:-2">'. _MD_ADDIMAGENOTE .'</span></td>'; + $display .= '<td><input type="file" name="uploadfile" size="50" maxlength="200"></td></tr>'; + $display .= '<tr><td colspan="2" style="text-align:center;padding:10px;">'; + $display .= "<input type=hidden name=cid value=0>\n"; + $display .= "<input type=hidden name=op value=addCat>"; + $display .= "<input type=submit value="._MD_ADD."></td></tr></table><br></form>"; + + // Add a New Sub-Category + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_cat']}"); + $numrows = DB_numROWS($result); + if($numrows > 0) { + $display .= '</td></tr><tr><td>'; + $display .= '<form method="post" action="index.php" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_ADDSUB . '</td></tr>'; + + $display .= '<tr><td width="20%">'. _MD_TITLEC.'</td><td><input type="text" name="title" size="30" maxlength="50"> ' ._MD_IN. ' '; + $display .= $mytree->makeMySelBox('title', 'title') . '</td></tr>'; + $display .= '<tr><td colspan="2" style="text-align:center;padding:10px;">'; + $display .= '<input type="hidden" name="op" value="addCat">'; + $display .= "<input type=submit value="._MD_ADD."></td></tr></table><br></form>"; + // Modify Category + $display .= '</td></tr><tr><td>'; + $display .= '<form method="post" action="index.php" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_MODCAT . '</td></tr>'; + $display .= '<tr><td width="20%">'. _MD_CATEGORYC .'</td><td>'; + $display .= $mytree->makeMySelBox('title', 'title') . '</td></tr>'; + $display .= '<tr><td colspan="2" style="text-align:center;padding:10px;">'; + $display .= '<input type="hidden" name="op" value="modCat">'; + $display .= "<input type=submit value="._MD_MODIFY."></td></tr></table><br></form>"; + } + $display .= '</td></tr></table>'; + + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; + +} + +function newfileConfigAdmin(){ + global $_CONF,$myts,$eh,$mytree,$LANG_FM02; + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= filemgmt_navbar($LANG_FM02['nav3']); + $display .= '<form method="POST" enctype="multipart/form-data" action="index.php" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_ADDNEWFILE . '</td></tr>'; + $display .= '<tr><td align="right">'._MD_FILETITLE.'</td><td>'; + $display .= '<input type="text" name="title" size="50" maxlength="100">'; + $display .= '</td></tr><tr><td align="right" nowrap>File:</td><td>'; + $display .= '<input type="file" name="newfile" size="50" maxlength="100">'; + $display .= '</td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_CATEGORYC.'</td><td>'; + $display .= $mytree->makeMySelBox('title', 'title'); + $display .= '</td></tr><tr><td></td><td></td></tr>'; + $display .= '<tr><td align="right" nowrap>'._MD_HOMEPAGEC.'</td><td>'; + $display .= '<input type="text" name="homepage" size="50" maxlength="100"></td></tr>'; + $display .= '<tr><td align="right">'._MD_VERSIONC.'</td><td>'; + $display .= '<input type="text" name="version" size="10" maxlength="10"></td></tr>'; + $display .= '<tr><td align="right" valign="top" nowrap>'._MD_DESCRIPTIONC.'</td><td>'; + $display .= '<textarea name="description" cols="60" rows="5"></textarea>'; + $display .= '</td></tr>'; + $display .= '<tr><td align="right"nowrap>'._MD_SHOTIMAGE.'</td><td>'; + $display .= '<input type="file" name="newfileshot" size="50" maxlength="60"></td></tr>'; + $display .= '<tr><td align="right"></td><td>'; + $display .= '</td></tr><tr><td align="right">'._MD_COMMENTOPTION.'</td><td>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="1" CHECKED> ' ._MD_YES.' </INPUT>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="0" > ' ._MD_NO.' </INPUT>'; + $display .= '</td></tr>'; + $display .= '<tr><td colspan="2" style="text-align:center;padding:10px;">'; + $display .= '<input type="hidden" name="op" value="addDownload"></input>'; + $display .= '<input type="submit" class="button" value="'._MD_ADD.'"></input>'; + $display .= '</td></tr></table>'; + $display .= '</form>'; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; + +} + +function modDownload() { + global $_CONF,$_FM_TABLES,$_USER,$myts,$eh,$mytree,$filemgmt_SnapStore,$filemgmt_FileSnapURL; + + $lid = $_GET['lid']; + $result = DB_query("SELECT cid, title, url, homepage, version, size, logourl, comments FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + $nrows = DB_numROWS($result); + if ($nrows == 0) { + redirect_header("index.php",2,_MD_NOMATCH); + exit(); + } + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + + $display .= '<form method=post enctype="multipart/form-data" action=index.php>'; + $display .= '<input type="hidden" name="op" value="modDownloadS">'; + $display .= '<input type="hidden" name="lid" value="'.$lid.'">'; + $display .= '<table width="100%" border="0" class="plugin">'; + + list($cid, $title, $url, $homepage, $version, $size, $logourl,$comments) = DB_fetchARRAY($result); + $title = $myts->makeTboxData4Edit($title); + $pathstring = "<a href=\"{$_CONF['site_url']}/filemgmt/index.php\">"._MD_MAIN."</a> : "; + $nicepath = $mytree->getNicePathFromId($cid, "title", "{$_CONF['site_url']}/filemgmt/viewcat.php?op="); + $pathstring .= $nicepath; + $pathstring .= "<a href=\"{$_CONF['site_url']}/filemgmt/index.php?id=$lid\">{$title}</a>"; + + $display .= '<tr><td colspan="3" width="100%" style="padding:5px;">' . $pathstring. '</td></tr>'; + $display .= '<tr><td colspan="3" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_MODDL. '</td></tr>'; + + $url = rawurldecode($myts->makeTboxData4Edit($url)); + $homepage = $myts->makeTboxData4Edit($homepage); + $version = $myts->makeTboxData4Edit($version); + $size = $myts->makeTboxData4Edit($size); + $logourl = rawurldecode($myts->makeTboxData4Edit($logourl)); + $result2 = DB_query("SELECT description FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid=$lid"); + list($description)=DB_fetchARRAY($result2); + $description = $myts->makeTareaData4Edit($description); + $display .= '<tr><td>'._MD_FILEID.'</td><td colspan="2"><b>'.$lid.'</b></td></tr>'; + $display .= '<tr><td>'._MD_FILETITLE.'</td><td colspan="2"><input type="text" name="title" value="'.$title.'" size="50" maxlength="200"></input></td></tr>' .LB; + $display .= '<tr><td>'._MD_DLFILENAME.'</td><td colspan="2"><input type="text" name="url" value="'.$url.'" size="50" maxlength="200"></input></td></tr>' .LB; + $display .= '<tr><td width="25%">'._MD_REPLFILENAME.'</td><td colspan="2"><input type="file" name="newfile" size="50" maxlength="200"></input></td></tr>' .LB; + $display .= '<tr><td>'._MD_HOMEPAGEC.'</td><td colspan="2"><input type="text" name="homepage" value="'.$homepage.'" size="50" maxlength="150"></input></td></tr>' .LB; + $display .= '<tr><td>'._MD_VERSIONC.'</td><td colspan="2"><input type="text" name="version" value="'.$version.'" size="10" maxlength="10"></input></td></tr>' .LB; + $display .= '<tr><td>'._MD_FILESIZEC.'</td><td colspan="2"><input type="text" name=size value="'.$size.'" size="10" maxlength="20"></input> '._MD_BYTES.'</td></tr>' .LB; + $display .= '<tr><td valign="top">'._MD_DESCRIPTIONC.'</td><td colspan="2"><textarea name="description" cols="55" rows="10">'.$description.'</textarea></td></tr>' .LB; + $display .= '<tr><td>'._MD_CATEGORYC.'</td><td colspan="2">'; + $display .= $mytree->makeMySelBox("title", "title", $cid,0,"cid"); + $display .= '</td></tr>' .LB; + + if (!empty($logourl) AND file_exists($filemgmt_SnapStore.$logourl)) { + $display .= '<tr><td>'._MD_SHOTIMAGE.'</td><td width="5%"><img src="' .$filemgmt_FileSnapURL.$logourl. '" width="80"></td>' .LB; + $display .= '<td width="35%"><input type="file" size="40" name="newfileshot"><br><br><input type="checkbox" name=deletesnap> Delete</td></tr>' .LB; + } else { + $display .= '<tr><td>'._MD_SHOTIMAGE.'</td>' .LB; + $display .= '<td colspan="2"><input type="file" size="40" name="newfileshot"></td></tr>' .LB; + } + + $display .= '<tr><td>'._MD_COMMENTOPTION.'</td><td colspan="2">'; + if ($comments) { + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="1" CHECKED> '._MD_YES.' </INPUT>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="0" > '._MD_NO.' </INPUT>'; + } else { + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="1" > '._MD_YES.' </INPUT>'; + $display .= '<INPUT TYPE="RADIO" NAME="commentoption" VALUE="0" CHECKED> '._MD_NO.' </INPUT>'; + } + $display .= '</td></tr>' .LB; + $display .= '<tr><td colspan="3" style="text-align:center;padding:10px;">'; + $display .= '<input type="submit" value="'._MD_SUBMIT.'"><span style="padding-left:15px;padding-right:15px;">'; + $display .= '<input type="submit" value="'._MD_DELETE.'" onClick=\'if (confirm("Delete this file ?")) {this.form.op.value="delDownload";return true}; return false\'>'; + $display .= "</span><input type=button value="._MD_CANCEL." onclick=\"javascript:history.go(-1)\">"; + $display .= '</td></tr></table></form>' .LB; + + + /* Display File Voting Information */ + $result5 = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_votedata']}"); + list ($totalvotes) = DB_fetchARRAY($result5); + + $display .= '<form method="post" action="index.php">'; + $display .= '<input type="hidden" name="op" value="">'; + $display .= '<input type="hidden" name="rid" value="">'; + $display .= '<input type="hidden" name="lid" value="'.$lid.'">'; + $display .= '<table valign="top" width="100%" class="pluginSubTable">'; + $display .= '<tr><th colspan="7">'; + if ($totalvotes == '') + $totalvotes = 0; + $display .= sprintf(_MD_DLRATINGS,$totalvotes); + $display .= '</th></tr>'; + // Show Registered Users Votes + $result5 = DB_query("SELECT ratingid, ratinguser, rating, ratinghostname, ratingtimestamp FROM {$_FM_TABLES['filemgmt_votedata']} WHERE lid='$lid' AND ratinguser != 0 ORDER BY ratingtimestamp DESC"); + $votes = DB_numROWS($result5); + $display .= '<tr><td colspan="7">'; + $display .= sprintf(_MD_REGUSERVOTES,$votes); + $display .= '</td></tr>'; + $display .= '<tr><th>'._MD_USER.'</th><th>'._MD_IP.'</th><th>'._MD_RATING.'</th><th>'._MD_USERAVG.'</th><th>'._MD_TOTALRATE.'</th><th>'._MD_DATE.'</th><th align="center">'._MD_DELETE.'</th></tr>'; + if ($votes == 0){ + $display .= '<tr><td align="center" colspan="7">'._MD_NOREGVOTES.'<br></td></tr>'; + } + $x=0; + $cssid = 1; + while(list($ratingid, $ratinguser, $rating, $ratinghostname, $ratingtimestamp)=DB_fetchARRAY($result5)) { + $formatted_date = formatTimestamp($ratingtimestamp); + + //Individual user information + $result2 = DB_query("SELECT rating FROM {$_FM_TABLES['filemgmt_votedata']} WHERE ratinguser='$ratinguser'"); + $uservotes = DB_numROWS($result2); + $useravgrating = 0; + while(list($rating2) = DB_fetchARRAY($result2)){ + $useravgrating = $useravgrating + $rating2; + } + $useravgrating = $useravgrating / $uservotes; + $useravgrating = number_format($useravgrating, 1); + $ratinguname = $_USER['username']; + $display .= "<tr class=\"pluginRow{$cssid}\"><td>$ratinguname</td><td>$ratinghostname</td><td>$rating</td>"; + $display .= "<td>$useravgrating</td><td>$uservotes</td><td>$formatted_date</td><td style=\"text-align:right;padding-right:20px;\">"; + $display .= '<input type="image" src="'.$_CONF['site_url'].'/filemgmt/images/delete.gif" '; + $display .= 'onClick=\'if (confirm("Delete this record")) {this.form.op.value="delVote";this.form.lid.value="'.$lid.'";this.form.rid.value="'.$ratingid.'";return true};return false;\' value="Delete"></input>'; + $display .= "</td></tr>\n"; + $x++; + $cssid = ($cssid == 1) ? 2 : 1; + + } + $display .= '</table></form>' .LB; + // Show Unregistered Users Votes + $result5 = DB_query("SELECT ratingid, rating, ratinghostname, ratingtimestamp FROM {$_FM_TABLES['filemgmt_votedata']} WHERE lid='$lid' AND ratinguser=0 ORDER BY ratingtimestamp DESC"); + $votes = DB_numROWS($result5); + $display .= '<form method="post" action="index.php" onSubmit="alert(this.form.op.value)">'; + $display .= '<input type="hidden" name="op" value="">'; + $display .= '<input type="hidden" name="rid" value="">'; + $display .= '<input type="hidden" name="lid" value="'.$lid.'">'; + $display .= '<table valign="top" width="100%" class="pluginSubTable">'; + $display .= '<tr><th colspan="7">'; + $display .= sprintf(_MD_ANONUSERVOTES,$votes); + $display .= '</th></tr>'; + $display .= '<tr><th colspan="2">'._MD_IP.'</th><th colspan="3">'._MD_RATING.'</th><th colspan="2">'._MD_DATE.'</th></tr>'; + if ($votes == 0) { + $display .= "<tr><td colspan=\"7\" align=\"center\">" ._MD_NOUNREGVOTES."<br></td></tr>"; + } + $x=0; + $cssid = 1; + while(list($ratingid, $rating, $ratinghostname, $ratingtimestamp)=DB_fetchARRAY($result5)) { + $formatted_date = formatTimestamp($ratingtimestamp); + $display .= "<tr class=\"pluginRow{$cssid}\" style=\"vertical-align:bottom;\"><td colspan=\"2\">$ratinghostname</td><td colspan=\"3\">$rating</td>"; + $display .= "<td>$formatted_date</td><td style=\"text-align:right;padding-right:20px;\">"; + $display .= '<input type="image" src="'.$_CONF['site_url'].'/filemgmt/images/delete.gif" '; + $display .= 'onClick=\'if (confirm("Delete this record")) {this.form.op.value="delVote";this.form.lid.value="'.$lid.'";this.form.rid.value="'.$ratingid.'";return true};return false;\' value="Delete"></input>'; + $display .= "</td></tr>"; + $x++; + $cssid = ($cssid == 1) ? 2 : 1; + } + $display .= "<tr><td colspan=\"6\"> <br></td></tr>\n"; + $display .= "</table></form>"; + $display .= CloseTable(); + $display .= "<br>"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + +function listBrokenDownloads() { + global $_CONF,$_TABLES,$_FM_TABLES,$LANG_FM02,$myts,$eh; + + $result = DB_query("SELECT * FROM {$_FM_TABLES['filemgmt_brokenlinks']} ORDER BY reportid"); + $totalbrokendownloads = DB_numROWS($result); + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock('<b>'._MD_ADMINTITLE.'</b>'); + $display .= filemgmt_navbar($LANG_FM02['nav5']); + + if ($totalbrokendownloads==0) { + $display .= _MD_NOBROKEN; + } else { + $display .= '<form method="post" action="index.php">'; + $display .= '<input type="hidden" name="op" value="">'; + $display .= '<input type="hidden" name="lid" value="">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="5" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_BROKENREPORTS. " ($totalbrokendownloads)</td></tr>"; + $display .= '<tr><td colspan="5">' . _MD_IGNOREDESC . "<br>"._MD_DELETEDESC."</td></tr>"; + $display .= '<tr class="pluginHeader"><th>'._MD_FILETITLE.'</th><th>'._MD_REPORTER.'</th>'; + $display .= '<th>'._MD_FILESUBMITTER.'</th><th>'._MD_IGNORE.'</th><th>'._MD_DELETE.'</th></tr>'; + + $cssid = 1; + while(list($reportid, $lid, $sender, $ip) = DB_fetchARRAY($result)) { + $result2 = DB_query("SELECT title, url, submitter FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + if ($sender != 0) { + $result3 = DB_query("SELECT username, email FROM {$_TABLES['users']} WHERE uid='$sender'"); + list($sendername, $email) = DB_fetchARRAY($result3); + } + list($title, $url, $owner) = DB_fetchARRAY($result2); + $result4 = DB_query("SELECT username, email FROM {$_TABLES['users']} WHERE uid='$owner'"); + list($ownername, $owneremail) = DB_fetchARRAY($result4); + $display .= '<tr class="pluginRow'.$cssid.'"><td><a href="'.$_CONF['site_url'].'/filemgmt/visit.php?lid='.$lid.'">'.$title.'</a></td>'; + + if ($email == '') { + $display .= "<td>$sendername ($ip)"; + } else { + $display .= "<td><a href=mailto:$email>$sendername</a> ($ip)"; + } + $display .= "</td>"; + if ($owneremail == '') { + $display .= "<td>$ownername"; + } else { + $display .= "<td><a href=mailto:$owneremail>$ownername</a>"; + } + $display .= "</td><td style='text-align:center'>"; + $display .= '<input type="image" src="'.$_CONF['site_url'].'/filemgmt/images/delete.gif" '; + $display .= 'onClick=\'if (confirm("Delete this broken file report?")) {this.form.op.value="ignoreBrokenDownloads";'; + $display .= 'this.form.lid.value="'.$lid.'";return true};return false;\'">'; + $display .= "</td>"; + $display .= "<td style='text-align:center'>"; + $display .= '<input type="image" src="'.$_CONF['site_url'].'/filemgmt/images/delete.gif" '; + $display .= 'onClick=\'if (confirm("Delete the file from your repository?")) {this.form.op.value="delBrokenDownloads";'; + $display .= 'this.form.lid.value="'.$lid.'";return true};return false;\'">'; + $display .= "</td></tr>\n"; + $cssid = ($cssid == 1) ? 2 : 1; + } + $display .= "</table>"; + } + $display .= CloseTable(); + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + +function delBrokenDownloads() { + global $_FM_TABLES,$eh; + + $lid = $_POST['lid']; + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + redirect_header("index.php?op=listBrokenDownloads",1,_MD_FILEDELETED); + exit(); +} + +function ignoreBrokenDownloads() { + global $_FM_TABLES,$eh; + + $lid = $_POST['lid']; + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid'"); + redirect_header("index.php?op=listBrokenDownloads",1,_MD_BROKENDELETED); + exit(); +} + +function delVote() { + global $_CONF,$_FM_TABLES,$eh; + + $rid = $_POST['rid']; + $lid = $_POST['lid']; + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_votedata']} WHERE ratingid='$rid'"); + updaterating($lid); + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php?lid=$lid&op=modDownload",2,_MD_VOTEDELETED); + exit(); +} + + +function modDownloadS() { + global $_CONF,$_FM_TABLES,$myts,$eh,$filemgmt_SnapStore,$filemgmt_FileStore; + + $cid = $_POST["cid"]; + if (($_POST["url"]) || ($_POST["url"]!="")) { + $url = rawurlencode($myts->makeTboxData4Save($_POST['url'])); + } + + $currentfile = DB_getITEM($_FM_TABLES['filemgmt_filedetail'], 'url', "lid='{$_POST['lid']}'"); + $currentfileFQN = $filemgmt_FileStore . $myts->makeTboxData4Save(rawurldecode($currentfile)); + $newfile = rawurlencode($myts->makeTboxData4Save($_FILES['newfile']['name'])); + COM_errorLOG("Currentfilename is:'$currentfile' and new file is:'$newfile'"); + if (($newfile != '' AND $currentfile != $newfile) OR ($newfile != '' and $currentfile == '')) { + COM_errorLOG("Download file has changed"); + if (uploadNewFile($_FILES["newfile"],$filemgmt_FileStore)) { + if (file_exists($currentfileFQN) && (!is_dir($currentfileFQN))) { + $err=@unlink ($currentfileFQN); + } + $url = rawurlencode($myts->makeTboxData4Save($_FILES['newfile']['name'])); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET url='$url' WHERE lid='{$_POST['lid']}'"); + } + } + + $currentsnapfile = DB_getITEM($_FM_TABLES['filemgmt_filedetail'], 'logourl', "lid='{$_POST['lid']}'"); + $currentSnapFQN = $filemgmt_SnapStore . $myts->makeTboxData4Save(rawurldecode($currentsnapfile)); + $newsnapfile = rawurlencode($myts->makeTboxData4Save($_FILES['newfileshot']['name'])); + if (($newsnapfile !="" AND $currentsnapfile != $newsnapfile) OR ($newsnapfile != '' and $currentsnapfile == '')) { + //COM_errorLOG("Snap file has changed"); + if (uploadNewFile($_FILES["newfileshot"],$filemgmt_SnapStore)) { + if (file_exists($currentSnapFQN) && (!is_dir($currentSnapFQN))) { + $err=@unlink ($currentSnapFQN); + } + $logourl = rawurlencode($myts->makeTboxData4Save($_FILES['newfileshot']['name'])); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET logourl='$logourl' WHERE lid='{$_POST['lid']}'"); + } + } elseif(isset($_POST['deletesnap'])) { + if (file_exists($currentSnapFQN) && (!is_dir($currentSnapFQN))) { + $err=@unlink ($currentSnapFQN); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET logourl='' WHERE lid='{$_POST['lid']}'"); + COM_errorLOG("Delete repository snapfile:$currentSnapFQN."); + } + } + + $title = $myts->makeTboxData4Save($_POST['title']); + $homepage = $myts->makeTboxData4Save($_POST['homepage']); + $version = $myts->makeTboxData4Save($_POST['version']); + $size = $myts->makeTboxData4Save($_POST['size']); + $description = $myts->makeTareaData4Save($_POST['description']); + $commentoption = $_POST['commentoption']; + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET cid='$cid', title='$title', url='$url', homepage='$homepage', version='$version', size='$size', status=1, date=".time().", comments='$commentoption' WHERE lid='{$_POST['lid']}'"); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedesc']} SET description='$description' WHERE lid='{$_POST['lid']}'"); + redirect_header("{$_CONF['site_url']}/filemgmt/index.php",2,_MD_DBUPDATED); + exit(); +} + +function delDownload() { + global $_FM_TABLES,$_CONF,$myts,$filemgmt_FileStore,$filemgmt_SnapStore,$eh; + + $lid = $myts->makeTboxData4Save($_POST['lid']); + $name = $myts->makeTboxData4Save(rawurldecode($_POST['url'])); + $tmpurl = rawurlencode($_POST['url']); + $tmpfile = $filemgmt_FileStore . $name; + + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE url='$tmpurl'"); + list($numrows) = DB_fetchARRAY($result); + $tmpsnap = DB_getItem($_FM_TABLES['filemgmt_filedetail'],'logourl',"lid='$lid'"); + $tmpsnap = $filemgmt_SnapStore . $tmpsnap; + + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_votedata']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid'"); + + // Check for duplicate files of the same filename (actual filename in repository) + // We don't want to delete actual file if there are more then 1 record linking to it. + // Site may be allowing more then 1 file listing to duplicate files + if ($numrows > 1) { + redirect_header("{$_CONF['site_url']}/filemgmt/index.php",2,_MD_FILENOTDELETED); + exit(); + } else { + if ($tmpfile != "" && file_exists($tmpfile) && (!is_dir($tmpfile))) { + $err=@unlink ($tmpfile); + } + if ($tmpsnap != "" && file_exists($tmpsnap) && (!is_dir($tmpsnap))) { + $err=@unlink ($tmpsnap); + } + } + redirect_header("{$_CONF['site_url']}/filemgmt/index.php",2,_MD_FILEDELETED); + exit(); +} + +function modCat() { + global $_CONF,$_TABLES,$_FM_TABLES,$myts,$eh,$mytree,$LANG_FM02; + + $cid = $_POST["cid"]; + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= filemgmt_navbar($LANG_FM02['nav2']); + $display .= '<form action="index.php" method="post" enctype="multipart/form-data" style="margin:0px;">'; + $display .= '<input type="hidden" name="op" value="modCatS">'; + $display .= '<input type="hidden" name="cid" value="'.$cid.'">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_MODCAT . '</td></tr>'; + + $result = DB_query("SELECT pid, title, imgurl, grp_access FROM {$_FM_TABLES['filemgmt_cat']} WHERE cid='$cid'"); + list($pid,$title,$imgurl,$grp_access) = DB_fetchARRAY($result); + $title = $myts->makeTboxData4Edit($title); + $imgurl = rawurldecode($myts->makeTboxData4Edit($imgurl)); + + $display .= '<form action="index.php" method="post" enctype="multipart/form-data">'; + $display .= '<tr><td>' . _MD_TITLEC. '</td><td><input type="text" name="title" value="'.$title.'" size="51" maxlength="50"></td></tr>'; + $display .= '<tr><td>' . _MD_CATSEC. '</td><td><select name="sel_access"><option value="0">Select Access</option>'; + $display .= COM_optionList($_TABLES['groups'], "grp_id,grp_name",$grp_access) . '</select></td></tr>'; + $display .= '<tr><td>' ._MD_IMGURLMAIN. '</td><td><input type="file" name="imgurl" value="'.$imgurl.'" size="50" maxlength="100"></td></tr>'; + $display .= '<tr><td>' . _MD_PARENT. '</td><td>'; + $display .= $mytree->makeMySelBox("title", "title", $pid, 1, "pid"); + $display .= '</td></tr>'; + $display .= '<tr><td colspan="2" style="text-align:center;padding:10px;">'; + $display .= '<input type="submit" value="'._MD_SAVE.'">'; + $display .= '<input type="submit" value="'._MD_DELETE.'" onClick=\'if (confirm("Delete this file ?")) {this.form.op.value="delCat";return true}; return false\'>'; + $display .= " <input type=button value="._MD_CANCEL." onclick=\"javascript:history.go(-1)\">"; + $display .= '</td></tr></table>'; + $display .= "</form>"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + + +function delNewDownload() { + global $_FM_TABLES,$filemgmt_FileStore,$filemgmt_SnapCat,$filemgmt_SnapStore,$myts,$eh; + + $lid = $_POST['lid']; + if (DB_count($_FM_TABLES['filemgmt_filedetail'],'lid',$lid) == 1) { + $tmpnames = explode(";",DB_getItem($_FM_TABLES['filemgmt_filedetail'],'platform',"lid='$lid'")); + $tmpfilename = $tmpnames[0]; + $tmpshotname = $tmpnames[1]; + $tmpfilename = $filemgmt_FileStore ."tmp/" . $tmpfilename; + $tmpshotname = $filemgmt_SnapStore ."tmp/" . $tmpshotname; + + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid='$lid'"); + if ($tmpfilename != '' && file_exists($tmpfilename) && (!is_dir($tmpfilename))) { + $err=@unlink ($tmpfilename); + //COM_errorLOG("Delete submitted file: ".$tmpfilename." Return status of unlink is: ".$err); + } + if ($tmpshotname != '' && file_exists($tmpshotname) && (!is_dir($tmpshotename))) { + $err=@unlink ($tmpshotname); + //COM_errorLOG("Delete submitted snapshot: ".$tmpshotname." Return status of unlink is: ".$err); + } + redirect_header("index.php?op=listNewDownloads",1,_MD_FILEDELETED); + } else { + redirect_header("index.php?op=listNewDownloads",1,_MD_ERRORNOFILE); + } + exit(); +} + + + +function modCatS() { + global $_CONF,$_FM_TABLES,$myts,$eh; + + $cid = $_POST['cid']; + $sid = $_POST['pid']; + $title = $myts->makeTboxData4Save($_POST['title']); + $title = str_replace('/','/',$title); + $grp_access = $_POST['sel_access']; + if ($grp_access < 1 ) { + $grp_access = 2; // All Users Group + } + if (($_POST["imgurl"]) || ($_POST["imgurl"]!="")) { + $imgurl = $myts->makeTboxData4Save($_POST["imgurl"]); + } + DB_query("UPDATE {$_FM_TABLES['filemgmt_cat']} SET title='$title', imgurl='$imgurl', pid='$sid', grp_access='$grp_access' where cid='$cid'"); + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php",2,_MD_DBUPDATED); + exit(); +} + +function delCat() { + global $_CONF,$_FM_TABLES,$eh, $mytree,$filemgmt_FileStore,$filemgmt_SnapCat,$filemgmt_SnapStore; + + $cid = $_POST['cid']; + //get all subcategories under the specified category + $arr=$mytree->getAllChildId($cid); + for($i=0;$i<sizeof($arr);$i++){ + //get all downloads in each subcategory + $result = DB_query("SELECT lid,url,logourl FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE cid='{$arr[$i]}'"); + //now for each download, delete the text data and votes associated with the download + while(list($lid,$url,$logourl)= DB_fetchARRAY($result)){ + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_votedata']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid'"); + $name = rawurldecode($url); + $fullname = $filemgmt_FileStore . $name; + if ($fullname !="" && file_exists($fullname) && (!is_dir($fullname))) { + $err=@unlink($fullname); + } + $name = rawurldecode($logourl); + $fullname = $filemgmt_SnapStore . $name; + if ($fullname !="" && file_exists($fullname) && (!is_dir($fullname))) { + $err=@unlink($fullname); + } + } + //all downloads for each subcategory is deleted, now delete the subcategory data + $catimage = DB_getItem($_FM_TABLES['filemgmt_cat'],'imgurl', "cid='{$arr[$i]}'"); + $catimage_filename = $filemgmt_SnapCat . $catimage; + if ($catimage != '' && file_exists($catimage_filename) && (!is_dir($catimage_filename))) { + // Check that there is only one category using this image + if (DB_count($_FM_TABLES['filemgmt_cat'],'imgurl',$catimage) == 1) { + @unlink($catimage_filename); + } + } + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_cat']} WHERE cid='{$arr[$i]}'"); + } + //all subcategory and associated data are deleted, now delete category data and its associated data + $result = DB_query("SELECT lid,url,logourl FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE cid='$cid'"); + while(list($lid,$url,$logourl)= DB_fetchARRAY($result)){ + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_filedesc']} WHERE lid='$lid'"); + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid'"); + + $name = rawurldecode($url); + $fullname = $filemgmt_FileStore . $name; + if ($fullname !="" && file_exists($fullname) && (!is_dir($fullname))) { + $err=@unlink($fullname); + } + $name = rawurldecode($logourl); + $fullname = $filemgmt_SnapStore . $name; + if ($fullname != '' && file_exists($fullname) && (!is_dir($fullname))) { + $err=@unlink($fullname); + } + } + $catimage = DB_getItem($_FM_TABLES['filemgmt_cat'],'imgurl', "cid='$cid'"); + $catimage_filename = $filemgmt_SnapCat . $catimage; + if ($catimage != '' && file_exists($catimage_filename) && (!is_dir($catimage_filename))) { + // Check that there is only one category using this image + if (DB_count($_FM_TABLES['filemgmt_cat'],'imgurl',$catimage) == 1) { + @unlink($catimage_filename); + } + } + DB_query("DELETE FROM {$_FM_TABLES['filemgmt_cat']} WHERE cid='$cid'"); + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php?op=categoryConfigAdmin",2,_MD_CATDELETED); + exit(); + +} + +function addCat() { + global $_CONF, $_FM_TABLES, $filemgmt_SnapCat,$filemgmt_SnapCatURL,$myts,$eh; + + $pid = $_POST['cid']; + $title = $_POST['title']; + $title = str_replace('/','/',$title); + $grp_access = $_POST['sel_access']; + if ($grp_access < 2) { + $grp_access = 2; + } + if ($title != '') { + $title = $myts->makeTboxData4Save($title); + if ($_FILES["uploadfile"]["name"]!="") { + $name = $_FILES["uploadfile"]['name']; // this is the real name of your file + $tmp = $_FILES["uploadfile"]['tmp_name']; // temporary name of file in temporary directory on server + $imgurl = rawurlencode($myts->makeTboxData4Save($name)); + if (is_uploaded_file ($tmp)) { // is this temporary file really uploaded? + if(!file_exists($filemgmt_SnapCat.$name)) { // Check to see the file already exists + $target = $filemgmt_SnapCat.$name; + $returnMove = move_uploaded_file($tmp, $target); // move temporary file to your upload directory + } + } + } + DB_query("INSERT INTO {$_FM_TABLES['filemgmt_cat']} (pid, title, imgurl,grp_access) VALUES ('$pid', '$title', '$imgurl','$grp_access')"); + } + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php?op=categoryConfigAdmin",2,_MD_NEWCATADDED); + exit(); +} + +function addDownload() { + global $_CONF,$_USER,$_FM_TABLES,$filemgmt_FileStoreURL,$filemgmt_FileSnapURL,$filemgmt_FileStore,$filemgmt_SnapStore; + global $myts,$eh; + + $filename = $myts->makeTboxData4Save($_FILES['newfile']['name']); + $url = $myts->makeTboxData4Save(rawurlencode($filename)); + $snapfilename = $myts->makeTboxData4Save($_FILES['newfileshot']['name']); + $logourl = $myts->makeTboxData4Save(rawurlencode($snapfilename)); + $title = $myts->makeTboxData4Save($_POST['title']); + $homepage = $myts->makeTboxData4Save($_POST['homepage']); + $version = $myts->makeTboxData4Save($_POST['version']); + $description = $myts->makeTareaData4Save($_POST['description']); + $commentoption = $_POST['commentoption']; + $submitter = $_USER['uid']; + $size = $myts->makeTboxData4Save(intval($_FILES['newfile']['size'])); + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE url='$url'"); + list($numrows) = DB_fetchARRAY($result); + $errormsg = ""; + + // Check if Title blank + if ($title=="") { + $eh->show("1104"); + } + // Check if Description blank + if ($description=="") { + $eh->show("1105"); + } + // Check if a file was uploaded + if ($_FILES['newfile']['size'] == 0) { + $eh->show("1017"); + } + + if ( !empty($_POST['cid']) ) { + $cid = $_POST['cid']; + } else { + $cid = 0; + } + + if (uploadNewFile($_FILES["newfile"],$filemgmt_FileStore)) { + $AddNewFile = true; + } + if (uploadNewFile($_FILES["newfileshot"],$filemgmt_SnapStore)) { + $AddNewFile = true; + } + + if ($AddNewFile){ + DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedetail']} (cid, title, url, homepage, version, size, logourl, submitter, status, date, hits, rating, votes, comments) VALUES ('$cid', '$title', '$url', '$homepage', '$version', '$size', '$logourl', '$submitter', 1, ".time().", 0, 0, 0,'$commentoption')"); + $newid = DB_insertID(); + DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedesc']} (lid, description) VALUES ($newid, '$description')"); + if ($duplicatefile) { + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php",2,_MD_NEWDLADDED_DUPFILE); + } elseif ($duplicatesnap) { + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php",2,_MD_NEWDLADDED_DUPSNAP); + } else { + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php",2,_MD_NEWDLADDED); + } + exit(); + + } else { + redirect_header("index.php",2,_MD_ERRUPLOAD.""); + exit(); + } + +} + + +function approve(){ + global $_FM_TABLES,$_TABLES,$_CONF,$myts,$eh,$filemgmt_FileStore,$filemgmt_SnapStore,$filemgmt_Emailoption,$filemgmtFilePermissions; + + $lid = $_POST['lid']; + $title = $_POST['title']; + $cid = $_POST['cid']; + if ( empty($cid) ) { + $cid = 0; + } + $homepage = $_POST['homepage']; + $version = $_POST['version']; + $size = $_POST['size']; + $description = $_POST['description']; + if (($_POST['url']) || ($_POST['url'] != '')) { + $name = $myts->makeTboxData4Save($_POST['url']); + $url = rawurlencode($name); + } + if (($_POST['logourl']) || ($_POST['logourl'] != '')) { + $shotname = $myts->makeTboxData4Save($_POST['logourl']); + $logourl = $myts->makeTboxData4Save(rawurlencode($_POST['logourl'])); + } + + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE url='$url' and status=1"); + list($numrows) = DB_fetchARRAY($result); + + // Comment out this check if you want to allow duplicate filelistings for same file in the repository + // Check for duplicate files of the same filename (actual filename in repository) + if ($numrows>0) { + $eh->show("1108"); + } + + $title = $myts->makeTboxData4Save($title); + $homepage = $myts->makeTboxData4Save($homepage); + $version = $myts->makeTboxData4Save($_POST['version']); + $size = $myts->makeTboxData4Save($_POST['size']); + $description = $myts->makeTareaData4Save($description); + $commentoption = $_POST["commentoption"]; + + // Move file from tmp directory under the document filestore to the main file directory + // Now to extract the temporary names for both the file and optional thumbnail. I've used th platform field which I'm not using now for anything. + $tmpnames = explode(";",DB_getItem($_FM_TABLES['filemgmt_filedetail'],'platform',"lid='$lid'")); + $tmpfilename = $tmpnames[0]; + $tmpshotname = $tmpnames[1]; + $tmp = $filemgmt_FileStore ."tmp/" . $tmpfilename; + if (file_exists($tmp) && (!is_dir($tmp))) { // if this temporary file was really uploaded? + $newfile = $filemgmt_FileStore .$name; + COM_errorLOG("File move from ".$tmp. " to " .$newfile ); + $rename = @rename ($tmp,$newfile); + COM_errorLOG("Results of rename is: ".$rename); + $chown = @chmod ($newfile,$filemgmtFilePermissions); + if (!file_exists($newfile )) { + COM_errorLOG("Filemgmt upload approve error: New file does not exist after move of tmp file: '".$newfile ."'"); + $AddNewFile = false; // Set false again - in case it was set true above for actual file + $eh->show("1101"); + } else { + $AddNewFile = true; + } + } else { + COM_errorLOG("Filemgmt upload approve error: Temporary file does not exist: '".$tmp ."'"); + $eh->show("1101"); + } + + if ($tmpshotname !="") { + $tmp = $filemgmt_SnapStore ."tmp/" . $tmpshotname; + if (file_exists($tmp) && (!is_dir($tmp))) { // if this temporary Thumbnail was really uploaded? + $newfile = $filemgmt_SnapStore .$shotname; + $rename = @rename ($tmp,$newfile); + $chown = @chmod ($newfile,$filemgmtFilePermissions); + if (!file_exists($newfile )) { + COM_errorLOG("Filemgmt upload approve error: New file does not exist after move of tmp file: '".$newfile ."'"); + $AddNewFile = false; // Set false again - in case it was set true above for actual file + $eh->show("1101"); + } + } else { + COM_errorLOG("Filemgmt upload approve error: Temporary file does not exist: '".$tmp ."'"); + $eh->show("1101"); + } + } + if ($AddNewFile) { + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET cid='$cid', title='$title', url='$url', homepage='$homepage', version='$version', size='$size', logourl='$logourl', status=1, date=".time() .", comments='$commentoption' where lid='$lid'"); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedesc']} SET description='$description' where lid='$lid'"); + + // Send a email to submitter notifying them that file was approved + if ($filemgmt_Emailoption) { + $result = DB_query("SELECT username, email FROM {$_TABLES['users']} a, {$_FM_TABLES['filemgmt_filedetail']} b WHERE a.uid=b.submitter and b.lid='$lid'"); + list ($submitter_name, $emailaddress) = DB_fetchARRAY($result); + $mailtext = sprintf(_MD_HELLO,$submitter_name); + $mailtext .= ",\n\n" ._MD_WEAPPROVED. " " .$title. " \n" ._MD_THANKSSUBMIT. "\n\n"; + $mailtext .= "{$_CONF["site_name"]}\n"; + $mailtext .= "{$_CONF['site_url']}\n"; + //COM_errorLOG("email: ".$emailaddress.", text: ".$mailtext); + if (function_exists(COM_mail) ) { + COM_mail($emailaddress,_MD_APPROVED,$mailtext); + } else { + mail($emailaddress ,"{$_CONF["site_name"]}: " . _MD_UPLOADAPPROVED ,$mailtext, "From: {$_CONF["site_name"]} <{$_CONF["site_mail"]}>\nReturn-Path: <{$_CONF["site_mail"]}>\nX-Mailer: GeekLog $VERSION" ); + } + } + } + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php?op=listNewDownloads",2,_MD_NEWDLADDED); + exit(); +} + + +function filemgmtConfigAdmin() { + global $filemgmt_AllUserAccess, $filemgmt_AllowUserUploads,$LANG_FM02; + global $mydownloads_perpage, $mydownloads_popular, $mydownloads_newdownloads, $mydownloads_trimdesc, $mydownloads_dlreport; + global $mydownloads_selectpriv, $mydownloads_uploadselect, $mydownloads_publicpriv, $mydownloads_uploadpublic; + global $mydownloads_useshots, $mydownloads_shotwidth, $mydownloads_whatsnew, $filemgmt_Emailoption; + global $filemgmt_FileStoreURL,$filemgmt_FileSnapURL, $filemgmt_FileStore, $filemgmt_SnapStore, $filemgmt_SnapCat, $filemgmt_SnapCatURL; + + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= filemgmt_navbar($LANG_FM02['nav1']); + $display .= '<form action="index.php" method="post" style="margin:0px;">'; + $display .= '<table width="100%" border="0" class="plugin">'; + $display .= '<tr><td colspan="2" width="100%" class="pluginHeader" style="padding:5px;">' . _MD_GENERALSET . '</td></tr>'; + $display .= '<tr><td nowrap>' ._MD_DLSPERPAGE. '</td>'; + $display .= "<td> + <select name=xmydownloads_perpage> + <option value=$mydownloads_perpage selected>$mydownloads_perpage</option> + <option value=5>5</option> + <option value=10>10</option> + <option value=15>15</option> + <option value=20>20</option> + <option value=25>25</option> + <option value=30>30</option> + <option value=50>50</option> + </select> + </td></tr><tr><td nowrap> + "._MD_HITSPOP."</td><td> + <select name=xmydownloads_popular> + <option value=$mydownloads_popular selected>$mydownloads_popular</option> + <option value=5>5</option> + <option value=10>10</option> + <option value=20>20</option> + <option value=50>50</option> + <option value=100>100</option> + <option value=500>500</option> + <option value=1000>1000</option> + </select> + </td></tr><tr><td nowrap> + "._MD_DLSNEW."</td><td> + <select name=xmydownloads_newdownloads> + <option value=$mydownloads_newdownloads selected>$mydownloads_newdownloads</option> + <option value=10>10</option> + <option value=15>15</option> + <option value=20>20</option> + <option value=25>25</option> + <option value=30>30</option> + <option value=50>50</option> + </select><BR>"; + $display .= "</td></tr><tr><td nowrap>" . _MD_DLREPORT . " </td><td>"; + if ($mydownloads_dlreport==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_dlreport\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_dlreport\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_dlreport\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_dlreport\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td nowrap>" . _MD_TRIMDESC . " </td><td>"; + if ($mydownloads_trimdesc==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_trimdesc\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_trimdesc\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_trimdesc\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_trimdesc\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td nowrap>" . _MD_WHATSNEWDESC . " </td><td>"; + if ($mydownloads_whatsnew==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_whatsnew\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_whatsnew\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_whatsnew\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_whatsnew\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td colspan=2><HR>"; + $display .= "</td></tr><tr><td nowrap>" . _MD_SELECTPRIV . " </td><td>"; + if ($mydownloads_selectpriv==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_selectpriv\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_selectpriv\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_selectpriv\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_selectpriv\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td nowrap>" . _MD_UPLOADSELECT . " </td><td>"; + if ($mydownloads_uploadselect==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadselect\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadselect\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadselect\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadselect\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td nowrap>" . _MD_ACCESSPRIV . " </td><td>"; + if ($mydownloads_publicpriv==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_publicpriv\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_publicpriv\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_publicpriv\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_publicpriv\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td nowrap>" . _MD_UPLOADPUBLIC . " </td><td>"; + if ($mydownloads_uploadpublic==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadpublic\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadpublic\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadpublic\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_uploadpublic\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr><tr><td colspan=2><HR>"; + $display .= "</td></tr><tr><td nowrap>" . _MD_USESHOTS . " </td><td>"; + if ($mydownloads_useshots==1) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_useshots\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_useshots\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_useshots\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"xmydownloads_useshots\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + $display .= "</td></tr>"; + $display .= "<tr><td nowrap>" . _MD_IMGWIDTH . " </td><td>"; + if($mydownloads_shotwidth!=""){ + $display .= "<INPUT TYPE=\"text\" size=\"10\" NAME=\"xmydownloads_shotwidth\" VALUE=\"$mydownloads_shotwidth\"></INPUT>"; + }else{ + $display .= "<INPUT TYPE=\"text\" size=\"10\" NAME=\"xmydownloads_shotwidth\" VALUE=\"140\"></INPUT>"; + } + + $display .= "</td></tr><tr><td nowrap>"._MD_EMAILOPTION."</td><td>"; + if ($filemgmt_Emailoption == true) { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"my_emailoption\" VALUE=\"1\" CHECKED> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"my_emailoption\" VALUE=\"0\" > " ._MD_NO." </INPUT>"; + } else { + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"my_emailoption\" VALUE=\"1\"> " ._MD_YES." </INPUT>"; + $display .= "<INPUT TYPE=\"RADIO\" NAME=\"my_emailoption\" VALUE=\"0\" CHECKED> " ._MD_NO." </INPUT>"; + } + + $display .= "</td></tr><tr><td nowrap>Directory to store files: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_filestore' VALUE='$filemgmt_FileStore'></INPUT>"; + $display .= "</td></tr><tr><td nowrap>Directory to store file thumbnails: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_snapstore' VALUE='$filemgmt_SnapStore'></INPUT>"; + $display .= "</td></tr><tr><td nowrap>Directory to store category thumbnails: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_snapcat' VALUE='$filemgmt_SnapCat'></INPUT>"; + $display .= "</td></tr><tr><td nowrap>URL to files: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_filestoreurl' VALUE='$filemgmt_FileStoreURL'></INPUT>"; + $display .= "</td></tr><tr><td nowrap>URL to file thumbnails: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_filesnapurl' VALUE='$filemgmt_FileSnapURL'></INPUT>"; + $display .= "</td></tr><tr><td nowrap>URL to category thumbnails: </td><td>"; + $display .= "<INPUT TYPE='text' size='60' maxlength='150' NAME='my_snapcaturl' VALUE='$filemgmt_SnapCatURL'></INPUT>"; + $display .= "</td></tr>"; + $display .= '<tr><td colspan="2" style="padding:10px;text-align:center">'; + $display .= "<input type=\"hidden\" name=\"op\" value=\"filemgmtConfigChange\">"; + $display .= "<input type=\"submit\" value=\""._MD_SAVE."\">"; + $display .= " <input type=\"button\" value=\""._MD_CANCEL."\" onclick=\"javascript:history.go(-1)\">"; + $display .= "</td></tr></table>"; + $display .= "</form>"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + +function filemgmtConfigChange($op='') { + global $_TABLES, $_CONF; + global $filemgmt_AllUserAccess, $filemgmt_AllowUserUploads; + global $mydownloads_perpage, $mydownloads_popular, $mydownloads_newdownloads, $mydownloads_trimdesc, $mydownloads_dlreport; + global $mydownloads_selectpriv, $mydownloads_uploadselect, $mydownloads_publicpriv, $mydownloads_uploadpublic; + global $mydownloads_useshots, $mydownloads_shotwidth, $mydownloads_whatsnew, $filemgmt_Emailoption; + global $filemgmt_FileStoreURL,$filemgmt_FileSnapURL, $filemgmt_FileStore, $filemgmt_SnapStore, $filemgmt_SnapCat, $filemgmt_SnapCatURL; + + $configfile = $_CONF['path'] . 'plugins/filemgmt/filemgmt.php'; + + if ($op == 'init') { + $xmydownloads_popular = $mydownloads_popular; + $xmydownloads_newdownloads = $mydownloads_newdownloads; + $xmydownloads_perpage = $mydownloads_perpage; + $xmydownloads_dlreport = $mydownloads_dlreport; + $xmydownloads_trimdesc = $mydownloads_trimdesc; + $xmydownloads_selectpriv = $mydownloads_selectpriv; + $xmydownloads_publicpriv = $mydownloads_publicpriv; + $xmydownloads_uploadselect = $mydownloads_uploadselect; + $xmydownloads_uploadpublic = $mydownloads_uploadpublic; + $xmydownloads_useshots = $mydownloads_useshots; + $xmydownloads_shotwidth = $mydownloads_shotwidth; + $xmydownloads_whatsnew = $mydownloads_whatsnew; + $my_emailoption = $filemgmt_Emailoption; + $my_filestoreurl = $_CONF['site_url'] . '/filemgmt_data/files/'; + $my_filesnapurl = $_CONF['site_url'] . '/filemgmt_data/snaps/'; + $my_snapcaturl = $_CONF['site_url'] . '/filemgmt_data/category_snaps/'; + $my_filestore = $_CONF['path_html'] . 'filemgmt_data/files/'; + $my_snapstore = $_CONF['path_html'] . 'filemgmt_data/snaps/'; + $my_snapcat = $_CONF['path_html'] . 'filemgmt_data/category_snaps/'; + + } else { + $xmydownloads_popular = $_POST['xmydownloads_popular']; + $xmydownloads_newdownloads = $_POST['xmydownloads_newdownloads']; + $xmydownloads_perpage = $_POST['xmydownloads_perpage']; + $xmydownloads_dlreport = $_POST['xmydownloads_dlreport']; + $xmydownloads_trimdesc = $_POST['xmydownloads_trimdesc']; + $xmydownloads_selectpriv = $_POST['xmydownloads_selectpriv']; + $xmydownloads_publicpriv = $_POST['xmydownloads_publicpriv']; + $xmydownloads_uploadselect = $_POST['xmydownloads_uploadselect']; + $xmydownloads_uploadpublic = $_POST['xmydownloads_uploadpublic']; + $xmydownloads_useshots = $_POST['xmydownloads_useshots']; + $xmydownloads_shotwidth = $_POST['xmydownloads_shotwidth']; + $xmydownloads_whatsnew = $_POST['xmydownloads_whatsnew']; + $my_emailoption = $_POST['my_emailoption']; + $my_filestoreurl = $_POST['my_filestoreurl']; + $my_filesnapurl = $_POST['my_filesnapurl']; + $my_snapcaturl = $_POST['my_snapcaturl']; + $my_filestore = $_POST['my_filestore']; + $my_snapstore = $_POST['my_snapstore']; + $my_snapcat = $_POST['my_snapcat']; + } + + // Check to see if Access Priv or Upload priv have changed + // Will need to update the GL access table if they have + + $feature1_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'filemgmt.user'"); + $feature2_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = 'filemgmt.upload'"); + + if ($xmydownloads_selectpriv != $mydownloads_selectpriv ) { + // Note: assuming "Logged-in Users" group is 13 - always has been + $result = DB_query("SELECT COUNT(*) FROM {$_TABLES['access']} WHERE acc_ft_id = '$feature1_id' AND acc_grp_id = 13"); + list($nrows) = DB_fetchArray($result); + if ($xmydownloads_selectpriv == 1 && $nrows == 0) { // Enable and there is no record now + COM_errorLog('Granting Logged-In users access to filemgmt.user feature',1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('$feature1_id', 13)"); + } elseif ($xmydownloads_selectpriv == 0 && $nrows == 1) { // Disable and there is a record + COM_errorLog('Removing Logged-In users access with filemgmt.user feature',1); + DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_grp_id = 13 AND acc_ft_id = '$feature1_id'"); + } + } + if ($xmydownloads_publicpriv != $mydownloads_publicpriv ) { + $result = DB_query("SELECT COUNT(*) FROM {$_TABLES['access']} WHERE acc_ft_id = '$feature1_id' AND acc_grp_id = 2"); + list($nrows) = DB_fetchArray($result); + if ($xmydownloads_publicpriv == 1 && $nrows == 0) { // Enable and there is no record now + COM_errorLog('Granting anonymous access to filemgmt.user feature',1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('$feature1_id', 2)"); + } elseif ($xmydownloads_publicpriv == 0 && $nrows == 1) { // Disable and there is a record + COM_errorLog('Removing anonymous access with filemgmt.user feature',1); + DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_grp_id = 2 AND acc_ft_id = '$feature1_id'"); + } + } + if ($xmydownloads_uploadselect != $mydownloads_uploadselect ) { + // Note: assuming "Logged-in Users" group is 13 - always has been + $result = DB_query("SELECT COUNT(*) FROM {$_TABLES['access']} WHERE acc_ft_id = '$feature2_id' AND acc_grp_id = 13"); + list($nrows) = DB_fetchArray($result); + if ($xmydownloads_uploadselect == 1 && $nrows == 0) { // Enable and there is no record now + COM_errorLog('Granting Logged-In users upload privilage to filemgmt.user feature',1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('$feature2_id', 13)"); + } elseif ($xmydownloads_uploadselect == 0 && $nrows == 1) { // Disable and there is a record + COM_errorLog('Removing Logged-In users upload privilage with filemgmt.user feature',1); + DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_grp_id = 13 AND acc_ft_id = '$feature2_id'"); + } + } + if ($xmydownloads_uploadpublic != $mydownloads_uploadpublic ) { + $result = DB_query("SELECT COUNT(*) FROM {$_TABLES['access']} WHERE acc_ft_id = '$feature2_id' AND acc_grp_id = 2"); + list($nrows) = DB_fetchArray($result); + if ($xmydownloads_uploadpublic == 1 && $nrows == 0) { // Enable and there is no record now + COM_errorLog('Granting anonymous upload privilage to filemgmt.user feature',1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ('$feature2_id', 2)"); + } elseif ($xmydownloads_uploadpublic == 0 && $nrows == 1) { // Disable and there is a record + COM_errorLog('Removing anonymous upload privilage with filemgmt.user feature',1); + DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_grp_id = 2 AND acc_ft_id = '$feature2_id'"); + } + } + + $file = fopen($configfile, "w"); + $content = ""; + $content .= "<?php\n"; + $content .= "\n"; + $content .= "\$mydownloads_popular = $xmydownloads_popular;\n"; + $content .= "\$mydownloads_newdownloads = $xmydownloads_newdownloads;\n"; + $content .= "\$mydownloads_perpage = $xmydownloads_perpage;\n"; + $content .= "\$mydownloads_trimdesc = $xmydownloads_trimdesc;\n"; + $content .= "\$mydownloads_whatsnew = $xmydownloads_whatsnew;\n"; + $content .= "\$mydownloads_dlreport = $xmydownloads_dlreport;\n"; + $content .= "\$mydownloads_selectpriv = $xmydownloads_selectpriv;\n"; + $content .= "\$mydownloads_publicpriv = $xmydownloads_publicpriv;\n"; + $content .= "\$mydownloads_uploadselect = $xmydownloads_uploadselect;\n"; + $content .= "\$mydownloads_uploadpublic = $xmydownloads_uploadpublic;\n"; + $content .= "\$mydownloads_useshots = $xmydownloads_useshots;\n"; + $content .= "\$mydownloads_shotwidth = $xmydownloads_shotwidth;\n"; + $content .= "\$filemgmt_Emailoption = $my_emailoption;\n"; + $content .= "\$filemgmt_FileStore = \"$my_filestore\";\n"; + $content .= "\$filemgmt_SnapStore = \"$my_snapstore\";\n"; + $content .= "\$filemgmt_SnapCat = \"$my_snapcat\";\n"; + $content .= "\$filemgmt_FileStoreURL = \"$my_filestoreurl\";\n"; + $content .= "\$filemgmt_FileSnapURL = \"$my_filesnapurl\";\n"; + $content .= "\$filemgmt_SnapCatURL = \"$my_snapcaturl\";\n"; + $content .= "\n"; + $content .= "?>\n"; + + fwrite($file, $content); + fclose($file); + +} + +function uploadNewFile($newfile,$directory) { + global $myts,$eh,$filemgmtDuplicatesAllowed,$filemgmtFilePermissions; + + if ($newfile["name"]!="") { + $name = $newfile['name']; // this is the real name of your file + $tmp = $newfile['tmp_name']; // temporary name of file in temporary directory on server + $name = $myts->makeTboxData4Save($name); + $logourl = rawurlencode($name); + COM_errorLOG("AddNewFileShot - Upload filename is " .$directory.$myts->makeTboxData4Save($name)); + if (is_uploaded_file ($tmp)) { // is this temporary file really uploaded? + $newfile = $directory.$name; + if(!file_exists($newfile)) { // Check to see the snapfile already exists + $returnMove = move_uploaded_file($tmp, $newfile); // move temp file to upload directory + if (!$returnMove) { + COM_errorLOG("Filemgmt File add by admin error: New file could not be created: ".$tmp." to ".$name); + $eh->show("1106"); + return false; + } else { + $chown =@chmod ($newfile,$filemgmtFilePermissions); + COM_errorLOG("File uploaded and moved ok"); + return true; + } + } else { + // Allow duplicate file names, user may want to have two filelisting to same file or has already copied the files manually + COM_errorLOG("Filemgmt - Warning: Added new filelisting for a file that already exists ". $directory.$name); + if (!$filemgmtDuplicatesAllowed) { + $eh->show("1108"); + return false; + } else { + return true; + } + } + } else { + COM_errorLOG("Filemgmt upload error: Temporary file does not exist: '".$tmp ."'"); + $eh->show("1107"); + return false; + } + } + return false; +} + + + +function filemgmt_comments($firstcomment) { + global $_USER,$_CONF; + + $comment_id = "filemgmt-".$_GET['lid']; + $file = $_GET['filename']; + if ($firstcomment) { + $story=$comment_id; + $pid=0; + $type="filemgmt"; + echo COM_refresh($_CONF['site_url'] . "/comment.php?sid=$story&pid=$pid&type=$type"); + } else { + $display = COM_siteHeader() . COM_userComments($comment_id,$file,'filemgmt','','nested'); + $display .= COM_siteFooter(); + } + echo $display; + exit(); + +} + +function filemgmt_error($errormsg) { + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= $errormsg; + $display .= COM_endBlock(); + echo $display; + exit(); +} + + +// Check and see if the current config has values for the filemgmt repository set. +// If not - then initialize these variables and write the filemgmt.php - config file. +if ($filemgmt_FileStoreURL == '' OR $filemgmt_FileStore == '') { + // Set default values and write over the config file + filemgmtConfigChange('init'); + // Read in the new values + include ($_CONF['path'] .'plugins/filemgmt/filemgmt.php'); +} + +switch ($op) { + default: + mydownloads(); + break; + case "comment": + filemgmt_comments($firstcomment); + break; + case "delNewDownload": + delNewDownload(); + break; + case "addCat": + addCat(); + break; + case "addSubCat": + addSubCat(); + break; + case "addDownload": + addDownload(); + break; + case "listBrokenDownloads": + listBrokenDownloads(); + break; + case "delBrokenDownloads": + delBrokenDownloads(); + break; + case "ignoreBrokenDownloads": + ignoreBrokenDownloads(); + break; + case "approve": + approve(); + break; + case "delVote": + delVote(); + modDownload(); + break; + case "delCat": + delCat(); + break; + case "modCat": + modCat(); + break; + case "modCatS": + modCatS(); + break; + case "modDownload": + modDownload(); + break; + case "modDownloadS": + modDownloadS(); + break; + case "delDownload": + delDownload(); + break; + case "filemgmtConfigAdmin": + filemgmtConfigAdmin(); + break; + case "filemgmtConfigChange": + filemgmtConfigChange(); + redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php",2,_MD_CONFIGUPDATED); + exit(); + break; + case "categoryConfigAdmin": + categoryConfigAdmin(); + break; + case "newfileConfigAdmin": + newfileConfigAdmin(); + break; + case "listNewDownloads": + listNewDownloads(); + break; +} + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/admin/install.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/admin/install.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,269 @@ +<?php + +// +---------------------------------------------------------------------------+ +// | Universal Plugin Install Script 1.4 for Geeklog - The Ultimate Weblog | +// +---------------------------------------------------------------------------+ +// | install.php | +// | | +// | This file installs the data structures for the FileManager plugin | +// | | +// | Install Script performs the following: | +// | 1) It creates the tables | +// | 2) It creates an admin security group for you plugin | +// | 3) It adds the security features and adds them to the admin group | +// | 4) It adds the plugin to the gl_plugins table | +// | 5) It adds any default data you have provided | +// +---------------------------------------------------------------------------+ +// | Copyright (C) 2002 by the following authors: | +// | | +// | Author: | +// | Blaine Lang (C) 2003 - blain****@porta***** | +// | Constructed with the Universal Plugin | +// | Copyright (C) 2002 by the following authors: | +// | Tom Willett - tomw****@pigst***** | +// | Blaine Lang - geekl****@langf***** | +// | The Universal Plugin is based on prior work by: | +// | Tony Bibbs - tony****@tonyb***** | +// +---------------------------------------------------------------------------+ +// | | +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +---------------------------------------------------------------------------+ +// + +require_once('../../../lib-common.php'); +require_once($_CONF['path'] . 'plugins/filemgmt/config.php'); +require_once($_CONF['path'] . 'plugins/filemgmt/functions.inc'); + + +// +// Universal plugin install variables +// Change these to match your plugin +// + +$pi_name = 'filemgmt'; // Plugin name +$pi_version = $CONF_FM['version']; // Plugin Version +$gl_version = '1.4'; // GL Version plugin for +$pi_url = 'http://www.portalparts.com'; // Plugin Homepage + + +// Default data +// Insert table name and sql to insert default data for your plugin. + +$DEFVALUES = array(); + + +$NEWFEATURE = array(); +$NEWFEATURE['filemgmt.user'] = "filemgmt Access"; +$NEWFEATURE['filemgmt.edit'] = "filemgmt Admin Rights"; +$NEWFEATURE['filemgmt.upload'] = "filemgmt File Upload Rights"; + + +/** +* Checks the requirements for this plugin and if it is compatible with this +* version of Geeklog. +* +* @return boolean true = proceed with install, false = not compatible +* +*/ +function plugin_compatible_with_this_geeklog_version () +{ + // Check for version 1.4+ + $gl_version = floatval (VERSION); + if ($gl_version >= 1.3) { + return true; + } else { + return false; + } +} + +// Only let Root users access this script +if (!SEC_inGroup('Root')) { + COM_errorLog("Someone has tried to illegally access the FileMgmt Pro install/uninstall page. User id: {$_USER['uid']}, Username: {$_USER['username']}, IP: $REMOTE_ADDR",1); + $display = COM_siteHeader(); + $display .= COM_startBlock($LANG_FM00['access_denied']); + $display .= $LANG_FM00['access_denied_msg']; + $display .= COM_endBlock(); + $display .= COM_siteFooter(true); + echo $display; + exit; +} + +/** +* Creates the datastructures for this plugin into the Geeklog database +* Note: Corresponding uninstall routine is in functions.inc +* @return boolean True if successful False otherwise +*/ + + +function plugin_install_now() +{ + global $pi_name, $pi_version, $gl_version, $pi_url, $NEWTABLE, $DEFVALUES, $NEWFEATURE; + global $_TABLES, $_CONF, $_FM_TABLES; + + COM_errorLog("Attempting to install the $pi_name Plugin",1); + $uninstall_plugin = 'plugin_uninstall_' . $pi_name; + + // Create the Plugins Tables + require_once($_CONF['path'] . 'plugins/filemgmt/sql/filemgmt_sql_install.php'); + for ($i = 1; $i <= count($_SQL); $i++) { + $progress .= "executing " . current($_SQL) . "<br>\n"; + COM_errorLOG("executing " . current($_SQL)); + DB_query(current($_SQL),'1'); + if (DB_error()) { + COM_errorLog("Error Creating $table table",1); + $uninstall_plugin ('DeletePlugin'); + return false; + exit; + } + next($_SQL); + } + COM_errorLog("Success - Created $table table",1); + + // Insert Default Data + + foreach ($DEFVALUES as $table => $sql) { + COM_errorLog("Inserting default data into $table table",1); + DB_query($sql,1); + if (DB_error()) { + COM_errorLog("Error inserting default data into $table table",1); + $uninstall_plugin (); + return false; + exit; + } + COM_errorLog("Success - inserting data into $table table",1); + } + + // Create the plugin admin security group + COM_errorLog("Attempting to create $pi_name admin group", 1); + DB_query("INSERT INTO {$_TABLES['groups']} (grp_name, grp_descr) " + . "VALUES ('$pi_name Admin', 'Users in this group can administer the $pi_name plugin')",1); + if (DB_error()) { + $uninstall_plugin (); + return false; + exit; + } + COM_errorLog('...success',1); + $group_id = DB_insertId(); + + // Save the grp id for later uninstall + COM_errorLog('About to save group_id to vars table for use during uninstall',1); + DB_query("INSERT INTO {$_TABLES['vars']} VALUES ('{$pi_name}_admingrp_id', $group_id)",1); + if (DB_error()) { + $uninstall_plugin (); + return false; + exit; + } + COM_errorLog('...success',1); + + // Add plugin Features + foreach ($NEWFEATURE as $feature => $desc) { + COM_errorLog("Adding $feature feature",1); + DB_query("INSERT INTO {$_TABLES['features']} (ft_name, ft_descr) " + . "VALUES ('$feature','$desc')",1); + if (DB_error()) { + COM_errorLog("Failure adding $feature feature",1); + $uninstall_plugin (); + return false; + exit; + } + $feat_id = DB_insertId(); + COM_errorLog("Success",1); + COM_errorLog("Adding $feature feature to admin group",1); + DB_query("INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES ($feat_id, $group_id)"); + if (DB_error()) { + COM_errorLog("Failure adding $feature feature to admin group",1); + $uninstall_plugin (); + return false; + exit; + } + COM_errorLog("Success",1); + } + + // OK, now give Root users access to this plugin now! NOTE: Root group should always be 1 + COM_errorLog("Attempting to give all users in Root group access to $pi_name admin group",1); + DB_query("INSERT INTO {$_TABLES['group_assignments']} VALUES ($group_id, NULL, 1)"); + if (DB_error()) { + $uninstall_plugin (); + return false; + exit; + } + + // Register the plugin with Geeklog + COM_errorLog("Registering $pi_name plugin with Geeklog", 1); + DB_delete($_TABLES['plugins'],'pi_name',$pi_name); + DB_query("INSERT INTO {$_TABLES['plugins']} (pi_name, pi_version, pi_gl_version, pi_homepage, pi_enabled) " + . "VALUES ('$pi_name', '$pi_version', '$gl_version', '$pi_url', 1)"); + + if (DB_error()) { + $uninstall_plugin (); + return false; + exit; + } + + + + COM_errorLog("Succesfully installed the $pi_name Plugin!",1); + return true; +} + + + +/* +* Main Function +*/ + +$display = ''; + +if ($_REQUEST['action'] == 'uninstall') { + $uninstall_plugin = 'plugin_uninstall_' . $pi_name; + if ($uninstall_plugin ()) { + $display = COM_refresh ($_CONF['site_admin_url'] + . '/plugins.php?msg=45'); + } else { + $display = COM_refresh ($_CONF['site_admin_url'] + . '/plugins.php?msg=73'); + } + +} else if (DB_count ($_TABLES['plugins'], 'pi_name', $pi_name) == 0) { + // plugin not installed + if (plugin_compatible_with_this_geeklog_version ()) { + if (plugin_install_now ()) { + $display = COM_refresh ($_CONF['site_admin_url'] + . '/plugins.php?msg=44'); + } else { + $display = COM_refresh ($_CONF['site_admin_url'] + . '/plugins.php?msg=72'); + } + } else { + // plugin needs a newer version of Geeklog + $display .= COM_siteHeader ('menu', $LANG32[8]) + . COM_startBlock ($LANG32[8]) + . '<p>' . $LANG32[9] . '</p>' + . COM_endBlock () + . COM_siteFooter (); + } +} else { + // plugin already installed + $display .= COM_siteHeader ('menu', $LANG01[77]) + . COM_startBlock ($LANG32[6]) + . '<p>' . $LANG32[7] . '</p>' + . COM_endBlock () + . COM_siteFooter(); +} + +echo $display; + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/config.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/config.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,99 @@ +<?php +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +/* Include the Filemgmt Plugin configuration which defines Directories and URL's and options +This file is set via the Filemgmt Plugin Admin menu - Configuration settings. +The script reads and write to this file - thus needs to be a separate file. +*/ + +include ("filemgmt.php"); + +$CONF_FM['version'] = '1.5.3'; + + +$_FM_TABLES['filemgmt_cat'] = $_DB_table_prefix . 'filemgmt_category'; +$_FM_TABLES['filemgmt_filedetail'] = $_DB_table_prefix . 'filemgmt_filedetail'; +$_FM_TABLES['filemgmt_filedesc'] = $_DB_table_prefix . 'filemgmt_filedesc'; +$_FM_TABLES['filemgmt_brokenlinks'] = $_DB_table_prefix . 'filemgmt_broken'; +$_FM_TABLES['filemgmt_modreq'] = $_DB_table_prefix . 'filemgmt_mod'; +$_FM_TABLES['filemgmt_votedata'] = $_DB_table_prefix . 'filemgmt_votedata'; +$_FM_TABLES['filemgmt_history'] = $_DB_table_prefix . 'filemgmt_downloadhistory'; + +// Permissions that will be used for new files into the repository +$filemgmtFilePermissions = (int) 0755; + +// Number of days to show new files listing +$filemgmtWhatsNewPeriodDays = 14; +// String Length for Filename Titles in WhatsNewBlock +$filemgmtWhatsNewTitleLength = 20; +// Should the Whats New Block show new FileMgmt Comments +$filemgmt_showWhatsNewComments = true; + +/* Configuration for the auto-rename or reject logic when users are submitted files for approval */ +/* Map any extensions to a new extension or 'reject' if they should not be allowed */ +/* Any file type not listed will be uploaded using original file extension */ + +$_FMDOWNLOAD = array( + 'php' => 'phps', + 'pl' => 'txt', + 'cgi' => 'txt', + 'py' => 'txt', + 'sh' => 'txt', + 'exe' => 'reject' +); + +// glmenu only use - for glmenu generated menus + +$CONF_FILEMGMT['glmenutype'] = 'block'; // Set to block or header + +$_FMDOWNLOAD['inconlib'] = array( + php => "php.gif", + phps => "php.gif", + bmp => "bmp.gif", + gif => "gif.gif", + jpg => "jpg.gif", + html => "htm.gif", + htm => "htm.gif", + mov => "mov.gif", + mp3 => "mp3.gif", + pdf => "pdf.gif", + ppt => "ppt.gif", + tar => "zip.gif", + gz => "zip.gif", + zip => "zip.gif", + txt => "txt.gif", + doc => "doc.gif", + xls => "xls.gif", + mpp => "mpp.gif", + exe => "exe.gif", + swf => "swf.gif", + vsd => "visio.gif", + none => "file.gif" + ); + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/filemgmt.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/filemgmt.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,23 @@ +<?php + +$mydownloads_popular = 20; +$mydownloads_newdownloads = 10; +$mydownloads_perpage = 5; +$mydownloads_trimdesc = 1; +$mydownloads_whatsnew = 1; +$mydownloads_dlreport = 1; +$mydownloads_selectpriv = 0; +$mydownloads_publicpriv = 1; +$mydownloads_uploadselect = 1; +$mydownloads_uploadpublic = 1; +$mydownloads_useshots = 1; +$mydownloads_shotwidth = 50; +$filemgmt_Emailoption = 1; +$filemgmt_FileStore = "D:/web1/Geeklog-1.x/public_html/filemgmt_data/files/"; +$filemgmt_SnapStore = "D:/web1/Geeklog-1.x/public_html/filemgmt_data/snaps/"; +$filemgmt_SnapCat = "D:/web1/Geeklog-1.x/public_html/filemgmt_data/category_snaps/"; +$filemgmt_FileStoreURL = "http://localhost/geeklogcvs/filemgmt_data/files/"; +$filemgmt_FileSnapURL = "http://localhost/geeklogcvs/filemgmt_data/snaps/"; +$filemgmt_SnapCatURL = "http://localhost/geeklogcvs/filemgmt_data/category_snaps/"; + +?> Added: trunk/plugins/filemgmt/functions.inc ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/functions.inc Tue Sep 9 05:43:45 2008 @@ -0,0 +1,876 @@ +<?php + +/* Reminder: always indent with 4 spaces (no tabs). */ +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +$langfile = $_CONF['path'] . 'plugins/filemgmt/language/' . $_CONF['language'] . '.php'; +if (file_exists ($langfile)) { + include_once ($langfile); +} else { + include_once ($_CONF['path'] . 'plugins/filemgmt/language/english.php'); +} + +include($_CONF['path'] . 'plugins/filemgmt/config.php'); + + +/** +* Returns the items for this plugin that should appear on the main menu +* +* NOTE: this MUST return the url/value pairs in the following format +* $<arrayname>[<label>] = <url> +* +*/ +function plugin_getmenuitems_filemgmt() +{ + global $_CONF, $LANG_FILEMGMT; + $menuitems = array(); + $menuitems["{$LANG_FILEMGMT['downloads']}"] = $_CONF['site_url'] . "/filemgmt/index.php"; + return $menuitems; +} + + +/** +* Called by the plugin Editor to display the current plugin code version +* This may be different then the version installed and registered currently. +* If newer then you may want to run the update +*/ +function plugin_chkVersion_filemgmt() { + global $CONF_FM; + return $CONF_FM['version']; +} + + +/** +* Called by the plugin Editor to run the SQL Update for a plugin update +*/ +function plugin_upgrade_filemgmt() { + global $_TABLES,$_FM_TABLES,$CONF_FM; + + $cur_version = DB_getItem($_TABLES['plugins'],'pi_version', "pi_name='filemgmt'"); + $gl_version = floatval (VERSION); + if ($gl_version >= 1.3) { + if ($cur_version == '1.3') { + DB_query("ALTER TABLE {$_FM_TABLES['filemgmt_cat']} ADD `grp_access` mediumint(8) DEFAULT '2' NOT NULL AFTER imgurl"); + DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '{$CONF_FM['version']}' WHERE pi_name = 'filemgmt'"); + DB_query("UPDATE {$_TABLES['plugins']} SET pi_gl_version = '1.4' WHERE pi_name = 'filemgmt'"); + + // Update all the comment records + $result = DB_query("SELECT cid,sid FROM {$_TABLES['comments']} WHERE type='filemgmt'"); + while (list($cid,$sid) = DB_fetchArray($result)) { + if (strpos($sid,'fileid_') === FALSE) { + $sid = "fileid_{$sid}"; + DB_query("UPDATE {$_TABLES['comments']} SET sid='$sid' WHERE cid='$cid'"); + } + } + return true; + } elseif ($cur_version == '1.5') { + DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '{$CONF_FM['version']}' WHERE pi_name = 'filemgmt'"); + DB_query("UPDATE {$_TABLES['plugins']} SET pi_gl_version = '1.4' WHERE pi_name = 'filemgmt'"); + return true; + } elseif ($cur_version == '1.5.1') { + DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '{$CONF_FM['version']}' WHERE pi_name = 'filemgmt'"); + return true; + } elseif ($cur_version == '1.5.2') { + DB_query("UPDATE {$_TABLES['plugins']} SET pi_version = '{$CONF_FM['version']}' WHERE pi_name = 'filemgmt'"); + return true; + } else { + return 5; + } + + } else { + return 3; + } +} + + +/** + * Include if plugin will be supporting comments + * + * @author Blaine Lang blain****@porta***** + * @return boolean true indicates comments are suppported + */ +function plugin_commentsupport_filemgmt() +{ + // Filemgmt Module will use comments + return true; +} + + +/** + * Plugin function that is called after comment form is submitted. + * Needs to atleast save the comment and check return value. + * Add any additional logic your plugin may need to perform on comments. + * + * @author Blaine Lang blain****@porta***** + * @param string $title Comment title field in comment form + * @param string $comment comment text + * @param string $id Item id to which $cid belongs + * @param int $pid comment parent + * @param string $postmode 'html' or 'text' + * @return mixed HTML string (redirect?) for success or comment form if failure. + */ +function plugin_savecomment_filemgmt($title,$comment,$id,$pid,$postmode) { + global $_CONF,$_FM_TABLES, $LANG03, $_TABLES; + + $title = strip_tags ($title); + $pid = COM_applyFilter ($pid, true); + $postmode = COM_applyFilter ($postmode); + + $ret = CMT_saveComment ( $title, $comment, $id, $pid, 'filemgmt',$postmode); + + if ( $ret > 0 ) { // failure + return COM_siteHeader() + . CMT_commentform ($title, $comment, $id, $pid, + 'filemgmt', $LANG03[14], $postmode) + . COM_siteFooter(); + } else { // success + $comments = DB_count ($_TABLES['comments'], 'sid', $id); + DB_change($_FM_TABLES['filemgmt_filedetail'],'comments', $comments, 'lid',$id); + return (COM_refresh (COM_buildUrl ($_CONF['site_url'] + . "/filemgmt/index.php?id=$id")) ); + } +} + + +/** + * Plugin API to delete a comment + * + * @author Blaine Lang blain****@porta***** + * @param int $cid Comment to be deleted + * @param string $id Item id to which $cid belongs + * @return mixed false for failure, HTML string (redirect?) for success + */function plugin_deletecomment_filemgmt($cid,$id) { + global $_CONF,$_FM_TABLES, $_TABLES; + + if (SEC_hasRights("filemgmt.edit")) { + if (CMT_deleteComment($cid, $id, 'filemgmt') == 0) { + // Now redirect the program flow to the view of the file and its comments + return (COM_refresh($_CONF['site_url'] . "/filemgmt/index.php?id=$id")); + } else { + return false; + } + } else { + return false; + } +} + + +/** + * Plugin API to display a specific comment thread + * + * @author Blaine Lang blain****@porta***** + * @param string $id Unique idenifier for item comment belongs to + * @param int $commentid Comment id to display (possibly including sub-comments) + * @param string $title comment title + * @param string $order 'ASC' or 'DSC' or blank + * @param string $format 'threaded', 'nested', or 'flat' + * @param int $page Page number of comments to display + * @param boolean $view True to view comment (by cid), false to display (by $pid) + * @return mixed results of calling the CMT_userComments function + */ +function plugin_displaycomment_filemgmt($id,$commentid,$title,$order,$format,$page,$view) { + global $LANG_FILEMGMT, $_TABLES, $_FM_TABLES, $_CONF, $LANG01; + + $id = str_replace('fileid_','',$id); + /* Plugin specific code to display relevant content above the comment thread */ + /* Example: Display the file details */ + include($_CONF['path_html'] ."filemgmt/include/functions.php"); + include_once($_CONF[path_html]. "filemgmt/include/xoopstree.php"); + include_once($_CONF[path_html]. "filemgmt/include/textsanitizer.php"); + + $comments = true; // Checked in filemgmt code in dlformat.php + + $myts = new MyTextSanitizer; // MyTextSanitizer object + $mytree = new XoopsTree($_DB_name,$_FM_TABLES['filemgmt_cat'],"cid","pid"); + + $display = COM_startBlock("<b>". $LANG_FILEMGMT['plugin_name'] ."</b>"); + $fields = 'd.lid, d.cid, d.title, d.url, d.homepage, d.version, d.size, d.logourl,'; + $fields .= 'd.submitter, d.status, d.date, d.hits, d.rating, d.votes, t.description'; + + $sql = "SELECT $fields FROM {$_FM_TABLES['filemgmt_filedetail']} d, "; + $sql .= "{$_FM_TABLES['filemgmt_filedesc']} t "; + $sql .= "WHERE d.lid='$id' AND d.lid=t.lid AND status > 0"; + $result=DB_query($sql); + list($lid, $cid, $dtitle, $url, $homepage, $version, $size, $logourl, $submitter, $status, $time, $hits, $rating, $votes, $description)=DB_fetchARRAY($result); + + $p = new Template($_CONF['path'] . 'plugins/filemgmt/templates'); + $p->set_file (array ( + 'page' => 'filelisting.thtml', + 'records' => 'filelisting_record.thtml', + 'category' => 'filelisting_category.thtml')); + + $p->set_var ('layout_url', $_CONF['layout_url']); + $p->set_var ('site_url',$_CONF['site_url']); + + $pathstring = "<a href='index.php'>"._MD_MAIN."</a> : "; + $nicepath = $mytree->getNicePathFromId($cid, "title", "{$_CONF['site_url']}/filemgmt/viewcat.php?op="); + $pathstring .= $nicepath; + $p->set_var('category_path_link',$pathstring); + + $rating = number_format($rating, 2); + $dtitle = $myts->makeTboxData4Show($dtitle); + $url = $myts->makeTboxData4Show($url); + $homepage = $myts->makeTboxData4Show($homepage); + $version = $myts->makeTboxData4Show($version); + $size = $myts->makeTboxData4Show($size); + $platform = $myts->makeTboxData4Show($platform); + $logourl = $myts->makeTboxData4Show($logourl); + $datetime = formatTimestamp($time); + $description = $myts->makeTareaData4Show($description,0); //no html + $result2 = DB_query("SELECT username,fullname,photo FROM {$_TABLES['users']} WHERE uid = $submitter"); + list ($submitter_name,$submitter_fullname,$photo) = DB_fetchARRAY($result2); + $submitter_name = COM_getDisplayName ($submitter, $submitter_name, $submitter_fullname); + include($_CONF[path_html] ."/filemgmt/include/dlformat.php"); + $p->set_var('cssid',1); + $p->parse ('filelisting_records', 'records'); + $p->parse ('output', 'page'); + $display .= $p->finish ($p->get_var('output')); + + $display .= COM_endBlock(); + + /* Get formatted comment thread */ + if (SEC_hasRights('filemgmt.edit')) { + $delete_option = true; + } else { + $delete_option = false; + } + + if ($view == 1) { + $display .= CMT_userComments ("fileid_$id", $title, 'filemgmt',$order,$format,$commentid,$page,true,$delete_option); + } else { + $display .= CMT_userComments ("fileid_$id", $title, 'filemgmt',$order,$format,$commentid,$page,false,$delete_option); + } + + return $display; +} + + +function plugin_statssummary_filemgmt () +{ + global $_FM_TABLES, $LANG_FILEMGMT; + + $sql = "SELECT COUNT(*), SUM(hits) FROM {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= filemgmt_buildAccessSql('WHERE'); + list($total_files,$total_downloads) = DB_fetchArray( DB_query($sql)); + + return array ($LANG_FILEMGMT['nofiles'], COM_numberFormat ($total_files) + . '(' . COM_numberFormat ($total_downloads) . ')'); +} + + +/** +* shows the statistics for the Filemgmot plugin on stats.php. If $showsitestats +* is 1 then we are to only print the overall stats in the 'site statistics box' +* otherwise we show the detailed stats for the photo album +* +* @showsitestats int Flag to let us know which stats to get +*/ +function plugin_showstats_filemgmt($showsitestats) +{ +global $LANG_FILEMGMT, $_FM_TABLES, $_CONF; + + $stat_templates = new Template($_CONF['path_layout'] . 'stats'); + $stat_templates->set_file(array('itemstats'=>'itemstatistics.thtml', + 'statrow'=>'singlestat.thtml')); + if ($showsitestats == 1) { + $sql = "SELECT COUNT(*), SUM(hits) FROM {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= filemgmt_buildAccessSql('WHERE'); + list($total_files,$total_downloads) = DB_fetchArray( DB_query($sql)); + $retval = "<table border = '0' width='100%' cellspacing='0' cellpadding='0'>"; + $retval .= "<tr><td>" . $LANG_FILEMGMT['nofiles'] . "</td>"; + $retval .= "<td align='right'>" . $total_files . " (" .$total_downloads .") </td></tr></table>"; + } else { + $sql = "SELECT a.lid, a.title, hits from {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= filemgmt_buildAccessSql('WHERE'); + $sql .= " AND hits > 0 ORDER BY hits desc LIMIT 10"; + $result = DB_query($sql); + $nrows = DB_numRows($result); + $retval .= COM_startBlock($LANG_FILEMGMT['StatsMsg1']); + if ($nrows > 0) { + $stat_templates->set_var('item_label',"Page Title"); + $stat_templates->set_var('stat_name',"Hits"); + for ($i = 0; $i < $nrows && $i < 10; $i++) { + list ($lid, $title,$hits) = DB_fetchARRAY($result); + $stat_templates->set_var('item_url', $_CONF[site_url]. "/filemgmt/index.php?id=".$lid); + $stat_templates->set_var('item_text', $title); + $stat_templates->set_var('item_stat', $hits); + $stat_templates->parse('stat_row','statrow',true); + } + $stat_templates->parse('output','itemstats'); + $retval .= $stat_templates->finish($stat_templates->get_var('output')); + } else { + $retval .= $LANG_FILEMGMT['StatsMsg2']; + } + $retval .= COM_endBlock(); + } + return $retval; +} + +/** +* Geeklog is asking us to provide any new items that show up in the type drop-down +* on search.php. Let's let users search the Filelistings in the Filemgmt Plugin +* +*/ + +function plugin_searchtypes_filemgmt() +{ + global $LANG_FILEMGMT; + + $tmp['filemgmt'] = $LANG_FILEMGMT['searchlabel']; + + return $tmp; +} + +/** +* this searches for files matching the user query and returns an array of +* for the header and table rows back to search.php where it will be formated and +* printed +* +* @query string Keywords user is looking for +* @datestart date/time Start date to get results for +* @dateend date/time End date to get results for +* @topic string The topic they were searching in +* @type string Type of items they are searching +* @author string Get all results by this author +* +*/ +function plugin_dopluginsearch_filemgmt($query, $datestart, $dateend, $topic, $type, $author) +{ + global $LANG_FILEMGMT, $_TABLES, $_FM_TABLES, $_CONF, $filemgmt_FileStoreURL; + + $query = addslashes($query); + if (empty($type)) { + $type = 'all'; + } + + // Bail if we aren't supppose to do our search + if ($type <> 'all' AND $type <> 'filemgmt') { + $plugin_results = new Plugin(); + $plugin_results->plugin_name = $LANG_FILEMGMT['plugin_name']; + $plugin_results->searchlabel = $LANG_FILEMGMT['searchlabel']; + return $plugin_results; + } + + // Build search SQL + $sql = "SELECT a.lid, a.lid, a.cid, a.title, url, submitter, comments, hits, UNIX_TIMESTAMP(date) as day, description "; + $sql .= "FROM {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON b.cid=a.cid "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_filedesc']} c ON c.lid=a.lid "; + $sql .= filemgmt_buildAccessSql('WHERE'); + $sql .= " AND a.status > 0 "; + $sql .= "AND ((comments like '%$query%' OR comments like '$query%' OR comments like '%$query') "; + $sql .= "OR (a.title like '%$query%' OR a.title like '$query%' OR a.title like '%$query') "; + $sql .= "OR (c.description like '%$query%' OR c.description like '$query%' OR c.description like '%$query')) "; + + if (!empty($datestart) && !empty($dateend)) { + $delim = substr($datestart, 4, 1); + $DS = explode($delim,$datestart); + $DE = explode($delim,$dateend); + $startdate = mktime(0,0,0,$DS[1],$DS[2],$DS[0]); + $enddate = mktime(0,0,0,$DE[1],$DE[2],$DE[0]) + 3600; + $sql .= "AND (UNIX_TIMESTAMP(date) BETWEEN '$startdate' AND '$enddate') "; + } + + if (!empty($author)) { + $sql .= "AND (submitter = '$author') "; + } + $sql .= "ORDER BY date desc"; + + // Perform search + $result = DB_query($sql); + + // OK, now return coma delmited string of table header labels + // Need to use language variables + require_once($_CONF['path_system'] . 'classes/plugin.class.php'); + $plugin_results = new Plugin(); + $plugin_results->plugin_name = 'filemgmt'; + $plugin_results->searchlabel = $LANG_FILEMGMT['searchlabel_results']; + $plugin_results->addSearchHeading('Title'); + $plugin_results->addSearchHeading('Description'); + $plugin_results->addSearchHeading('Author'); + $plugin_results->addSearchHeading('Downloads'); + $plugin_results->num_searchresults = DB_numRows($result); + + // NOTE if any of your data items need to be links then add them here! + // make sure data elements are in an array and in the same order as your + // headings above! + + for ($i = 1; $i <= $plugin_results->num_searchresults; $i++) { + $A = DB_fetchArray($result); + $thetime = COM_getUserDateTimeFormat($A['day']); + $url = $_CONF[site_url]. "/filemgmt/index.php?id=".$A['lid']; + $row = array("<a href={$url}>{$A['title']}</a>", wordwrap($A['description'],70,"<br>"), COM_getDisplayName($A['submitter']), $A['hits']); + $plugin_results->addSearchResult($row); + } + + $plugin_results->num_itemssearched = DB_count($_FM_TABLES['filemgmt_filedetail']); + + return $plugin_results; +} + + + + +/** +* This will put an option for Filemgmt Admin in the command and control block on +* moderation.php +* +*/ +function plugin_cclabel_filemgmt() +{ + global $LANG_FILEMGMT, $_CONF; + if (SEC_hasRights('filemgmt.edit')) { + return array($LANG_FILEMGMT['plugin_name'],$_CONF['site_admin_url'] . '/plugins/filemgmt/index.php',$_CONF['site_url'] . '/filemgmt/images/filemgmt.jpg'); + } else { + return false; + } + +} + +/** +* Setup the user menu options for this plugin +* +*/ + +function plugin_getuseroption_filemgmt() { + global $_CONF, $_FM_TABLES, $LANG_FILEMGMT,$mydownloads_uploadselect; + if (SEC_hasRights('filemgmt.upload') OR $mydownloads_uploadselect == 1) { + return array($LANG_FILEMGMT['usermenu3'], $_CONF['site_url'] . '/filemgmt/submit.php'); + } else { + return false; + } +} + + +/** +* returns the administrative option for this plugin +* * +*/ + +function plugin_getadminoption_filemgmt() +{ + global $_CONF, $_FM_TABLES, $LANG_FILEMGMT; + if (SEC_hasRights('filemgmt.edit')) { + $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE status=0"); + list($submittedfiles) = DB_fetchARRAY($result); + return array($LANG_FILEMGMT['admin_menu'], $_CONF['site_admin_url'] . '/plugins/filemgmt/index.php', $submittedfiles); + } +} + + + +/** +* Removes the datastructures for this plugin from the Geeklog database +* This may get called by the install routine to undue anything created during the install. +* Added check to see that plugin is first disabled. +*/ +function plugin_uninstall_filemgmt($installCheck='') +{ + global $LANG_FM00, $LANG_FILEMGMT, $_TABLES,$_FM_TABLES; + + $pi_name='filemgmt'; + $FEATURES = array ('filemgmt.edit', 'filemgmt.user','filemgmt.upload'); + $TABLES = array ('filemgmt_cat','filemgmt_filedetail','filemgmt_filedesc','filemgmt_brokenlinks','filemgmt_votedata','filemgmt_history'); + + // Check and see if plugin is still enabled - if so display warning and exit + if ($installCheck != '' && DB_getItem($_TABLES['plugins'],'pi_enabled', 'pi_name = "' .$pi_name. '"')) { + COM_errorLog("Plugin is installed and enabled. Disable first if you want to de-install it",1); + $display = COM_siteHeader(); + $display .= COM_startBlock($LANG_FM00['warning']); + $display .= $LANG_FM00['enabled']; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; + exit; + } + + // Ok to proceed and delete plugin - Unregister the plugin with Geeklog + COM_errorLog('Attempting to unregister the Forum plugin from Geeklog',1); + DB_query("DELETE FROM {$_TABLES['plugins']} WHERE pi_name = 'filemgmt'",1); + // Drop tables + foreach($TABLES as $table) { + $t = $_FM_TABLES["$table"]; + COM_errorLog("Removing Table $t",1); + DB_query("DROP TABLE $t",1); + } + + // Remove the Admin group definition for this plugin + $grp_id = DB_getItem($_TABLES['vars'], 'value', "name = '{$pi_name}_admingrp_id'"); + COM_errorLog("Removing $pi_name Admin Group", 1); + DB_query("DELETE FROM {$_TABLES['groups']} WHERE grp_id = $grp_id",1); + DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = '{$pi_name}_admingrp_id'"); + COM_errorLog("Removing root users from Admin Group of $pi_name"); + DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $grp_id",1); + + // Remove User group definition for this plugin + $grp_id = DB_getItem($_TABLES['vars'], 'value', "name = '{$pi_name}_usersgrp_id'"); + COM_errorLog("Removing $pi_name User Group", 1); + DB_query("DELETE FROM {$_TABLES['groups']} WHERE grp_id = $grp_id",1); + DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = '{$pi_name}_usersgrp_id'"); + COM_errorLog("Removing root users from Users Group of $pi_name"); + DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $grp_id",1); + + // Remove all the associated features - access rights. The feature ID's were stored in the vars table during install. + foreach ($FEATURES as $feature) { + COM_errorLog("Removing $feature feature and rights to it",1); + $feat_id = DB_getItem($_TABLES['features'], 'ft_id', "ft_name = '$feature'"); + COM_errorLog("DELETE FROM {$_TABLES['access']} WHERE acc_ft_id = $feat_id"); + DB_query("DELETE FROM {$_TABLES['access']} WHERE acc_ft_id = $feat_id",1); + DB_query("DELETE FROM {$_TABLES['features']} WHERE ft_id = $feat_id",1); + } + + DB_query("DELETE FROM {$_TABLES['comments']} WHERE type='filemgmt'"); + COM_errorLog("Removing all comments for plugin $pi_name"); + DB_query("DELETE FROM {$_TABLES['blocks']} WHERE phpblockfn='phpblock_NewDownloads'"); + COM_errorLog("Removing block definition for plugin $pi_name"); + + COM_errorLog('...success',1); + return true; +} + + +// Common function used to build group access SQL +function filemgmt_buildAccessSql($clause='AND') { + global $_TABLES,$_USER; + + if (DB_getItem($_TABLES['plugins'],'pi_version', "pi_name='filemgmt'") != 1.5) { + return ''; + } + + if (isset($_USER) AND $_USER['uid'] > 1) { + $uid = $_USER['uid']; + } else { + $uid = 1; + } + + $_GROUPS = SEC_getUserGroups($uid); + $groupsql = ''; + if (count($_GROUPS) == 1) { + $groupsql .= " $clause grp_access = '" . current($_GROUPS) ."'"; + } else { + $groupsql .= " $clause grp_access IN (" . implode(',',array_values($_GROUPS)) .")"; + } + return $groupsql; +} + +function plugin_getfeednames_filemgmt () +{ + global $_FM_TABLES; + + $feeds = array (); + $groupsql = filemgmt_buildAccessSql('WHERE'); + $result = DB_query ("SELECT cid,title FROM {$_FM_TABLES['filemgmt_cat']} $groupsql ORDER BY title ASC"); + $num = DB_numRows ($result); + + if ($num > 0) { + $feeds[] = array ('id' => '0', 'name' => 'all files'); + } + + for ($i = 0; $i < $num; $i++) { + $A = DB_fetchArray ($result); + $feeds[] = array ('id' => $A['cid'], 'name' => $A['title']); + } + + return $feeds; +} + +function filemgmt_buildSql ($topic, $limits) +{ + $where = ''; + if ($topic > 0) { + $where = 'cid=' . $topic; + } + + $limitsql = ''; + if (!empty ($limits)) { + if (substr ($limits, -1) == 'h') { // last xx hours + $limitsql = ''; + $hours = substr ($limits, 0, -1); + if (!empty ($where)) { + $where .= ' AND '; + } + $where .= "date >= DATE_SUB(NOW(),INTERVAL $hours HOUR)"; + } else { + $limitsql = ' LIMIT ' . $limits; + } + } + else + { + $limitsql = ' LIMIT 10'; + } + + if (!empty ($where)) { + $where = ' WHERE ' . $where; + } + + $sql = $where . $limitsql; + + return $sql; +} + +function plugin_getfeedcontent_filemgmt ($feed, &$link, &$update) +{ + global $_CONF, $_TABLES, $_FM_TABLES; + + $content = array (); + $lids = array (); + + $result = DB_query ("SELECT topic,limits FROM {$_TABLES['syndication']} WHERE fid = $feed"); + $F = DB_fetchArray ($result); + + $sql = "SELECT lid,title,submitter,date FROM {$_FM_TABLES['filemgmt_filedetail']}" . filemgmt_buildSql ($F['topic'], $F['limits']); + $result = DB_query ($sql); + $num = DB_numRows ($result); + for ($i = 0; $i < $num; $i++) { + $A = DB_fetchArray ($result); + $desc = DB_getItem ($_FM_TABLES['filemgmt_filedesc'], 'description', + "lid = {$A['lid']}"); + $filelink = $_CONF['site_url'] . '/filemgmt/index.php?id=' + . $A['lid']; + $content[] = array ('title' => $A['title'], + 'text' => $desc, + 'link' => $filelink, + 'uid' => $A['submitter'], + 'date' => $A['date'], + 'format' => 'text' + ); + $lids[] = $A['lid']; + } + + if ($F['topic'] == 0) { + $link = $_CONF['site_url'] . '/filemgmt/index.php'; + } else { + $link = $_CONF['site_url'] . '/filemgmt/viewcat.php?cid=' . $F['topic']; + } + $update = implode (',', $lids); + + return $content; +} + +function plugin_feedupdatecheck_filemgmt ($feed, $topic, $update_data, $limit) +{ + global $_FM_TABLES; + + $is_current = true; + + $sql = "SELECT lid FROM {$_FM_TABLES['filemgmt_filedetail']}" . filemgmt_buildSql ($topic, $limits); + $result = DB_query ($sql); + $num = DB_numRows ($result); + + $lids = array (); + for ($i = 0; $i < $num; $i++) { + $A = DB_fetchArray ($result); + $lids[] = $A['lid']; + } + $current = implode (',', $lids); + return ( $current != $update_data ) ? false : true; +} + +/** + * Whats New Block API Support + * Return the Headline and Byline for the new section in the Whatsnew Block +*/ +function plugin_whatsnewsupported_filemgmt() { + global $_CONF, $LANG_FM00,$mydownloads_whatsnew,$filemgmtWhatsNewPeriodDays; + if ($mydownloads_whatsnew == 1) { + return array( + $LANG_FM00['WhatsNewLabel'], + sprintf($LANG_FM00['WhatsNewPeriod'], $filemgmtWhatsNewPeriodDays) + ); + } else { + return false; + } +} + + +/** + * API function provides the content of our "What's New" feed +*/ +function plugin_getwhatsnew_filemgmt() { + global $_TABLES, $_FM_TABLES, $_CONF, $LANG_FILEMGMT, $LANG01; + global $filemgmtWhatsNewTitleLength,$filemgmtWhatsNewPeriodDays,$filemgmt_showWhatsNewComments; + + $items = array(); + if (SEC_hasRights('filemgmt.user') OR $mydownloads_publicpriv == 1) { + $sql = "SELECT a.lid, a.title FROM {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= "WHERE date >= UNIX_TIMESTAMP( DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY )) "; + $sql .= filemgmt_buildAccessSql(); + $sql .= "AND STATUS=1 ORDER BY date DESC LIMIT 15 "; + $result = DB_query( $sql ); + $nrows1 = DB_numRows( $result ); + if( $nrows1 == 0 ) { + $retval .= $LANG_FILEMGMT['no_new_files'] . '<br>' . LB; + } else { + for( $i = 0; $i < $nrows1; $i++ ) { + list($lid, $title) = DB_fetchArray( $result ); + $str = "<a href=\"{$_CONF['site_url']}/filemgmt/index.php?id=$lid\">"; + $str .= stripslashes(substr($title,0,$filemgmtWhatsNewTitleLength)); + $str .= '</a>'; + $items[] = $str; + } + } + if ($filemgmt_showWhatsNewComments) { + // Search for new comments + $sql = "SELECT a.lid,c.title FROM {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= "LEFT JOIN {$_TABLES['comments']} c ON c.sid = concat('fileid_' ,a.lid )"; + $sql .= filemgmt_buildAccessSql('WHERE'); + $sql .= " AND c.date >= DATE_SUB(NOW(), INTERVAL $filemgmtWhatsNewPeriodDays DAY ) AND c.type='filemgmt' "; + $sql .= "GROUP BY c.sid ORDER BY c.date DESC LIMIT 15 "; + + $result = DB_query($sql); + $nrows2 = DB_numRows( $result ); + if( $nrows2 == 0 ) { + $retval .= $LANG_FILEMGMT['no_comments'] . '<br>' . LB; + } else { + for( $i = 0; $i < $nrows2; $i++ ) { + list($lid, $title) = DB_fetchArray( $result ); + $titleLength = $filemgmtWhatsNewTitleLength + 13; // Compensate for the added HTML + $title = "<b>C:</b> ".$title; + $str = "<a href=\"{$_CONF['site_url']}/filemgmt/index.php?id=$lid\">"; + $str .= stripslashes(substr($title,0,$titleLength)); + $str .= '</a>'; + $items[] = $str; + } + } + } + + if ($nrows1 == 0 and $nrows2 == 0) { + return $retval; + } else { + return $items; + } + } else { + return $items; + } +} + + + +/** +* Implements the [file:] autotag. +* +*/ +function plugin_autotags_filemgmt ($op, $content = '', $autotag = '') +{ + global $_CONF, $_FM_TABLES; + + if ($op == 'tagname' ) { + return 'file'; + } else if ($op == 'parse') { + $file_id = COM_applyFilter ($autotag['parm1']); + $url = COM_buildUrl ($_CONF['site_url'] . '/filemgmt/index.php?id=' + . $file_id); + if (empty ($autotag['parm2'])) { + $linktext = stripslashes (DB_getItem ($_FM_TABLES['filemgmt_filedetail'], + 'title', "lid = '$file_id'")); + } else { + $linktext = $autotag['parm2']; + } + $link = '<a href="' . $url . '">' . $linktext . '</a>'; + $content = str_replace ($autotag['tagstr'], $link, $content); + + return $content; + } +} + + + +/* GLMENU USE ONLY API FUNCTIONS */ + +/* Function can be used in a Menuitem of type "PHP Function" +* It will generate the menuitems and submenus for your filemgmt plugin +* Works with the function plugin_glMenuCreateMenus_filemgmt() +*/ +function glmenu_filemgmt() { + global $_CONF,$_FM_TABLES,$CONF_FILEMGMT; + $menu_location = $CONF_FILEMGMT['glmenutype']; + + $retval = ''; + $sql = "SELECT cid,pid,title FROM {$_FM_TABLES['filemgmt_cat']} WHERE pid = 0 "; + $sql .= filemgmt_buildAccessSql('AND') . ' ORDER BY cid'; + $q1 = DB_query($sql); + while (list($cid,$pid,$title) = DB_fetchArray($q1)) { + $retval .= 'aI("image='.$_CONF['layout_url'] .'/glmenu/images/folder.gif;text='.$title.';showmenu=filemgmt-'.$cid.';url='.$_CONF['site_url'].'/filemgmt/viewcat.php?cid='.$cid.';");'; + } + return $retval; +} + + + +/* GL-Menu API function to generate requires Milonic Javascript functions */ +function plugin_glMenuCreateMenus_filemgmt() { + global $_CONF,$_FM_TABLES,$CONF_GLMENU,$CONF_FILEMGMT,$_FMDOWNLOAD; + + /* Generate the JS Menu Functions that are needed for the Content Editor submenus */ + $menu_location = $CONF_FILEMGMT['glmenutype']; + $retval .= ''; + $groupsql = filemgmt_buildAccessSql('WHERE'); + $sql = "SELECT cid,pid,title FROM {$_FM_TABLES['filemgmt_cat']} $groupsql ORDER BY cid"; + $q1 = DB_query($sql); + while (list($cid,$pid,$title) = DB_fetchArray($q1)) { + $menudata = ''; + $retval .= ' with(milonic=new menuname("filemgmt-'.$cid.'")) {'; + if ($menu_location == 'block') { + $retval .= 'style='.$CONF_GLMENU['blockmenustyle'] .';'; + } else { + $retval .= 'style='.$CONF_GLMENU['headersubmenustyle'] .';'; + } + /* Find and sub categories - that will be submenus */ + $q2 = DB_query("SELECT cid,pid,title FROM {$_FM_TABLES['filemgmt_cat']} $groupsql AND pid='{$cid}' "); + while (list ($subcid,$subpid,$subtitle) = DB_fetchArray($q2)) { + $menudata .= 'aI("image='.$_CONF['layout_url'] .'/glmenu/images/folder.gif;text='.$subtitle.';showmenu=filemgmt-'.$subcid.';url='.$_CONF['site_url'].'/filemgmt/viewcat.php?cid='.$subcid.';");'; + } + /* Show any links for files that are in this category */ + $q3 = DB_query("SELECT lid,title,url FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE cid='{$cid}'"); + while (list ($fileid,$filename,$url) = DB_fetchArray($q3)) { + $pos = strrpos($url,'.') + 1; + $ext = strtolower(substr($url, $pos)); + if (array_key_exists($ext, $_FMDOWNLOAD['inconlib'] )) { + $icon = "{$_CONF['layout_url']}/glmenu/images/{$_FMDOWNLOAD['inconlib'][$ext]}"; + } else { + $icon = "{$_CONF['layout_url']}/glmenu/images/{$_FMDOWNLOAD['inconlib']['none']}"; + } + $menudata .= 'aI("image='.$icon.';text='.$filename.';url='.$_CONF['site_url'].'/filemgmt/singlefile.php?lid='.$fileid.';");'; + } + if ($menudata != '') { + $retval .= $menudata; + } + + $retval .= '}'; + } + return $retval; + +} + + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/history ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/history Tue Sep 9 05:43:45 2008 @@ -0,0 +1,20 @@ +/* History of Changes */ + +Oct 14/07 - Version 1.5.3 +- Fix for possible remote file include vulneribility +- Added ability to change the number of categories and subcategories to show +- Bug fixes in subcategory display and sortable headings + + +April 2/06 -Version 1.5.2 + - Bug Fix: Search function should not return file listing that have not been approved - pending moderation approval + - Bug Fix: Corrected autotag link feature + - Bug Fix: Wrong error code being passed to error handler if new file submission is a duplicate file + - If user has filemgmt.edit right, show the delete comment feature + - Added test for file id is not a new (un-approved) file in main index.php + - tweaked the errorhandler display + +Mar 26/06 - Change to index.php to support MySQL 5. Need () around multiple tables in FROM Clause + +Mar 25/06: Archive Version 1.51c distributed. + Change to viewcat.php - corrected bad link in google paging base_url link \ No newline at end of file Added: trunk/plugins/filemgmt/language/english.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/language/english.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,375 @@ +<?php + +############################################################################### +# lang.php +# This is the english language page for the Geeklog File Mgmt Page Plug-in! +# +# Copyright (C) 2002 Blaine Lang +# blain****@porta***** +# +# 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 option) 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################### + + +// Language variables used by the Plug-in API + +$LANG_FM00 = array ( + 'access_denied' => 'Access Denied', + 'access_denied_msg' => 'Only Root Users have Access to this Page. Your user name and IP have been recorded.', + 'admin' => 'Plugin Admin', + 'install_header' => 'Install/Uninstall Plugin', + 'installed' => 'The Plugin and Block are now installed,<p><i>Enjoy,<br><a href="MAILTO:blain****@porta*****">Blaine</a></i>', + 'uninstalled' => 'The Plugin is Not Installed', + 'install_success' => 'Installation Successful<p><b>Next Steps</b>: + <ol><li>Use the Filemgmt Admin to complete the plugin configuration</ol> + <p>Review the <a href="%s">Install Notes</a> for more information.', + 'install_failed' => 'Installation Failed -- See your error log to find out why.', + 'uninstall_msg' => 'Plugin Successfully Uninstalled', + 'install' => 'Install', + 'uninstall' => 'UnInstall', + 'editor' => 'Plugin Editor', + 'warning' => 'De-Install Warning', + 'enabled' => '<p style="padding: 15px 0px 5px 25px;">Plugin is installed and enabled.<br>Disable first if you want to De-Install it.</p><div style="padding:5px 0px 5px 25px;"><a href="'.$_CONF['site_admin_url'].'/plugins.php">Plugin Editor</a></div', + 'WhatsNewLabel' => 'NEW FILES', + 'WhatsNewPeriod' => ' last %s days' +); + +// Admin Navbar +$LANG_FM02 = array( + 'nav1' => 'Settings', + 'nav2' => 'Categories', + 'nav3' => 'Add File', + 'nav4' => 'Downloads (%s)', + 'nav5' => 'Broken Files (%s)' +); + +$LANG_FILEMGMT = array( + 'newpage' => "New Page", + 'adminhome' => "Admin Home", + 'plugin_name' => "File Management", + 'searchlabel' => "File Listing", + 'searchlabel_results' => "File Listing Results", + 'downloads' => "My Downloads", + 'report' => "Top Downloads", + 'usermenu1' => "Downloads", + 'usermenu2' => " Top Rated", + 'usermenu3' => "Upload a file", + 'admin_menu' => "Filemgmt Admin", + 'writtenby' => "Written By", + 'date' => "Last Updated", + 'title' => "Title", + 'content' => "Content", + 'hits' => "Hits", + 'Filelisting' => "File Listing", + 'DownloadReport' => "Download History for single file", + 'StatsMsg1' => "Top Ten Accessed Files in Repository", + 'StatsMsg2' => "It appears there are no files defined for the filemgmt plugin on this site or no one has ever accessed them.", + 'usealtheader' => "Use Alt. Header", + 'url' => "URL", + 'edit' => "Edit", + 'lastupdated' => "Last Updated", + 'pageformat' => "Page Format", + 'leftrightblocks' => "Left & Right Blocks", + 'blankpage' => "Blank Page", + 'noblocks' => "No Blocks", + 'leftblocks' => "Left Blocks", + 'addtomenu' => 'Add To Menu', + 'label' => 'Label', + 'nofiles' => 'Number of files in our repository (Downloads)', + 'save' => 'save', + 'preview' => 'preview', + 'delete' => 'delete', + 'cancel' => 'cancel', + 'access_denied' => 'Access Denied', + 'invalid_install' => 'Someone has tried to illegally access the File Management install/uninstall page. User id: ', + 'start_install' => 'Attempting to install the Filemgmt Plugin', + 'start_dbcreate' => 'Attempting to create tables for Filemgmt plugin', + 'install_skip' => '... skipped as per filemgmt.cfg', + 'access_denied_msg' => 'You are illegally trying access the File Mgmt administration pages. Please note that all attempts to illegally access this page are logged', + 'installation_complete' => 'Installation Complete', + 'installation_complete_msg' => 'The data structures for the File Mgmt plugin for Geeklog have been successfully installed into your database! If you ever need to uninstall this plugin, please read the README document that came with this plugin.', + 'installation_failed' => 'Installation Failed', + 'installation_failed_msg' => 'The installation of the File Mgmt plugin failed. Please see your Geeklog error.log file for diagnostic information', + 'system_locked' => 'System Locked', + 'system_locked_msg' => 'The File Mgmt plugin has already been installed and is locked. If you are trying to uninstall this plugin, please read the README document that shipped with this plugin', + 'uninstall_complete' => 'Uninstall Complete', + 'uninstall_complete_msg' => 'The datastructures for the File Mgmt plugin have been successfully removed from your Geeklog database<br><br>You will need to manually remove all files in your file repository.', + 'uninstall_failed' => 'Uninstall Failed.', + 'uninstall_failed_msg' => 'The uninstall of the File Mgmt plugin failed. Please see your Geeklog error.log file for diagnostic information', + 'install_noop' => 'Plugin Install', + 'install_noop_msg' => 'The filemgmt plugin install executed but there was nothing to do.<br><br>Check your plugin install.cfg file.', + 'all_html_allowed' => 'All HTML is allowed', + 'no_new_files' => 'No new files', + 'no_comments' => 'No new comments', + 'more' => '<em>more ...</em>' +); + +$PLG_filemgmt_MESSAGE1 = 'Filemgmt Plugin Install Aborted<br>File: plugins/filemgmt/filemgmt.php is not writeable'; +$PLG_filemgmt_MESSAGE3 = 'This plugin requires Geeklog Version 1.4 or greater, upgrade aborted.'; +$PLG_filemgmt_MESSAGE4 = 'Plugin version 1.5 code not detected - upgrade aborted.'; +$PLG_filemgmt_MESSAGE5 = 'Filemgmt Plugin Upgrade Aborted<br>Current plugin version is not 1.3'; + + +// Language variables used by the plugin - general users access code. + +define("_MD_THANKSFORINFO","Thanks for the information. We'll look into your request shortly."); +define("_MD_BACKTOTOP","Back to Downloads Top"); +define("_MD_THANKSFORHELP","Thank you for helping to maintain this directory's integrity."); +define("_MD_FORSECURITY","For security reasons your user name and IP address will also be temporarily recorded."); + +define("_MD_SEARCHFOR","Search for"); +define("_MD_MATCH","Match"); +define("_MD_ALL","ALL"); +define("_MD_ANY","ANY"); +define("_MD_NAME","Name"); +define("_MD_DESCRIPTION","Description"); +define("_MD_SEARCH","Search"); + +define("_MD_MAIN","Main"); +define("_MD_SUBMITFILE","Submit File"); +define("_MD_POPULAR","Popular"); +define("_MD_NEW","New"); +define("_MD_TOPRATED","Top Rated"); + +define("_MD_NEWTHISWEEK","New this week"); +define("_MD_UPTHISWEEK","Updated this week"); + +define("_MD_POPULARITYLTOM","Popularity (Least to Most Hits)"); +define("_MD_POPULARITYMTOL","Popularity (Most to Least Hits)"); +define("_MD_TITLEATOZ","Title (A to Z)"); +define("_MD_TITLEZTOA","Title (Z to A)"); +define("_MD_DATEOLD","Date (Old Files Listed First)"); +define("_MD_DATENEW","Date (New Files Listed First)"); +define("_MD_RATINGLTOH","Rating (Lowest Score to Highest Score)"); +define("_MD_RATINGHTOL","Rating (Highest Score to Lowest Score)"); + +define("_MD_NOSHOTS","No Thumbnails Available"); +define("_MD_EDITTHISDL","Edit This Download"); + +define("_MD_LISTINGHEADING","<b>File Listing: There are %s files in our database</b>"); +define("_MD_LATESTLISTING","<b>Latest Listing:</b>"); +define("_MD_DESCRIPTIONC","Description:"); +define("_MD_EMAILC","Email: "); +define("_MD_CATEGORYC","Category: "); +define("_MD_LASTUPDATEC","Last Update: "); +define("_MD_DLNOW","Download Now!"); +define("_MD_VERSION","Ver"); +define("_MD_SUBMITDATE","Date"); +define("_MD_DLTIMES","Downloaded %s times"); +define("_MD_FILESIZE","File Size"); +define("_MD_SUPPORTEDPLAT","Supported Platforms"); +define("_MD_HOMEPAGE","Home Page"); +define("_MD_HITSC","Hits: "); +define("_MD_RATINGC","Rating: "); +define("_MD_ONEVOTE","1 vote"); +define("_MD_NUMVOTES","(%s)"); +define("_MD_NOPOST","N/A"); +define("_MD_NUMPOSTS","%s votes"); +define("_MD_COMMENTSC","Comments: "); +define ("_MD_ENTERCOMMENT", "Create first comment"); +define("_MD_RATETHISFILE","Rate this File"); +define("_MD_MODIFY","Modify"); +define("_MD_REPORTBROKEN","Report Broken File"); +define("_MD_TELLAFRIEND","Tell a Friend"); +define("_MD_VSCOMMENTS","View/Send Comments"); +define("_MD_EDIT","Edit"); + +define("_MD_THEREARE","There are %s files in our database"); +define("_MD_LATESTLIST","Latest Listings"); + +define("_MD_REQUESTMOD","Request Download Modification"); +define("_MD_FILE","File"); +define("_MD_FILEID","File ID: "); +define("_MD_FILETITLE","Title: "); +define("_MD_DLURL","Download URL: "); +define("_MD_HOMEPAGEC","Home Page: "); +define("_MD_VERSIONC","Version: "); +define("_MD_FILESIZEC","File Size: "); +define("_MD_NUMBYTES","%s bytes"); +define("_MD_PLATFORMC","Platform: "); +define("_MD_CONTACTEMAIL","Contact Email: "); +define("_MD_SHOTIMAGE","Thumbnail Img: "); +define("_MD_SENDREQUEST","Send Request"); + +define("_MD_VOTEAPPRE","Your vote is appreciated."); +define("_MD_THANKYOU","Thank you for taking the time to vote here at %s"); // %s is your site name +define("_MD_VOTEFROMYOU","Input from users such as yourself will help other visitors better decide which file to download."); +define("_MD_VOTEONCE","Please do not vote for the same resource more than once."); +define("_MD_RATINGSCALE","The scale is 1 - 10, with 1 being poor and 10 being excellent."); +define("_MD_BEOBJECTIVE","Please be objective, if everyone receives a 1 or a 10, the ratings aren't very useful."); +define("_MD_DONOTVOTE","Do not vote for your own resource."); +define("_MD_RATEIT","Rate It!"); + +define("_MD_INTFILEAT","Interesting Download File at %s"); // %s is your site name +define("_MD_INTFILEFOUND","Here is an interesting download file I have found at %s"); // %s is your site name + +define("_MD_RECEIVED","We received your download information. Thanks!"); +define("_MD_WHENAPPROVED","You'll receive an E-mail when it's approved."); +define("_MD_SUBMITONCE","Submit your file/script only once."); +define("_MD_APPROVED", "Your file has been approved"); +define("_MD_ALLPENDING","All file/script information are posted pending verification."); +define("_MD_DONTABUSE","Username and IP are recorded, so please don't abuse the system."); +define("_MD_TAKEDAYS","It may take several days for your file/script to be added to our database."); + +define("_MD_RANK","Rank"); +define("_MD_CATEGORY","Category"); +define("_MD_HITS","Hits"); +define("_MD_RATING","Rating"); +define("_MD_VOTE","Vote"); + +define("_MD_SEARCHRESULT4","Search results for <b>%s</b>:"); +define("_MD_MATCHESFOUND","%s matche(s) found."); +define("_MD_SORTBY","Sort by:"); +define("_MD_TITLE","Title"); +define("_MD_DATE","Date"); +define("_MD_POPULARITY","Popularity"); +define("_MD_CURSORTBY","Files currently sorted by: "); +define("_MD_FOUNDIN","Found in:"); +define("_MD_PREVIOUS","Previous"); +define("_MD_NEXT","Next"); +define("_MD_NOMATCH","No matches found to your query"); + +define("_MD_TOP10","%s Top 10"); // %s is a downloads category name +define("_MD_CATEGORIES","Categories"); + +define("_MD_SUBMIT","Submit"); +define("_MD_CANCEL","Cancel"); + +define("_MD_BYTES","Bytes"); +define("_MD_ALREADYREPORTED","You have already submitted a broken report for this resource."); +define("_MD_MUSTREGFIRST","Sorry, you don't have the permission to perform this action.<br>Please register or login first!"); +define("_MD_NORATING","No rating selected."); +define("_MD_CANTVOTEOWN","You cannot vote on the resource you submitted.<br>All votes are logged and reviewed."); + +// Language variables used by the plugin - Admin code. + +define("_MD_RATEFILETITLE","Record your file rating"); +define("_MD_ADMINTITLE","File Management Administration"); +define("_MD_UPLOADTITLE","File Management - Add new file"); +define("_MD_CATEGORYTITLE","File Listing - Category View"); +define("_MD_DLCONF","Downloads Configuration"); +define("_MD_GENERALSET","Configuration Settings"); +define("_MD_ADDMODFILENAME","Add new file"); +define ("_MD_ADDCATEGORYSNAP", "Optional Image: <small>(Top Level Categories only)</small>"); +define ("_MD_ADDIMAGENOTE", "(Image height will be resized to 50)"); +define("_MD_ADDMODCATEGORY","<b>Categories:</b> Add, Modify, and Delete Categories"); +define("_MD_DLSWAITING","Downloads Waiting for Validation"); +define("_MD_BROKENREPORTS","Broken File Reports"); +define("_MD_MODREQUESTS","Download Info Modification Requests"); +define("_MD_EMAILOPTION","Email submitter if file approved: "); +define("_MD_COMMENTOPTION","Enable comments:"); +define("_MD_SUBMITTER","Submitter: "); +define("_MD_DOWNLOAD","Download"); +define("_MD_FILELINK","File Link"); +define("_MD_SUBMITTEDBY","Submitted by: "); +define("_MD_APPROVE","Approve"); +define("_MD_DELETE","Delete"); +define("_MD_NOSUBMITTED","No New Submitted Downloads."); +define("_MD_ADDMAIN","Add MAIN Category"); +define("_MD_TITLEC","Title: "); +define("_MD_CATSEC", "Category Access: "); +define("_MD_IMGURL","<br>Image Filename <font size='-2'> (located in your filemgmt_data/category_snaps directory - Image height will be resized to 50)</font>"); +define("_MD_ADD","Add"); +define("_MD_ADDSUB","Add SUB-Category"); +define("_MD_IN","in"); +define("_MD_ADDNEWFILE","Add New File"); +define("_MD_MODCAT","Modify Category"); +define("_MD_MODDL","Modify Download Info"); +define("_MD_USER","User"); +define("_MD_IP","IP Address"); +define("_MD_USERAVG","User AVG Rating"); +define("_MD_TOTALRATE","Total Ratings"); +define("_MD_NOREGVOTES","No Registered User Votes"); +define("_MD_NOUNREGVOTES","No Unregistered User Votes"); +define("_MD_VOTEDELETED","Vote data deleted."); +define("_MD_NOBROKEN","No reported broken files."); +define("_MD_IGNOREDESC","Ignore (Ignores the report and only deletes this reported entry</b>)"); +define("_MD_DELETEDESC","Delete (Deletes <b>the reported file entry in the repository</b> but not the actual file)"); +define("_MD_REPORTER","Report Sender"); +define("_MD_FILESUBMITTER","File Submitter"); +define("_MD_IGNORE","Ignore"); +define("_MD_FILEDELETED","File Deleted."); +define("_MD_FILENOTDELETED","Record was removed but File was not Deleted.<p>More then 1 record pointing to same file."); +define("_MD_BROKENDELETED","Broken file report deleted."); +define("_MD_USERMODREQ","User Download Info Modification Requests"); +define("_MD_ORIGINAL","Original"); +define("_MD_PROPOSED","Proposed"); +define("_MD_OWNER","Owner: "); +define("_MD_NOMODREQ","No Download Modification Request."); +define("_MD_DBUPDATED","Database Updated Successfully!"); +define("_MD_MODREQDELETED","Modification Request Deleted."); +define("_MD_IMGURLMAIN","Image (Image height will be resized to 50): "); +define("_MD_PARENT","Parent Category:"); +define("_MD_SAVE","Save Changes"); +define("_MD_CATDELETED","Category Deleted."); +define("_MD_WARNING","WARNING: Are you sure you want to delete this Category and ALL its Files and Comments?"); +define("_MD_YES","Yes"); +define("_MD_NO","No"); +define("_MD_NEWCATADDED","New Category Added Successfully!"); +define("_MD_CONFIGUPDATED","New configuration saved"); +define("_MD_ERROREXIST","ERROR: The download info you provided is already in the database!"); +define("_MD_ERRORNOFILE","ERROR: File not found on record in the database!"); +define("_MD_ERRORTITLE","ERROR: You need to enter TITLE!"); +define("_MD_ERRORDESC","ERROR: You need to enter DESCRIPTION!"); +define("_MD_NEWDLADDED","New download added to the database."); +define("_MD_NEWDLADDED_DUPFILE","Warning: Duplicate File. New download added to the database."); +define("_MD_NEWDLADDED_DUPSNAP","Warning: Duplicate Snap. New download added to the database."); +define("_MD_HELLO","Hello %s"); +define("_MD_WEAPPROVED","We approved your download submission to our downloads section. The file name is: "); +define("_MD_THANKSSUBMIT","Thanks for your submission!"); +define("_MD_UPLOADAPPROVED","Your uploaded file was approved"); +define("_MD_DLSPERPAGE","Displayed Downloads per Page: "); +define("_MD_HITSPOP","Hits to be Popular: "); +define("_MD_DLSNEW","Number of Downloads as New on Top Page: "); +define("_MD_DLSSEARCH","Number of Downloads in Search Results: "); +define("_MD_TRIMDESC","Trim File Descriptions in Listing: "); +define("_MD_DLREPORT","Restrict access to Download report"); +define("_MD_WHATSNEWDESC","Enable WhatsNew Listing"); +define("_MD_SELECTPRIV","Restrict access to group 'Logged-In Users' only: "); +define("_MD_ACCESSPRIV","Enable Anonymous access: "); +define("_MD_UPLOADSELECT","Allow Logged-In uploads: "); +define("_MD_UPLOADPUBLIC","Allow Anonymous uploads: "); +define("_MD_USESHOTS","Display Category Images: "); +define("_MD_IMGWIDTH","Thumbnail Img Width: "); +define("_MD_MUSTBEVALID","Thumbnail image must be a valid image file under %s directory (ex. shot.gif). Leave it blank if no image file."); +define("_MD_REGUSERVOTES","Registered User Votes (total votes: %s)"); +define("_MD_ANONUSERVOTES","Anonymous User Votes (total votes: %s)"); +define("_MD_YOURFILEAT","Your file submitted at %s"); // this is an approved mail subject. %s is your site name +define("_MD_VISITAT","Visit our downloads section at %s"); +define("_MD_DLRATINGS","Download Rating (total votes: %s)"); +define("_MD_CONFUPDATED","Configuration Updated Successfully!"); +define("_MD_NOFILES","No Files Found"); + +// Additional Geeklog Defines +define("_MD_NOVOTE","Not rated yet"); +define("_IFNOTRELOAD","If the page does not automatically reload, please click <a href=%s>here</a>"); +define("_GL_ERRORNOACCESS","ERROR: No access to this Document Repository Section"); +define("_GL_ERRORNOUPLOAD","ERROR: You do not have upload privilages"); +define("_GL_ERRORNOADMIN","ERROR: This function is restricted"); +define("_GL_NOUSERACCESS","does not have access to the Document Repository"); +define("_MD_ERRUPLOAD","Filemgmt: Unable to upload - check permissions for the file store directories"); +define("_MD_DLFILENAME","Filename: "); +define("_MD_REPLFILENAME","Replacement File: "); +define("_MD_SCREENSHOT","Screenshot"); +define("_MD_SCREENSHOT_NA",' '); +define("_MD_COMMENTSWANTED","Comments are appreciated"); +define("_MD_CLICK2SEE","Click to see: "); +define("_MD_CLICK2DL","Click to download: "); +define("_MD_ORDERBY","Order By: "); +define("_MD_ORDERBY","Order By: "); +define("_MD_ORDERBY","Order By: "); + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/brokenfile.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/brokenfile.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,90 @@ +<?php +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// | | +// | Based on: | +// | myPHPNUKE Web Portal System - http://myphpnuke.com/ | +// | PHP-NUKE Web Portal System - http://phpnuke.org/ | +// | Thatware - http://thatware.org/ | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +require_once('../lib-common.php'); +include_once($_CONF[path_html]."filemgmt/include/header.php"); +include($_CONF[path_html] ."filemgmt/include/functions.php"); +$lid = COM_applyFilter($_REQUEST['lid'],true); +if ($lid == 0) { + echo COM_refresh($_CONF['site_url'] .'/filemgmt/index.php'); + exit; +} + +if ( isset($_POST['submit']) ) { + if( !$FilemgmtUser ) { + $sender = 0; + } else { + $sender = $uid; + } + $ip = $_SERVER['REMOTE_ADDR']; + if ( $sender != 0 ) { + // Check if REG user is trying to report twice. + $result=DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid' AND sender='$sender'"); + list ($count)=DB_fetchARRAY($result); + if ( $count > 0 ) { + redirect_header("index.php",2,_MD_ALREADYREPORTED); + exit(); + } + } else { + // Check if the sender is trying to vote more than once. + $result=DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_brokenlinks']} WHERE lid='$lid' AND ip='$ip'"); + list ($count)=DB_fetchARRAY($result); + if ( $count > 0 ) { + redirect_header("index.php",2,_MD_ALREADYREPORTED); + exit(); + } + } + DB_query("INSERT INTO {$_FM_TABLES['filemgmt_brokenlinks']} (lid, sender, ip) VALUES ('$lid', '$sender', '$ip')") or die(''); + redirect_header("index.php",2,_MD_THANKSFORINFO); + exit(); + +} else { + $display = COM_siteHeader('menu'); + $display .= COM_startBlock("<b>"._MD_ADMINTITLE."</b>"); + $display .= "<form action='brokenfile.php' method='post'>"; + $display .= "<input type='hidden' name='lid' value='$lid' />"; + $display .= "<table border=0 cellpadding=1 cellspacing=0 width=\"80%\" class=\"plugin\"><tr>"; + $display .= '<td class="pluginHeader">'._MD_REPORTBROKEN.'</td></tr>'; + $display .= '<tr><td style="padding:10px;">'; + $display .= _MD_THANKSFORHELP; + $display .= "<br>"._MD_FORSECURITY."<br /><br />"; + $display .= '</td></tr><tr><td style="padding:0px 0px 10px 10px;">'; + $display .= "<input type='submit' name='submit' value='"._MD_REPORTBROKEN."' />"; + $display .= " <input type='button' value='"._MD_CANCEL."' onclick='javascript:history.go(-1)' />"; + $display .= "</td></tr></table></form>"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(); + echo $display; +} + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/downloadhistory.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/downloadhistory.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,88 @@ +<?php +/* Reminder: always indent with 4 spaces (no tabs). */ +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// | | +// | Based on: | +// | myPHPNUKE Web Portal System - http://myphpnuke.com/ | +// | PHP-NUKE Web Portal System - http://phpnuke.org/ | +// | Thatware - http://thatware.org/ | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +require_once("../lib-common.php"); +include_once($_CONF[path_html]."filemgmt/include/header.php"); +include($_CONF[path_html] ."filemgmt/include/functions.php"); + +// Comment out the following security check if you want general filemgmt users access to this report +if (!SEC_hasRights("filemgmt.edit")) { + COM_errorLOG("Downloadhistory.php => Filemgmt Plugin Access denied. Attempted access for file ID:{$lid}, Remote address is:{$_SERVER['REMOTE_ADDR']}"); + redirect_header($_CONF['site_url']."/index.php",1,_GL_ERRORNOADMIN); + exit(); +} +$lid = COM_applyFilter($_GET['lid'],true); + +$result=DB_query("SELECT title FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE lid=$lid"); +list($dtitle)=DB_fetchARRAY($result); + +$result=DB_query("SELECT date,uid,remote_ip FROM {$_FM_TABLES['filemgmt_history']} WHERE lid=$lid"); +$display = COM_siteHeader('none'); + +$display .= "<table width='100%' border='0' cellspacing='1' cellpadding='4' class='plugin'><tr>"; +$display .= "<td colspan='3'><center><H2>". $LANG_FILEMGMT['DownloadReport'] ."</H2></center></td></tr><tr>"; +$display .= "<td colspan='3'><H4>File: " .$dtitle ."</H4></td></tr><tr>"; +$display .= "<td bgcolor='#000000' width='20%'><b><center><font color='#ffffff' size='3'>Date</font></center></b></td>"; +$display .= "<td bgcolor='#000000' width='20%'><b><center><font color='#ffffff' size='3'>User</font></center></b></td>"; +$display .= "<td bgcolor='#000000' width='20%'><b><center><font color='#ffffff' size='3'>Remote IP</font></center></b></td>"; +$display .= "</tr>"; + +$highlight = true; +while(list($date,$uid,$remote_ip)=DB_fetchARRAY($result)){ + $result2 = DB_query("SELECT username FROM {$_TABLES['users']} WHERE uid = $uid"); + list ($username) = DB_fetchARRAY($result2); + $result2 = DB_query("SELECT username FROM {$_TABLES['users']} WHERE uid = $uid"); + list ($username) = DB_fetchARRAY($result2); + + if ($highlight) { + $highlight=false; + $display .= "<td bgcolor='#f5f5f5' width=20%>$date</td>"; + $display .= "<td bgcolor='#f5f5f5' width=20%>$username</td>"; + $display .= "<td bgcolor='#f5f5f5' width=20%>$remote_ip</td>"; + $display .= "</tr>"; + }else { + $highlight=true; + $display .= "<td width=20%>$date</td>"; + $display .= "<td width=20%>$username</td>"; + $display .= "<td width=20%>$remote_ip</td>"; + $display .= "</tr>"; + } + +} +$display .= "</table>"; +$display .= "<br>"; +$display .= COM_siteFooter(); +echo $display; + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/images/Thumbs.db ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/arrow.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/bul1a.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/bul42.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/button.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/counter.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/decs.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/delete.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/dl.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/dot1.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/down.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/download.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/editicon.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/filemgmt.jpg ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/floder.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/home.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/newred.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/platform.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/pop.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/screenshoticon.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/size.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/speck.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/time.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/up.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/update.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/images/ver.gif ============================================================================== Binary file. No diff available. Added: trunk/plugins/filemgmt/public_html/include/dlformat.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/include/dlformat.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,136 @@ +<?php +// ------------------------------------------------------------------------- // +// Geeklog - PHP Content Management System // +// ------------------------------------------------------------------------- // +// Based on: // +// myPHPNUKE Web Portal System - http://myphpnuke.com/ // +// PHP-NUKE Web Portal System - http://phpnuke.org/ // +// Thatware - http://thatware.org/ // +// ------------------------------------------------------------------------- // +// Developed for Geeklog as File Management Module // +// By: Blaine Lang - July 2002 // +// blain****@porta***** // +// // +// Ver 1.2 Sept 24/2002: Enhancements to display formatting // +// ------------------------------------------------------------------------- // +// 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 option) 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, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// ------------------------------------------------------------------------- // + + +if (basename($GLOBALS['PHP_SELF']) == "dlformat.php") { + exit(); +} + +$path = $mytree->getPathFromId($cid, "title"); +$path = substr($path, 1); +$path = str_replace("/"," <img src='" .$_CONF[site_url] ."/filemgmt/images/arrow.gif' board='0' alt=''> ",$path); + +$p->set_var('LANG_CATEGORY',_MD_CATEGORYC); +$p->set_var('category_path',$path); + +if (empty($submitter_name)) { + $submitter_name = 'Unknown UID'; +} else { + $submitter_name = "<a href='" . $_CONF['site_url'] . "/users.php?mode=profile&uid=" . $submitter . "'>" .$submitter_name. "</a>"; +} +$p->set_var('LANG_SUBMITTEDBY',_MD_SUBMITTEDBY); +$p->set_var('submitter_name',$submitter_name); +$p->set_var('lid',$lid); +$p->set_var('LANG_DLNOW',_MD_DLNOW); +$p->set_var('dtitle',$dtitle); +$p->set_var('image_newdownload',newdownloadgraphic($time, $status)); +$p->set_var('image_popular', popgraphic($hits)); + +$p->set_var('download_title', _MD_CLICK2DL . urldecode($url)); +$p->set_var('url',$url); +$p->set_var('file_description',$description); + +if ( $rating!="0" || $rating!="0.00" ) { + $votestring = sprintf(_MD_NUMVOTES,$votes); + $p->set_var('rating',$rating); + $p->set_var('votestring', $votestring); +} else { + $p->set_var('rating',$rating); + $p->set_var('votestring', ''); +} +if ($logourl != '') { + $p->set_var('snapshot_icon','<img src="'.$_CONF['site_url'] .'/filemgmt/images/screenshoticon.gif" width="14" height="14" border="0">'); + $p->set_var('snapshot_url',$filemgmt_FileSnapURL . $logourl); + $p->set_var('LANG_CLICK2SEE', _MD_CLICK2SEE.$logourl); + $p->set_var('show_snapshoticon',''); + $p->set_var('show_snapshoticon_na','none'); +} else { + $p->set_var('show_snapshoticon','none'); + $p->set_var('show_snapshoticon_na',''); + $p->set_var('snapshot_icon',''); + $p->set_var('snapshot_url',''); + $p->set_var('LANG_CLICK2SEE',''); +} + +$p->set_var('LANG_MD_SCREENSHOT_NA', _MD_SCREENSHOT_NA); +$p->set_var('LANG_VERSION', _MD_VERSION); +$p->set_var('LANG_RATING', _MD_RATINGC); +$p->set_var('LANG_SUBMITDATE', _MD_SUBMITDATE); +$p->set_var('datetime',$datetime); +$p->set_var('version',$version); + +// Check if restricted access has been enabled for download report to admin's only +if (($hits > 0 && !$mydownloads_dlreport) || ( $hits > 0 && SEC_hasRights('filemgmt.edit'))) { + $p->set_var('begin_dlreport_link',"<a href=\"{$_CONF[site_url]}/filemgmt/downloadhistory.php?lid=$lid\" target=\"_blank\">"); + $p->set_var('end_dlreport_link','</a>'); +} else { + $p->set_var('begin_dlreport_link',''); + $p->set_var('end_dlreport_link',''); +} +$p->set_var('download_times',sprintf(_MD_DLTIMES,$hits)); +$p->set_var('download_count',$hits); +$p->set_var('LANG_FILESIZE',_MD_FILESIZE); +$p->set_var('file_size',PrettySize($size)); +$p->set_var('homepage_url',$homepage); +$p->set_var('LANG_HOMEPAGE',_MD_HOMEPAGE); +$p->set_var('homepage',$homepage); + +if ($comments) { + $commentCount=DB_count($_TABLES['comments'],'sid',"fileid_$lid"); + $recentPostMessage =_MD_COMMENTSWANTED; + if ($commentCount > 0) { + $result4 = DB_query("SELECT cid, UNIX_TIMESTAMP(date) AS day,username FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = 'fileid_$lid' ORDER BY date desc LIMIT 1"); + $C = DB_fetchArray($result4); + $recentPostMessage = $LANG01[27].': '.strftime($_CONF['daytime'],$C['day']). ' ' . $LANG01[104] . ' ' . $C['username']; + $comment_link = '<a href="' .$_CONF[site_url] .'/filemgmt/index.php?id=' .$lid.'" TITLE="'.$recentPostMessage.'">' .$commentCount.' ' .$LANG01[3]. '</a>'; + } else { + $comment_link = '<a href="' .$_CONF[site_url] . '/comment.php?type=filemgmt&sid=fileid_' .$lid.'" TITLE="'.$recentPostMessage.'">' . _MD_ENTERCOMMENT . '</a>'; + } + $p->set_var('comment_link',$comment_link); + $p->set_var('show_comments',''); +} else { + $p->set_var('show_comments','none'); +} + +$p->set_var('LANG_DOWNLOAD',_MD_DOWNLOAD); +$p->set_var('LANG_FILELINK',_MD_FILELINK); +$p->set_var('LANG_RATETHISFILE',_MD_RATETHISFILE); +$p->set_var('LANG_REPORTBROKEN',_MD_REPORTBROKEN); + +if ($FilemgmtAdmin) { + $p->set_var('LANG_EDIT', _MD_EDIT); + $p->set_var('show_editlink',''); +} else { + $p->set_var('LANG_EDIT', ''); + $p->set_var('show_editlink','none'); +} + + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/include/errorhandler.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/include/errorhandler.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,116 @@ +<?php +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// | | +// | Based on: | +// | myPHPNUKE Web Portal System - http://myphpnuke.com/ | +// | PHP-NUKE Web Portal System - http://phpnuke.org/ | +// | Thatware - http://thatware.org/ | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + +class ErrorHandler { + function show($e_code, $pages=1) { + global $_CONF; + $errmsg = array( + "0001" =>"Could not connect to the forums database.", + "0002" => "The forum you selected does not exist. Please go back and try again.", + "0003" => "Password Incorrect.", + "0004" => "Could not query the topics database.", + "0005" => "Error getting messages from the database.", + "0006" => "Please enter the Nickname and the Password.", + "0007" => "You are not the Moderator of this forum therefore you can't perform this function.", + "0008" => "You did not enter the correct password, please go back and try again.", + "0009" => "Could not remove posts from the database.", + "0010" => "Could not move selected topic to selected forum. Please go back and try again.", + "0011" => "Could not lock the selected topic. Please go back and try again.", + "0012" => "Could not unlock the selected topic. Please go back and try again.", + "0013" => "Could not query the database. <BR>Error: ".mysql_error()."", + "0014" => "No such user or post in the database.", + "0015" => "Search Engine was unable to query the forums database.", + "0016" => "That user does not exist. Please go back and search again.", + "0017" => "You must type a subject to post. You can't post an empty subject. Go back and enter the subject", + "0018" => "You must choose message icon to post. Go back and choose message icon.", + "0019" => "You must type a message to post. You can't post an empty message. Go back and enter a message.", + "0020" => "Could not enter data into the database. Please go back and try again.", + "0021" => "Can't delete the selected message.", + "0022" => "An error ocurred while querying the database.", + "0023" => "Selected message was not found in the forum database.", + "0024" => "You can't reply to that message. It wasn't sent to you.", + "0025" => "You can't post a reply to this topic, it has been locked. Contact the administrator if you have any question.", + "0026" => "The forum or topic you are attempting to post to does not exist. Please try again.", + "0027" => "You must enter your username and password. Go back and do so.", + "0028" => "You have entered an incorrect password. Go back and try again.", + "0029" => "Couldn't update post count.", + "0030" => "The forum you are attempting to post to does not exist. Please try again.", + "0031" => "Unknown Error", + "0035" => "You can't edit a post that's not yours.", + "0036" => "You do not have permission to edit this post.", + "0037" => "You did not supply the correct password or do not have permission to edit this post. Please go back and try again.", + "1001" => "Please enter value for Title.", + "1002" => "Please enter value for Phone.", + "1003" => "Please enter value for Summary.", + "1004" => "Please enter value for Address.", + "1005" => "Please enter value for City.", + "1006" => "Please enter value for State/Province.", + "1007" => "Please enter value for Zipcode.", + "1008" => "Please enter value for Description.", + "1009" => "Vote for the selected resource only once.<br>All votes are logged and reviewed.", + "1010" => "You cannot vote on the resource you submitted.<br>All votes are logged and reviewed.", + "1011" => "No rating selected - no vote tallied.", + "1013" => "Please enter a search query.", + "1016" => "Please enter value for Filename.", + "1017" => "The file was not uploaded - reported filesize of 0 bytes.", + "1101" => "Upload approval Error: The temporary file was not found. Check error.log", + "1102" => "Upload submit Error: The temporary filestore file was not created. Check error.log", + "1103" => "The download info you provided is already in the database!", + "1104" => "The download info was not complete - Need to enter a title for the new file", + "1105" => "The download info was not complete - Need to enter a description for the new file", + "1106" => "Upload Add Error: The new file was not created. Check error.log", + "1107" => "Upload Add Error: The temporary file was not found. Check error.log", + "1108" => "Duplicate file - already existing in filestore", + + "9999" => "OOPS! God Knows" + ); + + $errorno = array_keys($errmsg); + if (!in_array($e_code, $errorno)) { + $e_code = '9999'; + } + include_once($_CONF[path_html]."filemgmt/include/header.php"); + $display = COM_siteHeader('menu'); + $display .= '<table width="100%" class="plugin" border="0" cellspacing="0" cellpadding="1">'; + $display .= '<tr><td class="pluginAlert" style="text-align:right;padding:5px;">File Management Plugin</td>'; + $display .= "<td class=\"pluginAlert\" width=\"50%\" style=\"padding:5px 0px 5px 10px;\">Error Code: $e_code</td></tr>"; + $display .= "<tr><td colspan=\"2\" class=\"pluginInfo\"><b>ERROR:</b> $errmsg[$e_code]</td></tr>"; + $display .= '<tr><td colspan="2" class="pluginInfo" style="text-align:center;padding:10px;">'; + $display .= "[ <a href='javascript:history.go(-".$pages.")'>Go Back</a> ]</td></tr></table>"; + $display .= COM_siteFooter(); + echo $display; + die(""); + } +} + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/include/functions.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/include/functions.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,207 @@ +<?php +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// | | +// | Based on: | +// | myPHPNUKE Web Portal System - http://myphpnuke.com/ | +// | PHP-NUKE Web Portal System - http://phpnuke.org/ | +// | Thatware - http://thatware.org/ | +// +-------------------------------------------------------------------------+ +// | 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 option) 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, write to the Free Software Foundation, | +// | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | +// | | +// +-------------------------------------------------------------------------+ +// + + +function newdownloadgraphic($time, $status) { + global $_CONF; + + $count = 7; + $startdate = (time()-(86400 * $count)); + if ($startdate < $time) { + if($status==1){ + $functionretval = " <img src=\"{$_CONF[site_url]}/filemgmt/images/newred.gif\" alt=\"" ._MD_NEWTHISWEEK . '">'; + }elseif($status==2){ + $functionretval = " <img src=\"{$_CONF[site_url]}/filemgmt/images/update.gif\" alt=\"" ._MD_UPTHISWEEK . '">'; + } + } + return $functionretval; +} + +function popgraphic($hits) { + global $_CONF, $mydownloads_popular; + + if ($hits >= $mydownloads_popular) { + $functionretval = " <img src=\"{$_CONF[site_url]}/filemgmt/images/pop.gif\" alt=\"" ._MD_POPULAR . '" >'; + } + return $functionretval; +} + +//updates rating data in itemtable for a given item +function updaterating($sel_id){ + global $_FM_TABLES; + $voteresult = DB_query("select rating FROM {$_FM_TABLES['filemgmt_votedata']} WHERE lid = '$sel_id'"); + $votesDB = DB_numROWS($voteresult); + $totalrating = 0; + if ($votesDB > 0) { + while(list($rating)=DB_fetchARRAY($voteresult)){ + $totalrating += $rating; + } + $finalrating = $totalrating/$votesDB; + } + $finalrating = number_format($finalrating, 4); + DB_query("UPDATE {$_FM_TABLES['filemgmt_filedetail']} SET rating='$finalrating', votes='$votesDB' WHERE lid = '$sel_id'"); +} + +//returns the total number of items in items table that are accociated with a given table $table id +function getTotalItems($sel_id, $status=''){ + global $_FM_TABLES,$mytree; + $count = 0; + $arr = array(); + $sql = "SELECT count(*) from {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= "WHERE a.cid='$sel_id' and a.status='$status' $mytree->filtersql"; + list($thing) = DB_fetchArray(DB_query($sql)); + $count = $thing; + $arr = $mytree->getAllChildId($sel_id); + $size = sizeof($arr); + for($i=0;$i<$size;$i++){ + $sql = "SELECT count(*) from {$_FM_TABLES['filemgmt_filedetail']} a "; + $sql .= "LEFT JOIN {$_FM_TABLES['filemgmt_cat']} b ON a.cid=b.cid "; + $sql .= "WHERE a.cid='{$arr[$i]}}'and a.status='$status' $mytree->filtersql"; + list($thing) = DB_fetchArray(DB_query($sql)); + $count += $thing; + } + return $count; +} + +/* +* Function to display formatted times in user timezone +*/ +function formatTimestamp($usertimestamp) { + $datetime = date("M.d.y", $usertimestamp); + $datetime = ucfirst($datetime); + return $datetime; +} + +function PrettySize($size) { + $mb = 1024*1024; + if ( $size > $mb ) { + $mysize = sprintf ("%01.2f",$size/$mb) . " MB"; + } + elseif ( $size >= 1024 ) { + $mysize = sprintf ("%01.2f",$size/1024) . " KB"; + } + else { + $mysize = sprintf(_MD_NUMBYTES,$size); + } + return $mysize; +} + + +function myTextForm($url , $value) { + return "<form action='$url' method='post'><input type='submit' value='$value' /></form>\n"; +} + +function themecenterposts($title, $content) { + $retval .= "<table border='0' cellpadding='3' cellspacing='5' width='100%'>" + ."<tr>" + ."<td><div class='indextitle'>$title</div><br /></td>" + ."</tr>" + ."<tr><td>$content</td>" + ."</tr>" + ."<tr><td align='right'> </td>" + ."</tr>" + ."</table>"; + + return $retval; +} + +function redirect_header($url, $time=3, $message=''){ + $display = COM_siteHeader('menu'); + $display .= "<html><head>\n"; + $display .= "<meta http-equiv='Content-Type' content='text/html;' />\n"; + $display .= "<meta http-equiv='Refresh' content='$time; url=$url' />\n"; + $display .= "</head><body><div id='content'>\n"; + $display .= COM_startBlock(); + $display .= "<center>"; + if ( $message!="" ) { + $display .= "<br><p><h4>".$message."</h4>\n"; + } + $display .= "<br /><b>\n"; + $display .= sprintf(_IFNOTRELOAD,$url); + $display .= "\n"; + $display .= "<p></center></div>\n"; + $display .= COM_endBlock(); + $display .= COM_siteFooter(false); + echo $display; +} + +//Reusable Link Sorting Functions +function convertorderbyin($orderby) { + if ($orderby == "titleA") $orderby = "title ASC"; + if ($orderby == "dateA") $orderby = "date ASC"; + if ($orderby == "hitsA") $orderby = "hits ASC"; + if ($orderby == "ratingA") $orderby = "rating ASC"; + if ($orderby == "titleD") $orderby = "title DESC"; + if ($orderby == "dateD") $orderby = "date DESC"; + if ($orderby == "hitsD") $orderby = "hits DESC"; + if ($orderby == "ratingD") $orderby = "rating DESC"; + return $orderby; +} +function convertorderbytrans($orderby) { + if ($orderby == "hits ASC") $orderbyTrans = _MD_POPULARITYLTOM; + if ($orderby == "hits DESC") $orderbyTrans = _MD_POPULARITYMTOL; + if ($orderby == "title ASC") $orderbyTrans = _MD_TITLEATOZ; + if ($orderby == "title DESC") $orderbyTrans = _MD_TITLEZTOA; + if ($orderby == "date ASC") $orderbyTrans = _MD_DATEOLD; + if ($orderby == "date DESC") $orderbyTrans = _MD_DATENEW; + if ($orderby == "rating ASC") $orderbyTrans = _MD_RATINGLTOH; + if ($orderby == "rating DESC") $orderbyTrans = _MD_RATINGHTOL; + return $orderbyTrans; +} +function convertorderbyout($orderby) { + if ($orderby == "title ASC") $orderby = "titleA"; + if ($orderby == "date ASC") $orderby = "dateA"; + if ($orderby == "hits ASC") $orderby = "hitsA"; + if ($orderby == "rating ASC") $orderby = "ratingA"; + if ($orderby == "title DESC") $orderby = "titleD"; + if ($orderby == "date DESC") $orderby = "dateD"; + if ($orderby == "hits DESC") $orderby = "hitsD"; + if ($orderby == "rating DESC") $orderby = "ratingD"; + return $orderby; +} + +function randomfilename() { + + $length=10; + srand((double)microtime()*1000000); + $possible_charactors = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + $string = ""; + while(strlen($string)<$length) { + $string .= substr($possible_charactors, rand()%(strlen($possible_charactors)),1); + } + return($string); +} + + +?> \ No newline at end of file Added: trunk/plugins/filemgmt/public_html/include/header.php ============================================================================== --- (empty file) +++ trunk/plugins/filemgmt/public_html/include/header.php Tue Sep 9 05:43:45 2008 @@ -0,0 +1,75 @@ +<?php +// +-------------------------------------------------------------------------+ +// | File Management Plugin for Geeklog - by portalparts www.portalparts.com | +// +-------------------------------------------------------------------------+ +// | Filemgmt plugin - version 1.5 | +// | Date: Mar 18, 2006 | +// +-------------------------------------------------------------------------+ +// | Copyright (C) 2004 by Consult4Hire Inc. | +// | Author: | +// | Blaine Lang - blain****@porta***** | +// | | +// | Based on: | +// | myPHPNUKE Web Portal System - http://myphpnuke.com/ | +// | PHP-NUKE Web Portal System - http://phpnuke.org/ | +// | Thatware - http://thatware.org/ | +// +-------------------------------------------------------------------------+ +// | 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 option) any later version. | +// | ============================================================================== Diff truncated at 200k characters