예제 #1
0
     } else {
         $status['sql_file'] = $R['install_code_not_found'];
     }
     $status['php_ver'] = function_exists('version_compare') && version_compare(PHP_VERSION, '5.2.3', '>=') ? cot_rc('install_code_valid', array('text' => cot_rc('install_ver_valid', array('ver' => PHP_VERSION)))) : cot_rc('install_code_invalid', array('text' => cot_rc('install_ver_invalid', array('ver' => PHP_VERSION))));
     $status['mbstring'] = extension_loaded('mbstring') ? $R['install_code_available'] : $R['install_code_not_available'];
     $status['hash'] = extension_loaded('hash') && function_exists('hash_hmac') ? $R['install_code_available'] : $R['install_code_not_available'];
     $status['mysql'] = extension_loaded('pdo_mysql') ? $R['install_code_available'] : $R['install_code_not_available'];
     $t->assign(array('INSTALL_AV_DIR' => $status['avatars_dir'], 'INSTALL_CACHE_DIR' => $status['cache_dir'], 'INSTALL_PFS_DIR' => $status['pfs_dir'], 'INSTALL_EXFLDS_DIR' => $status['exflds_dir'], 'INSTALL_PHOTOS_DIR' => $status['photos_dir'], 'INSTALL_THUMBS_DIR' => $status['thumbs_dir'], 'INSTALL_CONFIG' => $status['config'], 'INSTALL_CONFIG_SAMPLE' => $status['config_sample'], 'INSTALL_SQL_FILE' => $status['sql_file'], 'INSTALL_PHP_VER' => $status['php_ver'], 'INSTALL_MBSTRING' => $status['mbstring'], 'INSTALL_HASH' => $status['hash'], 'INSTALL_MYSQL' => $status['mysql']));
     break;
 case 2:
     // Database form
     $t->assign(array('INSTALL_DB_HOST' => is_null($db_host) ? $cfg['mysqlhost'] : $db_host, 'INSTALL_DB_PORT' => is_null($db_port) ? $cfg['mysqlport'] : $db_port, 'INSTALL_DB_USER' => is_null($db_user) ? $cfg['mysqluser'] : $db_user, 'INSTALL_DB_NAME' => is_null($db_name) ? $cfg['mysqldb'] : $db_name, 'INSTALL_DB_X' => $db_x, 'INSTALL_DB_HOST_INPUT' => cot_inputbox('text', 'db_host', is_null($db_host) ? $cfg['mysqlhost'] : $db_host, 'size="32"'), 'INSTALL_DB_PORT_INPUT' => cot_inputbox('text', 'db_port', is_null($db_port) ? $cfg['mysqlport'] : $db_port, 'size="32"'), 'INSTALL_DB_USER_INPUT' => cot_inputbox('text', 'db_user', is_null($db_user) ? $cfg['mysqluser'] : $db_user, 'size="32"'), 'INSTALL_DB_NAME_INPUT' => cot_inputbox('text', 'db_name', is_null($db_name) ? $cfg['mysqldb'] : $db_name, 'size="32"'), 'INSTALL_DB_PASS_INPUT' => cot_inputbox('password', 'db_pass', '', 'size="32"'), 'INSTALL_DB_X_INPUT' => cot_inputbox('text', 'db_x', $db_x, 'size="32"')));
     break;
 case 3:
     // Settings
     if ($_POST['step'] != 3 && !cot_check_messages()) {
         $rtheme = $theme;
         $rscheme = $scheme;
         $rlang = $cfg['defaultlang'];
         $cfg['mainurl'] = $site_url;
     }
     $t->assign(array('INSTALL_THEME_SELECT' => cot_selectbox_theme($rtheme, $rscheme, 'theme'), 'INSTALL_LANG_SELECT' => cot_selectbox_lang($rlang, 'lang'), 'INSTALL_COUNTRY_SELECT' => cot_selectbox_countries($user['country'], 'user_country'), 'INSTALL_MAINURL' => cot_inputbox('text', 'mainurl', $cfg['mainurl'], 'size="32"'), 'INSTALL_USERNAME' => cot_inputbox('text', 'user_name', $user['name'], 'size="32"'), 'INSTALL_PASS1' => cot_inputbox('password', 'user_pass', '', 'size="32"'), 'INSTALL_PASS2' => cot_inputbox('password', 'user_pass2', '', 'size="32"'), 'INSTALL_EMAIL' => cot_inputbox('text', 'user_email', $user['email'], 'size="32"')));
 case 4:
     // Extensions
     cot_install_parse_extensions('Module', $default_modules, $selected_modules);
     cot_install_parse_extensions('Plugin', $default_plugins, $selected_plugins);
     // robots.txt
     $robotsTxtFilePath = './robots.txt';
     if (file_exists($robotsTxtFilePath) && is_writable($robotsTxtFilePath)) {
         $robotsTxtFile = file_get_contents($robotsTxtFilePath);
         $tmp = 'Host: ' . str_replace(array('http://', 'https://'), '', $cfg['mainurl']);
예제 #2
0
/**
 * Generates comments display for a given item
 *
 * @param string $ext_name Module or plugin code
 * @param string $code Item identifier
 * @param string $cat Item category code (optional)
 * @param bool $force_admin Enforces user to be administrator of comments for this item.
 *	E.g. to moderate his wall even if he is not a moderator
 * @return string Rendered HTML output for comments
 * @global CotDB $db
 */
function cot_comments_display($ext_name, $code, $cat = '', $force_admin = false)
{
    global $db, $db_com, $db_users, $cfg, $usr, $L, $sys, $R, $env, $pg, $cot_extrafields, $cache, $structure;
    // Check permissions and enablement
    list($auth_read, $auth_write, $auth_admin) = cot_auth('plug', 'comments');
    if ($auth_read && $auth_write && $force_admin) {
        $auth_admin = true;
        $_SESSION['cot_comments_force_admin'][$ext_name][$code] = true;
    }
    $enabled = cot_comments_enabled($ext_name, $cat, $code);
    if (!$auth_read || !$enabled && !$auth_admin) {
        return '';
    }
    $comments_join_columns = $comments_join_tables = $comments_join_where = '';
    // Get the URL and parameters
    $link_area = $env['ext'];
    $link_params = $_GET;
    if (defined('COT_PLUG')) {
        $link_area = 'plug';
        $link_params['e'] = $env['ext'];
    }
    if (isset($_GET['rwr'])) {
        unset($link_params['rwr'], $link_params['e']);
    }
    $cot_com_back = array($link_area, $link_params);
    $_SESSION['cot_com_back'][$ext_name][$cat][$code] = $cot_com_back;
    $d_var = 'dcm';
    list($pg, $d, $durl) = cot_import_pagenav($d_var, $cfg['plugin']['comments']['maxcommentsperpage']);
    $d = empty($d) ? 0 : (int) $d;
    if ($auth_write && $enabled) {
        require_once cot_incfile('forms');
    }
    $t = new XTemplate(cot_tplfile('comments', 'plug'));
    /* == Hook == */
    foreach (cot_getextplugins('comments.main') as $pl) {
        include $pl;
    }
    /* ===== */
    $editor = cot::$cfg['plugin']['comments']['markup'] ? 'input_textarea_minieditor' : '';
    $t->assign(array('COMMENTS_CODE' => $code, 'COMMENTS_FORM_SEND' => cot_url('plug', "e=comments&a=send&area={$ext_name}&cat={$cat}&item={$code}"), 'COMMENTS_FORM_AUTHOR' => $usr['id'] > 0 ? $usr['name'] : cot_inputbox('text', 'rname'), 'COMMENTS_FORM_AUTHORID' => $usr['id'], 'COMMENTS_FORM_TEXT' => $auth_write && $enabled ? cot_textarea('rtext', $rtext, 7, 120, '', $editor) . cot_inputbox('hidden', 'cb', base64_encode(serialize($cot_com_back))) : '', 'COMMENTS_DISPLAY' => $cfg['plugin']['comments']['expand_comments'] ? '' : 'none'));
    if ($auth_write && $enabled) {
        // Extra fields
        if (!empty(cot::$extrafields[cot::$db->com])) {
            foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                $uname = strtoupper($exfld['field_name']);
                $exfld_val = cot_build_extrafields('rcomments' . $exfld['field_name'], $exfld, $rcomments[$exfld['field_name']]);
                $exfld_title = cot_extrafield_title($exfld, 'comments_');
                $t->assign(array('COMMENTS_FORM_' . $uname => $exfld_val, 'COMMENTS_FORM_' . $uname . '_TITLE' => $exfld_title, 'COMMENTS_FORM_EXTRAFLD' => $exfld_val, 'COMMENTS_FORM_EXTRAFLD_TITLE' => $exfld_title));
                $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.EXTRAFLD');
            }
        }
        $allowed_time = cot_build_timegap($sys['now'] - $cfg['plugin']['comments']['time'] * 60, $sys['now']);
        $com_hint = cot_rc('com_edithint', array('time' => $allowed_time));
        /* == Hook == */
        foreach (cot_getextplugins('comments.newcomment.tags') as $pl) {
            include $pl;
        }
        /* ===== */
        $usr['id'] == 0 && $t->parse('COMMENTS.COMMENTS_NEWCOMMENT.GUEST');
        if ($usr['id'] == 0 && cot_check_messages() && $cache) {
            if ($ext_name == 'page' && $cfg['cache_page']) {
                $cache->page->clear('page/' . str_replace('.', '/', $structure['page'][$cat]['path']));
                $cfg['cache_page'] = false;
            }
        }
        cot_display_messages($t, 'COMMENTS.COMMENTS_NEWCOMMENT');
        $t->assign('COMMENTS_FORM_HINT', $com_hint);
        $t->parse('COMMENTS.COMMENTS_NEWCOMMENT');
    } else {
        $warning = $enabled ? $L['com_regonly'] : $L['com_closed'];
        $t->assign('COMMENTS_CLOSED', $warning);
        $t->parse('COMMENTS.COMMENTS_CLOSED');
    }
    $order = $cfg['plugin']['comments']['order'] == 'Chronological' ? 'ASC' : 'DESC';
    $comments_order = "com_id {$order}";
    /* == Hook == */
    foreach (cot_getextplugins('comments.query') as $pl) {
        include $pl;
    }
    /* ===== */
    $sql = $db->query("SELECT c.*, u.* {$comments_join_columns}\n\t\tFROM {$db_com} AS c LEFT JOIN {$db_users} AS u ON u.user_id = c.com_authorid {$comments_join_tables}\n\t\tWHERE com_area = ? AND com_code = ? {$comments_join_where} ORDER BY {$comments_order} LIMIT ?, ?", array($ext_name, $code, (int) $d, (int) $cfg['plugin']['comments']['maxcommentsperpage']));
    if ($sql->rowCount() > 0 && $enabled) {
        $i = $d;
        $kk = 0;
        $totalitems = cot_comments_count($ext_name, $code);
        /* === Hook - Part1 : Set === */
        $extp = cot_getextplugins('comments.loop');
        /* ===== */
        foreach ($sql->fetchAll() as $row) {
            $i++;
            $kk++;
            $com_admin = $auth_admin ? cot_rc('comments_code_admin', array('ipsearch' => cot_build_ipsearch($row['com_authorip']), 'delete_url' => cot_confirm_url(cot_url('plug', 'e=comments&a=delete&cat=' . $cat . '&id=' . $row['com_id'] . '&' . cot_xg()), 'comments', 'comments_confirm_delete'))) : '';
            $com_text = cot_parse($row['com_text'], $cfg['plugin']['comments']['markup']);
            $time_limit = $sys['now'] < $row['com_date'] + $cfg['plugin']['comments']['time'] * 60 ? TRUE : FALSE;
            $usr['isowner_com'] = $time_limit && ($usr['id'] > 0 && $row['com_authorid'] == $usr['id'] || $usr['id'] == 0 && !empty($_SESSION['cot_comments_edit'][$row['com_id']]) && $usr['ip'] == $row['com_authorip']);
            $com_gup = $sys['now'] - ($row['com_date'] + $cfg['plugin']['comments']['time'] * 60);
            $allowed_time = $usr['isowner_com'] && !$usr['isadmin'] ? ' - ' . cot_build_timegap($sys['now'] + $com_gup, $sys['now']) . $L['plu_comgup'] : '';
            $com_edit = $auth_admin || $usr['isowner_com'] ? cot_rc('comments_code_edit', array('edit_url' => cot_url('plug', 'e=comments&m=edit&cat=' . $cat . '&id=' . $row['com_id']), 'allowed_time' => $allowed_time)) : '';
            if ($row['com_area'] == 'page') {
                if ($usr['id'] == 0 && $usr['isowner_com'] && $cfg['cache_page']) {
                    $cfg['cache_page'] = $cfg['cache_index'] = false;
                }
            }
            $t->assign(array('COMMENTS_ROW_ID' => $row['com_id'], 'COMMENTS_ROW_ORDER' => $cfg['plugin']['comments']['order'] == 'Recent' ? $totalitems - $i + 1 : $i, 'COMMENTS_ROW_URL' => cot_url($link_area, $link_params, '#c' . $row['com_id']), 'COMMENTS_ROW_AUTHOR' => cot_build_user($row['com_authorid'], htmlspecialchars($row['com_author'])), 'COMMENTS_ROW_AUTHORID' => $row['com_authorid'], 'COMMENTS_ROW_TEXT' => $com_text, 'COMMENTS_ROW_DATE' => cot_date('datetime_medium', $row['com_date']), 'COMMENTS_ROW_DATE_STAMP' => $row['com_date'], 'COMMENTS_ROW_ADMIN' => $com_admin, 'COMMENTS_ROW_EDIT' => $com_edit, 'COMMENTS_ROW_ODDEVEN' => cot_build_oddeven($kk), 'COMMENTS_ROW_NUM' => $kk));
            // Extrafields
            if (!empty(cot::$extrafields[cot::$db->com])) {
                foreach (cot::$extrafields[cot::$db->com] as $exfld) {
                    $tag = mb_strtoupper($exfld['field_name']);
                    $exfld_title = cot_extrafield_title($exfld, 'comments_');
                    $t->assign(array('COMMENTS_ROW_' . $tag . '_TITLE' => $exfld_title, 'COMMENTS_ROW_' . $tag => cot_build_extrafields_data('comments', $exfld, $row['com_' . $exfld['field_name']]), 'COMMENTS_ROW_' . $tag . '_VALUE' => $row['com_' . $exfld['field_name']]));
                }
            }
            $t->assign(cot_generate_usertags($row, 'COMMENTS_ROW_AUTHOR_', htmlspecialchars($row['com_author'])));
            /* === Hook - Part2 : Include === */
            foreach ($extp as $pl) {
                include $pl;
            }
            /* ===== */
            $t->parse('COMMENTS.COMMENTS_ROW');
        }
        $pagenav = cot_pagenav($link_area, $link_params, $d, $totalitems, $cfg['plugin']['comments']['maxcommentsperpage'], $d_var, '#comments', $cfg['jquery'] && $cfg['ajax_enabled'], 'comments', 'plug', "e=comments&area={$ext_name}&cat={$cat}&item={$code}");
        $t->assign(array('COMMENTS_PAGES_INFO' => cot_rc('comments_code_pages_info', array('totalitems' => $totalitems, 'onpage' => $i - $d)), 'COMMENTS_PAGES_TOTALITEMS' => $totalitems, 'COMMENTS_PAGES_PAGESPREV' => $pagenav['prev'], 'COMMENTS_PAGES_PAGNAV' => $pagenav['main'], 'COMMENTS_PAGES_PAGESNEXT' => $pagenav['next']));
        $t->parse('COMMENTS.PAGNAVIGATOR');
    } elseif (!$sql->rowCount() && $enabled) {
        $t->assign(array('COMMENTS_EMPTYTEXT' => $L['com_nocommentsyet']));
        $t->parse('COMMENTS.COMMENTS_EMPTY');
    }
    /* == Hook == */
    foreach (cot_getextplugins('comments.tags') as $pl) {
        include $pl;
    }
    /* ===== */
    $t->parse('COMMENTS');
    $res_display = $t->text('COMMENTS');
    return $res_display;
}
예제 #3
0
     } else {
         $status['sql_file'] = $R['install_code_not_found'];
     }
     $status['php_ver'] = function_exists('version_compare') && version_compare(PHP_VERSION, '5.2.3', '>=') ? cot_rc('install_code_valid', array('text' => cot_rc('install_ver_valid', array('ver' => PHP_VERSION)))) : cot_rc('install_code_invalid', array('text' => cot_rc('install_ver_invalid', array('ver' => PHP_VERSION))));
     $status['mbstring'] = extension_loaded('mbstring') ? $R['install_code_available'] : $R['install_code_not_available'];
     $status['hash'] = extension_loaded('hash') && function_exists('hash_hmac') ? $R['install_code_available'] : $R['install_code_not_available'];
     $status['mysql'] = extension_loaded('pdo_mysql') ? $R['install_code_available'] : $R['install_code_not_available'];
     $t->assign(array('INSTALL_AV_DIR' => $status['avatars_dir'], 'INSTALL_CACHE_DIR' => $status['cache_dir'], 'INSTALL_PFS_DIR' => $status['pfs_dir'], 'INSTALL_EXFLDS_DIR' => $status['exflds_dir'], 'INSTALL_PHOTOS_DIR' => $status['photos_dir'], 'INSTALL_THUMBS_DIR' => $status['thumbs_dir'], 'INSTALL_CONFIG' => $status['config'], 'INSTALL_CONFIG_SAMPLE' => $status['config_sample'], 'INSTALL_SQL_FILE' => $status['sql_file'], 'INSTALL_PHP_VER' => $status['php_ver'], 'INSTALL_MBSTRING' => $status['mbstring'], 'INSTALL_HASH' => $status['hash'], 'INSTALL_MYSQL' => $status['mysql']));
     break;
 case 2:
     // Database form
     $t->assign(array('INSTALL_DB_HOST' => is_null($db_host) ? $cfg['mysqlhost'] : $db_host, 'INSTALL_DB_PORT' => is_null($db_port) ? $cfg['mysqlport'] : $db_port, 'INSTALL_DB_USER' => is_null($db_user) ? $cfg['mysqluser'] : $db_user, 'INSTALL_DB_NAME' => is_null($db_name) ? $cfg['mysqldb'] : $db_name, 'INSTALL_DB_X' => $db_x, 'INSTALL_DB_HOST_INPUT' => cot_inputbox('text', 'db_host', is_null($db_host) ? $cfg['mysqlhost'] : $db_host, 'size="32"'), 'INSTALL_DB_PORT_INPUT' => cot_inputbox('text', 'db_port', is_null($db_port) ? $cfg['mysqlport'] : $db_port, 'size="32"'), 'INSTALL_DB_USER_INPUT' => cot_inputbox('text', 'db_user', is_null($db_user) ? $cfg['mysqluser'] : $db_user, 'size="32"'), 'INSTALL_DB_NAME_INPUT' => cot_inputbox('text', 'db_name', is_null($db_name) ? $cfg['mysqldb'] : $db_name, 'size="32"'), 'INSTALL_DB_PASS_INPUT' => cot_inputbox('password', 'db_pass', '', 'size="32"'), 'INSTALL_DB_X_INPUT' => cot_inputbox('text', 'db_x', $db_x, 'size="32"')));
     break;
 case 3:
     // Settings
     if (cot_import('step', 'POST', 'INT') != 3 && !cot_check_messages()) {
         $rtheme = $theme;
         $rscheme = $scheme;
         $rlang = $lang;
         $cfg['mainurl'] = $site_url;
     }
     $t->assign(array('INSTALL_THEME_SELECT' => cot_selectbox_theme($rtheme, $rscheme, 'theme'), 'INSTALL_LANG_SELECT' => cot_selectbox_lang($rlang, 'lang'), 'INSTALL_COUNTRY_SELECT' => cot_selectbox_countries($user['country'], 'user_country'), 'INSTALL_MAINURL' => cot_inputbox('text', 'mainurl', $cfg['mainurl'], 'size="32"'), 'INSTALL_USERNAME' => cot_inputbox('text', 'user_name', $user['name'], 'size="32"'), 'INSTALL_PASS1' => cot_inputbox('password', 'user_pass', '', 'size="32"'), 'INSTALL_PASS2' => cot_inputbox('password', 'user_pass2', '', 'size="32"'), 'INSTALL_EMAIL' => cot_inputbox('text', 'user_email', $user['email'], 'size="32"')));
 case 4:
     // Extensions
     cot_install_parse_extensions('Module', $default_modules, $selected_modules);
     cot_install_parse_extensions('Plugin', $default_plugins, $selected_plugins);
     // robots.txt
     $robotsTxtFilePath = './robots.txt';
     if (file_exists($robotsTxtFilePath) && is_writable($robotsTxtFilePath)) {
         $robotsTxtFile = file_get_contents($robotsTxtFilePath);
         $tmp = 'Host: ' . str_replace(array('http://', 'https://'), '', $cfg['mainurl']);
예제 #4
0
/**
 * Renders different messages on page
 *
 * @param XTemplate $tpl Current template object reference
 * @param string $block Current template block
 */
function cot_display_messages($tpl, $block = 'MAIN')
{
    global $L;
    if (!cot_check_messages()) {
        return;
    }
    $block = !empty($block) ? $block . '.' : '';
    $errors = cot_get_messages('', 'error');
    if (count($errors) > 0) {
        foreach ($errors as $msg) {
            $text = isset($L[$msg['text']]) ? $L[$msg['text']] : $msg['text'];
            $tpl->assign('ERROR_ROW_MSG', $text);
            $tpl->parse($block . 'ERROR.ERROR_ROW');
        }
        $tpl->parse($block . 'ERROR');
    }
    $warnings = cot_get_messages('', 'warning');
    if (count($warnings) > 0) {
        foreach ($warnings as $msg) {
            $text = isset($L[$msg['text']]) ? $L[$msg['text']] : $msg['text'];
            $tpl->assign('WARNING_ROW_MSG', $text);
            $tpl->parse($block . 'WARNING.WARNING_ROW');
        }
        $tpl->parse($block . 'WARNING');
    }
    $okays = cot_get_messages('', 'ok');
    if (count($okays) > 0) {
        foreach ($okays as $msg) {
            $text = isset($L[$msg['text']]) ? $L[$msg['text']] : $msg['text'];
            $tpl->assign('DONE_ROW_MSG', $text);
            $tpl->parse($block . 'DONE.DONE_ROW');
        }
        $tpl->parse($block . 'DONE');
    }
    cot_clear_messages();
}
예제 #5
0
if (!empty($vote)) {
    $vote = explode(" ", $vote);
}
if (empty($vote)) {
    $vote = cot_import('vote', 'P', 'ARR');
}
$ratings = cot_import('ratings', 'G', 'BOL');
$out['subtitle'] = $L['Polls'];
/* === Hook === */
foreach (cot_getextplugins('polls.main') as $pl) {
    include $pl;
}
/* ===== */
require_once $cfg['system_dir'] . '/header.php';
$t = new XTemplate(cot_tplfile('polls'));
if (cot_check_messages()) {
    cot_display_messages($t);
}
if ((int) $id > 0) {
    $id = (int) cot_import($id, 'D', 'INT');
    if ((int) $db->query("SELECT COUNT(*) FROM {$db_polls} WHERE poll_id={$id} AND poll_type='index'")->fetchColumn() != 1) {
        cot_die_message(404, TRUE);
    }
    cot_poll_vote();
    $poll_form = cot_poll_form($id);
    $t->assign(array('POLLS_TITLE' => cot_parse($poll_form['poll_text'], $cfg['polls']['markup']), 'POLLS_FORM' => $poll_form['poll_block'], 'POLLS_VIEWALL' => cot_rc_link(cot_url('polls', 'id=viewall'), $L['polls_viewarchives'])));
    /* === Hook === */
    foreach (cot_getextplugins('polls.view.tags') as $pl) {
        include $pl;
    }
    /* ===== */