function google_sitemap_url_handler(&$sm, $url_array) { if (!defined('VIVVO_PROXY_URL')) { if (defined('VIVVO_SYSTEM_PROXY_URL')) { define('VIVVO_PROXY_URL', VIVVO_SYSTEM_PROXY_URL); } else { define('VIVVO_PROXY_URL', ''); } } defined('VIVVO_ABSOLUTE_URL') or define('VIVVO_ABSOLUTE_URL', make_absolute_url('')); $template =& $sm->get_template(); $template->assign('CURRENT_TIME', strval(date('Y-m-d\\TH:i:s', VIVVO_START_TIME) . substr(date('O', VIVVO_START_TIME), 0, 3) . ':' . substr(date('O', VIVVO_START_TIME), 3, 2))); header("Content-type: text/xml; charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/google_sitemap.tpl'); echo $sm->get_output(); exit; }
function login_content_handler(&$sm) { $template = $sm->get_template(); $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl'); $um = $sm->get_url_manager(); $dm = $sm->get_dump_manager(); $dm->restore_dump(md5(make_proxied_url('login.html'))); if (defined('VIVVO_ABSOLUTE_URL')) { $index_url = VIVVO_ABSOLUTE_URL; } else { $index_url = make_absolute_url(''); } $action = $sm->action_status; $template->assign('DUMP_MESSAGES', $dm->_dump_pool); if ($action) { if ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'login') { header('Location: ' . $index_url); exit; } elseif ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'register' or $um->get_param('action') == 'login' && $um->get_param('cmd') == 'confirm') { $template->assign('REGISTRATION', strval('1')); } elseif ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'changePassword') { $template->assign('REGISTRATION', strval('0')); } else { $template->assign('REGISTRATION', strval('0')); } } elseif ($um->isset_param('action') && $action === false) { $in_user = $um->get_param_regexp('/^USER_/'); $current_user = new Users($sm, $in_user); $template->assign('user', $current_user); } else { $template->assign('REGISTRATION', strval('0')); } $content_template = new template($sm, $template); if ($um->get_param('activation_key')) { $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/change_password.tpl'); $content_template->assign('key', htmlspecialchars($um->get_param('activation_key'))); } else { $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/register.tpl'); } $template->assign('PAGE_CONTENT', $content_template->get_output()); }
function get_absolute_href() { return make_absolute_url($this->get_href(), false); }
private function set_selected($category, $current_url) { if ($category->get_redirect()) { $url = preg_replace('|/index(\\.\\d+)?\\.html$|', '/', make_absolute_url($category->get_redirect())); } else { $url = preg_replace('|/index(\\.\\d+)?\\.html$|', '/', $category->get_absolute_href()); } if (substr($current_url, 0, $url_len = strlen($url)) == $url) { $category->set_selected(strlen($current_url) == $url_len, true); } foreach ($category->subcategories as $subcategory) { $this->set_selected($subcategory, $current_url); } }
function forgot_mail($username, $email) { if (!$this->check_token()) { return false; } if (!vivvo_hooks_manager::call('login_forgotMail', array(&$username, &$email))) { return vivvo_hooks_manager::get_status(); } if (isset($_SESSION['vivvo']['register_time']) && $_SESSION['vivvo']['register_time'] + 60 > VIVVO_START_TIME) { $this->set_error_code(2755); return false; } require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Users.class.php'; $lang = vivvo_lang::get_instance(); $user_list = new Users_list(); if (!$username && !$email) { $this->set_error_code(2712); return false; } else { if ($username) { $user_list->search(array('search_username' => $username)); $user = current($user_list->list); } elseif ($email) { $user_list->search(array('search_email_address' => $email)); $user = current($user_list->list); } if ($user) { $search = array('(', ')', '<', '>', '@', ';', ':', '\\', '"', '.', '[', ']'); $replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); $vivvo_website_title = str_replace($search, $replace, VIVVO_WEBSITE_TITLE); $vivvo_website_title = "=?UTF-8?B?" . base64_encode($vivvo_website_title) . "?="; $headers['From'] = $vivvo_website_title . '<' . VIVVO_EMAIL_SEND_FROM . '>'; $recipients = array(); $recipients[] = $user->email_address; $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_FORGOT_SUBJECT) . "?="; $headers['Content-Type'] = "text/plain; charset=UTF-8;"; $body_template = new template(); $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_FORGOT_BODY); $body_template->set_string_template($template_sting); $confirm_url = make_absolute_url('login.html?activation_key=' . md5($user->username . $user->email_address . $user->password)); $body_template->assign('activation_url', $confirm_url); $body_template->assign('user', $user); $body = $body_template->get_output() . "\n\n"; if (VIVVO_EMAIL_SMTP_PHP == 1) { $mail_object = new Mail(); $mail_object->send($recipients, $headers, $body); } else { $mail_options['driver'] = 'smtp'; $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST; $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT; $mail_options['localhost'] = 'localhost'; if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') { $mail_options['auth'] = true; $mail_options['username'] = VIVVO_EMAIL_SMTP_PASSWORD; $mail_options['password'] = VIVVO_EMAIL_SMTP_USERNAME; } else { $mail_options['auth'] = false; $mail_options['username'] = ''; $mail_options['password'] = ''; } $mail_object = Mail::factory('smtp', $mail_options); $mail_object->send($recipients, $headers, $body); } } $_SESSION['vivvo']['register_time'] = time(); return true; } }
/** * Defines VIVVO_PROXY_URL in case it is not already defined. */ function define_proxy_url() { if (!defined('VIVVO_PROXY_URL')) { if (defined('VIVVO_SYSTEM_PROXY_URL')) { define('VIVVO_PROXY_URL', VIVVO_SYSTEM_PROXY_URL); } else { define('VIVVO_PROXY_URL', ''); } } defined('VIVVO_ABSOLUTE_URL') or define('VIVVO_ABSOLUTE_URL', make_absolute_url('')); }
/** * Mobile url manager */ function mobile_url_handler(&$sm, $url_array) { $um = $sm->get_url_manager(); $sm->set_theme('mobile'); array_shift($um->_url_array); define('VIVVO_TEMPLATE_DIR_OVERWRITE', 'mobile'); $template = $sm->get_template(); if (defined('VIVVO_SYSTEM_PROXY_URL')) { if (!defined('VIVVO_PROXY_URL')) { define('VIVVO_PROXY_URL', VIVVO_SYSTEM_PROXY_URL . 'mobile/'); } else { define('VIVVO_PROXY_URL_OVERWRITE', VIVVO_SYSTEM_PROXY_URL . 'mobile/'); $template->assign('VIVVO_PROXY_URL', strval(VIVVO_PROXY_URL_OVERWRITE)); } } elseif (defined('VIVVO_PROXY_URL')) { define('VIVVO_PROXY_URL_OVERWRITE', VIVVO_PROXY_URL . 'mobile/'); } else { define('VIVVO_PROXY_URL', 'mobile/'); } if (defined('VIVVO_ABSOLUTE_URL')) { $template->assign('VIVVO_ABSOLUTE_URL', make_absolute_url('')); } else { define('VIVVO_ABSOLUTE_URL', make_absolute_url('')); } if ($um->_url_array[0] == 'search') { if ($um->isset_param('search_do_advanced')) { require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; $params = Articles_list::get_search_params_from_url($sm); unset($params['pg']); if ($um->isset_param('search_archive')) { $params['search_archive'] = 1; } $params['search_do_advanced'] = true; $params = base64_encode(serialize($params)); $params = rtrim($params, '='); header('Location:' . make_absolute_url('mobile/index.html?search_options=' . $params)); exit; } $sm->set_template_dir(); $sm->load_action_handlers(); $sm->set_theme(); $template->set_template_file(VIVVO_FS_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl'); $content_template = new template($sm, $template); $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/advanced_search.tpl'); $template->assign_template('PAGE_CONTENT', $content_template); $output = $sm->get_output(); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; echo str_replace('$generation_time$', time() - $_generation_time . 's', $output); exit; } elseif ($um->_url_array[0] == 'login') { $dm = $sm->get_dump_manager(); $dm->restore_dump(md5(VIVVO_URL . 'mobile/login')); $sm->set_template_dir(); $sm->load_action_handlers(); $sm->set_theme(); $action = $sm->execute_action(); $template->set_template_file(VIVVO_FS_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl'); $template->assign('DUMP_MESSAGES', $dm->_dump_pool); if ($sm->user) { $template->assign('CURRENT_USER', $sm->user); } if ($um->isset_param('action') && $action === false) { $in_user = $um->get_param_regexp('/^USER_/'); $current_user = new Users($sm, $in_user); $template->assign('user', $current_user); } else { $template->assign('REGISTRATION', strval('0')); } $content_template = new template($sm, $template); $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/register.tpl'); $template->assign_template('PAGE_CONTENT', $content_template); $output = $sm->get_output(); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; echo str_replace('$generation_time$', time() - $_generation_time . 's', $output); ob_end_flush(); exit; } else { $um->parse_url(); } return true; }
/** * Returns HTML needed for rendering chart * * @param mixed $provider Data provider class (array('class' => 'ClassName', 'file' => 'classfile.php') or just 'ClassName') * @param array $params Array of data selection parameters * @param array $appearance Appearance settings * @return string */ public static function get_html($provider, array $params = array(), array $appearance = array()) { $id = md5(serialize($params)); is_array($_SESSION['vivvo']) or $_SESSION['vivvo'] = array(); is_array($_SESSION['vivvo']['chart']) or $_SESSION['vivvo']['chart'] = array(); $_SESSION['vivvo']['chart'][$id] = array('provider' => is_object($provider) ? get_class($provider) : $provider, 'params' => $params); $appearance = array_map('json_encode', array_merge(array('alternative_content' => 'You need to upgrade your Flash Player', 'flash_background' => '#FFFFFF', 'preloader_color' => '#999999', 'width' => '520', 'height' => '400'), $appearance)); $appearance['alternative_content'] = json_decode($appearance['alternative_content'], true); $amcharts_path = self::$amcharts_path; $amcharts_swf = self::$amcharts_swf; $amcharts_path = json_encode($amcharts_path); $amcharts_swf = json_encode($amcharts_swf); $settings_file = json_encode(urlencode(make_absolute_url(VIVVO_CHART_URL . '/' . $id . '/settings'))); $data_file = json_encode(urlencode(make_absolute_url(VIVVO_CHART_URL . '/' . $id . '/data'))); return <<<HTML <div id="d_{$id}" style="width:100%;height:100%;position:relative"> \t<strong>{$appearance[alternative_content]}</strong> </div> <script type="text/javascript"> \t// <![CDATA[ \t(function(){ \t\tvar chart = new SWFObject({$amcharts_swf}, 'f_{$id}', {$appearance[width]}, {$appearance[height]}, '8', {$appearance[flash_background]}); \t\tchart.addParam('wmode', 'transparent'); \t\tchart.addVariable('path', {$amcharts_path}); \t\tchart.addVariable('settings_file', {$settings_file}); \t\tchart.addVariable('data_file', {$data_file}); \t\tchart.addVariable('preloader_color', {$appearance[preloader_color]}); \t\tchart.write('d_{$id}'); \t})(); \t// ]]> </script> HTML; }
function feed_url_handler(&$sm, $url_array) { if (!defined('VIVVO_PROXY_URL')) { if (defined('VIVVO_SYSTEM_PROXY_URL')) { define('VIVVO_PROXY_URL', VIVVO_SYSTEM_PROXY_URL); } else { define('VIVVO_PROXY_URL', ''); } } defined('VIVVO_ABSOLUTE_URL') or define('VIVVO_ABSOLUTE_URL', make_absolute_url('')); $template = $sm->get_template(); $um = $sm->get_url_manager(); array_shift($um->_url_array); if ($_GET['output_type'] == 'sitemap') { define('VIVVO_SKIP_URL_PARSING', true); } $um->parse_url(); $template->assign('CURRENT_TIME', date('Y-m-d H:i:s', VIVVO_START_TIME)); require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; if (empty($sm->article_list_params)) { $sm->article_list_params = Articles_list::get_search_params_from_url($sm); } if (!$um->get_param('output_type')) { $um->set_param('output_type', 'rss'); } if ($um->get_param('output_type') == 'atom') { if (VIVVO_MODULES_FEED == 1) { if (VIVVO_MODULES_CATEGORY_INCLUDE_FEED) { if (empty($sm->article_list_params['search_options']['search_cid'])) { $sm->article_list_params['search_options']['search_cid'] = VIVVO_MODULES_CATEGORY_INCLUDE_FEED; } else { $search_cid = explode(',', $sm->article_list_params['search_options']['search_cid']); $restrict_cid = explode(',', VIVVO_MODULES_CATEGORY_INCLUDE_FEED); $search_cid = array_intersect($search_cid, $restrict_cid); if (!empty($search_cid)) { $sm->article_list_params['search_options']['search_cid'] = implode(',', $search_cid); } else { $sm->article_list_params['search_options']['search_cid'] = '-1'; } } } $sm->article_list_params['search_options']['search_rss_feed'] = '1'; header("Content-type: text/xml; charset=UTF-8"); if (isset($sm->article_list_params['search_options']['search_id']) && $sm->article_list_params['search_options']['search_id'] != '') { $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/atom1.0_comments.tpl'); } else { $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/atom1.0.tpl'); } } else { go_404(); } } elseif ($um->get_param('output_type') == 'rss') { if (VIVVO_MODULES_FEED == 1) { if (VIVVO_MODULES_CATEGORY_INCLUDE_FEED) { if (empty($sm->article_list_params['search_options']['search_cid'])) { $sm->article_list_params['search_options']['search_cid'] = VIVVO_MODULES_CATEGORY_INCLUDE_FEED; } else { $search_cid = explode(',', $sm->article_list_params['search_options']['search_cid']); $restrict_cid = explode(',', VIVVO_MODULES_CATEGORY_INCLUDE_FEED); $search_cid = array_intersect($search_cid, $restrict_cid); if (!empty($search_cid)) { $sm->article_list_params['search_options']['search_cid'] = implode(',', $search_cid); } else { $sm->article_list_params['search_options']['search_cid'] = '-1'; } } } $sm->article_list_params['search_options']['search_rss_feed'] = '1'; header("Content-type: text/xml; charset=UTF-8"); if (isset($sm->article_list_params['search_options']['search_id']) && $sm->article_list_params['search_options']['search_id'] != '') { $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/rss2.0_comments.tpl'); } else { $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/rss2.0.tpl'); } } else { go_404(); } } elseif ($um->get_param('output_type') == 'txt') { if (VIVVO_MODULES_PLAINTEXT == 1) { header("Content-type: text/plain; charset=UTF-8"); if ($um->get_param('search_id')) { $sm->set_content(); $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/article_text.tpl'); } else { $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/text.tpl'); } } else { go_404(); } } elseif ($um->get_param('output_type') == 'sitemap') { header("Content-type: text/xml; charset=UTF-8"); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/google_sitemap.tpl'); } else { go_404(); } $template->assign('content_params', $sm->article_list_params); echo $sm->get_output(); exit; }
function generate_output($params) { $this->set_template($params); $sm = vivvo_lite_site::get_instance(); $um = $sm->get_url_manager(); $lang = vivvo_lang::get_instance(); if (!isset($params['search_by_year']) && !$um->isset_param('search_by_year')) { $year = date('Y', VIVVO_START_TIME); $params['search_by_year'] = $year; } else { if (isset($params['search_by_year'])) { $year = (int) $params['search_by_year']; } else { $year = (int) $um->get_param('search_by_year'); $params['search_by_year'] = $year; } } if (!isset($params['search_by_month']) && !$um->isset_param('search_by_month')) { $month = date('n', VIVVO_START_TIME); $params['search_by_month'] = $month; } else { if (isset($params['search_by_month'])) { $month = (int) $params['search_by_month']; } else { $month = (int) $um->get_param('search_by_month'); $params['search_by_month'] = $month; } } //Articles per day if ($month > 0 && $year > 1900) { if (!isset($params['search_do_advanced'])) { $params['search_status'] = -1; } require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php'; $article_params = Articles_list::get_search_params(null, $params); $article_list = new Articles_list(); $article_list->search($article_params['search_options'], '', 'ascending', 0, 0, false); $article_list->_query->_fields = array(); $article_list->_query->add_fields('DAYOFMONTH( created ) AS day'); $article_list->_query->add_fields('count( * ) AS count'); $article_list->_query->add_group_by('TO_DAYS( created )'); $query = $article_list->_query->get_query(); $num_of_days = date('t', mktime(0, 0, 0, $month, 1, $year)); $day_of_week = date('w', mktime(0, 0, 0, $month, 1, $year)); $prev_month = $month - 1; if ($prev_month == 0) { $prev_month = 12; $prev_year = $year - 1; } else { $prev_year = $year; } $next_month = $month + 1; if ($next_month == 13) { $next_month = 1; $next_year = $year + 1; } else { $next_year = $year; } $prev_num_of_days = date('t', mktime(0, 0, 0, $prev_month, 1, $prev_year)); if ($day_of_week != 0) { for ($i = 1 - $day_of_week; $i <= 0; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = ''; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } } for ($i = 1; $i <= $num_of_days; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = $i; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } $next_day_of_week = date('w', mktime(0, 0, 0, $month, $num_of_days, $year)); if ($next_day_of_week != 6) { for ($i = $num_of_days + 1; $i < $num_of_days + 6 - $next_day_of_week + 1; $i++) { $this->data[$i] = array(); $this->data[$i]['label'] = ''; $this->data[$i]['count'] = 0; $this->data[$i]['url'] = ''; } } $count_sum = 0; $res = $sm->get_db()->query($query); if (!is_a($res, 'mdb2_error')) { while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) { if ($row['count'] > 0) { $count_sum += $row['count']; $this->data[$row['day']]['count'] += $row['count']; if (isset($params['search_status']) && $params['search_status'] == -1) { $this->data[$row['day']]['url'] = make_proxied_url('archive/' . $year . '/' . $month . '/' . $row['day']); } else { $day_params = $article_params; $day_params['search_do_advanced'] = true; $day_params['search_by_day'] = $row['day']; $search_option = base64_encode(serialize($day_params)); $this->data[$row['day']]['url'] = make_absolute_url('index.php?search_options=' . $search_option); } } } } $res->free(); } if ($count_sum) { $month_params = $article_params; if (isset($params['search_status']) && $params['search_status'] == -1) { $this->_template->assign('month_url', make_proxied_url('archive/' . $year . '/' . $month . '/')); } else { $month_params['search_do_advanced'] = true; $search_option = base64_encode(serialize($month_params)); $this->_template->assign('month_url', make_absolute_url('index.php?search_options=' . $search_option)); } } $this->_template->assign('count_list', $this->data); $this->_template->assign('year', $year); $this->_template->assign('month', strval($lang->get_value('LNG_MONTH_' . $month))); $this->_template->assign('prev_year', intval($year - 1)); $this->_template->assign('prev_month_year', $prev_year); $this->_template->assign('prev_month', $prev_month); $this->_template->assign('next_year', intval($year + 1)); $this->_template->assign('next_month_year', $next_year); $this->_template->assign('next_month', $next_month); }
public function renderHtmlHeaders() { header('Location: ' . make_absolute_url($this->viewdata)); }