/** * Метод, предназначенный для получения и вывода списка Запросов * * @param boolean $pagination признак формирования постраничного списка */ function _requestListGet($pagination = true) { global $AVE_DB, $AVE_Template; $limit = ''; // Если используется постраничная навигация if ($pagination) { // Определяем лимит записей на страницу и начало диапазона выборки $limit = $this->_limit; $start = get_current_page() * $limit - $limit; // Получаем общее количество запросов $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request")->GetCell(); // Если количество больше, чем установленный лимит, тогда формируем постраничную навигацию if ($num > $limit) { $page_nav = " <a class=\"pnav\" href=\"index.php?do=request&page={s}&cp=" . SESSION . "\">{t}</a> "; $page_nav = get_pagination(ceil($num / $limit), 'page', $page_nav); $AVE_Template->assign('page_nav', $page_nav); } $limit = $pagination ? "LIMIT " . $start . "," . $limit : ''; } // Выполняем запрос к БД на получение списка запросов с учетом лимита вывода на страницу (если необходимо) $items = array(); $sql = $AVE_DB->Query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . PREFIX . "_request\r\n\t\t\tORDER BY Id ASC\r\n\t\t\t" . $limit . "\r\n\t\t"); // Формируем массив из полученных данных while ($row = $sql->FetchRow()) { $row->request_author = get_username_by_id($row->request_author_id); array_push($items, $row); } // Возвращаем массив return $items; }
/** * 返回国家列表 * @access public */ function index() { $country = get_post_value('country'); $region = get_post_value('region'); $province = get_post_value('province'); $city = get_post_value('city'); $field = array('country.country_id', 'country.country', 'region.region_id', 'region.region', 'province.province_id', 'province.province', 'city.city_id', 'city.city', 'city.status', 'city.orders'); // 排序方法2 $orderby = array('country.orders', 'region.orders', 'province.orders'); $m = new Address(); $m->clear(); $m->setField($field); $m->setWhere('country.status', '!=', '50000'); $m->setWhere('region.status', '!=', '50000'); $m->setWhere('province.status', '!=', '50000'); $m->setWhere('city.status', '!=', '50000'); if ($country != '') { $m->setWhere('country.country_id', '=', $country); } if ($region != '') { $m->setWhere('region.region_id', '=', $region); } if ($province != '') { $m->setWhere('province.province_id', '=', $province); } if ($city != '') { $m->setWhere('city.city', 'LIKE', '%' . $city . '%'); } $m->setTable('vcb_address_country AS country'); $m->setJoin('vcb_address_region as region', 'country.country_id=region.country_id'); $m->setJoin('vcb_address_province as province', 'region.region_id=province.region_id'); $m->setJoin('vcb_address_city as city', 'province.province_id=city.province_id'); $m->setOrderBy($orderby); $count = $m->getRowsCount(); //合计计录数 //分页其他参数 $page = new Page($count); $parameter = array('country' => get_post_value('country')); $page->setParameter($parameter); $showPage = $page->showPage(); $showTotal = $page->showTotal(); $m->setPage(get_current_page()); $data = $m->select(); //状态标题 $count = count($data); for ($i = 0; $i < $count; $i++) { $status = $data[$i]['status']; $data[$i]['status_name'] = $m->getStatus($status); } $this->assign('data', $data); //输出数据 $this->assign('showPage', $showPage); //输出分页 $this->assign('showTotal', $showTotal); //输出分页合计 $r = $m->getRegion($country); $this->assign('region', $r); $p = $m->getProvince($region); $this->assign('province', $p); }
function render_ui($ui_page, $title = null) { $page =& get_current_page(); $renderer =& get_renderer(); $layout_page = load_layout_page($ui_page); if ($layout_page !== null) { if (empty($title)) { $title = $page->title; } if (empty($title)) { $title = $page->name; } $vars = new_global_wiki_variables(); $vars->set('title', $title); $info_text = get_info_text(); if (count($info_text) > 0) { $vars->set('info_text', implode(' ', $info_text)); } $redirected_page =& get_redirected_page(); if ($redirected_page !== null) { $vars->set('redir_page', $redirected_page->name); } $layout_page->render($vars); } }
function do_pages($total, $page_size = 15) { global $db; if ($total < $page_size) { return; } $query = preg_replace('/page=[0-9]+/', '', $_SERVER['QUERY_STRING']); $query = preg_replace('/^&*(.*)&*$/', "\$1", $query); if (!empty($query)) { $query = htmlspecialchars($query); $query = "&{$query}"; } $current = get_current_page(); $total_pages = ceil($total / $page_size); echo '<div class="pages">'; if ($current == 1) { echo '<span class="nextprev">«</span>'; } else { $i = $current - 1; echo '<a href="?page=' . $i . $query . '">«</a>'; } echo '<span class="current">' . $current . '</span>'; if ($current < $total_pages) { $i = $current + 1; echo '<a href="?page=' . $i . $query . '">»</a>'; } else { echo '<span class="nextprev">»</span>'; } echo "</div>\n"; }
function group_read($from_where, $order_by) { global $db, $main_smarty, $view, $user, $rows, $page_size, $offset; // figure out what "page" of the results we're on $offset = (get_current_page() - 1) * $page_size; // pagesize set in the admin panel $search->pagesize = $page_size; if ($order_by == "") { $order_by = "group_date DESC"; } include_once mnminclude . 'smartyvariables.php'; global $db, $main_smarty; $rows = $db->get_var("SELECT count(*) FROM " . table_groups . " WHERE " . $from_where . " "); $group = $db->get_results("SELECT distinct(group_id) as group_id FROM " . table_groups . " WHERE " . $from_where . " ORDER BY group_status DESC, " . $order_by . " LIMIT {$offset},{$page_size} "); if ($group) { foreach ($group as $groupid) { $group_display .= group_print_summary($groupid->group_id); } $main_smarty->assign('group_display', $group_display); } if (Auto_scroll == 2 || Auto_scroll == 3) { $main_smarty->assign("scrollpageSize", $page_size); } else { $main_smarty->assign('group_pagination', do_pages($rows, $page_size, "groups", true)); } return true; }
/** * 架构函数 * @param array $totalRows 总的记录数 * @param array $listRows 每页显示记录数 * @param array $parameter 分页跳转的参数 */ public function __construct($totalRows, $listRows = null, $parameter = array()) { /* 基础设置 */ $this->_url = CURRENT_URL ; $this->totalRows = $totalRows; //设置总记录数 $this->listRows = !isset($listRows) ? DEFAULT_LIMIT : $listRows; // 设置每页显示行数 $this->parameter = empty ( $parameter ) ? '' : $parameter; $this->_currentPage = get_current_page(); $this->_currentPage = $this->_currentPage >0 ? $this->_currentPage :1; }
/** * @param string $include * @param string $page (optional) */ function include_template_part($include, $page = "") { global $pwt; if (!file_exists(dirname(__FILE__) . "/tpl/{$include}.php")) { trigger_error("Template {$include}.php not found.", E_USER_WARNING); return; } $page = $page === "" ? get_current_page() : explode("/", $page); $home = get_relative_home_path($page); include dirname(__FILE__) . "/tpl/{$include}.php"; }
function doPages($page_size, $thepage, $query_string, $total = 0) { //per page count $index_limit = 5; //set the query string to blank, then later attach it with $query_string $query = ''; if (strlen($query_string) > 0) { $query = "&" . $query_string; } //get the current page number example: 3, 4 etc: see above method description $current = get_current_page(); $total_pages = ceil($total / $page_size); $start = max($current - intval($index_limit / 2), 1); $end = $start + $index_limit - 1; $pagging = '<div class="paging">'; if ($current == 1) { $pagging .= '<span class="prn">< Previous</span> '; } else { $i = $current - 1; $pagging .= '<a class="prn" title="go to page ' . $i . '" rel="nofollow" href="' . $thepage . '?page=' . $i . $query . '">< Previous</a> '; $pagging .= '<span class="prn">...</span> '; } if ($start > 1) { $i = 1; $pagging .= '<a title="go to page ' . $i . '" href="' . $thepage . '?page=' . $i . $query . '">' . $i . '</a> '; } for ($i = $start; $i <= $end && $i <= $total_pages; $i++) { if ($i == $current) { $pagging .= '<span>' . $i . '</span> '; } else { $pagging .= '<a title="go to page ' . $i . '" href="' . $thepage . '?page=' . $i . $query . '">' . $i . '</a> '; } } if ($total_pages > $end) { $i = $total_pages; $pagging .= '<a title="go to page ' . $i . '" href="' . $thepage . '?page=' . $i . $query . '">' . $i . '</a> '; } if ($current < $total_pages) { $i = $current + 1; $pagging .= '<span class="prn">...</span> '; $pagging .= '<a class="prn" title="go to page ' . $i . '" rel="nofollow" href="' . $thepage . '?page=' . $i . $query . '">Next ></a> '; } else { $pagging .= '<span class="prn">Next ></span> '; } //if nothing passed to method or zero, then dont print result, else print the total count below: if ($total != 0) { //prints the total result count just below the paging $pagging .= '(' . $total . ' Records)'; } $pagging .= '</div>'; return $pagging; }
function doPages($page_size, $thepage, $query_string, $total = 0) { //per page count $index_limit = 10; //set the query string to blank, then later attach it with $query_string $query = ''; if (strlen($query_string) > 0) { $query = "&" . $query_string; } //get the current page number example: 3, 4 etc: see above method description $current = get_current_page(); $total_pages = ceil($total / $page_size); $start = max($current - intval($index_limit / 2), 1); $end = $start + $index_limit - 1; echo '<br /><br /><div class="paging">'; if ($current == 1) { echo '<span class="prn">< Previous</span> '; } else { $i = $current - 1; echo '<a href="' . $thepage . '?page=' . $i . $query . '" class="prn" rel="nofollow" title="go to page ' . $i . '">< Previous</a> '; echo '<span class="prn">...</span> '; } if ($start > 1) { $i = 1; echo '<a href="' . $thepage . '?page=' . $i . $query . '" title="go to page ' . $i . '">' . $i . '</a> '; } for ($i = $start; $i <= $end && $i <= $total_pages; $i++) { if ($i == $current) { echo '<span>' . $i . '</span> '; } else { echo '<a href="' . $thepage . '?page=' . $i . $query . '" title="go to page ' . $i . '">' . $i . '</a> '; } } if ($total_pages > $end) { $i = $total_pages; echo '<a href="' . $thepage . '?page=' . $i . $query . '" title="go to page ' . $i . '">' . $i . '</a> '; } if ($current < $total_pages) { $i = $current + 1; echo '<span class="prn">...</span> '; echo '<a href="' . $thepage . '?page=' . $i . $query . '" class="prn" rel="nofollow" title="go to page ' . $i . '">Next ></a> '; } else { echo '<span class="prn">Next ></span> '; } //if nothing passed to method or zero, then dont print result, else print the total count below: if ($total != 0) { //prints the total result count just below the paging echo '<p id="total_count">(total ' . $total_pages . ' page)</p></div>'; } }
function get_user_posts($user_id = 0) { global $conn; $post_per_page = get_posts_per_page(); $current_page = get_current_page(); $offset = ($current_page - 1) * $post_per_page; $posts_query = "SELECT *\n\t\tFROM posts\n\t\tWHERE user_id={$user_id}\n\t\tORDER BY publish_date DESC\n\t\tLIMIT {$offset}, {$post_per_page}"; $posts_query = mysqli_query($conn, $posts_query); $all_posts = array(); // $counter = 0; while ($post = mysqli_fetch_assoc($posts_query)) { // $all_posts[$counter++] = $post; $all_posts[] = $post; } return $all_posts; }
/** * Постраничная навигация документа * * @param string $text текст многострочной части документа * @return string */ function document_pagination($text) { global $AVE_Core; // IE8 <div style="page-break-after: always"><span style="display: none"> </span></div> // Chrome <div style="page-break-after: always; "><span style="DISPLAY:none"> </span></div> // FF <div style="page-break-after: always;"><span style="display: none;"> </span></div> $pages = preg_split('#<div style="page-break-after:[; ]*always[; ]*"><span style="display:[ ]*none[;]*"> </span></div>#i', $text); $total_page = @sizeof($pages); if ($total_page > 1) { $text = @$pages[get_current_page('artpage') - 1]; $page_nav = ' <a class="pnav" href="index.php?id=' . $AVE_Core->curentdoc->Id . '&doc=' . (empty($AVE_Core->curentdoc->document_alias) ? prepare_url($AVE_Core->curentdoc->document_title) : $AVE_Core->curentdoc->document_alias) . '&artpage={s}' . '">{t}</a> '; $page_nav = get_pagination($total_page, 'artpage', $page_nav, get_settings('navi_box')); $text .= rewrite_link($page_nav); } return $text; }
/** * Вывод списка рубрик * */ function rubricList() { global $AVE_DB, $AVE_Template; $rubrics = array(); $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_rubrics")->GetCell(); $page_limit = $this->_limit; $seiten = ceil($num / $page_limit); $set_start = get_current_page() * $page_limit - $page_limit; if ($num > $page_limit) { $page_nav = " <a class=\"pnav\" href=\"index.php?do=rubs&page={s}&cp=" . SESSION . "\">{t}</a> "; $page_nav = get_pagination($seiten, 'page', $page_nav); $AVE_Template->assign('page_nav', $page_nav); } $sql = $AVE_DB->Query("\r\n\t\t\tSELECT\r\n\t\t\t\trub.*,\r\n\t\t\t\tCOUNT(doc.Id) AS doc_count\r\n\t\t\tFROM\r\n\t\t\t\t" . PREFIX . "_rubrics AS rub\r\n\t\t\tLEFT JOIN\r\n\t\t\t\t" . PREFIX . "_documents AS doc\r\n\t\t\t\t\tON rubric_id = rub.Id\r\n\t\t\tGROUP BY rub.Id\r\n\t\t\tLIMIT " . $set_start . "," . $page_limit); while ($row = $sql->FetchRow()) { array_push($rubrics, $row); } $AVE_Template->assign('rubrics', $rubrics); }
/** * Административная часть (задачи) */ function roadmapTaskList($tpl_dir, $project_id, $status) { global $AVE_DB, $AVE_Template; $project_id = (int) $project_id; $status = (int) $status; $limit = $this->_limit; $num = $AVE_DB->Query("\r\n\t\t\tSELECT COUNT(*)\r\n\t\t\tFROM " . PREFIX . "_modul_roadmap_tasks\r\n\t\t\tWHERE pid = '" . $project_id . "'\r\n\t\t\tAND task_status = '" . $status . "'\r\n\t\t")->GetCell(); $pages = ceil($num / $limit); $start = get_current_page() * $limit - $limit; $items = array(); $sql = $AVE_DB->Query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . PREFIX . "_modul_roadmap_tasks\r\n\t\t\tWHERE pid = '" . $project_id . "'\r\n\t\t\tAND task_status = '" . $status . "'\r\n\t\t\tORDER BY priority\r\n\t\t\tLIMIT " . $start . "," . $limit); while ($row = $sql->FetchRow()) { $row->username = get_username_by_id($row->uid); switch ($row->priority) { case '1': $row->priority = $AVE_Template->get_config_vars('ROADMAP_TASK_HIGHEST'); break; case '2': $row->priority = $AVE_Template->get_config_vars('ROADMAP_TASK_HIGH'); break; case '3': $row->priority = $AVE_Template->get_config_vars('ROADMAP_TASK_NORMAL'); break; case '4': $row->priority = $AVE_Template->get_config_vars('ROADMAP_TASK_LOW'); break; case '5': $row->priority = $AVE_Template->get_config_vars('ROADMAP_TASK_LOWEST'); break; } array_push($items, $row); } if ($num > $limit) { $page_nav = " <a class=\"pnav\" href=\"index.php?do=modules&action=modedit&mod=roadmap&moduleaction=show_tasks&closed=" . $status . "&id=" . $project_id . "&cp=" . SESSION . "&page={s}\">{t}</a> "; $page_nav = get_pagination($pages, 'page', $page_nav); $AVE_Template->assign('page_nav', $page_nav); } $AVE_Template->assign('items', $items); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_tasks.tpl')); }
function get_page_nav() { global $smarty_q, $config_q; $current_page = get_current_page(); $quotes_count = $smarty_q->get_template_vars("quotes_count"); $max_pages = floor($quotes_count / $config_q["quotes_on_page"]); $start = $current_page - 10; $end = $current_page + 10; $pages = array(); $k = 1; for ($i = $start; $i < $end; $i++) { if ($i > 0 && $i <= $max_pages) { $pages[$k] = array("caption" => $i, "index" => $k); if ($i == $current_page) { $pages[$k]["selected"] = true; } else { $pages[$k]["selected"] = false; } $k++; } } return $pages; }
} if (isset($_REQUEST['search'])) { $search->filterToStatus = "all"; } if (!isset($_REQUEST['search'])) { $search->orderBy = "link_published_date DESC, link_date DESC"; } if (isset($_REQUEST['tag'])) { $search->searchTerm = sanitize($_REQUEST['search'], 3); $search->isTag = true; } if (isset($thecat)) { $search->category = $catID; } // figure out what "page" of the results we're on $search->offset = (get_current_page() - 1) * $page_size; // pagesize set in the admin panel $search->pagesize = $page_size; // since this is index, we only want to view "published" stories $search->filterToStatus = "published"; // this is for the tabs on the top that filter if (isset($_GET['part'])) { $search->setmek = $db->escape($_GET['part']); } $search->do_setmek(); // do the search $search->doSearch(); $linksum_count = $search->countsql; $linksum_sql = $search->sql; if (isset($_REQUEST['category'])) { $category_data = get_cached_category_data('category_safe_name', sanitize($_REQUEST['category'], 1));
/** * Постраничная навигация для запросов и модулей * * @param int $total_pages количество страниц в документе * @param string $type тип постраничной навигации, * допустимые значения: page, apage, artpage * @param string $template_label шаблон метки навигации * @param string $navi_box контейнер постраничной навигации * @return string HTML-код постраничной навигации */ function get_pagination($total_pages, $type, $template_label, $navi_box = '') { $nav = ''; if (!in_array($type, array('page', 'apage', 'artpage'))) { $type = 'page'; } $curent_page = get_current_page($type); if ($curent_page == 1) { $seiten = array($curent_page, $curent_page + 1, $curent_page + 2, $curent_page + 3, $curent_page + 4); } elseif ($curent_page == 2) { $seiten = array($curent_page - 1, $curent_page, $curent_page + 1, $curent_page + 2, $curent_page + 3); } elseif ($curent_page + 1 == $total_pages) { $seiten = array($curent_page - 3, $curent_page - 2, $curent_page - 1, $curent_page, $curent_page + 1); } elseif ($curent_page == $total_pages) { $seiten = array($curent_page - 4, $curent_page - 3, $curent_page - 2, $curent_page - 1, $curent_page); } else { $seiten = array($curent_page - 2, $curent_page - 1, $curent_page, $curent_page + 1, $curent_page + 2); } $seiten = array_unique($seiten); $total_label = trim(get_settings('total_label')); $start_label = trim(get_settings('start_label')); $end_label = trim(get_settings('end_label')); $separator_label = trim(get_settings('separator_label')); $next_label = trim(get_settings('next_label')); $prev_label = trim(get_settings('prev_label')); if ($total_pages > 5 && $curent_page > 3) { //Первая $nav .= '<li>' . str_replace('{t}', $start_label, str_replace(array('&' . $type . '={s}', '&' . $type . '={s}', '/' . $type . '-{s}'), '', $template_label)) . '</li>'; if ($separator_label != '') { $nav .= '<li>' . $separator_label . '</li>'; } } if ($curent_page > 1) { if ($curent_page == 2) { //$nav .= str_replace('{t}', $prev_label, str_replace(array('&'.$type.'={s}','&'.$type.'={s}'), '', $template_label)); //ХЗ $nav .= '<li>' . str_replace('{t}', $prev_label, str_replace(array('&' . $type . '={s}', '&' . $type . '={s}', '/' . $type . '-{s}'), '', $template_label)) . '</li>'; } else { //$nav .= str_replace('{t}', $prev_label, str_replace('{s}', ($curent_page - 1), $template_label)); //Предыдущая $nav .= '<li>' . str_replace('{t}', $prev_label, str_replace('{s}', $curent_page - 1, $template_label)) . '</li>'; } } // while (list(,$val) = each($seiten)) foreach ($seiten as $val) { if ($val >= 1 && $val <= $total_pages) { if ($curent_page == $val) { //Текущая $nav .= str_replace(array('{s}', '{t}'), $val, '<li class="active"><a class="active">' . $curent_page . '</a></li>'); } else { if ($val == 1) { $nav .= '<li>' . str_replace('{t}', $val, str_replace(array('&' . $type . '={s}', '&' . $type . '={s}', '/' . $type . '-{s}'), '', $template_label)) . '</li>'; } else { //Остальные неактивные $nav .= '<li>' . str_replace(array('{s}', '{t}'), $val, $template_label) . '</li>'; } } } } if ($curent_page < $total_pages) { //$nav .= str_replace('{t}', $next_label, str_replace('{s}', ($curent_page + 1), $template_label)); //Сдедующая $nav .= '<li>' . str_replace('{t}', $next_label, str_replace('{s}', $curent_page + 1, $template_label)) . '</li>'; } if ($total_pages > 5 && $curent_page < $total_pages - 2) { if ($separator_label != '') { $nav .= '<li>' . $separator_label . '</li>'; } //Последняя $nav .= '<li>' . str_replace('{t}', $end_label, str_replace('{s}', $total_pages, $template_label)) . '</li>'; } if ($nav != '') { //Страница ХХХ из ХХХ if ($total_label != '') { $nav = '<span class="pages">' . sprintf($total_label, $curent_page, $total_pages) . '</span> ' . $nav; } if ($navi_box != '') { $nav = sprintf($navi_box, $nav); } } return $nav; }
function do_pages($total, $page_size = 25, $margin = true) { global $db, $globals; if ($total > 0 && $total < $page_size) { return; } // MDOMENECH if (1 || !$globals['mobile']) { $index_limit = 5; $go_prev = _('previous'); $go_next = _('next'); } else { $index_limit = 1; $go_prev = ''; $go_next = ''; } $separator = '…'; $query = preg_replace('/page=[0-9]+/', '', $_SERVER['QUERY_STRING']); $query = preg_replace('/^&*(.*)&*$/', "\$1", $query); if (!empty($query)) { $query = htmlspecialchars($query); $query = "&{$query}"; } $current = get_current_page(); $total_pages = ceil($total / $page_size); $start = max($current - intval($index_limit / 2), 1); $end = $start + $index_limit - 1; if ($margin) { echo '<div class="pages margin">'; } else { echo '<div class="pages">'; } // MDOMENECH echo '<ul class="pagination">'; if ($current == 1) { echo '<li><span class="nextprev">' . $go_prev . '</span></li>'; } else { $i = $current - 1; if ($i > 10) { $nofollow = ' rel="nofollow"'; } else { $nofollow = ''; } echo '<li><a href="?page=' . $i . $query . '"' . $nofollow . ' rel="prev">' . $go_prev . '</a></li>'; } if ($total_pages > 0) { if ($start > 1) { $i = 1; echo '<li><a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a></li>'; } for ($i = $start; $i <= $end && $i <= $total_pages; $i++) { if ($i == $current) { echo '<li><span class="current">' . $i . '</span></li>'; } else { if ($i > 10) { $nofollow = ' rel="nofollow"'; } else { $nofollow = ''; } echo '<li><a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '"' . $nofollow . '>' . $i . '</a></li>'; } } if ($total_pages > $end) { $i = $total_pages; if ($i > 10) { $nofollow = ' rel="nofollow"'; } else { $nofollow = ''; } echo '<li><a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '"' . $nofollow . '>' . $i . '</a></li>'; } } else { if ($current > 2) { echo '<li><a href="?page=1' . $query . '" title="' . _('ir a página') . " 1" . '">1</a></li>'; } echo '<li><span class="current">' . $current . '</span></li>'; } if ($total < 0 || $current < $total_pages) { $i = $current + 1; if ($i > 10) { $nofollow = ' rel="nofollow"'; } else { $nofollow = ''; } echo '<li><a href="?page=' . $i . $query . '"' . $nofollow . ' rel="next">' . $go_next . '</a></li>'; } else { echo '<li><span class="nextprev">' . $go_next . '</span></li>'; } echo '</ul><!-- pagination -->'; echo '</div>'; }
<!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta charset="utf-8"> <?php $page = get_current_page(); if (!isset($sub_title)) { $sub_title = isset($page['title']) ? $page['title'] : lang_key('list_your_ad'); } $seo = isset($page['seo_settings']) && $page['seo_settings'] != '' ? (array) json_decode($page['seo_settings']) : array(); if (!isset($meta_desc)) { $meta_desc = isset($seo['meta_description']) ? $seo['meta_description'] : get_settings('site_settings', 'meta_description', 'autocon car dealership'); } if (!isset($key_words)) { $key_words = isset($seo['key_words']) ? $seo['key_words'] : get_settings('site_settings', 'key_words', 'car dealership,car listing, house, car'); } if (!isset($crawl_after)) { $crawl_after = isset($seo['crawl_after']) ? $seo['crawl_after'] : get_settings('site_settings', 'crawl_after', 3); } ?> <?php if (isset($post)) { echo isset($post) ? social_sharing_meta_tags_for_post($post) : ''; } elseif (isset($blog_meta)) {
/** * Обработка тега запроса. * Возвращает список документов удовлетворяющих параметрам запроса * оформленный с использованием шаблона * * @param int $id идентификатор запроса * @return string */ function request_parse($id) { global $AVE_Core, $AVE_DB, $request_documents; $return = ''; if (is_array($id)) { $id = $id[1]; } $row_ab = $AVE_DB->Query("\r\n\t\tSELECT *\r\n\t\tFROM " . PREFIX . "_request\r\n\t\tWHERE Id = '" . $id . "'\r\n\t")->FetchRow(); if (is_object($row_ab)) { $ttl = (int) $row_ab->request_cache_lifetime; $limit = $row_ab->request_items_per_page < 1 ? 1 : $row_ab->request_items_per_page; $main_template = $row_ab->request_template_main; $item_template = $row_ab->request_template_item; $request_order_by = $row_ab->request_order_by; $request_asc_desc = $row_ab->request_asc_desc; $request_order = $request_order_by . " " . $request_asc_desc; $request_order_fields = ''; $request_order_tables = ''; if ($row_ab->request_order_by_nat) { $request_order_tables = "LEFT JOIN " . PREFIX . "_document_fields AS s" . $row_ab->request_order_by_nat . "\r\n\t\t\t ON (s" . $row_ab->request_order_by_nat . ".document_id = a.Id and s" . $row_ab->request_order_by_nat . ".rubric_field_id=" . $row_ab->request_order_by_nat . ")"; $request_order_fields = "s" . $row_ab->request_order_by_nat . ".field_value, "; $request_order = "s" . $row_ab->request_order_by_nat . ".field_value " . $row_ab->request_asc_desc; } $doctime = get_settings('use_doctime') ? "AND a.document_published <= UNIX_TIMESTAMP() AND\r\n \t\t \t(a.document_expire = 0 OR a.document_expire >=UNIX_TIMESTAMP())" : ''; $where_cond = empty($_POST['req_' . $id]) && empty($_SESSION['doc_' . $AVE_Core->curentdoc->Id]['req_' . $id]) ? unserialize($row_ab->request_where_cond) : unserialize(request_get_condition_sql_string($row_ab->Id)); $where_cond['from'] = str_replace('%%PREFIX%%', PREFIX, $where_cond['from']); $where_cond['where'] = str_replace('%%PREFIX%%', PREFIX, $where_cond['where']); if ($row_ab->request_show_pagination == 1) { if (!empty($AVE_Core->install_modules['comment']->Status)) { $num = $AVE_DB->Query(eval2var(" ?> \r\n\t\t\t\t\tSELECT COUNT(*)\r\n\t\t\t\t\tFROM \r\n\t\t\t\t\t" . ($where_cond['from'] ? $where_cond['from'] : '') . "\r\n\t\t\t\t\t" . PREFIX . "_documents AS a\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\ta.Id != '1'\r\n\t\t\t\t\tAND a.Id != '" . PAGE_NOT_FOUND_ID . "'\r\n\t\t\t\t\tAND a.Id != '" . get_current_document_id() . "'\r\n\t\t\t\t\tAND a.rubric_id = '" . $row_ab->rubric_id . "'\r\n\t\t\t\t\tAND a.document_deleted != '1'\r\n\t\t\t\t\tAND a.document_status != '0'\r\n\t\t\t\t\t" . $where_cond['where'] . "\r\n\t\t\t\t\t" . $doctime . "\r\n\t\t\t\t<?php "), $ttl, 'rub_' . $row_ab->rubric_id)->GetCell(); } else { $num = $AVE_DB->Query(eval2var(" ?>\r\n\t\t\t\t\tSELECT COUNT(*)\r\n\t\t\t\t\tFROM \r\n\t\t\t\t\t" . ($where_cond['from'] ? $where_cond['from'] : '') . "\r\n\t\t\t\t\t" . PREFIX . "_documents AS a\r\n\t\t\t\t\tWHERE\r\n\t\t\t\t\t\ta.Id != '1'\r\n\t\t\t\t\tAND a.Id != '" . PAGE_NOT_FOUND_ID . "'\r\n\t\t\t\t\tAND a.Id != '" . get_current_document_id() . "'\r\n\t\t\t\t\tAND a.rubric_id = '" . $row_ab->rubric_id . "'\r\n\t\t\t\t\tAND a.document_deleted != '1'\r\n\t\t\t\t\tAND a.document_status != '0'\r\n\t\t\t\t\t" . $where_cond['where'] . "\r\n\t\t\t\t\t" . $doctime . "\r\n\t\t\t\t<?php "), $ttl, 'rub_' . $row_ab->rubric_id)->GetCell(); } $seiten = ceil($num / $limit); if (isset($_REQUEST['apage']) && is_numeric($_REQUEST['apage']) && $_REQUEST['apage'] > $seiten) { $redirect_link = rewrite_link('index.php?id=' . $AVE_Core->curentdoc->Id . '&doc=' . (empty($AVE_Core->curentdoc->document_alias) ? prepare_url($AVE_Core->curentdoc->document_title) : $AVE_Core->curentdoc->document_alias) . (isset($_REQUEST['artpage']) && is_numeric($_REQUEST['artpage']) ? '&artpage=' . $_REQUEST['artpage'] : '') . (isset($_REQUEST['page']) && is_numeric($_REQUEST['page']) ? '&page=' . $_REQUEST['page'] : '')); header('Location:' . $redirect_link); exit; } $start = get_current_page('apage') * $limit - $limit; } else { $start = 0; } if ($row_ab->request_items_per_page != 0) { $filter_limit = "LIMIT " . $start . "," . $limit; } if (!empty($AVE_Core->install_modules['comment']->Status)) { $q = " ?>\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t" . $request_order_fields . "\r\n\t\t\t\t\ta.Id,\r\n\t\t\t\t\ta.document_title,\r\n\t\t\t\t\ta.document_alias,\r\n\t\t\t\t\ta.document_author_id,\r\n\t\t\t\t\ta.document_count_view,\r\n\t\t\t\t\ta.document_published,\r\n\t\t\t\t\tCOUNT(b.document_id) AS nums\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . ($where_cond['from'] ? $where_cond['from'] : '') . "\r\n\t\t\t\t\t" . PREFIX . "_documents AS a\r\n\t\t\t\tLEFT JOIN\r\n\t\t\t\t\t" . PREFIX . "_modul_comment_info AS b\r\n\t\t\t\t\t\tON b.document_id = a.Id\r\n\t\t\t\t " . ($request_order_tables > '' ? $request_order_tables : '') . "\t\r\n\t\t\t\tWHERE\r\n\t\t\t\t\ta.Id != '1'\r\n\t\t\t\tAND a.Id != '" . PAGE_NOT_FOUND_ID . "'\r\n\t\t\t\tAND a.Id != '" . get_current_document_id() . "'\r\n\t\t\t\tAND a.rubric_id = '" . $row_ab->rubric_id . "'\r\n\t\t\t\tAND a.document_deleted != '1'\r\n\t\t\t\tAND a.document_status != '0'\r\n\t\t\t\t" . $where_cond['where'] . "\r\n\t\t\t\t" . $doctime . "\r\n\t\t\t\tGROUP BY a.Id\r\n\t\t\t\tORDER BY " . $request_order . "\r\n\t\t\t\t" . $filter_limit . " <?php "; } else { $q = " ?>\r\n\t\t\t\tSELECT\r\n\t\t\t\t\t" . $request_order_fields . "\r\n\t\t\t\t\ta.Id,\r\n\t\t\t\t\ta.document_title,\r\n\t\t\t\t\ta.document_alias,\r\n\t\t\t\t\ta.document_author_id,\r\n\t\t\t\t\ta.document_count_view,\r\n\t\t\t\t\ta.document_published\r\n\t\t\t\tFROM\r\n\t\t\t\t\t" . ($where_cond['from'] ? $where_cond['from'] : '') . "\r\n\t\t\t\t\t\r\n\t\t\t\t\t" . PREFIX . "_documents AS a\r\n\t\t\t\t\t" . ($request_order_tables > '' ? $request_order_tables : "") . "\r\n\t\t\t\tWHERE\r\n\t\t\t\t\ta.Id != '1'\r\n\t\t\t\tAND a.Id != '" . PAGE_NOT_FOUND_ID . "'\r\n\t\t\t\tAND a.Id != '" . get_current_document_id() . "'\r\n\t\t\t\tAND a.rubric_id = '" . $row_ab->rubric_id . "'\r\n\t\t\t\tAND a.document_deleted != '1'\r\n\t\t\t\tAND a.document_status != '0'\r\n\t\t\t\t" . $where_cond['where'] . "\r\n\t\t\t\t" . $doctime . "\r\n\t\t\t\tORDER BY " . $request_order . "\r\n\t\t\t\t" . $filter_limit . " <?php "; } $q = eval2var($q); $q = $AVE_DB->Query($q, $ttl, 'rub_' . $row_ab->rubric_id); if ($q->NumRows() > 0) { $main_template = preg_replace('/\\[tag:if_empty](.*?)\\[\\/tag:if_empty]/si', '', $main_template); $main_template = str_replace(array('[tag:if_notempty]', '[/tag:if_notempty]'), '', $main_template); } else { $main_template = preg_replace('/\\[tag:if_notempty](.*?)\\[\\/tag:if_notempty]/si', '', $main_template); $main_template = str_replace(array('[tag:if_empty]', '[/tag:if_empty]'), '', $main_template); } $page_nav = ''; if ($row_ab->request_show_pagination == 1 && $seiten > 1 && $row_ab->request_items_per_page != 0) { $page_nav = ' <a class="pnav" href="index.php?id=' . $AVE_Core->curentdoc->Id . '&doc=' . (empty($AVE_Core->curentdoc->document_alias) ? prepare_url($AVE_Core->curentdoc->document_title) : $AVE_Core->curentdoc->document_alias) . (isset($_REQUEST['artpage']) && is_numeric($_REQUEST['artpage']) ? '&artpage=' . $_REQUEST['artpage'] : '') . '&apage={s}' . (isset($_REQUEST['page']) && is_numeric($_REQUEST['page']) ? '&page=' . $_REQUEST['page'] : '') . '">{t}</a> '; $page_nav = get_pagination($seiten, 'apage', $page_nav, get_settings('navi_box')); $page_nav = rewrite_link($page_nav); } $rows = array(); $request_documents = array(); while ($row = $q->FetchRow()) { array_push($request_documents, $row->Id); array_push($rows, $row); } $items = ''; foreach ($rows as $row) { $cachefile_docid = BASE_DIR . '/cache/sql/doc_' . $row->Id . '/request-' . $id . '.cache'; if (!file_exists($cachefile_docid)) { $item = preg_replace('/\\[tag:rfld:(\\d+)]\\[(more|esc|[0-9-]+)]/e', "request_get_document_field(\"\$1\", {$row->Id}, \"\$2\")", $item_template); //if(!file_exists(dirname($cachefile_docid)))mkdir(dirname($cachefile_docid),0777,true); //file_put_contents($cachefile_docid,$item); } else { $item = file_get_contents($cachefile_docid); } $link = rewrite_link('index.php?id=' . $row->Id . '&doc=' . (empty($row->document_alias) ? prepare_url($row->document_title) : $row->document_alias)); $item = str_replace('[tag:link]', $link, $item); $item = str_replace('[tag:docid]', $row->Id, $item); $item = str_replace('[tag:doctitle]', $row->document_title, $item); $item = str_replace('[tag:docparent]', $row->document_parent, $item); $item = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $row->document_published)), $item); $item = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $row->document_published)), $item); $item = str_replace('[tag:docauthor]', get_username_by_id($row->document_author_id), $item); $item = str_replace('[tag:docviews]', $row->document_count_view, $item); $item = str_replace('[tag:doccomments]', isset($row->nums) ? $row->nums : '', $item); $items .= $item; } $main_template = str_replace('[tag:pages]', $page_nav, $main_template); $main_template = str_replace('[tag:doctotal]', $seiten * $q->NumRows(), $main_template); $main_template = str_replace('[tag:pagetitle]', $AVE_DB->Query("SELECT document_title FROM " . PREFIX . "_documents WHERE Id = '" . $AVE_Core->curentdoc->Id . "' ")->GetCell(), $main_template); $main_template = str_replace('[tag:docid]', $AVE_Core->curentdoc->Id, $main_template); $main_template = str_replace('[tag:docdate]', pretty_date(strftime(DATE_FORMAT, $AVE_Core->curentdoc->document_published)), $main_template); $main_template = str_replace('[tag:doctime]', pretty_date(strftime(TIME_FORMAT, $AVE_Core->curentdoc->document_published)), $main_template); $main_template = str_replace('[tag:docauthor]', get_username_by_id($AVE_Core->curentdoc->document_author_id), $main_template); $main_template = preg_replace('/\\[tag:dropdown:([,0-9]+)\\]/e', "request_get_dropdown(\"\$1\", " . $row_ab->rubric_id . ", " . $row_ab->Id . ");", $main_template); $return = str_replace('[tag:content]', $items, $main_template); $return = str_replace('[tag:path]', ABS_PATH, $return); $return = str_replace('[tag:mediapath]', ABS_PATH . 'templates/' . THEME_FOLDER . '/', $return); $return = $AVE_Core->coreModuleTagParse($return); } return $return; }
/** * Метод вывода списка опросов * * @param string $tpl_dir путь к папке с шаблонами модуля * @param string $lang_file путь к языковому файлу модуля */ function pollList($tpl_dir, $lang_file) { global $AVE_DB, $AVE_Template; $AVE_Template->config_load($lang_file, 'showpolls'); $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_modul_poll")->GetCell(); $limit = $this->_adminlimit; $pages = ceil($num / $limit); $start = get_current_page() * $limit - $limit; $items = array(); $sql = $AVE_DB->Query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . PREFIX . "_modul_poll\r\n\t\t\tLIMIT " . $start . "," . $limit); while ($row = $sql->FetchRow()) { $row_hits = $AVE_DB->Query("\r\n\t\t\t\tSELECT SUM(poll_item_hits)\r\n\t\t\t\tFROM " . PREFIX . "_modul_poll_items\r\n\t\t\t\tWHERE poll_id = '" . $row->id . "'\r\n\t\t\t\tGROUP BY poll_id\r\n\t\t\t")->GetCell(); $row->sum_hits = floor($row_hits); $row->comments = $AVE_DB->Query("\r\n\t\t\t\tSELECT COUNT(*)\r\n\t\t\t\tFROM " . PREFIX . "_modul_poll_comments\r\n\t\t\t\tWHERE poll_id = '" . $row->id . "'\r\n\t\t\t")->GetCell(); array_push($items, $row); } if ($num > $limit) { $page_nav = " <a class=\"pnav\" href=\"index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp=" . SESSION . "&page={s}\">{t}</a> "; $page_nav = get_pagination($pages, 'page', $page_nav); $AVE_Template->assign('page_nav', $page_nav); } $AVE_Template->assign('items', $items); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'admin_forms.tpl')); }
function group_shared($requestID, $catId, $flag = 0) { global $db, $main_smarty, $the_template, $page_size, $cached_links; if (!is_numeric($requestID)) { die; } $link = new Link(); $group_shared_display = ""; if ($catId) { $child_cats = ''; // do we also search the subcategories? if (Independent_Subcategories == true) { $child_array = ''; // get a list of all children and put them in $child_array. children_id_to_array($child_array, table_categories, $catId); if ($child_array != '') { // build the sql foreach ($child_array as $child_cat_id) { $child_cat_sql .= ' OR `link_category` = ' . $child_cat_id . ' '; if (Multiple_Categories) { $child_cat_sql .= ' OR ac_cat_id = ' . $child_cat_id . ' '; } } } } if (Multiple_Categories) { $child_cat_sql .= " OR ac_cat_id = {$catId} "; } $from_where .= " AND (link_category={$catId} " . $child_cat_sql . ")"; } $offset = (get_current_page() - 1) * $page_size; if ($flag == 1) { $sql = "SELECT SQL_CALC_FOUND_ROWS b.* FROM " . table_group_shared . " a\r\n\t\t\t\t LEFT JOIN " . table_links . " b ON link_id=share_link_id\r\n\t\t\t\t WHERE share_group_id = {$requestID} AND !ISNULL(link_id) {$from_where} \r\n\t\t\t\t GROUP BY link_id\r\n\t\t\t\t ORDER BY link_published_date DESC, link_date DESC "; } else { $sql = "SELECT SQL_CALC_FOUND_ROWS b.* FROM " . table_group_shared . " a\r\n\t\t\t\t LEFT JOIN " . table_links . " b ON link_id=share_link_id\r\n\t\t\t\t WHERE share_group_id = {$requestID} AND !ISNULL(link_id) {$from_where} \r\n\t\t\t\t GROUP BY link_id\r\n\t\t\t\t ORDER BY link_published_date DESC, link_date DESC LIMIT {$offset}, {$page_size}"; } // Search on additional categories if ($catId && Multiple_Categories) { $sql = str_replace("WHERE", " LEFT JOIN " . table_additional_categories . " ON ac_link_id=link_id WHERE", $sql); } $links = $db->get_results($sql); $rows = $db->get_var("SELECT FOUND_ROWS()"); if ($flag == 1) { return $rows; } if ($links) { foreach ($links as $dblink) { $link->id = $dblink->link_id; $cached_links[$dblink->link_id] = $dblink; $link->read(); $group_shared_display .= $link->print_summary('summary', true); } } $main_smarty->assign('group_shared_display', $group_shared_display); //for auto scrolling if (Auto_scroll == 2 || Auto_scroll == 3) { $main_smarty->assign("scrollpageSize", $page_size); $main_smarty->assign('total_row', $rows); if ($catId) { $main_smarty->assign('catID', $catId); } $main_smarty->assign('total_row', $rows); } else { $main_smarty->assign('group_story_pagination', do_pages($rows, $page_size, 'group_story', true)); } }
function do_pages($total, $page_size = 25, $margin = true) { global $db; if ($total > 0 && $total < $page_size) { return; } $index_limit = 5; $query = preg_replace('/page=[0-9]+/', '', $_SERVER['QUERY_STRING']); $query = preg_replace('/^&*(.*)&*$/', "\$1", $query); if (!empty($query)) { $query = htmlspecialchars($query); $query = "&{$query}"; } $current = get_current_page(); $total_pages = ceil($total / $page_size); $start = max($current - intval($index_limit / 2), 1); $end = $start + $index_limit - 1; if ($margin) { echo '<div class="pages-margin">'; } else { echo '<div class="pages">'; } if ($current == 1) { echo '<span class="nextprev">« ' . _('anterior') . '</span>'; } else { $i = $current - 1; echo '<a href="?page=' . $i . $query . '">« ' . _('anterior') . '</a>'; } if ($total_pages > 0) { if ($start > 1) { $i = 1; echo '<a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>'; echo '<span>...</span>'; } for ($i = $start; $i <= $end && $i <= $total_pages; $i++) { if ($i == $current) { echo '<span class="current">' . $i . '</span>'; } else { echo '<a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>'; } } if ($total_pages > $end) { $i = $total_pages; echo '<span>...</span>'; echo '<a href="?page=' . $i . $query . '" title="' . _('ir a página') . " {$i}" . '">' . $i . '</a>'; } } else { if ($current > 2) { echo '<a href="?page=1" title="' . _('ir a página') . " 1" . '">1</a>'; echo '<span>...</span>'; } echo '<span class="current">' . $current . '</span>'; } if ($total < 0 || $current < $total_pages) { $i = $current + 1; echo '<a href="?page=' . $i . $query . '">» ' . _('siguiente') . '</a>'; } else { echo '<span class="nextprev">» ' . _('siguiente') . '</span>'; } echo "</div><!--html1:do_pages-->\n"; }
do_tabs('main', _('más comentadas'), true); print_period_tabs(); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); do_best_stories(); do_best_comments(); do_vertical_tags('published'); echo '</div>' . "\n"; /*** END SIDEBAR ***/ echo '<div id="newswrap">' . "\n"; echo '<div class="topheading"><h2>' . _('noticias más comentadas') . '</h2></div>'; $link = new Link(); // Use memcache if available if ($globals['memcache_host'] && get_current_page() < 4) { $memcache_key = 'topcommented_' . $from . '_' . get_current_page(); } if (!($memcache_key && ($rows = memcache_mget($memcache_key . 'rows')) && ($links = memcache_mget($memcache_key)))) { // It's not in memcache if ($time_link) { $rows = min(100, $db->get_var("SELECT count(*) FROM links WHERE {$time_link}")); } else { $rows = min(100, $db->get_var("SELECT count(*) FROM links")); } if ($rows == 0) { do_error(_('no hay noticias seleccionadas'), 500); } $links = $db->get_results("{$sql} LIMIT {$offset},{$page_size}"); if ($memcache_key) { memcache_madd($memcache_key . 'rows', $rows, 1800); memcache_madd($memcache_key, $links, 1800);
/** * setPage 设置页码 * @access public * @param int $var */ public function setPage($var = '') { if ($var == '') { $var = get_current_page(); } $this->_db->setPage($var); }
function check_default_vars($m, $no) { global $subID, $Ajaxpid, $AjaxURL, $post, $wpdb, $wp_db_version, $cformsSettings; $eol = $cformsSettings['global']['cforms_crlf'][b] != 1 ? "\r\n" : "\n"; if ($_POST['comment_post_ID' . $no]) { $pid = $_POST['comment_post_ID' . $no]; } else { if ($Ajaxpid != '') { $pid = $Ajaxpid; } else { if (function_exists('get_the_ID')) { $pid = get_the_ID(); } } } if ($_POST['cforms_pl' . $no]) { $permalink = $_POST['cforms_pl' . $no]; } else { if ($Ajaxpid != '') { $permalink = $AjaxURL; } else { if (function_exists('get_permalink') && function_exists('get_userdata')) { $permalink = get_permalink($pid); } } } ### ### if the "month" is not spelled correctly, try the commented out line instead of the one after ### ### $date = utf8_encode(html_entity_decode( mysql2date(get_option('date_format'), current_time('mysql')) )); $date = mysql2date(get_option('date_format'), current_time('mysql')); $time = gmdate(get_option('time_format'), current_time('timestamp')); $page = get_current_page(); if (substr($cformsSettings['form' . $no]['cforms' . $no . '_tellafriend'], 0, 1) == '2') { // WP comment fix $page = $permalink; } $find = $wpdb->get_row("SELECT p.post_title, p.post_excerpt, u.display_name FROM {$wpdb->posts} AS p LEFT JOIN ({$wpdb->users} AS u) ON p.post_author = u.ID WHERE p.ID='{$pid}'"); $CurrUser = wp_get_current_user(); $m = str_replace('{Referer}', $_SERVER['HTTP_REFERER'], $m); $m = str_replace('{PostID}', $pid, $m); $m = str_replace('{Form Name}', $cformsSettings['form' . $no]['cforms' . $no . '_fname'], $m); $m = str_replace('{Page}', $page, $m); $m = str_replace('{Date}', $date, $m); $m = str_replace('{Author}', $find->display_name, $m); $m = str_replace('{Time}', $time, $m); $m = str_replace('{IP}', cf_getip(), $m); $m = str_replace('{BLOGNAME}', get_option('blogname'), $m); $m = str_replace('{CurUserID}', $CurrUser->ID, $m); $m = str_replace('{CurUserName}', $CurrUser->display_name, $m); $m = str_replace('{CurUserEmail}', $CurrUser->user_email, $m); $m = str_replace('{CurUserFirstName}', $CurrUser->user_firstname, $m); $m = str_replace('{CurUserLastName}', $CurrUser->user_lastname, $m); $m = str_replace('{Permalink}', $permalink, $m); $m = str_replace('{Title}', $find->post_title, $m); $m = str_replace('{Excerpt}', $find->post_excerpt, $m); $m = preg_replace("/\r\n\\./", "\n", $m); ### normalize $m = str_replace("\r\n", "\n", $m); $m = str_replace("\r", "\n", $m); $m = str_replace("\n", $eol, $m); if ($cformsSettings['global']['cforms_database'] && $subID != '') { $m = str_replace('{ID}', $subID, $m); } return $m; }
$main_smarty = new Smarty(); include 'config.php'; include mnminclude . 'html1.php'; include mnminclude . 'link.php'; include mnminclude . 'tags.php'; include mnminclude . 'user.php'; include mnminclude . 'smartyvariables.php'; // breadcrumbs and page title $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Live'); $navwhere['link1'] = getmyurl('live', ''); $navwhere['text2'] = $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Unpublished'); $navwhere['link2'] = getmyurl('live_unpublished', ''); $main_smarty->assign('navbar_where', $navwhere); $main_smarty->assign('posttitle', $main_smarty->get_config_vars('PLIGG_Visual_Breadcrumb_Queued')); // figure out what "page" of the results we're on $offset = (get_current_page() - 1) * $top_users_size; // always check groups (to hide private groups) $from = " LEFT JOIN " . table_groups . " ON " . table_links . ".link_group_id = " . table_groups . ".group_id "; $groups = $db->get_results("SELECT * FROM " . table_group_member . " WHERE member_user_id = {$current_user->user_id} and member_status = 'active'"); if ($groups) { $group_ids = array(); foreach ($groups as $group) { $group_ids[] = $group->member_group_id; } $group_list = join(",", $group_ids); $where = " AND (" . table_groups . ".group_privacy!='private' OR ISNULL(" . table_groups . ".group_privacy) OR " . table_groups . ".group_id IN({$group_list})) "; } else { $group_list = ''; $where = " AND (" . table_groups . ".group_privacy!='private' OR ISNULL(" . table_groups . ".group_privacy))"; } $select = "SELECT * ";
function bannerList($tpl_dir) { global $AVE_DB, $AVE_Template; $limit = $this->_limit; $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_modul_banners")->GetCell(); $seiten = ceil($num / $limit); $start = get_current_page() * $limit - $limit; $banners = array(); $sql = $AVE_DB->Query("\r\n\t\t\tSELECT *\r\n\t\t\tFROM " . PREFIX . "_modul_banners\r\n\t\t\tLIMIT " . $start . "," . $limit); while ($row = $sql->FetchRow()) { array_push($banners, $row); } if ($num > $limit) { $page_nav = ' <a class="pnav" href="index.php?do=modules&action=modedit&mod=' . BANNER_DIR . '&moduleaction=1&cp=' . SESSION . '&page={s}">{t}</a> '; $page_nav = get_pagination($seiten, 'page', $page_nav); $AVE_Template->assign('page_nav', $page_nav); } $AVE_Template->assign('banners', $banners); $AVE_Template->assign('mod_path', BANNER_DIR); $AVE_Template->assign('categories', $this->_bannerCategoryGet()); $AVE_Template->assign('content', $AVE_Template->fetch($tpl_dir . 'banners.tpl')); }
* @package AVE.cms * @subpackage module_Forums * @filesource */ if (!defined("USERPOP")) { exit; } global $AVE_DB, $AVE_Template, $mod; $limit = 20; $Phrase = isset($_REQUEST['Phrase']) && $_REQUEST['Phrase'] != '' && $_REQUEST['Phrase'] > 0 && is_numeric($_REQUEST['Phrase']) && $_REQUEST['Phrase'] == 1 ? " = " : " LIKE "; $searchUser = isset($_REQUEST['uname']) && !empty($_REQUEST['uname']) ? " a.uname {$Phrase} '" . addslashes($_REQUEST['uname']) . "%%' AND " : ""; $query = "SELECT\r\n\t\ta.pn_receipt,\r\n\t\ta.uname,\r\n\t\ta.uid,\r\n\t\tb.Id,\r\n\t\tb.status\r\n\tFROM\r\n\t\t" . PREFIX . "_modul_forum_userprofile as a,\r\n\t\t" . PREFIX . "_users as b\r\n\tWHERE\r\n\t\ta.uid = b.Id AND\r\n\t\ta.pn_receipt = '1' AND\r\n\t\t" . $searchUser . "\r\n\t\tb.status = '1'\r\n\tORDER BY\r\n\t\ta.uname ASC\r\n"; $r_poster = $AVE_DB->Query($query); $num = $r_poster->NumRows(); $num_pages = ceil($num / $limit); $a = get_current_page() * $limit - $limit; $r_poster = $AVE_DB->Query($query . "LIMIT {$a},{$limit}"); $poster = array(); while ($post = $r_poster->FetchRow()) { $poster[] = $post; } $AVE_Template->assign("poster", $poster); //======================================================= // Navigation erzeugen //======================================================= if ($num > $limit) { $nav = " <a class=\"page_navigation\" href=\"index.php?module=forums&show=userpop&pop=1&theme_folder=" . $_GET['theme_folder'] . "&uname=" . @$_REQUEST['uname'] . "&Phrase=" . @$_REQUEST['Phrase'] . "&page={s}\">{t}</a> "; $nav = get_pagination($num_pages, 'page', $nav); $AVE_Template->assign("nav", $nav); } $tpl_out = $AVE_Template->fetch($mod['tpl_dir'] . "users.tpl");
if ($argv[0] == _priv) { // Load priv.php include 'priv.php'; die; } include mnminclude . 'html1.php'; include mnminclude . 'favorites.php'; $globals['search_options'] = array('w' => 'posts'); if ($current_user->user_id > 0) { array_push($globals['extra_js'], 'jquery.form.min.js'); } $user = new User(); $min_date = date("Y-m-d H:00:00", time() - 192800); // about 48 hours $page_size = 50; $offset = (get_current_page() - 1) * $page_size; $page_title = _('nótame') . ' | ' . $globals['site_name']; $view = false; switch ($argv[0]) { case '_best': $tab_option = 2; $page_title = _('mejores notas') . ' | ' . _('menéame'); $min_date = date("Y-m-d H:00:00", time() - 86400); // about 24 hours $where = "post_date > '{$min_date}'"; $order_by = "ORDER BY post_karma desc"; $limit = "LIMIT {$offset},{$page_size}"; $rows = $db->get_var("SELECT count(*) FROM posts where post_date > '{$min_date}'"); break; case '_geo': $tab_option = 3;
function cforms($args = '', $no = '') { global $smtpsettings, $subID, $cforms_root, $wpdb, $track, $wp_db_version, $cformsSettings; parse_str($args, $r); $oldno = $no == '1' ? '' : $no; ### remeber old val, to reset session when in new MP form ##debug db("Original form on page #{$oldno}"); ### multi page form: overwrite $no $isWPcommentForm = substr($cformsSettings['form' . $oldno]['cforms' . $oldno . '_tellafriend'], 0, 1) == '2'; $isMPform = $cformsSettings['form' . $oldno]['cforms' . $oldno . '_mp']['mp_form']; $isTAF = substr($cformsSettings['form' . $oldno]['cforms' . $oldno . '_tellafriend'], 0, 1); ##debug db("Comment form = {$isWPcommentForm}"); db("Multi-page form = {$isMPform}"); if ($isMPform && is_array($_SESSION['cforms']) && $_SESSION['cforms']['current'] > 0 && !$isWPcommentForm) { $no = $_SESSION['cforms']['current']; } ### Safety, in case someone uses '1' for the default form $no = $no == '1' ? '' : $no; ##debug db("Switch to form #{$no}"); $moveBack = false; ### multi page form: reset button if (isset($_REQUEST['resetbutton' . $no]) && is_array($_SESSION['cforms'])) { $no = $oldno; unset($_SESSION['cforms']); $_SESSION['cforms']['current'] = 0; $_SESSION['cforms']['first'] = $oldno; $_SESSION['cforms']['pos'] = 1; ##debug db("Reset-Button pressed"); } else { ### multi page form: back button if (isset($_REQUEST['backbutton' . $no]) && isset($_SESSION['cforms']) && $_SESSION['cforms']['pos'] - 1 >= 0) { $no = $_SESSION['cforms']['list'][$_SESSION['cforms']['pos']-- - 1]; $_SESSION['cforms']['current'] = $no; $moveBack = true; ##debug db("Back-Button pressed"); } else { ### mp init: must be mp, first & not submitted! if ($isMPform && $cformsSettings['form' . $oldno]['cforms' . $oldno . '_mp']['mp_first'] && !isset($_REQUEST['sendbutton' . $no])) { ##debug db("Current form is *first* MP-form"); db("Session found, you're on the first form and session is reset!"); $no = $oldno == '1' ? '' : $oldno; ### restore old val unset($_SESSION['cforms']); $_SESSION['cforms']['current'] = 0; $_SESSION['cforms']['first'] = $no; $_SESSION['cforms']['pos'] = 1; } } } ##debug db(print_r($_SESSION, 1)); ### custom fields support if (!(strpos($no, '+') === false)) { $no = substr($no, 0, -1); $customfields = build_fstat($args); $field_count = count($customfields); $custom = true; } else { $custom = false; $field_count = $cformsSettings['form' . $no]['cforms' . $no . '_count_fields']; } $content = ''; $err = 0; $filefield = 0; $validations = array(); $all_valid = 1; $off = 0; $fieldsetnr = 1; $c_errflag = false; $custom_error = ''; $usermessage_class = ''; ### get user credentials if (function_exists('wp_get_current_user')) { $user = wp_get_current_user(); } ### non Ajax method if (isset($_REQUEST['sendbutton' . $no])) { require_once dirname(__FILE__) . '/lib_nonajax.php'; $usermessage_class = $all_valid ? ' success' : ' failure'; } ### called from lib_WPcomments ? if ($isWPcommentForm && $send2author) { return $all_valid; } ### ### ### paint form ### ### $success = false; ### fix for WP Comment (loading after redirect) if (isset($_GET['cfemail']) && $isWPcommentForm) { $usermessage_class = ' success'; $success = true; if ($_GET['cfemail'] == 'sent') { $usermessage_text = preg_replace('|\\r\\n|', '<br />', stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_success'])); } elseif ($_GET['cfemail'] == 'posted') { $usermessage_text = preg_replace('|\\r\\n|', '<br />', stripslashes($cformsSettings['form' . $no]['cforms_commentsuccess'])); } } $break = '<br />'; $nl = "\n"; $tab = "\t"; $tt = "\t\t"; $ntt = "\n\t\t"; $nttt = "\n\t\t\t"; ### either show info message above or below $usermessage_text = check_default_vars($usermessage_text, $no); $usermessage_text = check_cust_vars($usermessage_text, $track, $no); ### logic: possibly change usermessage if (function_exists('my_cforms_logic')) { $usermessage_text = my_cforms_logic($trackf, $usermessage_text, 'successMessage'); } $umc = $usermessage_class != '' && $no > 1 ? ' ' . $usermessage_class . $no : ''; ##debug db("User info for form #{$no}"); ### where to show message if (substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 0, 1) == 'y') { $content .= $ntt . '<div id="usermessage' . $no . 'a" class="cf_info' . $usermessage_class . $umc . ' ">' . $usermessage_text . '</div>'; $actiontarget = 'a'; } else { if (substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 1, 1) == 'y') { $actiontarget = 'b'; } } ### multi page form: overwrite $no, move on to next form if ($all_valid && isset($_REQUEST['sendbutton' . $no])) { $isMPformNext = false; ### default $oldcurrent = $no; if ($isMPform && isset($_SESSION['cforms']) && $_SESSION['cforms']['current'] > 0 && $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_next'] != -1) { $isMPformNext = true; $no = check_form_name($cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_next']); ##debug db("Session active and now moving on to form #{$no}"); ### logic: possibly change next form if (function_exists('my_cforms_logic')) { $no = my_cforms_logic($trackf, $no, "nextForm"); } ### use trackf! $oldcurrent = $_SESSION['cforms']['current']; $_SESSION['cforms']['current'] = $no == '' ? 1 : $no; $field_count = $cformsSettings['form' . $no]['cforms' . $no . '_count_fields']; } elseif ($isMPform && $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_next'] == -1) { ##debug db("Session was active but is being reset now"); $oldcurrent = $no; $no = $_SESSION['cforms']['first']; unset($_SESSION['cforms']); $_SESSION['cforms']['current'] = 0; $_SESSION['cforms']['first'] = $no; $_SESSION['cforms']['pos'] = 1; $field_count = $cformsSettings['form' . $no]['cforms' . $no . '_count_fields']; } } ##debug db("All good, currently on form #{$no}"); ##debug: optional ## db(print_r($_SESSION,1)); ## db(print_r($track,1)); ### redirect == 2 : hide form? || or if max entries reached! w/ SESSION support if#2 if ($all_valid && ($cformsSettings['form' . $no]['cforms' . $no . '_hide'] && isset($_REQUEST['sendbutton' . $no]) || $cformsSettings['form' . $oldcurrent]['cforms' . $oldcurrent . '_hide'] && isset($_REQUEST['sendbutton' . $oldcurrent]))) { return $content; } else { if ($cformsSettings['form' . $no]['cforms' . $no . '_maxentries'] != '' && get_cforms_submission_left($no) <= 0 || !cf_check_time($no)) { if ($cflimit == "reached") { return stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_limittxt']); } else { return $content . stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_limittxt']); } } } ### alternative form action $alt_action = false; if ($cformsSettings['form' . $no]['cforms' . $no . '_action'] == '1') { $action = $cformsSettings['form' . $no]['cforms' . $no . '_action_page']; $alt_action = true; } else { if ($isWPcommentForm) { $action = $cforms_root . '/lib_WPcomment.php'; } else { $action = get_current_page(false) . '#usermessage' . $no . $actiontarget; } } ### start with form tag $content .= $ntt . '<form enctype="multipart/form-data" action="' . $action . '" method="post" class="cform' . ($cformsSettings['form' . $no]['cforms' . $no . '_dontclear'] ? ' cfnoreset' : '') . '" id="cforms' . $no . 'form">' . $nl; ### Session item counter (for default values) $sItem = 1; ### start with no fieldset $fieldsetopen = false; $verification = false; $captcha = false; $upload = false; $fscount = 1; $ol = false; for ($i = 1; $i <= $field_count; $i++) { if (!$custom) { $field_stat = explode('$#$', $cformsSettings['form' . $no]['cforms' . $no . '_count_field_' . $i]); } else { $field_stat = explode('$#$', $customfields[$i - 1]); } $field_name = $field_stat[0]; $field_type = $field_stat[1]; $field_required = $field_stat[2]; $field_emailcheck = $field_stat[3]; $field_clear = $field_stat[4]; $field_disabled = $field_stat[5]; $field_readonly = $field_stat[6]; ### ommit certain fields if (in_array($field_type, array('cauthor', 'url', 'email')) && $user->ID) { continue; } ### check for custom err message and split field_name $obj = explode('|err:', $field_name, 2); $fielderr = $obj[1]; if ($fielderr != '') { switch ($field_type) { case 'upload': $custom_error .= 'cf_uploadfile' . $no . '-' . $i . '$#$' . $fielderr . '|'; break; case 'captcha': $custom_error .= 'cforms_captcha' . $no . '$#$' . $fielderr . '|'; break; case 'verification': $custom_error .= 'cforms_q' . $no . '$#$' . $fielderr . '|'; break; case "cauthor": case "url": case "email": case "comment": $custom_error .= $field_type . '$#$' . $fielderr . '|'; break; default: preg_match('/^([^#\\|]*).*/', $field_name, $input_name); if (strpos($input_name[1], '[id:') > 0) { preg_match('/\\[id:(.+)\\]/', $input_name[1], $input_name); } $custom_error .= $cformsSettings['form' . $no]['cforms' . $no . '_customnames'] == '1' ? cf_sanitize_ids($input_name[1]) : 'cf' . $no . '_field_' . $i; $custom_error .= '$#$' . $fielderr . '|'; break; } } ### check for title attrib $obj = explode('|title:', $obj[0], 2); $fieldTitle = $obj[1] != '' ? ' title="' . str_replace('"', '"', stripslashes($obj[1])) . '"' : ''; ### special treatment for selectboxes if (in_array($field_type, array('multiselectbox', 'selectbox', 'radiobuttons', 'send2author', 'luv', 'subscribe', 'checkbox', 'checkboxgroup', 'ccbox', 'emailtobox'))) { $chkboxClicked = array(); if (in_array($field_type, array('luv', 'subscribe', 'checkbox', 'ccbox')) && strpos($obj[0], '|set:') > 1) { $chkboxClicked = explode('|set:', stripslashes($obj[0])); $obj[0] = $chkboxClicked[0]; } $options = explode('#', stripslashes($obj[0])); $field_name = $options[0]; } ### check if fieldset is open if (!$fieldsetopen && !$ol && $field_type != 'fieldsetstart') { $content .= $tt . '<ol class="cf-ol">'; $ol = true; } $labelclass = ''; ### visitor verification if (!$verification && $field_type == 'verification') { srand(microtime() * 1000003); $qall = explode("\r\n", $cformsSettings['global']['cforms_sec_qa']); $n = rand(0, count(array_keys($qall)) - 1); $q = $qall[$n]; $q = explode('=', $q); ### q[0]=qestion q[1]=answer $field_name = stripslashes(htmlspecialchars($q[0])); $labelclass = ' class="secq"'; } else { if ($field_type == 'captcha') { $labelclass = ' class="seccap"'; } } $defaultvalue = ''; ### setting the default val & regexp if it exists if (!in_array($field_type, array('fieldsetstart', 'fieldsetend', 'radiobuttons', 'send2author', 'luv', 'subscribe', 'checkbox', 'checkboxgroup', 'ccbox', 'emailtobox', 'multiselectbox', 'selectbox', 'verification'))) { ### check if default val & regexp are set $obj = explode('|', $obj[0], 3); if ($obj[2] != '') { $reg_exp = str_replace('"', '"', stripslashes($obj[2])); } else { $reg_exp = ''; } if ($obj[1] != '') { $defaultvalue = str_replace('"', '"', check_default_vars(stripslashes($obj[1]), $no)); } $field_name = $obj[0]; } ### label ID's $labelIDx = ''; $labelID = $cformsSettings['global']['cforms_labelID'] == '1' ? ' id="label-' . $no . '-' . $i . '"' : ''; ### <li> ID's $liID = $cformsSettings['global']['cforms_liID'] == '1' || substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 2, 1) == "y" || substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 3, 1) == "y" ? ' id="li-' . $no . '-' . $i . '"' : ''; ### input field names & label if ($cformsSettings['form' . $no]['cforms' . $no . '_customnames'] == '1') { if (strpos($field_name, '[id:') !== false) { $idPartA = strpos($field_name, '[id:'); $idPartB = strpos($field_name, ']', $idPartA); $input_id = $input_name = cf_sanitize_ids(substr($field_name, $idPartA + 4, $idPartB - $idPartA - 4)); $field_name = substr_replace($field_name, '', $idPartA, $idPartB - $idPartA + 1); } else { $input_id = $input_name = cf_sanitize_ids(stripslashes($field_name)); } } else { $input_id = $input_name = 'cf' . $no . '_field_' . $i; } $field_class = ''; $field_value = ''; switch ($field_type) { case 'luv': $input_id = $input_name = 'luv'; break; case 'subscribe': $input_id = $input_name = 'subscribe'; break; case 'verification': if (is_user_logged_in() && $cformsSettings['global']['cforms_captcha_def']['foqa'] != '1') { continue 2; } $input_id = $input_name = 'cforms_q' . $no; break; case 'captcha': if (is_user_logged_in() && $cformsSettings['global']['cforms_captcha_def']['fo'] != '1') { continue 2; } $input_id = $input_name = 'cforms_captcha' . $no; break; case 'upload': $input_id = $input_name = 'cf_uploadfile' . $no . '-' . $i; $field_class = 'upload'; break; case "send2author": case "email": case "cauthor": case "url": $input_id = $input_name = $field_type; case "datepicker": case "yourname": case "youremail": case "friendsname": case "friendsemail": case "textfield": case "pwfield": $field_class = 'single'; break; case "hidden": $field_class = 'hidden'; break; case 'comment': $input_id = $input_name = $field_type; $field_class = 'area'; break; case 'textarea': $field_class = 'area'; break; } ### additional field classes if ($field_disabled) { $field_class .= ' disabled'; } if ($field_readonly) { $field_class .= ' readonly'; } if ($field_emailcheck) { $field_class .= ' fldemail'; } if ($field_required) { $field_class .= ' fldrequired'; } ### error ? $liERR = $insertErr = ''; ### only for mp forms if ($moveBack || $isMPformNext) { $field_value = htmlspecialchars(stripslashes($_SESSION['cforms']['cf_form' . $no][$_SESSION['cforms']['cf_form' . $no]['$$$' . $sItem++]])); } if (!$all_valid) { ### errors... if ($validations[$i] == 1) { $field_class .= ''; } else { $field_class .= ' cf_error'; ### enhanced error display if (substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 2, 1) == "y") { $liERR = 'cf_li_err'; } if (substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 3, 1) == "y") { $insertErr = $fielderr != '' ? '<ul class="cf_li_text_err"><li>' . stripslashes($fielderr) . '</li></ul>' : ''; } } if ($field_type == 'multiselectbox' || $field_type == 'checkboxgroup') { $field_value = $_REQUEST[$input_name]; ### in this case it's an array! will do the stripping later } else { $field_value = htmlspecialchars(stripslashes($_REQUEST[$input_name])); } } else { if (!isset($_REQUEST['sendbutton' . $no]) && isset($_REQUEST[$input_name]) || $cformsSettings['form' . $no]['cforms' . $no . '_dontclear']) { ### only pre-populating fields... if ($field_type == 'multiselectbox' || $field_type == 'checkboxgroup') { $field_value = $_REQUEST[$input_name]; } else { $field_value = htmlspecialchars(stripslashes($_REQUEST[$input_name])); } } } ### print label only for non "textonly" fields! Skip some others too, and handle them below indiv. if (!in_array($field_type, array('hidden', 'textonly', 'fieldsetstart', 'fieldsetend', 'ccbox', 'luv', 'subscribe', 'checkbox', 'checkboxgroup', 'send2author', 'radiobuttons'))) { $content .= $nttt . '<li' . $liID . ' class="' . $liERR . '">' . $insertErr . '<label' . $labelID . ' for="' . $input_id . '"' . $labelclass . '><span>' . stripslashes($field_name) . '</span></label>'; } ### if not reloaded (due to err) then use default values if ($field_value == '' && $defaultvalue != '') { $field_value = $defaultvalue; } ### field disabled or readonly, greyed out? $disabled = $field_disabled ? ' disabled="disabled"' : ''; $readonly = $field_readonly ? ' readonly="readonly"' : ''; ### add input field $dp = ''; $naming = false; $field = ''; $val = ''; $force_checked = false; $cookieset = ''; switch ($field_type) { case "upload": $upload = true; ### set upload flag for ajax suppression! $field = '<input' . $readonly . $disabled . ' type="file" name="cf_uploadfile' . $no . '[]" id="cf_uploadfile' . $no . '-' . $i . '" class="cf_upload ' . $field_class . '"' . $fieldTitle . '/>'; break; case "textonly": $field .= $nttt . '<li' . $liID . ' class="textonly' . ($defaultvalue != '' ? ' ' . $defaultvalue : '') . '"' . ($reg_exp != '' ? ' style="' . $reg_exp . '" ' : '') . '>' . stripslashes($field_name) . '</li>'; break; case "fieldsetstart": if ($fieldsetopen) { $field = $ntt . '</ol>' . $nl . $tt . '</fieldset>' . $nl; $fieldsetopen = false; $ol = false; } if (!$fieldsetopen) { if ($ol) { $field = $ntt . '</ol>' . $nl; } $field .= $tt . '<fieldset class="cf-fs' . $fscount++ . '">' . $nl . $tt . '<legend>' . stripslashes($field_name) . '</legend>' . $nl . $tt . '<ol class="cf-ol">'; $fieldsetopen = true; $ol = true; } break; case "fieldsetend": if ($fieldsetopen) { $field = $ntt . '</ol>' . $nl . $tt . '</fieldset>' . $nl; $fieldsetopen = false; $ol = false; } else { $field = ''; } break; case "verification": $field = '<input type="text" name="' . $input_name . '" id="cforms_q' . $no . '" class="secinput ' . $field_class . '" value=""' . $fieldTitle . '/>'; $verification = true; break; case "captcha": $field = '<input type="text" name="' . $input_name . '" id="cforms_captcha' . $no . '" class="secinput' . $field_class . '" value=""' . $fieldTitle . '/>' . '<img id="cf_captcha_img' . $no . '" class="captcha" src="' . $cforms_root . '/cforms-captcha.php?ts=' . $no . get_captcha_uri() . '" alt=""/>' . '<a title="' . __('reset captcha image', 'cforms') . '" href="javascript:reset_captcha(\'' . $no . '\')"><img class="captcha-reset" src="' . $cforms_root . '/images/spacer.gif" alt="Captcha"/></a>'; $captcha = true; break; case "cauthor": $cookieset = 'comment_author_' . COOKIEHASH; case "url": $cookieset = $cookieset == '' ? 'comment_author_url_' . COOKIEHASH : $cookieset; case "email": $cookieset = $cookieset == '' ? 'comment_author_email_' . COOKIEHASH : $cookieset; $field_value = $_COOKIE[$cookieset] != '' ? $_COOKIE[$cookieset] : $field_value; case "datepicker": case "yourname": case "youremail": case "friendsname": case "friendsemail": case "textfield": case "pwfield": $field_value = check_post_vars($field_value); $type = $field_type == 'pwfield' ? 'password' : 'text'; $field_class = $field_type == 'datepicker' ? $field_class . ' cf_date' : $field_class; $onfocus = $field_clear ? ' onfocus="clearField(this)" onblur="setField(this)"' : ''; $field = '<input' . $readonly . $disabled . ' type="' . $type . '" name="' . $input_name . '" id="' . $input_id . '" class="' . $field_class . '" value="' . $field_value . '"' . $onfocus . $fieldTitle . '/>'; if ($reg_exp != '') { $field .= '<input type="hidden" name="' . $input_name . '_regexp" id="' . $input_id . '_regexp" value="' . $reg_exp . '"' . $fieldTitle . '/>'; } $field .= $dp; break; case "hidden": $field_value = check_post_vars($field_value); if (preg_match('/^<([a-zA-Z0-9]+)>$/', $field_value, $getkey)) { $field_value = $_GET[$getkey[1]]; } $field .= $nttt . '<li class="cf_hidden"><input type="hidden" class="cfhidden" name="' . $input_name . '" id="' . $input_id . '" value="' . $field_value . '"' . $fieldTitle . '/></li>'; break; case "comment": case "textarea": $onfocus = $field_clear ? ' onfocus="clearField(this)" onblur="setField(this)"' : ''; $field = '<textarea' . $readonly . $disabled . ' cols="30" rows="8" name="' . $input_name . '" id="' . $input_id . '" class="' . $field_class . '"' . $onfocus . $fieldTitle . '>' . $field_value . '</textarea>'; if ($reg_exp != '') { $field .= '<input type="hidden" name="' . $input_name . '_regexp" id="' . $input_id . '_regexp" value="' . $reg_exp . '"' . $fieldTitle . '/>'; } break; case "subscribe": if (class_exists('sg_subscribe') && $field_type == 'subscribe') { global $sg_subscribe; sg_subscribe_start(); if (($email = $sg_subscribe->current_viewer_subscription_status()) == 'admin' && current_user_can('manage_options')) { $field .= '<li' . $liID . '>' . str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->author_text) . '</li>'; continue; } else { if ($email != '') { $field .= '<li' . $liID . '>' . str_replace('[manager_link]', $sg_subscribe->manage_link($email, true, false), $sg_subscribe->subscribed_text) . '</li>'; continue; } } $val = ' value="subscribe"'; } case "luv": if (function_exists('comment_luv') && $field_type == 'luv') { get_currentuserinfo(); global $user_level; if ($user_level == 10) { continue 2; } //empty for now $val = ' value="luv"'; } case "ccbox": case "checkbox": if (!$field_value) { $preChecked = strpos($chkboxClicked[1], 'true') !== false ? ' checked="checked"' : ''; } else { $preChecked = $field_value && $field_value != '-' ? ' checked="checked"' : ''; } ### '-' for mp session! $err = ''; if (!$all_valid && $validations[$i] != 1) { $err = ' cf_errortxt'; } if ($options[1] != '') { $opt = explode('|', $options[1], 2); $before = '<li' . $liID . ' class="' . $liERR . '">' . $insertErr; $after = '<label' . $labelID . ' for="' . $input_id . '" class="cf-after' . $err . '"><span>' . $opt[0] . '</span></label></li>'; $ba = 'a'; } else { $opt = explode('|', $field_name, 2); $before = '<li' . $liID . ' class="' . $liERR . '">' . $insertErr . '<label' . $labelID . ' for="' . $input_name . '" class="cf-before' . $err . '"><span>' . $opt[0] . '</span></label>'; $after = '</li>'; $ba = 'b'; } ### if | val provided, then use "X" if ($val == '') { $val = $opt[1] != '' ? ' value="' . $opt[1] . '"' : ''; } $field = $nttt . $before . '<input' . $readonly . $disabled . ' type="checkbox" name="' . $input_name . '" id="' . $input_id . '" class="cf-box-' . $ba . $field_class . '"' . $val . $fieldTitle . $preChecked . '/>' . $after; break; case "checkboxgroup": $liID_b = $liID != '' ? substr($liID, 0, -1) . 'items"' : ''; array_shift($options); $field .= $nttt . '<li' . $liID . ' class="cf-box-title">' . $field_name . '</li>' . $nttt . '<li' . $liID_b . ' class="cf-box-group">'; $id = 1; $j = 0; ### mp session support if ($moveBack || $isMPformNext) { $field_value = explode(',', $field_value); } foreach ($options as $option) { ### supporting names & values $boxPreset = explode('|set:', $option); $opt = explode('|', $boxPreset[0], 2); if ($opt[1] == '') { $opt[1] = $opt[0]; } $checked = ''; if ($moveBack || $isMPformNext) { if (in_array($opt[1], array_values($field_value))) { $checked = 'checked="checked"'; } } elseif (is_array($field_value)) { if ($opt[1] == htmlspecialchars(stripslashes(strip_tags($field_value[$j])))) { $checked = 'checked="checked"'; $j++; } } else { if (strpos($boxPreset[1], 'true') !== false) { $checked = ' checked="checked"'; } } if ($labelID != '') { $labelIDx = substr($labelID, 0, -1) . $id . '"'; } if ($opt[0] == '') { $field .= $nttt . $tab . '<br />'; } else { $field .= $nttt . $tab . '<input' . $readonly . $disabled . ' type="checkbox" id="' . $input_id . '-' . $id . '" name="' . $input_name . '[]" value="' . $opt[1] . '" ' . $checked . ' class="cf-box-b"' . $fieldTitle . '/>' . '<label' . $labelIDx . ' for="' . $input_id . '-' . $id++ . '" class="cf-group-after"><span>' . $opt[0] . "</span></label>"; } } $field .= $nttt . '</li>'; break; case "multiselectbox": ### $field .= $nttt . '<li><label ' . $labelID . ' for="'.$input_name.'"'. $labelclass . '><span>' . stripslashes(($field_name)) . '</span></label>'; $field .= '<select' . $readonly . $disabled . ' multiple="multiple" name="' . $input_name . '[]" id="' . $input_id . '" class="cfselectmulti ' . $field_class . '"' . $fieldTitle . '>'; array_shift($options); $j = 0; ### mp session support if ($moveBack || $isMPformNext) { $field_value = explode(',', $field_value); } foreach ($options as $option) { ### supporting names & values $optPreset = explode('|set:', $option); $opt = explode('|', $optPreset[0], 2); if ($opt[1] == '') { $opt[1] = $opt[0]; } $checked = ''; if ($moveBack || $isMPformNext) { if (in_array($opt[1], array_values($field_value))) { $checked = 'selected="selected"'; } } elseif (is_array($field_value)) { if ($opt[1] == stripslashes(htmlspecialchars(strip_tags($field_value[$j])))) { $checked = ' selected="selected"'; $j++; } } else { if (strpos($optPreset[1], 'true') !== false) { $checked = ' selected="selected"'; } } $field .= $nttt . $tab . '<option value="' . str_replace('"', '"', $opt[1]) . '"' . $checked . '>' . $opt[0] . '</option>'; } $field .= $nttt . '</select>'; break; case "emailtobox": case "selectbox": $field = '<select' . $readonly . $disabled . ' name="' . $input_name . '" id="' . $input_id . '" class="cformselect' . $field_class . '" ' . $fieldTitle . '>'; array_shift($options); $jj = $j = 0; foreach ($options as $option) { ### supporting names & values $optPreset = explode('|set:', $option); $opt = explode('|', $optPreset[0], 2); if ($opt[1] == '') { $opt[1] = $opt[0]; } ### email-to-box valid entry? if ($field_type == 'emailtobox' && $opt[1] != '-') { $jj = $j++; } else { $jj = '--'; } $checked = ''; if ($field_value == '') { if (strpos($optPreset[1], 'true') !== false) { $checked = ' selected="selected"'; } } else { if ($opt[1] == $field_value || $jj == $field_value) { $checked = ' selected="selected"'; } } $field .= $nttt . $tab . '<option value="' . ($field_type == 'emailtobox' ? $jj : $opt[1]) . '"' . $checked . '>' . $opt[0] . '</option>'; } $field .= $nttt . '</select>'; break; case "send2author": $force_checked = strpos($field_stat[0], '|set:') === false ? true : false; case "radiobuttons": $liID_b = $liID != '' ? substr($liID, 0, -1) . 'items"' : ''; ### only if label ID's active array_shift($options); $field .= $nttt . '<li' . $liID . ' class="' . $liERR . ' cf-box-title">' . $insertErr . $field_name . '</li>' . $nttt . '<li' . $liID_b . ' class="cf-box-group">'; $id = 1; foreach ($options as $option) { $checked = ''; ### supporting names & values $radioPreset = explode('|set:', $option); $opt = explode('|', $radioPreset[0], 2); if ($opt[1] == '') { $opt[1] = $opt[0]; } if ($field_value == '') { if (strpos($radioPreset[1], 'true') !== false || $force_checked && $id == 1) { $checked = ' checked="checked"'; } } else { if ($opt[1] == $field_value) { $checked = ' checked="checked"'; } } if ($labelID != '') { $labelIDx = substr($labelID, 0, -1) . $id . '"'; } if ($opt[0] == '') { $field .= $nttt . $tab . '<br />'; } else { $field .= $nttt . $tab . '<input' . $readonly . $disabled . ' type="radio" id="' . $input_id . '-' . $id . '" name="' . $input_name . '" value="' . $opt[1] . '"' . $checked . ' class="cf-box-b' . ($second ? ' cformradioplus' : '') . ($field_required ? ' fldrequired' : '') . '"' . $fieldTitle . '/>' . '<label' . $labelIDx . ' for="' . $input_id . '-' . $id++ . '" class="cf-after"><span>' . $opt[0] . "</span></label>"; } } $field .= $nttt . '</li>'; break; } ### add new field $content .= $field; ### adding "required" text if needed if ($field_emailcheck == 1) { $content .= '<span class="emailreqtxt">' . stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_emailrequired']) . '</span>'; } else { if ($field_required == 1 && !in_array($field_type, array('ccbox', 'luv', 'subscribe', 'checkbox', 'radiobuttons'))) { $content .= '<span class="reqtxt">' . stripslashes($cformsSettings['form' . $no]['cforms' . $no . '_required']) . '</span>'; } } ### close out li item if (!in_array($field_type, array('hidden', 'fieldsetstart', 'fieldsetend', 'radiobuttons', 'luv', 'subscribe', 'checkbox', 'checkboxgroup', 'ccbox', 'textonly', 'send2author'))) { $content .= '</li>'; } } ### all fields ### close any open tags if ($ol) { $content .= $ntt . '</ol>'; } if ($fieldsetopen) { $content .= $ntt . '</fieldset>'; } ### rest of the form if ($cformsSettings['form' . $no]['cforms' . $no . '_ajax'] == '1' && !$upload && !$custom && !$alt_action) { $ajaxenabled = ' onclick="return cforms_validate(\'' . $no . '\', false)"'; } else { if (($upload || $custom || $alt_action) && $cformsSettings['form' . $no]['cforms' . $no . '_ajax'] == '1') { $ajaxenabled = ' onclick="return cforms_validate(\'' . $no . '\', true)"'; } else { $ajaxenabled = ''; } } ### just to appease html "strict" $content .= $ntt . '<fieldset class="cf_hidden">' . $nttt . '<legend> </legend>'; ### if visitor verification turned on: if ($verification) { $content .= $nttt . '<input type="hidden" name="cforms_a' . $no . '" id="cforms_a' . $no . '" value="' . md5(rawurlencode(strtolower($q[1]))) . '"/>'; } ### custom error $custom_error = substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 2, 1) . substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 3, 1) . substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 4, 1) . $custom_error; ### TAF or WP comment or Extra Fields if ((int) $isTAF > 0) { $nono = $isWPcommentForm ? '' : $no; if ($isWPcommentForm) { $content .= $nttt . '<input type="hidden" name="comment_parent" id="comment_parent" value="' . ($_REQUEST['replytocom'] != '' ? $_REQUEST['replytocom'] : '0') . '"/>'; } $content .= $nttt . '<input type="hidden" name="comment_post_ID' . $nono . '" id="comment_post_ID' . $nono . '" value="' . (isset($_GET['pid']) ? $_GET['pid'] : get_the_ID()) . '"/>' . $nttt . '<input type="hidden" name="cforms_pl' . $no . '" id="cforms_pl' . $no . '" value="' . (isset($_GET['pid']) ? get_permalink($_GET['pid']) : get_permalink()) . '"/>'; } $content .= $nttt . '<input type="hidden" name="cf_working' . $no . '" id="cf_working' . $no . '" value="' . rawurlencode($cformsSettings['form' . $no]['cforms' . $no . '_working']) . '"/>' . $nttt . '<input type="hidden" name="cf_failure' . $no . '" id="cf_failure' . $no . '" value="' . rawurlencode($cformsSettings['form' . $no]['cforms' . $no . '_failure']) . '"/>' . $nttt . '<input type="hidden" name="cf_codeerr' . $no . '" id="cf_codeerr' . $no . '" value="' . rawurlencode($cformsSettings['global']['cforms_codeerr']) . '"/>' . $nttt . '<input type="hidden" name="cf_customerr' . $no . '" id="cf_customerr' . $no . '" value="' . rawurlencode($custom_error) . '"/>' . $nttt . '<input type="hidden" name="cf_popup' . $no . '" id="cf_popup' . $no . '" value="' . $cformsSettings['form' . $no]['cforms' . $no . '_popup'] . '"/>'; $content .= $ntt . '</fieldset>'; ### multi page form: reset $reset = ''; if ($cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_form'] && $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_reset']) { $reset = '<input tabindex="999" type="submit" name="resetbutton' . $no . '" id="resetbutton' . $no . '" class="resetbutton" value="' . $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_resettext'] . '" onclick="return confirm(\'' . __('Note: This will reset all your input!', 'cforms') . '\')">'; } ### multi page form: back $back = ''; if ($cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_form'] && $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_back']) { $back = '<input type="submit" name="backbutton' . $no . '" id="backbutton' . $no . '" class="backbutton" value="' . $cformsSettings['form' . $no]['cforms' . $no . '_mp']['mp_backtext'] . '">'; } $content .= $ntt . '<p class="cf-sb">' . $reset . $back . '<input type="submit" name="sendbutton' . $no . '" id="sendbutton' . $no . '" class="sendbutton" value="' . $cformsSettings['form' . $no]['cforms' . $no . '_submit_text'] . '"' . $ajaxenabled . '/></p>'; $content .= $ntt . '</form>'; ### Thank you for leaving this in place $content .= $ntt . '<p class="linklove" id="ll' . $no . '"><a href="http://www.deliciousdays.com/cforms-plugin"><em>cforms</em> contact form by delicious:days</a></p>'; ### either show message above or below $usermessage_text = check_default_vars($usermessage_text, $no); $usermessage_text = check_cust_vars($usermessage_text, $track, $no); if (substr($cformsSettings['form' . $no]['cforms' . $no . '_showpos'], 1, 1) == 'y' && !($success && $cformsSettings['form' . $no]['cforms' . $no . '_hide'])) { $content .= $tt . '<div id="usermessage' . $no . 'b" class="cf_info ' . $usermessage_class . $umc . '" >' . $usermessage_text . '</div>' . $nl; } ### flush debug messages dbflush(); return $content; }