Пример #1
0
 function _loadFromDatabase($cid)
 {
     global $_TABLES;
     $result = DB_query("SELECT * FROM {$_TABLES['downloadcategories']} WHERE cid='" . addslashes($cid) . "'");
     $A = DB_fetchArray($result);
     foreach ($A as $key => $val) {
         $this->{'_' . $key} = $val;
     }
     $this->_title = DLM_htmlspecialchars($this->_title);
     $this->_imgurl = DLM_htmlspecialchars($this->_imgurl);
     $this->_old_cid = $this->_cid;
     $this->_imgurlold = $this->_imgurl;
 }
Пример #2
0
 /**
  * Show the downloads editor
  */
 function showEditor($mode = 'edit')
 {
     global $_CONF, $_TABLES, $_USER, $_GROUPS, $_SCRIPTS, $LANG01, $LANG12, $LANG24, $MESSAGE, $_DLM_CONF, $LANG_DLM, $LANG_ACCESS;
     $retval = '';
     $this->initCatTree();
     $p = COM_applyFilter($_GET['p']);
     if (!empty($p)) {
         $this->_page = $p;
     }
     $lc = COM_applyFilter($_GET['cid']);
     if (!empty($lc)) {
         $this->_listing_cid = $lc;
     }
     if (!empty($this->_editor_mode)) {
         $mode = $this->_editor_mode;
     } else {
         $this->_editor_mode = $mode;
     }
     if ($mode == 'edit' || $mode == 'clone') {
         if ($this->_retry == true) {
             $this->_loadFromArgs($_POST);
         } else {
             $this->_lid = COM_applyFilter($_GET['lid']);
             $this->_loadFromDatabase($this->_lid);
         }
     }
     if ($mode == 'create' || $mode == 'submit') {
         if ($this->_retry == true) {
             $this->_loadFromArgs($_POST);
         } else {
             $this->_initVars();
             $homepage = DB_getItem($_TABLES['users'], 'homepage', "uid = '" . addslashes($this->_owner_id) . "'");
             $this->_homepage = DLM_htmlspecialchars(stripslashes($homepage));
         }
     }
     if ($mode != 'create' && $mode != 'submit') {
         $this->_checkHasAccess();
     }
     if ($mode == 'editsubmission') {
         if ($this->_retry == true) {
             $this->_loadFromArgs($_POST);
         } else {
             $this->_lid = COM_applyFilter($_GET['id']);
             $this->_loadSubmission($this->_lid);
         }
     }
     $ja = $_CONF['language'] == 'japanese_utf-8';
     $T = new Template($_DLM_CONF['path_layout']);
     $T->set_file(array('t_mod_download' => 'mod_download.thtml', 't_mod_newfile' => 'mod_newfile.thtml', 't_mod_newfile2' => 'mod_newfile2.thtml', 't_mod_newfileshot' => 'mod_newfileshot.thtml', 't_mod_submit_delete' => 'mod_submit_delete.thtml', 't_mod_submit_cancel' => 'mod_submit_cancel.thtml', 't_mod_submit_preview' => 'mod_submit_preview.thtml', 't_mod_file_id' => 'mod_file_id.thtml', 't_mod_dl_file_name' => 'mod_dl_file_name.thtml', 't_mod_file_size' => 'mod_file_size.thtml', 't_mod_votes' => 'mod_votes.thtml', 't_mod_submitter' => 'mod_submitter.thtml', 't_mod_tempfile' => 'mod_tempfile.thtml', 't_mod_logourl' => 'mod_logourl.thtml', 't_mod_tempsnap' => 'mod_tempsnap.thtml', 't_mod_date' => 'mod_date' . ($ja ? '_ja' : '') . '.thtml', 't_mod_mg_autotag' => 'mod_mg_autotag.thtml'));
     if ($mode == 'submit') {
         $T->set_file(array('t_mod_newfile' => 'mod_newfilesubmit.thtml', 't_mod_newfileshot' => 'mod_newfileshotsubmit.thtml'));
     }
     DLM_setDefaultTemplateVars($T);
     $lang = array('main', 'fileid', 'filetitle', 'dlfilename', 'replfilename', 'homepage', 'ver', 'filesize', 'bytes', 'description', 'detail', 'category', 'shotimage', 'addshotimage', 'replshotimage', 'released', 'listing', 'yes', 'no', 'submit', 'delete', 'cancel', 'confirm_delete', 'submitter', 'release_date', 'postmode', 'comment_mode', 'project', 'toolbar', 'toolbar1', 'toolbar2', 'toolbar3', 'toolbar5', 'md5', 'mg_autotag', 'mg_autotag_info', 'upload', 'tags', 'preview');
     foreach ($lang as $v) {
         $T->set_var('lang_' . $v, $LANG_DLM[$v]);
     }
     $action = 'index.php';
     switch ($mode) {
         case 'edit':
             $op = 'saveDownload';
             break;
         case 'create':
             $T->set_var('lang_submit', $LANG_DLM['add']);
             $T->set_var('lang_replfilename', $LANG_DLM['addfilename']);
             $T->set_var('lang_replshotimage', $LANG_DLM['addshotimage']);
             $op = 'add';
             break;
         case 'clone':
             $T->set_var('lang_submit', $LANG_DLM['add']);
             $op = 'add';
             break;
         case 'editsubmission':
             $T->set_var('lang_submit', $LANG_DLM['approve']);
             $op = 'approve';
             break;
         case 'submit':
             $T->set_var('lang_submit', $LANG12[8]);
             $T->set_var('lang_replfilename', $LANG_DLM['addfilename']);
             $op = 'submit';
             $action = 'submit.php?type=downloads';
             break;
     }
     $categorylist = $this->_cat_tree->makeSelBox('title', 'corder', $this->_cid, 0, 'cid');
     if ($mode == 'edit' || $mode == 'clone' || $mode == 'editsubmission') {
         if (empty($this->_old_lid)) {
             $this->_old_lid = $this->_lid;
         }
         $this->_title = DLM_htmlspecialchars(stripslashes($this->_title));
         $this->_project = DLM_htmlspecialchars(stripslashes($this->_project));
         $pathstring = $this->_cat_tree->getNicePathFromId($cid, "title", "{$_CONF['site_url']}/downloads/index.php?op=");
         $this->_url = DLM_htmlspecialchars(stripslashes($this->_url));
         $this->_logourl = DLM_htmlspecialchars(stripslashes($this->_logourl));
         $this->_mg_autotag = DLM_htmlspecialchars(stripslashes($this->_mg_autotag));
         $this->_tags = DLM_htmlspecialchars(stripslashes($this->_tags));
         $this->_homepage = DLM_htmlspecialchars(stripslashes($this->_homepage));
         $this->_version = DLM_htmlspecialchars($this->_version);
         $this->_size = DLM_htmlspecialchars($this->_size);
         $this->_md5 = DLM_htmlspecialchars(stripslashes($this->_md5));
     }
     if ($mode == 'editsubmission') {
         $tempfileurl = $_CONF['site_url'] . '/admin/plugins/downloads/tmpfile.php?id=' . $this->_lid;
         $tempsnapurl = '';
         if (!empty($this->_logourl)) {
             $tempsnapurl = $_DLM_CONF['snapstore_url'] . '/tmp' . date('YmdHis', $this->_date) . DLM_createSafeFileName($this->_logourl);
         }
         $T->set_var('lang_tempfile', $LANG_DLM['tempfile']);
         $T->set_var('tempsnapurl', $tempsnapurl);
         $T->set_var('tempfileurl', $tempfileurl);
     }
     if ($mode == 'clone') {
         if ($this->_retry != true && !empty($this->_lid)) {
             $this->_lid = $this->_createID($this->_lid . '_');
             if (strlen($this->_lid) > 40) {
                 $this->_lid = $this->_createID();
             }
         }
     }
     if (version_compare(VERSION, '2.1.0') >= 0) {
         require_once $_CONF['path_system'] . 'classes/gltext.class.php';
         $description = GLText::getEditText($this->_description, $this->_postmode, 2);
         $detail = GLText::getEditText($this->_detail, $this->_postmode, 2);
         $file_description = GLText::getPreviewText($this->_description, $this->_postmode, 'story.edit', 2);
         $file_detail = GLText::getPreviewText($this->_detail, $this->_postmode, 'story.edit', 2);
     } else {
         require_once $_CONF['path'] . 'plugins/downloads/include/gltext.class.php';
         $gltext = new GLPText();
         $description = $gltext->getEditText($this->_description, $this->_postmode);
         $detail = $gltext->getEditText($this->_detail, $this->_postmode);
         $file_description = $gltext->getDisplayText($this->_description, $this->_postmode);
         $file_detail = $gltext->getDisplayText($this->_detail, $this->_postmode);
     }
     list($year, $month, $day, $hour, $minute, $second) = explode(',', date('Y,m,d,H,i,s', $this->_date));
     $enabled_adv_editor = $_CONF['advanced_editor'] && $_USER['advanced_editor'];
     $show_texteditor = '';
     $show_htmleditor = 'none';
     if ($enabled_adv_editor && $this->_postmode == 'adveditor') {
         $show_texteditor = 'none';
         $show_htmleditor = '';
     }
     $allowed_html = '';
     if (version_compare(VERSION, '2.1.0') >= 0) {
         $postmode_list = 'plaintext,html';
         if ($enabled_adv_editor) {
             $postmode_list .= ',adveditor';
         }
         if ($_CONF['wikitext_editor']) {
             $postmode_list .= ',wikitext';
         }
         $postmode_array = explode(',', $postmode_list);
         foreach ($postmode_array as $pm) {
             $allowed_html .= COM_allowedHTML('story.edit', false, 1, $pm);
         }
         $allowed_html .= COM_allowedAutotags(false, array('code', 'raw'));
     } else {
         $allowed_html = COM_allowedHTML();
         $allowed_html = str_replace('[page_break], ', '', $allowed_html);
         // No support [page_break]
     }
     $T->set_var('lang_allowed_html', $allowed_html);
     if (version_compare(VERSION, '2.1.0') >= 0) {
         // Loads jQuery UI datepicker and timepicker-addon
         $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider');
         $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker');
         $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n');
         $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon');
         $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n');
         $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js');
         $langCode = COM_getLangIso639Code();
         $toolTip = $MESSAGE[118];
         $imgUrl = $_CONF['site_url'] . '/images/calendar.png';
         $_SCRIPTS->setJavaScript("jQuery(function () {" . "  geeklog.hour_mode = 24;" . "  geeklog.datetimepicker.set('release', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE);
     }
     if ($enabled_adv_editor) {
         // Add JavaScript
         if (version_compare(VERSION, '2.1.0') >= 0) {
             $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js');
             COM_setupAdvancedEditor('/downloads/adveditor.js', 'story.edit');
         } else {
             if (version_compare(VERSION, '2.0.0') < 0) {
                 $js = 'geeklogEditorBasePath = "' . $_CONF['site_url'] . '/fckeditor/";';
                 $_SCRIPTS->setJavaScript($js, true);
             }
             $_SCRIPTS->setJavaScriptFile('fckeditor', '/fckeditor/fckeditor.js');
             $_SCRIPTS->setJavaScriptFile('downloadeditor_fckeditor', '/downloads/downloadeditor_fckeditor.js');
         }
     }
     if (empty($this->_postmode)) {
         $this->_postmode = $_DLM_CONF['postmode'];
     }
     $post_options = COM_optionList($_TABLES['postmodes'], 'code,name', $this->_postmode);
     if ($enabled_adv_editor) {
         if ($this->_postmode == 'adveditor') {
             $post_options .= '<option value="adveditor" ' . UC_SELECTED . '>' . $LANG24[86] . '</option>';
         } else {
             $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>';
         }
     }
     if ($_CONF['wikitext_editor']) {
         if ($this->_postmode == 'wikitext') {
             $post_options .= '<option value="wikitext" ' . UC_SELECTED . '>' . $LANG24[88] . '</option>';
         } else {
             $post_options .= '<option value="wikitext">' . $LANG24[88] . '</option>';
         }
     }
     $hidden_values = $this->_makeForm_hidden('owner_id', $this->_owner_id);
     $hidden_values .= $this->_makeForm_hidden('editor_mode', $this->_editor_mode);
     $hidden_values .= $this->_makeForm_hidden('page', $this->_page);
     if (!empty($this->_listing_cid) && $this->_listing_cid != ROOTID) {
         $hidden_values .= $this->_makeForm_hidden('listing_cid', $this->_listing_cid);
     }
     $T->set_var('show_texteditor', $show_texteditor);
     $T->set_var('show_htmleditor', $show_htmleditor);
     $T->set_var('post_options', $post_options);
     $T->set_var('action', $action);
     $T->set_var('op', $op);
     $T->set_var('lid', $this->_lid);
     $T->set_var('old_lid', $this->_old_lid);
     $T->set_var('pathstring', $pathstring);
     $T->set_var('title', $this->_title);
     $T->set_var('url', $this->_url);
     $T->set_var('homepage', $this->_homepage);
     $T->set_var('version', $this->_version);
     $T->set_var('size', $this->_size);
     $T->set_var('md5', $this->_md5);
     $T->set_var('logourl', $this->_logourl);
     $T->set_var('mg_autotag', $this->_mg_autotag);
     $T->set_var('tags', $this->_tags);
     $T->set_var('description', $description);
     $T->set_var('detail', $detail);
     $T->set_var('project', $this->_project);
     $T->set_var('snapstore_url', $_DLM_CONF['snapstore_url']);
     $T->set_var('categorylist', $categorylist);
     $T->set_var('val_is_released_1', $this->_is_released ? UC_SELECTED : '');
     $T->set_var('val_is_released_0', !$this->_is_released ? UC_SELECTED : '');
     $T->set_var('val_is_listing_1', $this->_is_listing ? UC_SELECTED : '');
     $T->set_var('val_is_listing_0', !$this->_is_listing ? UC_SELECTED : '');
     $T->set_var('shot_autotag', $this->_makeForm_shot_mg_autotag());
     $T->set_var('shot', $this->_makeForm_shot());
     $T->set_var('year_options', COM_getYearFormOptions($year));
     $T->set_var('month_options', DLM_getMonthFormOptions($month));
     $T->set_var('day_options', COM_getDayFormOptions($day));
     $T->set_var('hour_options', COM_getHourFormOptions($hour, 24));
     $T->set_var('minute_options', COM_getMinuteFormOptions($minute, 1));
     $T->set_var('second_options', COM_getMinuteFormOptions($second, 1));
     $T->set_var('old_date', $this->_date);
     $T->set_var('comment_options', COM_optionList($_TABLES['commentcodes'], 'code,name', $this->_commentcode));
     $T->set_var('gltoken_name', CSRF_TOKEN);
     $T->set_var('gltoken', SEC_createToken());
     $T->set_var('submitter', $this->_owner_id);
     $T->set_var('displayName', COM_getDisplayName($this->_owner_id));
     if ($mode == 'submit') {
         $T->set_var('lang_commentoption', $LANG_DLM['commentoption']);
         $T->set_var('val_commentoption_1', UC_SELECTED);
         $T->set_var('val_commentoption_0', '');
     }
     $T->parse('mod_submitter', 't_mod_submitter');
     if ($mode == 'editsubmission' || $mode == 'submit') {
         $T->set_var('mod_mg_autotag', '');
         $hidden_values .= $this->_makeForm_hidden('mg_autotag', $this->_mg_autotag);
     } else {
         if ($_DLM_CONF['enabled_mg_autotag'] == 1) {
             $T->parse('mod_mg_autotag', 't_mod_mg_autotag');
         } else {
             $T->set_var('mod_mg_autotag', '');
             $hidden_values .= $this->_makeForm_hidden('mg_autotag', $this->_mg_autotag);
         }
     }
     $T->set_var('hidden_values', $hidden_values);
     if ($mode == 'edit' || $mode == 'clone') {
         $T->parse('mod_newfile', 't_mod_newfile');
         $T->parse('mod_newfileshot', 't_mod_newfileshot');
         if ($mode == 'edit') {
             $T->parse('mod_submit_delete', 't_mod_submit_delete');
         }
         $T->parse('mod_submit_cancel', 't_mod_submit_cancel');
         $T->parse('mod_file_size', 't_mod_file_size');
     }
     if ($mode == 'editsubmission') {
         $T->parse('mod_dl_file_name', 't_mod_dl_file_name');
         $T->parse('mod_tempfile', 't_mod_tempfile');
         $T->parse('mod_file_size', 't_mod_file_size');
         $T->set_var('mod_tempsnap', '');
         if ($tempsnapurl != '') {
             $T->parse('mod_tempsnap', 't_mod_tempsnap');
         }
         $T->parse('mod_logourl', 't_mod_logourl');
         $T->parse('mod_submit_delete', 't_mod_submit_delete');
         $T->parse('mod_submit_cancel', 't_mod_submit_cancel');
     }
     if ($mode == 'create') {
         $T->parse('mod_newfile', 't_mod_newfile2');
         $T->parse('mod_newfileshot', 't_mod_newfileshot');
         $T->parse('mod_submit_cancel', 't_mod_submit_cancel');
     }
     if ($mode == 'submit') {
         $T->parse('mod_newfile', 't_mod_newfile');
         $T->parse('mod_newfileshot', 't_mod_newfileshot');
     }
     if ($_DLM_CONF['enabled_preview_on_upload'] === false && ($mode == 'create' || $mode == 'submit')) {
         $T->set_var('mod_submit_preview', '');
     } else {
         $T->parse('mod_submit_preview', 't_mod_submit_preview');
     }
     $T->parse('mod_file_id', 't_mod_file_id');
     $T->parse('mod_date', 't_mod_date');
     $T->parse('output', 't_mod_download');
     $blocktitle = $LANG_DLM['moddl'];
     if ($mode == 'editsubmission') {
         $blocktitle = $LANG_DLM['dlswaiting'];
     }
     if ($mode == 'create') {
         $blocktitle = $LANG_DLM['addnewfile'];
     }
     if ($mode == 'clone') {
         $blocktitle = $LANG_DLM['addnewfile'];
     }
     if ($mode == 'submit') {
         $blocktitle = $LANG_DLM['uploadtitle'];
     }
     $retval .= $this->_showMessage();
     $retval .= COM_startBlock($blocktitle, '', COM_getBlockTemplate('_admin_block', 'header'));
     $retval .= $T->finish($T->get_var('output'));
     $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
     if (!empty($file_description) || !empty($file_detail)) {
         // Display Preview Block
         $T2 = new Template($_DLM_CONF['path_layout']);
         $T2->set_file('t_mod_preview', 'mod_preview.thtml');
         $T2->set_var('file_description', $file_description);
         $T2->set_var('file_detail', $file_detail);
         $T2->parse('output', 't_mod_preview');
         $blocktitle = $LANG_DLM['preview'];
         $retval .= COM_startBlock($blocktitle, '', COM_getBlockTemplate('_admin_block', 'header'));
         $retval .= $T2->finish($T2->get_var('output'));
         $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
     }
     if ($mode == 'edit') {
         // Display File Voting Information
         $retval .= $this->_showVotes_reguser($this->_lid);
         $retval .= $this->_showVotes_anon($this->_lid);
     }
     if ($mode != 'submit' || $this->_retry == true) {
         $retval = DLM_createHTMLDocument($retval, array('pagetitle' => $blocktitle));
     }
     return $retval;
 }
Пример #3
0
function makeCategoryPart($cid)
{
    global $_CONF, $_DLM_CONF, $LANG_DLM, $mytree;
    $T = new Template($_DLM_CONF['path_layout']);
    $T->set_file(array('categorypart' => 'filelisting_category.thtml', 'categoryrow' => 'filelisting_category_row.thtml', 'categoryitem' => 'filelisting_category_item.thtml'));
    DLM_setDefaultTemplateVars($T);
    $arr = $mytree->getFirstChild($cid, 'corder');
    // all child ID are listed (Affected by the language mode)
    if (count($arr) == 0) {
        return '';
    }
    //  if ($_DLM_CONF['numCategoriesPerRow'] < 1) $_DLM_CONF['numCategoriesPerRow'] = 1; // probably no longer necessary
    //  if ($_DLM_CONF['numCategoriesPerRow'] > 6) $_DLM_CONF['numCategoriesPerRow'] = 6; // probably no longer necessary
    $count = 0;
    foreach ($arr as $ele) {
        // Each category
        $chtitle = DLM_htmlspecialchars($ele['title']);
        $T->set_var('cid', $ele['cid']);
        $T->set_var('chtitle', $chtitle);
        $T->set_var('totaldownload', getTotalItems($ele['cid']));
        $category_image_link = '&nbsp;';
        if ($_DLM_CONF['download_useshots']) {
            if ($ele['imgurl'] && $ele['imgurl'] != "http://") {
                $imgurl = $_DLM_CONF['snapcat_url'] . '/' . DLM_htmlspecialchars($ele['imgurl']);
            } else {
                $imgurl = $_CONF['site_url'] . '/downloads/images/download.png';
            }
            $category_image_link = COM_createImage($imgurl, $chtitle, array('width' => $_DLM_CONF['download_shotwidth']));
            $category_image_link = COM_createLink($category_image_link, $_CONF['site_url'] . '/downloads/index.php?cid=' . $ele['cid']);
        }
        $T->set_var('category_link', $category_image_link);
        $T->parse('category_row', 'categoryitem', true);
        $count++;
        if ($count == $_DLM_CONF['numCategoriesPerRow']) {
            $T->parse('category_records', 'categoryrow', true);
            $T->set_var('category_row', '');
            $count = 0;
        }
    }
    if ($count > 0) {
        $T->parse('category_records', 'categoryrow', true);
    }
    return $T->finish($T->parse('category_part', 'categorypart'));
}
Пример #4
0
            echo DLM_showErrorMessage('voteonce');
            exit;
        }
    }
    //All is well.  Add to Line Item Rate to DB.
    $datetime = time();
    DB_query("INSERT INTO {$_TABLES['downloadvotes']} " . "(lid, ratinguser, rating, ratinghostname, ratingtimestamp) " . "VALUES ('" . addslashes($lid) . "', {$uid}, {$rating}, '{$ip}', {$datetime})");
    //All is well.  Calculate Score & Add to Summary (for quick retrieval & sorting) to DB.
    DLM_updaterating($lid);
    echo PLG_afterSaveSwitch('home', '', 'downloads', 113);
    exit;
}
$lid = COM_applyFilter($_GET['lid']);
$result = DB_query("SELECT title FROM {$_TABLES['downloads']} WHERE lid='" . addslashes($lid) . "'");
list($title) = DB_fetchArray($result);
$title = DLM_htmlspecialchars($title);
$pagetitle = $LANG_DLM['plugin_name'];
$display = '';
$display .= COM_startBlock($LANG_DLM['plugin_name']);
$T = new Template($_DLM_CONF['path_layout']);
$T->set_file(array('t_vote' => 'vote.thtml'));
DLM_setDefaultTemplateVars($T);
$T->set_var('val_lid', $lid);
$T->set_var('lang_file', $LANG_DLM['file']);
$T->set_var('val_title', $title);
$T->set_var('lang_ratefiletitle', $LANG_DLM['ratefiletitle']);
$T->set_var('lang_voteonce', $LANG_DLM['voteonce']);
$T->set_var('lang_ratingscale', $LANG_DLM['ratingscale']);
$T->set_var('lang_beobjective', $LANG_DLM['beobjective']);
$T->set_var('lang_donotvote', $LANG_DLM['donotvote']);
$option_list = '<option>--</option>';