function create_download() { $action = $this->action; $subAction = $this->subAction; $id = $this->id; $sql = e107::getDb(); $tp = e107::getParser(); $fl = e107::getFile(); $mes = e107::getMessage(); // print_a($this); global $e107, $cal, $rs, $ns, $file_array, $image_array, $thumb_array; require_once e_PLUGIN . 'download/download_shortcodes.php'; require_once e_PLUGIN . 'download/handlers/download_class.php'; require_once e_HANDLER . "form_handler.php"; $download = new download(); 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->select("rbinary")) //TODO Remove me. { while ($row = $sql->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->select("download_category")) { //$ns->tablerender(ADLAN_24, "<div style='text-align:center'>".DOWLAN_5."</div>"); $mes->addInfo(DOWLAN_5); return; } $download_active = 1; if ($_GET['action'] == "edit" && !$_POST['submit']) { if ($sql->select("download", "*", "download_id=" . intval($_GET['id']))) { $row = $sql->fetch(); extract($row); $mirrorArray = $this->makeMirrorArray($row['download_mirror']); } } if ($subAction == "dlm" && !$_POST['submit']) { require_once e_PLUGIN . 'download/download_shortcodes.php'; if ($sql->select("upload", "*", "upload_id=" . $id)) { $row = $sql->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 = "\n\t \n\t <ul class='nav nav-tabs'>\n\t <li class='active'><a data-toggle='tab' href='#download-create'>" . DOWLAN_175 . "</a></li>\n\t <li><a data-toggle='tab' href='#download-edit-external'>" . DOWLAN_176 . "</a></li>\n\t <li><a data-toggle='tab' href='#download-edit-mirror'>" . DOWLAN_128 . "</a></li>\n\t </ul>\n\t <form method='post' action='" . e_SELF . "?" . e_QUERY . "' id='myform'>\n\t <div class='tab-content'>\n\t <div class='tab-pane active' id='download-create'>\n\t \n\t \n\t <table class='table adminform' style='margin:0'>\n\t <tr>\n\t <td>" . DOWLAN_13 . "</td>\n\t <td style='width:80%'>\n\t <div>" . DOWLAN_131 . " "; // $text .= "<select name='download_url' class='tbox'> // <option value=''> </option>\n"; $counter = 0; while (isset($file_array[$counter])) { $fpath = str_replace(e_DOWNLOAD, "", $file_array[$counter]['path']) . $file_array[$counter]['fname']; $selected = ''; if (stristr($fpath, $download_url) !== FALSE) { $selected = " selected='selected'"; $found = 1; } // $text .= "<option value='".$fpath."' $selected>".$fpath."</option>\n"; $counter++; } if (preg_match("/http:|https:|ftp:/", $download_url)) { $download_url_external = $download_url; $download_url = ''; } $etext = " - (" . DOWLAN_68 . ")"; if (file_exists(e_UPLOAD . $download_url)) { $etext = ""; } if (!$found && $download_url) { // $text .= "<option value='".$download_url."' selected='selected'>".$download_url.$etext."</option>\n"; } // $text .= " </select>"; $text .= e107::getForm()->filepicker("download_url", $download_url, DOWLAN_131, "media=download_file&title=Choose a file"); $text .= "\n\t </div>\n\t </td>\n\t </tr>\n\t </table>\n\t </div>\n\t <div class='tab-pane' id='download-edit-external'>\n\t <table class='table adminform' style='margin:0'>\n\t <tr>\n\t <td>" . DOWLAN_149 . "</td>\n\t <td style='width:80%;'>\n\t <input class='tbox input-xxlarge' type='text' name='download_url_external' size='90' value='{$download_url_external}' maxlength='255'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td>" . DOWLAN_66 . "</td>\n\t <td>\n\t <input class='tbox' type='text' name='download_filesize_external' size='8' value='{$download_filesize}' maxlength='10'/>\n\t \t <select class='tbox' name='download_filesize_unit'>\n\t\t\t\t\t\t <option value='B'{$b_sel}>" . CORE_LAN_B . "</option>\n\t\t\t\t\t\t <option value='KB'{$kb_sel}>" . CORE_LAN_KB . "</option>\n\t\t\t\t\t\t <option value='MB'>" . CORE_LAN_MB . "</option>\n\t\t\t\t\t\t <option value='GB'>" . CORE_LAN_GB . "</option>\n\t\t\t\t\t\t <option value='TB'>" . CORE_LAN_TB . "</option>\n\t\t\t\t\t\t\t </select>\n\t </td>\n\t </tr>\n\t </table>\n\t </div>\n\t <div class='tab-pane' id='download-edit-mirror'>\n\t <table class='table adminlist'>\n\t <tr>\n\t <td style='width:20%'><span title='" . DOWLAN_129 . "' style='cursor:help'>" . DOWLAN_128 . "</span></td>\n\t <td style='width:80%'>"; // See if any mirrors to display if (!$sql->select("download_mirror")) { // No mirrors defined here $text .= DOWLAN_144 . "</td></tr>"; } else { $text .= DOWLAN_132 . "<div id='mirrorsection'>"; $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 .= "\n\t <div {$opt}>\n\t <select name='download_mirror_name[]' class='tbox'>\n\t <option value=''> </option>"; foreach ($mirrorList as $mirror) { extract($mirror); $text .= "<option value='{$mirror_id}'" . ($mirror_id == $mirrorArray[$count - 1]['id'] ? " selected='selected'" : "") . ">{$mirror_name}</option>\n"; } $text .= "</select>\n\t <input class='tbox' type='text' name='download_mirror[]' style='width: 60%;' value=\"" . $mirrorArray[$count - 1]['url'] . "\" maxlength='200'/>\n\t <input class='tbox' type='text' name='download_mirror_size[]' style='width: 15%;' value=\"" . $mirrorArray[$count - 1]['filesize'] . "\" maxlength='10'/>"; if (DOWNLOAD_DEBUG) { if ($id) { $text .= '(' . $mirrorArray[$count - 1]['requests'] . ')'; } else { $text .= "<input class='tbox' type='text' name='download_mirror_requests[]' style='width: 10%;' value=\"" . $mirrorArray[$count - 1]['requests'] . "\" maxlength='10'/>"; } } $text .= " </div>"; } $text .= " </div>\n\t <input class='btn btn-default button' type='button' name='addoption' value='" . DOWLAN_130 . "' onclick=\"duplicateHTML('mirror','mirrorsection')\"/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%' ><span style='cursor:help' title='" . DOWLAN_154 . "'>" . DOWLAN_155 . "</span></td>\n\t <td style='width:80%'>\n\t <input type='radio' name='download_mirror_type' value='1'" . ($download_mirror_type ? " checked='checked'" : "") . "/> " . DOWLAN_156 . "<br/>\n\t <input type='radio' name='download_mirror_type' value='0'" . (!$download_mirror_type ? " checked='checked'" : "") . "/> " . DOWLAN_157 . "\n\t </td>\n\t </tr>"; } // 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 .= "\n\t </table>\n\t </div>\n\t </div>\n\t <fieldset id='download-edit-therest'>\n\t <table class='table adminform' >\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_11 . "</td>\n\t <td style='width:80%'>"; $text .= $download->getCategorySelectList($download_category); // $text .= download::getCategorySelectList($download_category); $text .= " </td>\n\t </tr>\n\t <tr>\n\t <td >" . DOWLAN_12 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox input-xxlarge' type='text' name='download_name' size='60' value=\"" . $tp->toForm($download_name) . "\" maxlength='200'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_15 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author' size='60' value='{$download_author}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_16 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author_email' size='60' value='{$download_author_email}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_17 . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox' type='text' name='download_author_website' size='60' value='{$download_author_website}' maxlength='100'/>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_18 . "</td>\n\t <td style='width:80%'>\n\t "; $text .= $frm->bbarea('download_description', $download_description); $text .= " </td>\n\t </tr>\n\t \n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_19 . "</td>\n\t <td style='width:80%'>"; /* $text = "<select name='download_image' class='tbox'> <option value=''> </option>"; foreach($image_array as $img) { $fpath = str_replace(e_FILE."downloadimages/","",$img['path'].$img['fname']); $sel = ($download_image == $fpath) ? " selected='selected'" : ""; $text .= "<option value='".$fpath."' $sel>".$fpath."</option>\n"; } $text .= " </select>"; */ $text .= $frm->imagepicker('download_image', $download_image, '', 'download_image'); if ($subAction == "dlm" && $download_image) { $text .= "\n\t <input type='hidden' name='move_image' value='1'/>\n"; } $text .= " </td>\n\t </tr>"; if (is_dir(e_FILE . "downloadthumbs")) { $text .= "\n\t <tr>\n\t\t\t <td style='width:20%'>" . DOWLAN_20 . "</td>\n\t\t\t <td style='width:80%'>"; /* $text .= " <select name='download_thumb' class='tbox'> <option value=''> </option>"; foreach($thumb_array as $thm){ $tpath = str_replace(e_FILE."downloadthumbs/","",$thm['path'].$thm['fname']); $sel = ($download_thumb == $tpath) ? " selected='selected'" : ""; $text .= "<option value='".$tpath."' $sel>".$tpath."</option>\n"; } $text .= " </select>"; */ $text .= $frm->imagepicker('download_thumb', $download_thumb, '', 'download_thumb'); $text .= "\n\t\t\t </td>\n\t\t\t </tr>"; } $text .= "\n\t <tr>\n\t <td style='width:20%'>" . LAN_DATESTAMP . "</td>\n\t <td style='width:80%'>"; if (!$download_datestamp) { $download_datestamp = time(); } $text .= $frm->datepicker('download_datestamp', $download_datestamp); // $update_checked = ($_POST['update_datestamp']) ? "checked='checked'" : ""; // $text .= " <span><input type='checkbox' value='1' name='update_datestamp' $update_checked/>".DOWLAN_148."</span>"; $text .= "\n\t </td>\n\t </tr>\n\t \n\t \t\t\t <tr>\n\t <td >" . LAN_SEFURL . "</td>\n\t <td style='width:80%'>\n\t <input class='tbox input-xxlarge' type='text' name='download_sef' size='60' value=\"" . $tp->toForm($download_sef) . "\" maxlength='250'/>\n\t </td>\n\t </tr> \n\t \n\t \n\t <tr>\n\t <td >" . LAN_KEYWORDS . "</td>\n\t <td style='width:80%'>" . $frm->tags('download_keywords', $download_keywords) . "\n\t \n\t </td>\n\t </tr> \n\t \n\t\t\t\t\t \n\t \n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_21 . "</td>\n\t <td style='width:80%'>\n\t <select name='download_active' class='tbox'>"; foreach ($download_status as $key => $val) { $sel = $download_active == $key ? " selected = 'selected' " : ""; $text .= "<option value='{$key}' {$sel}>{$val}</option>\n"; } $text .= " </select>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_102 . "</td>\n\t <td style='width:80%'>"; if ($download_comment == "0") { $text .= LAN_YES . ": <input type='radio' name='download_comment' value='1'/>\n\t " . LAN_NO . ": <input type='radio' name='download_comment' value='0' checked='checked'/>"; } else { $text .= LAN_YES . ": <input type='radio' name='download_comment' value='1' checked='checked'/>\n\t " . LAN_NO . ": <input type='radio' name='download_comment' value='0'/>"; } $text .= " </td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_145 . "</td>\n\t <td style='width:80%'>" . r_userclass('download_visible', $download_visible, 'off', 'public, nobody, member, admin, classes, language') . "</td>\n\t </tr>\n\t <tr>\n\t <td style='width:20%'>" . DOWLAN_106 . "</td>\n\t <td style='width:80%'>" . r_userclass('download_class', $download_class, 'off', 'public, nobody, member, admin, classes, language') . "</td>\n\t </tr>"; if ($subAction == "dlm") { $text .= "\n\t <tr>\n\t <td style='width:30%'>" . DOWLAN_153 . "</td>\n\t <td style='width:70%'>\n\t <select name='move_file' class='tbox'>\n\t <option value=''>" . LAN_NO . "</option>"; $dl_dirlist = $fl->get_dirs(e_DOWNLOAD); if ($dl_dirlist) { sort($dl_dirlist); $text .= "<option value='" . e_DOWNLOAD . "'>/</option>\n"; foreach ($dl_dirlist as $dirs) { $text .= "<option value='" . e_DOWNLOAD . $dirs . "/'>" . $dirs . "/</option>\n"; } } else { $text .= "<option value='" . e_DOWNLOAD . "'>" . LAN_YES . "</option>\n"; } $text .= " </select>\n\t </td>\n\t </tr>\n\t <tr>\n\t <td style='width:30%'>" . DOWLAN_103 . "</td>\n\t <td style='width:70%'>\n\t <input type='checkbox' name='remove_upload' value='1'/>\n\t <input type='hidden' name='remove_id' value='{$id}'/>\n\t </td>\n\t </tr>"; } //triggerHook $data = array('method' => 'form', 'table' => 'download', 'id' => $id, 'plugin' => 'download', 'function' => 'create_download'); $text .= $frm->renderHooks($data); $text .= "\n\t \t \n\t </table>\n\t <div class='buttonsbar center'>"; if ($id && $subAction == "edit") { $text .= "<input class='btn btn-default button' type='submit' name='submit_download' value='" . DOWLAN_24 . "'/> "; } else { $text .= "<input class='btn btn-default button' type='submit' name='submit_download' value='" . DOWLAN_25 . "'/>"; } $text .= "\n\t </div>\n\t \n\t </fieldset>\n\t </form>\n\t \n\t \n\t "; // $ns->tablerender(ADLAN_24, $text); echo $text; }