userclassOptions = 'blank,nobody,guest,public,main,admin,member,classes'; // Save basic search string if (isset($_POST['download-search-text'])) { $this->searchField = $_POST['download-search-text']; } // Save advanced search criteria if (isset($_POST['download_advanced_search_submit'])) { $this->advancedSearchFields = $_POST['download_advanced_search']; } } /* function show_filter_form($action, $subAction, $id, $from, $amount) { global $e107, $mySQLdefaultdb, $pref, $user_pref; $frm = new e_form(); $filterColumns = ($user_pref['admin_download_disp'] ? $user_pref['admin_download_disp'] : array("download_name","download_class")); // $url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => 123)); $url = "admin_download.php"; // Search field $text .= "
"; // Advanced search fields $text .= "
"; return $text; } */ /* function show_existing_items($action, $subAction, $id, $from, $amount) { global $sql, $rs, $ns, $tp, $mySQLdefaultdb, $pref, $user_pref; $frm = new e_form(); $sortorder = $subAction ? $subAction : $pref['download_order']; $sortdirection = $id=="asc" ? "asc" : "desc"; $amount = 10; if(!$sortorder) { $sortorder = "download_id"; } $sort_link = $sortdirection == 'asc' ? 'desc' : 'asc'; $columnInfo = array( "checkboxes" => array("title" => "", "forced"=> TRUE, "width" => "3%", "thclass" => "center first", "toggle" => "dl_selected"), "download_id" => array("title"=>DOWLAN_67, "type"=>"", "width"=>"auto", "thclass"=>"", "forced"=>true), "download_name" => array("title"=>DOWLAN_12, "type"=>"", "width"=>"auto", "thclass"=>""), "download_url" => array("title"=>DOWLAN_13, "type"=>"", "width"=>"auto", "thclass"=>""), "download_author" => array("title"=>DOWLAN_15, "type"=>"", "width"=>"auto", "thclass"=>""), "download_author_email" => array("title"=>DOWLAN_16, "type"=>"", "width"=>"auto", "thclass"=>""), "download_author_website" => array("title"=>DOWLAN_17, "type"=>"", "width"=>"auto", "thclass"=>""), "download_description" => array("title"=>DOWLAN_18, "type"=>"", "width"=>"auto", "thclass"=>""), "download_filesize" => array("title"=>DOWLAN_66, "type"=>"", "width"=>"auto", "thclass"=>"right"), "download_requested" => array("title"=>DOWLAN_29, "type"=>"", "width"=>"auto", "thclass"=>"center"), "download_category" => array("title"=>DOWLAN_11, "type"=>"", "width"=>"auto", "thclass"=>""), "download_active" => array("title"=>DOWLAN_21, "type"=>"", "width"=>"auto", "thclass"=>"center"), "download_datestamp" => array("title"=>DOWLAN_182, "type"=>"", "width"=>"auto", "thclass"=>""), "download_thumb" => array("title"=>DOWLAN_20, "type"=>"", "width"=>"auto", "thclass"=>"center"), "download_image" => array("title"=>DOWLAN_19, "type"=>"", "width"=>"auto", "thclass"=>""), "download_comment" => array("title"=>DOWLAN_102, "type"=>"", "width"=>"auto", "thclass"=>"center"), "download_class" => array("title"=>DOWLAN_113, "type"=>"", "width"=>"auto", "thclass"=>""), "download_mirror" => array("title"=>DOWLAN_128, "type"=>"", "width"=>"auto", "thclass"=>""), "download_mirror_type" => array("title"=>DOWLAN_195, "type"=>"", "width"=>"auto", "thclass"=>""), "download_visible" => array("title"=>DOWLAN_43, "type"=>"", "width"=>"auto", "thclass"=>""), "options" => array("title"=>LAN_OPTIONS, "width"=>"10%", "thclass"=>"center last", "forced"=>true) ); $filterColumns = ($user_pref['admin_download_disp']) ? $user_pref['admin_download_disp'] : array("download_name","download_class"); $query = "SELECT d.*, dc.* FROM `#download` AS d LEFT JOIN `#download_category` AS dc ON dc. download_category_id=d.download_category"; if ($this->searchField) { $where = array(); array_push($where, "download_name REGEXP('".$this->searchField."')"); array_push($where, "download_description REGEXP('".$this->searchField."')"); array_push($where, "download_author REGEXP('".$this->searchField."')"); array_push($where, "download_author_email REGEXP('".$this->searchField."')"); array_push($where, "download_author_website REGEXP('".$this->searchField."')"); $where = " WHERE ".implode(" OR ", $where); $query .= "$where ORDER BY {$sortorder} {$sortdirection}"; } else if ($this->advancedSearchFields) { $where = array(); if (strlen($this->advancedSearchFields['name']) > 0) { array_push($where, "download_name REGEXP('".$this->advancedSearchFields['name']."')"); } if (strlen($this->advancedSearchFields['url']) > 0) { array_push($where, "download_url REGEXP('".$this->advancedSearchFields['url']."')"); } if (strlen($this->advancedSearchFields['author']) > 0) { array_push($where, "download_author REGEXP('".$this->advancedSearchFields['author']."')"); } if (strlen($this->advancedSearchFields['description']) > 0) { array_push($where, "download_description REGEXP('".$this->advancedSearchFields['description']."')"); } if (strlen($this->advancedSearchFields['category']) != 0) { array_push($where, "download_category=".$this->advancedSearchFields['category']); } if (strlen($this->advancedSearchFields['filesize']) > 0) { array_push($where, "download_filesize".$this->advancedSearchFields['filesize_condition'].($this->advancedSearchFields['filesize']*$this->advancedSearchFields['filesize_units'])); } if ($this->advancedSearchFields['status'] != 99) { array_push($where, "download_active=".$this->advancedSearchFields['status']); } if (strlen($this->advancedSearchFields['date']) > 0) { switch ($this->advancedSearchFields['date_condition']) { case "<=" : { array_push($where, "download_datestamp".$this->advancedSearchFields['date_condition'].($this->advancedSearchFields['date']+86400)); break; } case "=" : { array_push($where, "(download_datestamp>=".$this->advancedSearchFields['date']." AND download_datestamp<=".($this->advancedSearchFields['date']+86399).")"); break; } case ">=" : { array_push($where, "download_datestamp".$this->advancedSearchFields['date_condition'].$this->advancedSearchFields['date']); break; } } } if (strlen($this->advancedSearchFields['requested']) > 0) { array_push($where, "download_requested".$this->advancedSearchFields['requested_condition'].$this->advancedSearchFields['requested']); } if ($this->advancedSearchFields['visible']) { array_push($where, "download_visible=".$this->advancedSearchFields['visible']); } if ($this->advancedSearchFields['class']) { array_push($where, "download_class=".$this->advancedSearchFields['class']); } $where = (count($where) > 0 ? " WHERE ".implode(" AND ", $where) : ""); $query .= "$where ORDER BY {$sortorder} {$sortdirection}"; } else { $query .= " ORDER BY ".($subAction ? $subAction : $sortorder)." ".($id ? $id : $sortdirection)." LIMIT $from, $amount"; } $text .= "
".DOWLAN_7.""; if ($dl_count = $sql->db_Select_gen($query)) { $text .= $rs->form_open("post", e_SELF."?".e_QUERY, "myform")." ".$frm->colGroup($columnInfo,$filterColumns) .$frm->thead($columnInfo,$filterColumns,"main.[FIELD].[ASC].[FROM]")." "; $rowStyle = "even"; while ($row = $sql->db_Fetch()) { $mirror = strlen($row['download_mirror']) > 0; $text .= "\n \n"; // Display Chosen options foreach($filterColumns as $disp) { switch ($disp) { case "download_name" : $text .= ""; } $text .= " "; } $text .= "
".$frm->checkbox("dl_selected[".$row["download_id"]."]", $row['download_id'])." ".$row['download_id'].""; $text .= "".$tp->toHTML($row['download_name']).""; break; case "download_category" : $text .= ""; $text .= $tp->toHTML($row['download_category_name']); break; case "download_datestamp" : global $gen; $text .= ""; $text .= ($row[$disp]) ? $gen->convert_date($row[$disp],'short') : ""; break; case "download_class" : case "download_visible" : $text .= ""; $text .= r_userclass_name($row[$disp])." "; break; case "download_filesize" : $text .= ""; //$text .= ($row[$disp]) ? $this->e107->parseMemorySize(($row[$disp])) : ""; $text .= ($row[$disp]) ? (intval($row[$disp])) : ""; break; case "download_thumb" : $text .= ""; $text .= ($row[$disp]) ? "" : ""; break; case "download_image" : $text .= ""; $text .= "".$row[$disp].""; break; case "download_description" : $text .= ""; $text .= $tp->toHTML($row[$disp],TRUE); break; case "download_active" : $text .= ""; if ($row[$disp]== 1) { $text .= ""; } elseif ($row[$disp]== 2) { $text .= ""; } else { $text .= ""; } break; case "download_comment" : $text .= ""; $text .= ($row[$disp]) ? ADMIN_TRUE_ICON : ""; break; case "download_mirror" : $text .= ""; $mirrorArray = $this->makeMirrorArray($row[$disp], TRUE); foreach($mirrorArray as $mirror) { $title = DOWLAN_66." ".$mirror['filesize']."; ".DOWLAN_29." ".$mirror['requests']; $text .= "
"; $text .= $tp->toHTML($mirror['url']).'
'; } break; case "download_mirror_type" : $text .= "
"; if ($mirror) { switch ($row[$disp]) { case 1: $text .= DOWLAN_196; break; default: $text .= DOWLAN_197; } } break; case "download_requested" : case "download_active" : case "download_thumb" : case "download_comment" : $text .= ""; $text .= $tp->toHTML($row[$disp]); break; default : $text .= ""; $text .= $tp->toHTML($row[$disp]); } $text .= " ".ADMIN_EDIT_ICON." toJS(DOWLAN_33." [ID: ".$row['download_id']." ]")."') \"/>
"; // $text .= ""; } else { // 'No downloads yet' $text .= "
".DOWLAN_6."
"; } // Next-Previous. $downloads = $sql->db_Count("download"); if ($downloads > $amount && !$this->searchFields && !$this->advancedSearchFields) { $parms = "{$downloads},{$amount},{$from},".e_SELF."?".(e_QUERY ? "$action.$subAction.$id." : "main.{$sortorder}.{$sortdirection}.")."[FROM]"; $text .= "
".$this->batch_options(). $tp->parseTemplate("{NEXTPREV={$parms}}")."
"; } $text .= "
"; return $text; } */ // --------------------------------------------------------------------------- /* function batch_options() { $frm = new e_form(); $classes = get_userclass_list(); return $frm->batchoptions( array('delete_selected'=>LAN_DELETE), array( 'userclass' =>array('Assign userclass...',$classes), 'visibility'=>array('Assign Visibility..',$classes) ) ); } function _observe_processBatch() { list($type,$tmp,$uclass) = explode("_",$_POST['execute_batch']); $method = "batch_".$type; if ((method_exists($this,$method) || $type='visibility') && isset ($_POST['dl_selected'])) { if($type=='userclass' || $type=='visibility') { $mode = ($type=='userclass') ? 'download_class' : 'download_visible'; $this->batch_userclass($_POST['dl_selected'],$uclass,$mode); } else { $this->$method($_POST['dl_selected']); } } } function batch_userclass($download_ids,$uclass,$mode='download_class') { $emessage = &eMessage::getInstance(); if(e107::getDb() -> db_Update("download", $mode." ='{$uclass}' WHERE download_id IN (".implode(",",$download_ids).") ")) { $emessage->add("It Worked", E_MESSAGE_SUCCESS); } else { $emessage->add("It Failed", E_MESSAGE_ERROR); } }*/ // Given the string which is stored in the DB, turns it into an array of mirror entries // If $byID is true, the array index is the mirror ID. Otherwise its a simple array /* function makeMirrorArray($source, $byID = FALSE) { $ret = array(); if ($source) { $mirrorTArray = explode(chr(1), $source); $count = 0; foreach($mirrorTArray as $mirror) { if ($mirror) { list($mid, $murl, $mreq, $msize) = explode(",", $mirror); $ret[$byID ? $mid : $count] = array('id' => $mid, 'url' => $murl, 'requests' => $mreq, 'filesize' => $msize); $count++; } } } return $ret; } */ /* // Turn the array into a string which can be stored in the DB function compressMirrorArray($source) { if (!is_array($source) || !count($source)) return ''; $inter = array(); foreach ($source as $s) { $inter[] = $s['id'].','.$s['url'].','.$s['requests'].','.$s['filesize']; } return implode(chr(1),$inter); }*/ /* function create_download($subAction='', $id='') { global $download, $e107, $cal, $tp, $sql, $fl, $rs, $ns, $file_array, $image_array, $thumb_array; require_once(e_PLUGIN.'download/download_shortcodes.php'); require_once(e_HANDLER."form_handler.php"); if ($file_array = $fl->get_files(e_DOWNLOAD, "","standard",5)) { sort($file_array); } if ($public_array = $fl->get_files(e_UPLOAD)) { foreach($public_array as $key=>$val) { $file_array[] = str_replace(e_UPLOAD,"",$val); } } */ /* if ($sql->db_Select("rbinary")) //TODO Remove me. { while ($row = $sql->db_Fetch()) { extract($row); $file_array[] = "Binary ".$binary_id."/".$binary_name; } } */ /* if ($image_array = $fl->get_files(e_FILE.'downloadimages/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) { sort($image_array); } if ($thumb_array = $fl->get_files(e_FILE.'downloadthumbs/', '\.gif$|\.jpg$|\.png$|\.GIF$|\.JPG$|\.PNG$','standard',2)) { sort($thumb_array); } $frm = new e_form(); $mirrorArray = array(); $download_status[0] = DOWLAN_122; $download_status[1] = DOWLAN_123; $download_status[2] = DOWLAN_124; if (!$sql->db_Select("download_category")) { $ns->tablerender(ADLAN_24, "
".DOWLAN_5."
"); return; } $download_active = 1; if ($_GET['action'] == "edit" && !$_POST['submit']) { if ($sql->db_Select("download", "*", "download_id=".intval($_GET['id']))) { $row = $sql->db_Fetch(); extract($row); $mirrorArray = $this->makeMirrorArray($row['download_mirror']); } } if ($subAction == "dlm" && !$_POST['submit']) { require_once(e_PLUGIN.'download/download_shortcodes.php'); if ($sql->db_Select("upload", "*", "upload_id=".$id)) { $row = $sql->db_Fetch(); $download_category = $row['upload_category']; $download_name = $row['upload_name'].($row['upload_version'] ? " v" . $row['upload_version'] : ""); $download_url = $row['upload_file']; $download_author_email = $row['upload_email']; $download_author_website = $row['upload_website']; $download_description = $row['upload_description']; $download_image = $row['upload_ss']; $download_filesize = $row['upload_filesize']; $image_array[] = array("path" => "", "fname" => $row['upload_ss']); $download_author = substr($row['upload_poster'], (strpos($row['upload_poster'], ".")+1)); } } $text = "
".DOWLAN_13."
".DOWLAN_131."  
".DOWLAN_149."
".DOWLAN_66."
"; } else { $text .= DOWLAN_132."
"; $mirrorList = $sql -> db_getList(); // Get the list of possible mirrors $m_count = (count($mirrorArray) ? count($mirrorArray) : 1); // Count of mirrors actually in use (or count of 1 if none defined yet) for($count = 1; $count <= $m_count; $count++) { $opt = ($count==1) ? "id='mirror'" : ""; $text .="
"; if (DOWNLOAD_DEBUG) { if ($id) { $text .= '('.$mirrorArray[($count-1)]['requests'].')'; } else { $text .= ""; } } $text .= "
"; } $text .="
"; } // End of mirror-related stuff $download_author = $subAction != "edit" && $download_author == "" ? USERNAME : $download_author;//TODO what if editing an no author specified $download_author_email = $subAction != "edit" && $download_author_email == "" ? USEREMAIL : $download_author_email; $text .= "
".DOWLAN_128." "; // See if any mirrors to display if (!$sql -> db_Select("download_mirror")) { // No mirrors defined here $text .= DOWLAN_144."
".DOWLAN_155." ".DOWLAN_156."
".DOWLAN_157."
"; if ($subAction == "dlm") { $text .= " "; } //triggerHook $data = array('method'=>'form', 'table'=>'download', 'id'=>$id, 'plugin'=>'download', 'function'=>'create_download'); $hooks = $e107->e_event->triggerHook($data); $text .= "
".DOWLAN_11." "; $text .= $this->getCategorySelectList($download_category); $text .= "
".DOWLAN_12." toForm($download_name)."\" maxlength='200'/>
".DOWLAN_15."
".DOWLAN_16."
".DOWLAN_17."
".DOWLAN_18." "; $text .= $frm->bbarea('download_description',$download_description); $text .= "
Activation between // TODO
".DOWLAN_19." "; if ($subAction == "dlm" && $download_image) { $text .= " \n"; } $text .= "
".DOWLAN_20."
".LAN_DATESTAMP." "; if (!$download_datestamp){ $download_datestamp = time(); } $cal_options['showsTime'] = false; $cal_options['showOthers'] = false; $cal_options['weekNumbers'] = false; $cal_options['ifFormat'] = "%d/%m/%Y %H:%M:%S"; $cal_options['timeFormat'] = "24"; $cal_attrib['class'] = "tbox"; $cal_attrib['size'] = "22"; $cal_attrib['name'] = "download_datestamp"; $cal_attrib['value'] = date("d/m/Y H:i:s", $download_datestamp); $text .= $cal->make_input_field($cal_options, $cal_attrib); $update_checked = ($_POST['update_datestamp']) ? "checked='checked'" : ""; $text .= "   ".DOWLAN_148."
".DOWLAN_21."
".DOWLAN_102." "; if ($download_comment == "0") { $text .= LAN_YES.": ".LAN_NO.": "; } else { $text .= LAN_YES.": ".LAN_NO.": "; } $text .= "
".DOWLAN_145." ".r_userclass('download_visible', $download_visible, 'off', 'public, nobody, member, admin, classes, language')."
".DOWLAN_106." ".r_userclass('download_class', $download_class, 'off', 'public, nobody, member, admin, classes, language')."
".DOWLAN_153."
".DOWLAN_103."
"; if ($id && $subAction == "edit") { $text .= " "; } else { $text .= ""; } $text .= "
"; $ns->tablerender(ADLAN_24, $text); } */ // ----------------------------------------------------------------------------- /* function show_message($message) { global $ns; $ns->tablerender("", "
".$message."
"); } */ // ----------------------------------------------------------------------------- /* // Actually save a new or edited download to the DB function submit_download($subAction, $id) { global $e107, $tp, $sql, $DOWNLOADS_DIRECTORY, $e_event; $dlInfo = array(); $dlMirrors = array(); if ($subAction == 'edit') { if ($_POST['download_url_external'] == '') { $_POST['download_filesize_external'] = FALSE; } } if ($_POST['download_url_external'] && $_POST['download_url'] == '') { $dlInfo['download_url'] = $tp->toDB($_POST['download_url_external']); $filesize = intval($_POST['download_filesize_external']); } else { $dlInfo['download_url'] = $tp->toDB($_POST['download_url']); if ($_POST['download_filesize_external']) { $filesize = intval($_POST['download_filesize_external']); } else { if (strpos($DOWNLOADS_DIRECTORY, "/") === 0 || strpos($DOWNLOADS_DIRECTORY, ":") >= 1) { $filesize = filesize($DOWNLOADS_DIRECTORY.$dlInfo['download_url']); } else { $filesize = filesize(e_BASE.$DOWNLOADS_DIRECTORY.$dlInfo['download_url']); } } } if (!$filesize) { if ($sql->db_Select("upload", "upload_filesize", "upload_file='{$dlInfo['download_url']}'")) { $row = $sql->db_Fetch(); $filesize = $row['upload_filesize']; } } $dlInfo['download_filesize'] = $filesize; // ---- Move Images and Files ------------ if ($_POST['move_image']) { if ($_POST['download_thumb']) { $oldname = e_UPLOAD.$_POST['download_thumb']; $newname = e_FILE."downloadthumbs/".$_POST['download_thumb']; if (!$this -> move_file($oldname,$newname)) { return; } } if ($_POST['download_image']) { $oldname = e_UPLOAD.$_POST['download_image']; $newname = e_FILE."downloadimages/".$_POST['download_image']; if (!$this -> move_file($oldname,$newname)) { return; } } } if ($_POST['move_file'] && $_POST['download_url']) { $oldname = e_UPLOAD.$_POST['download_url']; $newname = $_POST['move_file'].$_POST['download_url']; if (!$this -> move_file($oldname,$newname)) { return; } $dlInfo['download_url'] = str_replace(e_DOWNLOAD,"",$newname); } // ------------------------------------------ $dlInfo['download_description'] = $tp->toDB($_POST['download_description']); $dlInfo['download_name'] = $tp->toDB($_POST['download_name']); $dlInfo['download_author'] = $tp->toDB($_POST['download_author']); $dlInfo['download_author_email'] = $tp->toDB($_POST['download_author_email']); $dlInfo['download_author_website'] = $tp->toDB($_POST['download_author_website']); $dlInfo['download_category'] = intval($_POST['download_category']); $dlInfo['download_active'] = intval($_POST['download_active']); $dlInfo['download_thumb'] = $tp->toDB($_POST['download_thumb']); $dlInfo['download_image'] = $tp->toDB($_POST['download_image']); $dlInfo['download_comment'] = $tp->toDB($_POST['download_comment']); $dlInfo['download_class'] = intval($_POST['download_class']); $dlInfo['download_visible'] =intval($_POST['download_visible']); if (preg_match("#(.*?)/(.*?)/(.*?) (.*?):(.*?):(.*?)$#", $_POST['download_datestamp'], $matches)) { $dlInfo['download_datestamp'] = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]); } else { $dlInfo['download_datestamp'] = time(); } if ($_POST['update_datestamp']) { $dlInfo['download_datestamp'] = time(); } $mirrorStr = ""; $mirrorFlag = FALSE; // See if any mirrors defined // Need to check all the possible mirror names - might have deleted the first one if we're in edit mode foreach ($_POST['download_mirror_name'] as $mn) { if ($mn) { $mirrorFlag = TRUE; break; } } if ($mirrorFlag) { $mirrors = count($_POST['download_mirror_name']); $mirrorArray = array(); $newMirrorArray = array(); if ($id && $sql->db_Select('download','download_mirror', 'download_id = '.$id)) // Get existing download stats { if ($row = $sql->db_Fetch()) { $mirrorArray = $this->makeMirrorArray($row['download_mirror'], TRUE); } } for($a=0; $a<$mirrors; $a++) { $mid = trim($_POST['download_mirror_name'][$a]); $murl = trim($_POST['download_mirror'][$a]); $msize = trim($_POST['download_mirror_size'][$a]); if ($mid && $murl) { $newMirrorArray[$mid] = array('id' => $mid, 'url' => $murl, 'requests' => 0, 'filesize' => $msize); if (DOWNLOAD_DEBUG && !$id) { $newMirrorArray[$mid]['requests'] = intval($_POST['download_mirror_requests'][$a]); } } } // Now copy across any existing usage figures foreach ($newMirrorArray as $k => $m) { if (isset($mirrorArray[$k])) { $newMirrorArray[$k]['requests'] = $mirrorArray[$k]['requests']; } } $mirrorStr = $this->compressMirrorArray($newMirrorArray); } $dlMirrors['download_mirror']=$mirrorStr; $dlMirrors['download_mirror_type']=intval($_POST['download_mirror_type']); if ($id) { // Its an edit // Process triggers before calling admin_update so trigger messages can be shown $data = array('method'=>'update', 'table'=>'download', 'id'=>$id, 'plugin'=>'download', 'function'=>'update_download'); $hooks = $e107->e_event->triggerHook($data); require_once(e_HANDLER."message_handler.php"); $emessage = &eMessage::getInstance(); $emessage->add($hooks, E_MESSAGE_SUCCESS); admin_update($sql->db_UpdateArray('download',array_merge($dlInfo,$dlMirrors),'WHERE download_id='.intval($id)), 'update', DOWLAN_2." (".$_POST['download_name'].")"); $dlInfo['download_id'] = $id; $this->downloadLog('DOWNL_06',$dlInfo,$dlMirrors); $dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings unset($dlInfo['download_class']); // Also replicating 0.7 $e_event->trigger('dlupdate', $dlInfo); } else { if ($download_id = $sql->db_Insert('download',array_merge($dlInfo,$dlMirrors))) { // Process triggers before calling admin_update so trigger messages can be shown $data = array('method'=>'create', 'table'=>'download', 'id'=>$download_id, 'plugin'=>'download', 'function'=>'create_download'); $hooks = $e107->e_event->triggerHook($data); require_once(e_HANDLER."message_handler.php"); $emessage = &eMessage::getInstance(); $emessage->add($hooks, E_MESSAGE_SUCCESS); admin_update($download_id, 'insert', DOWLAN_1." (".$_POST['download_name'].")"); $dlInfo['download_id'] = $download_id; $this->downloadLog('DOWNL_05',$dlInfo,$dlMirrors); $dlInfo['download_datestamp'] = $time; // This is what 0.7 did, regardless of settings unset($dlInfo['download_class']); // Also replicating 0.7 $e_event->trigger("dlpost", $dlInfo); if ($_POST['remove_upload']) { $sql->db_Update("upload", "upload_active='1' WHERE upload_id='".$_POST['remove_id']."'"); $mes = "
".$_POST['download_name']." ".DOWLAN_104; $mes .= "

".DOWLAN_105.""; $this->show_message($mes); } } } } */ /* function downloadLog($aText, &$dlInfo, &$mirrorInfo=NULL) { global $admin_log; $logString = DOWLAN_9; foreach ($dlInfo as $k => $v) { $logString .= '[!br!]'.$k.'=>'.$v; } if ($mirrorInfo != NULL) { foreach ($mirrorInfo as $k => $v) { $logString .= '[!br!]'.$k.'=>'.$v; } } $admin_log->log_event($aText,$logString,E_LOG_INFORMATIVE,''); } */ // ----------------------------------------------------------------------------- /* function show_categories($subAction, $id) { global $download, $sql, $sql2, $rs, $ns, $tp; require_once(e_HANDLER."form_handler.php"); $frm = new e_form(); $text = $rs->form_open("post", e_SELF."?".e_QUERY, "myform"); $text .= "
"; $qry = " SELECT dc.*, COUNT(d.download_id) AS filecount FROM #download_category AS dc LEFT JOIN #download AS d ON d.download_category = dc.download_category_id GROUP BY dc.download_category_id ORDER BY dc.download_category_order "; if ($sql->db_Select_gen($qry)) { $categories = $sql->db_getList(); foreach($categories as $cat) { $cat_array[$cat['download_category_parent']][] = $cat; } $text .= " "; //Start displaying parent categories foreach($cat_array[0] as $parent) { if (strstr($parent['download_category_icon'], chr(1))) { list($parent['download_category_icon'], $parent['download_category_icon_empty']) = explode(chr(1), $parent['download_category_icon']); } $text .= " "; //Show sub categories if (is_array($cat_array[$parent['download_category_id']])) { foreach($cat_array[$parent['download_category_id']] as $subcat) { if (strstr($subcat['download_category_icon'], chr(1))) { list($subcat['download_category_icon'], $subcat['download_category_icon_empty']) = explode(chr(1), $subcat['download_category_icon']); } $text .= " "; //Show sub-sub categories if (is_array($cat_array[$subcat['download_category_id']])) { foreach($cat_array[$subcat['download_category_id']] as $subsubcat) { if (strstr($subsubcat['download_category_icon'], chr(1))) { list($subsubcat['download_category_icon'], $subsubcat['download_category_icon_empty']) = explode(chr(1), $subsubcat['download_category_icon']); } $text .= ""; } } } } } $text .= "
".DOWLAN_11." ".DOWLAN_52." ".LAN_ORDER." ".LAN_OPTIONS."
".($parent['download_category_icon'] ? "" : " ")." "; $text .= $tp->toHTML($parent['download_category_name']); $text .= "
"; $text .= $tp->toHTML($parent['download_category_description']); $text .= "
".ADMIN_EDIT_ICON." "; if (!is_array($cat_array[$parent['download_category_id']])) { $text .= "toJS(DOWLAN_34." [ID: {$parent['download_category_id']} ]")."') \"/>"; } $text .= "
".($subcat['download_category_icon'] ? "" : " ")." "; $text .= $tp->toHTML($subcat['download_category_name']); $text .= "
"; $text .= $tp->toHTML($subcat['download_category_description']); $text .= "
{$subcat['filecount']} ".ADMIN_EDIT_ICON.""; if (!is_array($cat_array[$subcat['download_category_id']]) && !$subcat['filecount']) { $text .= "toJS(DOWLAN_34." [ID: {$subcat['download_category_id']} ]")."') \"/>"; } $text .= "
".($subsubcat['download_category_icon'] ? "" : " ")."     "; $text .= $tp->toHTML($subsubcat['download_category_name']); $text .= "
    "; $text .= $tp->toHTML($subsubcat['download_category_description']); $text .= "
{$subsubcat['filecount']} ".ADMIN_EDIT_ICON." "; if (!$subsubcat['filecount']) { $text .= "toJS(DOWLAN_34." [ID: {$subsubcat['download_category_id']} ]")."') \"/>"; } $text .= "
"; $text .= "
"; } else { $text .= "
".DOWLAN_38."
"; } $text .= ""; $ns->tablerender(DOWLAN_37, $text); unset($download_category_id, $download_category_name, $download_category_description, $download_category_parent, $download_category_icon, $download_category_class); $handle = opendir(e_IMAGE."icons"); while ($file = readdir($handle)) { if ($file != "." && $file != ".." && $file != "/" && $file != "CVS") { $iconlist[] = $file; } } closedir($handle); if ($subAction == "edit" && !$_POST['add_category']) { if ($sql->db_Select("download_category", "*", "download_category_id=$id")) { $row = $sql->db_Fetch(); extract($row); $main_category_parent = $download_category_parent; if (strstr($download_category_icon, chr(1))) { list($download_category_icon, $download_category_icon_empty) = explode(chr(1), $download_category_icon); } else { $download_category_icon_empty = ""; } } } $frm_action = (isset($_POST['add_category'])) ? e_SELF."?cat" : e_SELF."?".e_QUERY; $text = "
".DOWLAN_37.": ". $this->getCategorySelectList($main_category_parent, false, false, DOWLAN_40)."
".DOWLAN_12.":
".DOWLAN_18.": ".$frm->bbarea('download_category_description',$download_category_description)."
".DOWLAN_41.": ".$frm->iconpicker('download_category_icon', $download_category_icon, DOWLAN_42) ."
".DOWLAN_147.": ".$frm->iconpicker('download_category_icon_empty', $download_category_icon_empty, DOWLAN_42) ."
".DOWLAN_43.":
(".DOWLAN_44.")
".r_userclass("download_category_class", $download_category_class, 'off', 'public, nobody, member, admin, classes, language')."
"; if ($id && $subAction == "edit" && !isset($_POST['add_category'])) { $text .= " "; } else { $text .= ""; } $text .= "
"; $ns->tablerender(DOWLAN_39, $text); } */ /* function show_download_options() { global $pref, $ns; require_once(e_HANDLER."form_handler.php"); $frm = new e_form(true); //enable inner tabindex counter $agree_flag = $pref['agree_flag']; $agree_text = $pref['agree_text']; $c = $pref['download_php'] ? " checked = 'checked' " : ""; $sacc = (varset($pref['download_incinfo'],0) == '1') ? " checked = 'checked' " : ""; $order_options = array( "download_id" => "Id No.", "download_datestamp" => LAN_DATE, "download_requested" => ADLAN_24, "download_name" => DOWLAN_59, "download_author" => DOWLAN_15 ); $sort_options = array( "ASC" => DOWLAN_62, "DESC" => DOWLAN_63 ); $text = "
\n
".LAN_DL_USE_PHP." " .$frm->checkbox('download_php', '1', $pref['download_php']) .$frm->label(LAN_DL_USE_PHP_INFO, 'download_php', '1') ."
".LAN_DL_SUBSUB_CAT." " .$frm->checkbox('download_subsub', '1', $pref['download_subsub']) .$frm->label(LAN_DL_SUBSUB_CAT_INFO, 'download_subsub', '1') ."
".LAN_DL_SUBSUB_COUNT." " .$frm->checkbox('download_incinfo', '1', $pref['download_incinfo']) .$frm->label(LAN_DL_SUBSUB_COUNT_INFO, 'download_incinfo', '1') ."
".DOWLAN_55." ".$frm->text('download_view', $pref['download_view'], '4', array('size'=>'4'))."
".DOWLAN_56." ".$frm->select('download_order', $order_options, $pref['download_order'])."
".LAN_ORDER." ".$frm->select('download_sort', $sort_options, $pref['download_sort'])."
".DOWLAN_160."
".DOWLAN_164."
".DOWLAN_151." ". r_userclass("download_reportbroken", $pref['download_reportbroken'])."
".DOWLAN_150." ". ($pref['download_email'] ? "" : "")."
".DOWLAN_100." ". ($agree_flag ? "" : "")."
".DOWLAN_101." ".$frm->bbarea('agree_text',$agree_text)."
".DOWLAN_146." ".$frm->bbarea('download_denied',$pref['download_denied'])."
".DOWLAN_XXX." //TODO
"; $ns->tablerender(LAN_DL_OPTIONS, $text); } * */ /* function show_upload_list() { global $ns, $sql, $gen, $e107, $tp; $frm = new e_form(true); //enable inner tabindex counter $imgd = e_BASE.$IMAGES_DIRECTORY; $columnInfo = array( "checkboxes" => array("title" => "", "forced"=> TRUE, "width" => "3%", "thclass" => "center first", "toggle" => "dl_selected"), "upload_id" => array("title"=>DOWLAN_67, "type"=>"", "width"=>"auto", "thclass"=>"", "forced"=>true), "upload_date" => array("title"=>DOWLAN_78, "type"=>"", "width"=>"auto", "thclass"=>""), "upload_uploader" => array("title"=>DOWLAN_79, "type"=>"", "width"=>"auto", "thclass"=>""), "upload_name" => array("title"=>DOWLAN_12, "type"=>"", "width"=>"auto", "thclass"=>""), "upload_file_name" => array("title"=>DOWLAN_59, "type"=>"", "width"=>"auto", "thclass"=>""), "upload_size" => array("title"=>DOWLAN_66, "type"=>"", "width"=>"auto", "thclass"=>"right"), "options" => array("title"=>LAN_OPTIONS,"width"=>"15%", "thclass"=>"center last", "forced"=>true) ); //TODO $filterColumns = ($user_pref['admin_download_disp'] ? $user_pref['admin_download_disp'] : array("download_name","download_class")); $filterColumns = array("upload_id","upload_date","upload_uploader","upload_name","upload_file_name","upload_size"); $text = "
" .$frm->colGroup($columnInfo,$filterColumns) .$frm->thead($columnInfo,$filterColumns,"main.[FIELD].[ASC].[FROM]")." "; } else { $activeUploads = $sql -> db_getList(); $text .= DOWLAN_80." ".($active_uploads == 1 ? DOWLAN_81 : DOWLAN_82)." ".$active_uploads." ".($active_uploads == 1 ? DOWLAN_83 : DOWLAN_84); $text .= ""; foreach($activeUploads as $row) { $post_author_id = substr($row['upload_poster'], 0, strpos($row['upload_poster'], ".")); $post_author_name = substr($row['upload_poster'], (strpos($row['upload_poster'], ".")+1)); $poster = (!$post_author_id ? "".$post_author_name."" : "".$post_author_name.""); $upload_datestamp = $gen->convert_date($row['upload_datestamp'], "short"); $text .= " "; } } $text .= "
"; if (!$active_uploads = $sql->db_Select("upload", "*", "upload_active=0 ORDER BY upload_id ASC")) { $text .= DOWLAN_19.".
".$frm->checkbox("dl_selected[".$row["upload_id"]."]", $row['upload_id'])." ".$row['upload_id']." ".$upload_datestamp." ".$poster." ".$row['upload_name']." ".$row['upload_file']." ".$e107->parseMemorySize($row['upload_filesize'])."
".DOWLAN_91." ".DOWLAN_162." toJS(" [ ".$row['upload_name']." ] ".DOWLAN_33)."') \"/>
"; $ns->tablerender(DOWLAN_22, $text); } function show_upload_filetypes() { global $ns; //TODO is there an e107:: copy of this if (!is_object($e_userclass)) { $e_userclass = new user_class; } if(!getperms("0")) exit; //TODO still needed? $definition_source = DOWLAN_71; $source_file = ''; $edit_upload_list = varset($_POST['upload_do_edit'], false); if (isset($_POST['generate_filetypes_xml'])) { // Write back edited data to filetypes_.xml $file_text = "\n"; foreach ($_POST['file_class_select'] as $k => $c) { if (!isset($_POST['file_line_delete_'.$c]) && varsettrue($_POST['file_type_list'][$k])) { $file_text .= " \n"; } } $file_text .= ""; if ((($handle = fopen(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES,'wt')) == FALSE) || (fwrite($handle,$file_text) == FALSE) || (fclose($handle) == FALSE)) { $text = DOWLAN_88.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES; } else { $text = DOWLAN_86.e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES.'
'.DOWLAN_87.e_ADMIN.e_READ_FILETYPES.'
'; } $ns->tablerender(DOWLAN_49, $text); } $current_perms = array(); if (($edit_upload_list && is_readable(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES)) || (!$edit_upload_list && is_readable(e_ADMIN.e_READ_FILETYPES))) { require_once(e_HANDLER.'xml_class.php'); $xml = new xmlClass; $xml->setOptArrayTags('class'); $source_file = $edit_upload_list ? e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES : e_ADMIN.e_READ_FILETYPES; $temp_vars = $xml->loadXMLfile($source_file, true, false); if ($temp_vars === FALSE) { echo "Error parsing XML file!"; } else { foreach ($temp_vars['class'] as $v1) { $v = $v1['@attributes']; $current_perms[$v['name']] = array('type' => $v['type'],'maxupload' => $v['maxupload']); } } } elseif (is_readable(e_ADMIN.'filetypes.php')) { $source_file = 'filetypes.php'; $current_perms[e_UC_MEMBER] = array('type' => implode(',',array_keys(get_allowed_filetypes('filetypes.php', ''))),'maxupload' => '2M'); if (is_readable(e_ADMIN.'admin_filetypes.php')) { $current_perms[e_UC_ADMIN] = array('type' => implode(',',array_keys(get_allowed_filetypes('admin_filetypes.php', ''))),'maxupload' => '2M'); $source_file .= ' + admin_filetypes.php'; } } else { // Set a default $current_perms[e_UC_MEMBER] = array('type' => 'zip,tar,gz,jpg,png','maxupload' => '2M'); } $frm = new e_form(true); //enable inner tabindex counter $columnInfo = array( "ftypes_userclass" => array("title"=>DOWLAN_73, "type"=>"", "width"=>"auto", "thclass"=>"", "forced"=>true), "ftypes_extension" => array("title"=>DOWLAN_74, "type"=>"", "width"=>"auto", "thclass"=>""), "ftypes_max_size" => array("title"=>DOWLAN_75, "type"=>"", "width"=>"auto", "thclass"=>""), "ftypes_confirm_del" => array("title"=>DOWLAN_76, "type"=>"", "width"=>"auto", "thclass"=>"last"), ); $filterColumns = array("ftypes_userclass", "ftypes_extension", "ftypes_max_size", "ftypes_confirm_del"); $text = "

". str_replace(array('--SOURCE--', '--DEST--'),array(e_UPLOAD_TEMP_DIR.e_SAVE_FILETYPES,e_ADMIN.e_READ_FILETYPES),DOWLAN_85) ."

". DOWLAN_72.$source_file."

" .$frm->colGroup($columnInfo) .$frm->thead($columnInfo,$filterColumns)." "; foreach ($current_perms as $uclass => $uinfo) { $text .= " "; } // Now put up a box to add a new setting $text .= "
".DOWLAN_90."
"; $ns->tablerender(DOWLAN_23, $text); } function show_upload_options() { global $pref, $ns; require_once(e_HANDLER."form_handler.php"); $frm = new e_form(true); //enable inner tabindex counter $text = "
".DOWLAN_26." " .$frm->radio_switch('upload_enabled', $pref['upload_enabled']) ."
" .$frm->label(DOWLAN_51, 'upload_enabled', '1') ."
" ."
".DOWLAN_35." " .$frm->text('upload_maxfilesize', $pref['upload_maxfilesize'], '4', array('size'=>'10')) ."
" .$frm->label(str_replace(array("%1", "%2"), array(ini_get('upload_max_filesize'), ini_get('post_max_size')), DOWLAN_58), 'upload_maxfilesize', '1') ."
" ."
".DOWLAN_61." " .r_userclass("upload_class", $pref['upload_class']) ."
" .$frm->label(DOWLAN_60, 'upload_class', '1') ."
" ."
"; $ns->tablerender(LAN_DL_OPTIONS, $text); }*/ /* function create_category($subAction, $id) { global $sql, $tp, $admin_log; $download_category_name = $tp->toDB($_POST['download_category_name']); $download_category_description = $tp->toDB($_POST['download_category_description']); $download_category_icon = $tp->toDB($_POST['download_category_icon']); $download_category_class = $tp->toDB($_POST['download_category_class']); $download_categoory_parent = intval($_POST['download_category_parent']); if (isset($_POST['download_category_icon_empty']) && $_POST['download_category_icon_empty'] != "") { $download_category_icon .= trim(chr(1).$tp->toDB($_POST['download_category_icon_empty'])); } if ($id) { admin_update($sql->db_Update("download_category", "download_category_name='{$download_category_name}', download_category_description='{$download_category_description}', download_category_icon ='{$download_category_icon}', download_category_parent= '{$download_categoory_parent}', download_category_class='{$download_category_class}' WHERE download_category_id='{$id}'"), 'update', DOWLAN_48); $admin_log->log_event('DOWNL_03',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); } else { admin_update($sql->db_Insert("download_category", "0, '{$download_category_name}', '{$download_category_description}', '{$download_category_icon}', '{$download_categoory_parent}', '{$download_category_class}', 0 "), 'insert', DOWLAN_47); $admin_log->log_event('DOWNL_02',$download_category_name.'[!br!]'.$download_category_description,E_LOG_INFORMATIVE,''); } if ($subAction == "sn") { $sql->db_Delete("tmp", "tmp_time='{$id}' "); } } */ /* function show_existing_mirrors() { global $sql, $ns, $tp, $subAction, $id, $delete, $del_id, $admin_log; require_once(e_HANDLER."form_handler.php"); $frm = new e_form(); if ($delete == "mirror") { admin_update($sql -> db_Delete("download_mirror", "mirror_id=".$del_id), delete, DOWLAN_135); $admin_log->log_event('DOWNL_14','ID: '.$del_id,E_LOG_INFORMATIVE,''); } if (!$sql -> db_Select("download_mirror")) { $text = "
".DOWLAN_144."
"; // No mirrors defined yet } else { $text = "
"; $mirrorList = $sql -> db_getList(); foreach($mirrorList as $mirror) { extract($mirror); $text .= " "; } $text .= "
ID ".DOWLAN_12." ".DOWLAN_136." ".LAN_OPTIONS."
$mirror_id ".$tp -> toHTML($mirror_name)." ".($mirror_image ? "" : DOWLAN_28)." ".ADMIN_EDIT_ICON."
"; } $ns -> tablerender(DOWLAN_138, $text); require_once(e_HANDLER."file_class.php"); $fl = new e_file; $imagelist = $fl->get_files(e_FILE.'downloadimages/'); if ($subAction == "edit" && !defined("SUBMITTED")) { $sql -> db_Select("download_mirror", "*", "mirror_id='".intval($id)."' "); $mirror = $sql -> db_Fetch(); extract($mirror); $edit = TRUE; } else { unset($mirror_name, $mirror_url, $mirror_image, $mirror_location, $mirror_description); $edit = FALSE; } $text = "
\n
".DOWLAN_12."
".DOWLAN_139."
".DOWLAN_136."
".DOWLAN_141."
".DOWLAN_18." "; $text .= $frm->bbarea('mirror_description',$mirror_description); $text .= "
".($edit ? "" : "")."
"; $caption = ($edit ? DOWLAN_142 : DOWLAN_143); $ns -> tablerender($caption, $text); } function submit_mirror() { global $tp, $sql, $admin_log; define("SUBMITTED", TRUE); if (isset($_POST['mirror_name']) && isset($_POST['mirror_url'])) { $name = $tp -> toDB($_POST['mirror_name']); $url = $tp -> toDB($_POST['mirror_url']); $location = $tp -> toDB($_POST['mirror_location']); $description = $tp -> toDB($_POST['mirror_description']); $logString = $name.'[!br!]'.$url.'[!br!]'.$location.'[!br!]'.$description; if (isset($_POST['id'])) { admin_update($sql -> db_Update("download_mirror", "mirror_name='{$name}', mirror_url='{$url}', mirror_image='".$tp->toDB($_POST['mirror_image'])."', mirror_location='{$location}', mirror_description='{$description}' WHERE mirror_id=".intval($_POST['id'])), 'update', DOWLAN_133); $admin_log->log_event('DOWNL_13','ID: '.intval($_POST['id']).'[!br!]'.$logString,E_LOG_INFORMATIVE,''); } else { admin_update($sql -> db_Insert("download_mirror", "0, '{$name}', '{$url}', '".$tp->toDB($_POST['mirror_image'])."', '{$location}', '{$description}', 0"), 'insert', DOWLAN_134); $admin_log->log_event('DOWNL_12',$logString,E_LOG_INFORMATIVE,''); } } }*/ // --------------------------------------------------------------------------- /* function move_file($oldname,$newname) { global $ns; if (file_exists($newname)) { return TRUE; } if (!file_exists($oldname) || is_dir($oldname)) { $ns -> tablerender(LAN_ERROR,DOWLAN_68 . " : ".$oldname); return FALSE; } $directory = dirname($newname); if (is_writable($directory)) { if (!rename($oldname,$newname)) { $ns -> tablerender(LAN_ERROR,DOWLAN_152." ".$oldname ." -> ".$newname); return FALSE; } else { return TRUE; } } else { $ns -> tablerender(LAN_ERROR,$directory ." ".LAN_NOTWRITABLE); return FALSE; } } */ /* /** * * @private */ /* function _getConditionList($name, $value) { $text .= " "; return $text; }*/ /** * * @private */ /* function _getStatusList($name, $value) { $download_status[99]= ' '; $download_status[0] = DOWLAN_122; $download_status[1] = DOWLAN_123; $download_status[2] = DOWLAN_124; $text = ""; foreach($download_status as $key=>$val){ $sel = ($value == $key && $value != null) ? " selected='selected'" : ""; $text .= "\n"; } return $text; } */ function observer() { //Required on create & savepreset action triggers // if(isset($_POST['news_userclass']) && is_array($_POST['news_userclass'])) // { // $_POST['news_class'] = implode(",", $_POST['news_userclass']); // unset($_POST['news_userclass']); // } // // if(isset($_POST['delete']) && is_array($_POST['delete'])) // { // $this->_observe_delete(); // } // elseif(isset($_POST['submit_news'])) // { // $this->_observe_submit_item($this->getSubAction(), $this->getId()); // } // elseif(isset($_POST['create_category'])) // { // $this->_observe_create_category(); // } // elseif(isset($_POST['update_category'])) // { // $this->_observe_update_category(); // } // elseif(isset($_POST['save_prefs'])) // { // $this->_observe_save_prefs(); // } // elseif(isset($_POST['submitupload'])) // { // $this->_observe_upload(); // } // elseif(isset($_POST['news_comments_recalc'])) // { // $this->_observe_newsCommentsRecalc(); // } if(isset($_POST['etrigger_ecolumns'])) { // $this->_observe_saveColumns(); } } /* function _observe_saveColumns() { global $user_pref,$admin_log; $user_pref['admin_download_disp'] = $_POST['e-columns']; save_prefs('user'); } */ } ?>