Ejemplo n.º 1
0
/**
 * Returns all page tags for coTemplate
 *
 * @param mixed $page_data Page Info Array or ID
 * @param string $tag_prefix Prefix for tags
 * @param int $textlength Text truncate
 * @param bool $admin_rights Page Admin Rights
 * @param bool $pagepath_home Add home link for page path
 * @param string $emptytitle Page title text if page does not exist
 * @return array
 * @global CotDB $db
 */
function cot_generate_pagetags($page_data, $tag_prefix = '', $textlength = 0, $admin_rights = null, $pagepath_home = false, $emptytitle = '')
{
    global $db, $cot_extrafields, $cfg, $L, $Ls, $R, $db_pages, $usr, $sys, $cot_yesno, $structure, $db_structure;
    static $extp_first = null, $extp_main = null;
    static $pag_auth = array();
    if (is_null($extp_first)) {
        $extp_first = cot_getextplugins('pagetags.first');
        $extp_main = cot_getextplugins('pagetags.main');
    }
    /* === Hook === */
    foreach ($extp_first as $pl) {
        include $pl;
    }
    /* ===== */
    if (!is_array($page_data)) {
        $sql = $db->query("SELECT * FROM {$db_pages} WHERE page_id = '" . (int) $page_data . "' LIMIT 1");
        $page_data = $sql->fetch();
    }
    if ($page_data['page_id'] > 0 && !empty($page_data['page_title'])) {
        if (is_null($admin_rights)) {
            if (!isset($pag_auth[$page_data['page_cat']])) {
                $pag_auth[$page_data['page_cat']] = cot_auth('page', $page_data['page_cat'], 'RWA1');
            }
            $admin_rights = (bool) $pag_auth[$page_data['page_cat']][2];
        }
        $pagepath = cot_structure_buildpath('page', $page_data['page_cat']);
        $catpath = cot_breadcrumbs($pagepath, $pagepath_home);
        $page_data['page_pageurl'] = empty($page_data['page_alias']) ? cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id']) : cot_url('page', 'c=' . $page_data['page_cat'] . '&al=' . $page_data['page_alias']);
        $page_link[] = array($page_data['page_pageurl'], $page_data['page_title']);
        $page_data['page_fulltitle'] = cot_breadcrumbs(array_merge($pagepath, $page_link), $pagepath_home);
        if (!empty($page_data['page_url']) && $page_data['page_file']) {
            $dotpos = mb_strrpos($page_data['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($page_data['page_url'], $dotpos, 5));
            $page_data['page_fileicon'] = cot_rc('page_icon_file_path', array('type' => $type));
            if (!file_exists($page_data['page_fileicon'])) {
                $page_data['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $page_data['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $page_data['page_fileicon']));
        } else {
            $page_data['page_fileicon'] = '';
        }
        $date_format = 'datetime_medium';
        $text = cot_parse($page_data['page_text'], $cfg['page']['markup'], $page_data['page_parser']);
        $text_cut = cot_cut_more($text);
        if ($textlength > 0 && mb_strlen($text_cut) > $textlength) {
            $text_cut = cot_string_truncate($text_cut, $textlength);
        }
        $cutted = mb_strlen($text) > mb_strlen($text_cut) ? true : false;
        $cat_url = cot_url('page', 'c=' . $page_data['page_cat']);
        $validate_url = cot_url('admin', "m=page&a=validate&id={$page_data['page_id']}&x={$sys['xk']}");
        $unvalidate_url = cot_url('admin', "m=page&a=unvalidate&id={$page_data['page_id']}&x={$sys['xk']}");
        $edit_url = cot_url('page', "m=edit&id={$page_data['page_id']}");
        $delete_url = cot_url('page', "m=edit&a=update&delete=1&id={$page_data['page_id']}&x={$sys['xk']}");
        $page_data['page_status'] = cot_page_status($page_data['page_state'], $page_data['page_begin'], $page_data['page_expire']);
        $temp_array = array('URL' => $page_data['page_pageurl'], 'ID' => $page_data['page_id'], 'TITLE' => $page_data['page_fulltitle'], 'ALIAS' => $page_data['page_alias'], 'STATE' => $page_data['page_state'], 'STATUS' => $page_data['page_status'], 'LOCALSTATUS' => $L['page_status_' . $page_data['page_status']], 'SHORTTITLE' => htmlspecialchars($page_data['page_title'], ENT_COMPAT, 'UTF-8', false), 'CAT' => $page_data['page_cat'], 'CATURL' => $cat_url, 'CATTITLE' => htmlspecialchars($structure['page'][$page_data['page_cat']]['title']), 'CATPATH' => $catpath, 'CATPATH_SHORT' => cot_rc_link($cat_url, htmlspecialchars($structure['page'][$page_data['page_cat']]['title'])), 'CATDESC' => htmlspecialchars($structure['page'][$page_data['page_cat']]['desc']), 'CATICON' => $structure['page'][$page_data['page_cat']]['icon'], 'KEYWORDS' => htmlspecialchars($page_data['page_keywords']), 'DESC' => htmlspecialchars($page_data['page_desc']), 'TEXT' => $text, 'TEXT_CUT' => $text_cut, 'TEXT_IS_CUT' => $cutted, 'DESC_OR_TEXT' => !empty($page_data['page_desc']) ? htmlspecialchars($page_data['page_desc']) : $text, 'MORE' => $cutted ? cot_rc('list_more', array('page_url' => $page_data['page_pageurl'])) : '', 'AUTHOR' => htmlspecialchars($page_data['page_author']), 'OWNERID' => $page_data['page_ownerid'], 'OWNERNAME' => htmlspecialchars($page_data['user_name']), 'DATE' => cot_date($date_format, $page_data['page_date']), 'BEGIN' => cot_date($date_format, $page_data['page_begin']), 'EXPIRE' => cot_date($date_format, $page_data['page_expire']), 'UPDATED' => cot_date($date_format, $page_data['page_updated']), 'DATE_STAMP' => $page_data['page_date'], 'BEGIN_STAMP' => $page_data['page_begin'], 'EXPIRE_STAMP' => $page_data['page_expire'], 'UPDATED_STAMP' => $page_data['page_updated'], 'FILE' => $cot_yesno[$page_data['page_file']], 'FILE_URL' => empty($page_data['page_url']) ? '' : cot_url('page', 'c=' . $page_data['page_cat'] . '&id=' . $page_data['page_id'] . '&a=dl'), 'FILE_SIZE' => $page_data['page_size'] / 1024, 'FILE_SIZE_BYTES' => $page_data['page_size'], 'FILE_SIZE_READABLE' => cot_build_filesize($page_data['page_size'], 1), 'FILE_ICON' => $page_data['page_fileicon'], 'FILE_COUNT' => $page_data['page_filecount'], 'FILE_COUNTTIMES' => cot_declension($page_data['page_filecount'], $Ls['Times']), 'FILE_NAME' => basename($page_data['page_url']), 'COUNT' => $page_data['page_count'], 'ADMIN' => $admin_rights ? cot_rc('list_row_admin', array('unvalidate_url' => $unvalidate_url, 'edit_url' => $edit_url)) : '', 'NOTAVAILABLE' => $page_data['page_begin'] > $sys['now'] ? $L['page_notavailable'] . cot_build_timegap($sys['now'], $pag['page_begin']) : '');
        // Admin tags
        if ($admin_rights) {
            $validate_confirm_url = cot_confirm_url($validate_url, 'page', 'page_confirm_validate');
            $unvalidate_confirm_url = cot_confirm_url($unvalidate_url, 'page', 'page_confirm_unvalidate');
            $delete_confirm_url = cot_confirm_url($delete_url, 'page', 'page_confirm_delete');
            $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
            $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            $temp_array['ADMIN_UNVALIDATE'] = $page_data['page_state'] == 1 ? cot_rc_link($validate_confirm_url, $L['Validate'], 'class="confirmLink"') : cot_rc_link($unvalidate_confirm_url, $L['Putinvalidationqueue'], 'class="confirmLink"');
            $temp_array['ADMIN_UNVALIDATE_URL'] = $page_data['page_state'] == 1 ? $validate_confirm_url : $unvalidate_confirm_url;
            $temp_array['ADMIN_DELETE'] = cot_rc_link($delete_confirm_url, $L['Delete'], 'class="confirmLink"');
            $temp_array['ADMIN_DELETE_URL'] = $delete_confirm_url;
        } else {
            if ($usr['id'] == $page_data['page_ownerid']) {
                $temp_array['ADMIN_EDIT'] = cot_rc_link($edit_url, $L['Edit']);
                $temp_array['ADMIN_EDIT_URL'] = $edit_url;
            }
        }
        if (cot_auth('page', 'any', 'W')) {
            $clone_url = cot_url('page', "m=add&c={$page_data['page_cat']}&clone={$page_data['page_id']}");
            $temp_array['ADMIN_CLONE'] = cot_rc_link($clone_url, $L['page_clone']);
            $temp_array['ADMIN_CLONE_URL'] = $clone_url;
        }
        // Extrafields
        if (isset($cot_extrafields[$db_pages])) {
            foreach ($cot_extrafields[$db_pages] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array[$tag . '_TITLE'] = isset($L['page_' . $exfld['field_name'] . '_title']) ? $L['page_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array[$tag] = cot_build_extrafields_data('page', $exfld, $page_data['page_' . $exfld['field_name']], $page_data['page_parser']);
                $temp_array[$tag . '_VALUE'] = $page_data['page_' . $exfld['field_name']];
            }
        }
        // Extra fields for structure
        if (isset($cot_extrafields[$db_structure])) {
            foreach ($cot_extrafields[$db_structure] as $exfld) {
                $tag = mb_strtoupper($exfld['field_name']);
                $temp_array['CAT_' . $tag . '_TITLE'] = isset($L['structure_' . $exfld['field_name'] . '_title']) ? $L['structure_' . $exfld['field_name'] . '_title'] : $exfld['field_description'];
                $temp_array['CAT_' . $tag] = cot_build_extrafields_data('structure', $exfld, $structure['page'][$page_data['page_cat']][$exfld['field_name']]);
                $temp_array['CAT_' . $tag . '_VALUE'] = $structure['page'][$page_data['page_cat']][$exfld['field_name']];
            }
        }
        /* === Hook === */
        foreach ($extp_main as $pl) {
            include $pl;
        }
        /* ===== */
    } else {
        $temp_array = array('TITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted'], 'SHORTTITLE' => !empty($emptytitle) ? $emptytitle : $L['Deleted']);
    }
    $return_array = array();
    foreach ($temp_array as $key => $val) {
        $return_array[$tag_prefix . $key] = $val;
    }
    return $return_array;
}
Ejemplo n.º 2
0
    $sql_pfs_update = $db->query("UPDATE {$db_pfs} SET\n\t\tpfs_desc='" . $db->prep($rdesc) . "',\n\t\tpfs_folderid={$folderid}\n\t\tWHERE pfs_userid={$userid} AND pfs_id={$id}");
    cot_redirect(cot_url('pfs', "f={$pfs_folderid}&" . $more, '', true));
}
/* ============= */
$out['subtitle'] = $L['pfs_title'];
if (!$standalone) {
    require_once $cfg['system_dir'] . '/header.php';
}
$t = new XTemplate(cot_tplfile('pfs.edit'));
if ($standalone) {
    cot_sendheaders();
    $html = Resources::render();
    if ($html) {
        $out['head_head'] = $html . $out['head_head'];
    }
    $t->assign(array('PFS_HEAD' => $out['head_head']));
    $t->parse('MAIN.STANDALONE_HEADER');
    $t->parse('MAIN.STANDALONE_FOOTER');
}
$t->assign(array('PFS_TITLE' => cot_breadcrumbs($title, $cfg['homebreadcrumb']), 'PFS_ACTION' => cot_url('pfs', 'm=edit&a=update&id=' . $pfs_id . '&' . $more), 'PFS_FILE' => $pfs_file, 'PFS_DATE' => cot_date('datetime_medium', $pfs_date), 'PFS_DATE_STAMP' => $pfs_date, 'PFS_FOLDER' => cot_selectbox_folders($userid, '', $pfs_folderid), 'PFS_URL' => $ff, 'PFS_DESC' => cot_inputbox('text', 'rdesc', $pfs_desc, 'size="56" maxlength="255"'), 'PFS_SIZE' => cot_build_filesize($pfs_size_bytes, 1), 'PFS_SIZE_BYTES' => $pfs_size_bytes, 'PFS_SIZE_KB' => $pfs_size_bytes / 1024));
cot_display_messages($t);
/* === Hook === */
foreach (cot_getextplugins('pfs.edit.tags') as $pl) {
    include $pl;
}
/* ===== */
$t->parse('MAIN');
$t->out('MAIN');
if (!$standalone) {
    require_once $cfg['system_dir'] . '/footer.php';
}
Ejemplo n.º 3
0
    if ($files_count > 0) {
        $thumbspagination = $opt == 'thumbs' ? '&opt=thumbs' : '';
        $totalitems = $files_count;
        $pagnavParams = 'f=' . $f;
        if (!empty($more)) {
            $pagnavParams .= '&' . $more;
        }
        $pagnavParams .= $thumbspagination;
        $pagenav = cot_pagenav('pfs', $pagnavParams, $d, $totalitems, $cfg['pfs']['maxpfsperpage']);
        $filesinfolder .= $f > 0 ? $L['pfs_filesinthisfolder'] : $L['pfs_filesintheroot'];
        $t->assign(array('PFS_FILESCOUNT_TITLE' => cot_declension($files_count, $Ls['Files']), 'PFS_ONPAGE_FILES_TITLE' => cot_declension($iji, $Ls['Files']), 'PFS_FILESCOUNT' => $files_count, 'PFS_INTHISFOLDER' => $filesinfolder, 'PFS_ONPAGE_FILES' => $iji, 'PFS_PAGING_PREV' => $pagenav['prev'], 'PFS_PAGING_CURRENT' => $pagenav['main'], 'PFS_PAGING_NEXT' => $pagenav['next']));
    }
}
// ========== Statistics =========
$showthumbs .= $opt != 'thumbs' && $files_count > 0 && $cfg['pfs']['th_amode'] != 'Disabled' ? cot_rc_link(cot_url('pfs', 'f=' . $f . '&' . $more . '&opt=thumbs'), $L['Thumbnails']) : '';
$t->assign(array('PFS_TOTALSIZE' => cot_build_filesize($pfs_totalsize, 1), 'PFS_TOTALSIZE_BYTES' => $pfs_totalsize, 'PFS_TOTALSIZE_KB' => floor($pfs_totalsize / 1024), 'PFS_MAXTOTAL' => cot_build_filesize($maxtotal, 1), 'PFS_MAXTOTAL_BYTES' => $maxtotal, 'PFS_MAXTOTAL_KB' => $maxtotal / 1024, 'PFS_PERCENTAGE' => $maxtotal > 0 ? round($pfs_totalsize / $maxtotal * 100) : 0, 'PFS_MAXFILESIZE' => cot_build_filesize($maxfile, 1), 'PFS_MAXFILESIZE_BYTES' => $maxfile, 'PFS_MAXFILESIZE_KB' => $maxfile / 1024, 'PFS_SHOWTHUMBS' => $showthumbs));
// ========== Upload =========
$t->assign(array('PFS_UPLOAD_FORM_MAX_SIZE' => $maxfile, 'PFS_UPLOAD_FORM_USERID' => $userid));
$t->assign(array('PFS_UPLOAD_FORM_ACTION' => cot_url('pfs', "f={$f}&a=upload&{$more}"), 'PFS_UPLOAD_FORM_FOLDERS' => cot_selectbox_folders($userid, '', $f)));
for ($ii = 0; $ii < $cfg['pfs']['pfsmaxuploads']; $ii++) {
    $t->assign(array('PFS_UPLOAD_FORM_ROW_ID' => $ii, 'PFS_UPLOAD_FORM_ROW_NUM' => $ii + 1));
    $t->parse('MAIN.PFS_UPLOAD_FORM.PFS_UPLOAD_FORM_ROW');
}
$t->parse('MAIN.PFS_UPLOAD_FORM');
// ========== Allowed =========
reset($cot_extensions);
sort($cot_extensions);
foreach ($cot_extensions as $k => $line) {
    $t->assign(array('ALLOWED_ROW_ICON' => $icon[$line[0]], 'ALLOWED_ROW_EXT' => $line[0], 'ALLOWED_ROW_DESC' => $filedesc[$line[0]]));
    $t->parse('MAIN.ALLOWED_ROW');
}
Ejemplo n.º 4
0
$id = cot_import('id', 'G', 'INT');
$v = $db->prep(cot_import('v', 'G', 'TXT'));
$gd_supported = array('jpg', 'jpeg', 'png', 'gif');
list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = cot_auth('pfs', 'a');
// cot_block($usr['auth_read']);
$pos = mb_strlen(mb_stristr($v, '-'));
$fid = mb_substr($v, 0, -$pos);
$imgpath = $cfg['pfs']['pfsuserfolder'] ? $cfg['pfs_dir'] . '/' . $fid . '/' . $v : $cfg['pfs_dir'] . $v;
$dotpos = mb_strrpos($imgpath, '.') + 1;
$f_extension = mb_strtolower(mb_substr($imgpath, $dotpos, 4));
if (!empty($v) && file_exists($imgpath) && in_array($f_extension, $gd_supported)) {
    $pfs_header1 = cot_rc('code_pfs_header', array('metas' => ''));
    $pfs_header2 = $R['code_pfs_header_end'];
    $pfs_footer = $R['code_pfs_footer'];
    $sql_pfs = $db->query("SELECT p.*, u.user_name FROM {$db_pfs} p, {$db_users} u WHERE p.pfs_file=" . $db->quote($v) . " AND p.pfs_userid=u.user_id LIMIT 1");
    if (!($row = $sql_pfs->fetch())) {
        $pfs_owner = $L['SFS'];
    } else {
        $pfs_owner = cot_build_user($row['pfs_userid'], htmlspecialchars($row['user_name']));
    }
    $pfs_img = "<img src=\"" . $imgpath . "\" alt=\"" . $row['pfs_desc'] . "\" />";
    $pfs_imgsize = @getimagesize($imgpath);
    $sql_pfs = $db->query("UPDATE {$db_pfs} SET pfs_count=pfs_count+1 WHERE pfs_file=" . $db->quote($v) . " LIMIT 1");
} else {
    cot_die();
}
/* ============= */
$t = new XTemplate(cot_tplfile('pfs.view'));
$t->assign(array('PFSVIEW_HEADER1' => $pfs_header1, 'PFSVIEW_HEADER2' => $pfs_header2, 'PFSVIEW_FOOTER' => $pfs_footer, 'PFSVIEW_FILE_NAME' => $id, 'PFSVIEW_FILE_DATE' => cot_date('datetime_medium', $row['pfs_date']), 'PFSVIEW_FILE_DATE_STAMP' => $row['pfs_date'], 'PFSVIEW_FILE_ID' => $row['pfs_id'], 'PFSVIEW_FILE_USERID' => $row['pfs_userid'], 'PFSVIEW_FILE_USERNAME' => $pfs_owner, 'PFSVIEW_FILE_DESC' => htmlspecialchars($row['pfs_desc']), 'PFSVIEW_FILE_COUNT' => $row['pfs_count'], 'PFSVIEW_FILE_SIZE' => cot_build_filesize($row['pfs_size'], 1), 'PFSVIEW_FILE_SIZE_BYTES' => $row['pfs_size'], 'PFSVIEW_FILE_SIZEX' => $pfs_imgsize[0], 'PFSVIEW_FILE_SIZEY' => $pfs_imgsize[1], 'PFSVIEW_FILE_IMAGE' => $pfs_img));
$t->parse('MAIN');
$t->out('MAIN');
Ejemplo n.º 5
0
$t->assign(cot_generate_usertags($pag, 'PAGE_OWNER_'));
$pag['page_file'] = intval($pag['page_file']);
if ($pag['page_file'] > 0) {
    if ($sys['now'] > $pag['page_begin']) {
        if (!empty($pag['page_url'])) {
            $dotpos = mb_strrpos($pag['page_url'], ".") + 1;
            $type = mb_strtolower(mb_substr($pag['page_url'], $dotpos, 5));
            $pag['page_fileicon'] = cot_rc('page_icon_file_path');
            if (!file_exists($pag['page_fileicon'])) {
                $pag['page_fileicon'] = cot_rc('page_icon_file_default');
            }
            $pag['page_fileicon'] = cot_rc('page_icon_file', array('icon' => $pag['page_fileicon']));
        } else {
            $pag['page_fileicon'] = '';
        }
        $t->assign(array('PAGE_FILE_SIZE' => $pag['page_size'] / 1024, 'PAGE_FILE_SIZE_BYTES' => $pag['page_size'], 'PAGE_FILE_SIZE_READABLE' => cot_build_filesize($pag['page_size'], 1), 'PAGE_FILE_COUNT' => $pag['page_filecount'], 'PAGE_FILE_ICON' => $pag['page_fileicon'], 'PAGE_FILE_NAME' => basename($pag['page_url']), 'PAGE_FILE_COUNTTIMES' => cot_declension($pag['page_filecount'], $Ls['Times'])));
        if ($pag['page_file'] === 2 && $usr['id'] == 0 || $pag['page_file'] === 2 && !$usr['auth_download']) {
            $t->assign(array('PAGE_FILETITLE' => $L['Members_download'], 'PAGE_FILE_URL' => cot_url('users', 'm=register')));
        } else {
            $t->assign(array('PAGE_FILETITLE' => $pag['page_title'], 'PAGE_FILE_URL' => cot_url('page', array('c' => $pag['page_cat'], 'id' => $id, 'a' => 'dl'))));
        }
    }
}
// Multi tabs
$pag['page_tabs'] = explode('[newpage]', $t->vars['PAGE_TEXT'], 99);
$pag['page_totaltabs'] = count($pag['page_tabs']);
if ($pag['page_totaltabs'] > 1) {
    if (empty($pag['page_tabs'][0])) {
        $remove = array_shift($pag['page_tabs']);
        $pag['page_totaltabs']--;
    }