/**
 * Resets number of today's reads (cron task function).
 *
 * @param vivvo_lite_site	$sm
 */
function auto_reset_today_read($sm)
{
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $article_list = new Articles_list($sm);
    $article_list->search(array(), '', 'ascending', 0, 0, false);
    require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php';
    $pm = new vivvo_post_master($sm);
    $article_list->sql_update_list($pm, array('today_read' => '0'), NULL, true);
    if (defined('VIVVO_CRONJOB_MODE')) {
        echo 'auto_reset_today_read: Finished.' . PHP_EOL;
    }
}
Esempio n. 2
0
/**
 * Archive articles (cron task function).
 *
 * @param vivvo_lite_site	$sm
 */
function auto_archive($sm)
{
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    if (VIVVO_ARTICLE_AUTO_ARCHIVE > 0) {
        $article_list = new Articles_list();
        $search_params = array('search_cid' => VIVVO_ARTICLE_AUTO_ARCHIVE_ITEMS, 'search_before_after' => 0, 'search_search_date' => VIVVO_ARTICLE_AUTO_ARCHIVE);
        $article_list->search($search_params, '', 'ascending', 0, 0, false);
        require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php';
        $article_list->sql_update_list(new vivvo_post_master(), array('status' => '-1'), null, true);
        if (defined('VIVVO_CRONJOB_MODE')) {
            echo 'auto_archive: Finished.' . PHP_EOL;
        } else {
            admin_log('(Cron task: Auto Archive)', 'Finished.');
        }
    }
}
Esempio n. 3
0
function search_content_handler(&$sm)
{
    $um =& $sm->get_url_manager();
    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 = strtr(rtrim(base64_encode(serialize($params)), '='), '+/', '-_');
        //$params = rtrim($params, '=');
        if ($um->isset_param('search_archive')) {
            header('Location:' . make_proxied_url('archive/index.html?search_options=' . $params));
        } else {
            header('Location:' . make_proxied_url('index.html?search_options=' . $params));
        }
        exit;
    }
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_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('PAGE_CONTENT', $content_template->get_output());
}
Esempio n. 4
0
function author_content_handler(&$sm)
{
    $template =& $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header =& $sm->get_header_manager();
    $um =& $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $sm->article_list_params = Articles_list::get_search_params_from_url($sm);
    $sm->article_list_params['search_options'] = array();
    if (VIVVO_MODULES_FEATURED_AUTHOR_PAGE == 1 && ($um->isset_param('show_authors') || $um->get_param('search_user_id') && !$um->get_param('search_do_advanced'))) {
        if ($um->isset_param('show_authors')) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_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/authors_page.tpl');
            $template->assign_template('PAGE_CONTENT', $content_template);
            $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_AUTHORS')));
        } else {
            $user_manager =& $sm->get_user_manager();
            $user_list =& $user_manager->get_user_list($sm);
            $user_list_a =& $user_list->get_user_by_id($um->get_param('search_user_id'));
            if ($user_list_a) {
                $sm->article_list_params['search_options']['search_user_id'] = $user_list_a->get_id();
                if ($um->get_param('search_by_year')) {
                    $sm->article_list_params['search_options']['search_by_year'] = $um->get_param('search_by_year');
                }
                if ($um->get_param('search_by_month')) {
                    $sm->article_list_params['search_options']['search_by_month'] = $um->get_param('search_by_month');
                }
                if ($um->get_param('search_by_year')) {
                    $sm->article_list_params['search_limit'] = 200;
                }
                $template->assign('CURRENT_AUTHOR', $user_list_a);
                $template->assign('PAGE_TITLE', strval($user_list_a->get_name()));
                if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/' . $um->get_param('force_template'))) {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/' . $um->get_param('force_template'));
                } else {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'author/default.tpl');
                }
                if (VIVVO_MODULES_FEED == 1) {
                    $header->add_rss(switch_format('rss', CURRENT_URL), $user_list_a->get_name());
                }
            } else {
                go_404();
            }
        }
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
        $template->assign('content_params', $sm->article_list_params);
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    } else {
        go_404();
    }
}
Esempio n. 5
0
/**
 * Delete articles (cron task function).
 *
 * @param vivvo_lite_site	$sm
 */
function auto_delete($sm)
{
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    if (VIVVO_ARTICLE_AUTO_DELETE > 0) {
        $al = new Articles_list($sm);
        $al->_query->add_where('created < ( DATE_SUB( \'' . date('Y-m-d H:i:s') . '\', INTERVAL ' . VIVVO_ARTICLE_AUTO_DELETE . ' DAY ))');
        $al->_query->set_from('`' . VIVVO_DB_PREFIX . 'articles`');
        $al->_query->add_fields('*');
        $article_params['search_options']['search_cid'] = VIVVO_ARTICLE_AUTO_DELETE_ITEMS;
        $al->search($article_params['search_options'], '', 'ascending', 0, 0, false);
        require_once VIVVO_FS_FRAMEWORK . 'vivvo_post.php';
        $pm = new vivvo_post_master($sm);
        $al->sql_delete_list($pm, NULL, true);
        if (defined('VIVVO_CRONJOB_MODE')) {
            echo 'auto_delete: Finished.' . PHP_EOL;
        } else {
            admin_log('(Cron task: Auto Delete)', 'Finished.');
        }
    }
}
Esempio n. 6
0
function tag_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $sm->article_list_params = Articles_list::get_search_params_from_url($sm);
    $sm->article_list_params['search_options'] = array();
    if (VIVVO_MODULES_TAGS == 1 && ($um->isset_param('show_tags') || ($um->get_param('search_tag_id') || $um->get_param('search_tag')) && !$um->get_param('search_do_advanced'))) {
        //Tag view page
        if ($um->isset_param('show_tags')) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_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/tags_page.tpl');
            $template->assign_template('PAGE_CONTENT', $content_template);
            $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_TAGS')));
        } else {
            require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
            if ($um->get_param('search_tag_id')) {
                $sm->article_list_params['search_options']['search_tag_id'] = $um->get_param('search_tag_id');
                $tag_list =& new Tags_list($sm);
                $tag =& $tag_list->get_tag_by_id($um->get_param('search_tag_id'));
            } else {
                $sm->article_list_params['search_options']['search_tag'] = $um->get_param('search_tag');
                $tag_list =& new Tags_list($sm);
                $tag =& $tag_list->get_tag_by_name($um->get_param('search_tag'));
            }
            if ($tag) {
                if (VIVVO_MODULES_FEED == 1) {
                    $header->add_rss(switch_format('rss', CURRENT_URL), $tag->name);
                }
                $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_TAG') . ': ' . $tag->name));
                if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . $um->get_param('force_template'))) {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . $um->get_param('force_template'));
                } else {
                    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'tag/' . VIVVO_TAG_LAYOUT);
                }
            } else {
                go_404();
            }
        }
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
        $template->assign('content_params', $sm->article_list_params);
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    } else {
        go_404();
    }
}
Esempio n. 7
0
function date_content_handler(&$sm)
{
    $template =& $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header =& $sm->get_header_manager();
    $um =& $sm->get_url_manager();
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
    $sm->article_list_params = Articles_list::get_search_params_from_url($sm);
    $sm->article_list_params['search_options'] = array();
    if (VIVVO_MODULES_ARCHIVE_VIEW == 1 && ($um->get_param('search_by_year') && !$um->get_param('search_do_advanced'))) {
        //Date view page
        if ($um->get_param('search_by_year')) {
            $sm->article_list_params['search_options']['search_by_year'] = $um->get_param('search_by_year');
        }
        if ($um->get_param('search_by_month')) {
            $sm->article_list_params['search_options']['search_by_month'] = $um->get_param('search_by_month');
        }
        if ($um->get_param('search_by_day')) {
            $sm->article_list_params['search_options']['search_by_day'] = $um->get_param('search_by_day');
        }
        $sm->article_list_params['search_sort_by'] = 'created';
        $sm->article_list_params['search_order'] = 'ascending';
        if ($um->get_param('search_by_day')) {
            $template->assign('PAGE_TITLE', strval(intval($um->get_param('search_by_year')) . ' ' . intval($um->get_param('search_by_month')) . ' ' . intval($um->get_param('search_by_day'))));
        } elseif ($um->get_param('search_by_month')) {
            $template->assign('PAGE_TITLE', strval(intval($um->get_param('search_by_year')) . ' ' . intval($um->get_param('search_by_month'))));
        } else {
            $template->assign('PAGE_TITLE', intval($um->get_param('search_by_year')));
        }
        if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'archive/' . $um->get_param('force_template'))) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'archive/' . $um->get_param('force_template'));
        } else {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'archive/' . VIVVO_ARCHIVE_LAYOUT);
        }
        if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($sm->article_list_params['cache'])) {
            $sm->article_list_params['cache'] = 1;
        }
        $template->assign('content_params', $sm->article_list_params);
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    } else {
        go_404();
    }
}
Esempio n. 8
0
function article1_url_handler(&$sm, $url_array)
{
    $um = $sm->get_url_manager();
    $params = array('url_module' => 'article');
    $last_chunk = end($url_array);
    if (preg_match('/^(\\d+)-?/', $last_chunk, $article_url)) {
        if (isset($article_url[1])) {
            require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
            $article = Articles_list::factory()->get_article_by_id($article_url[1], $um->list['search_cid']);
            if ($article) {
                $params['search_id'] = $article->id;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
    return $params;
}
 function _stats()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $template = $this->load_template($this->_template_root . 'stats_modal.xml');
     if ($um->isset_param('article_id')) {
         $article = Articles_list::factory()->get_article_by_id($um->get_param('article_id'));
         if ($article) {
             $template->assign('article', $article);
         }
     }
     return $template;
 }
Esempio n. 10
0
function article_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    if ($um->get_param('search_id')) {
        //Article page
        $id = $um->get_param('search_id');
        require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
        $al = Articles_list::factory();
        $sm->article = $al->get_article_by_id($id);
        if ($sm->article !== false) {
            $sm->set_categories();
            $category = $sm->categories->list[$sm->article->get_category_id()];
            if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $um->get_param('force_template'))) {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $um->get_param('force_template'));
            } else {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'article/' . $category->get_article_template());
            }
            // 1. is user and is admin
            // 2. is user and can read article category
            // 3. guest and can read article category
            if ($sm->user && ($sm->user->is_admin() || $sm->user->can('READ', 'Categories', $category->id)) || !$sm->user && $sm->guest_group && $sm->guest_group->can('READ', 'Categories', $category->id)) {
                if (!defined('VIVVO_ADMIN_MODE')) {
                    if (($sm->article->status == 0 || strtotime($sm->article->created) > VIVVO_START_TIME) && !($sm->user && $sm->user->can('ACCESS_ADMIN'))) {
                        go_404();
                    }
                    $sm->article->on_display();
                }
                $template->assign('CURRENT_CATEGORY', $category);
                if (isset($sm->article->author_obj)) {
                    $template->assign('CURRENT_AUTHOR', $sm->article->author_obj);
                }
                // revision view:
                // 1. both 'news' and 'rev' parameters must be passed trough GET
                // 2. 'news' parameter must be equal to 'search_id' parameter from url_manager
                // 3. user must have EDITOR privilege for this category, or be an author of article (with WRITE privilege)
                if (!empty($_GET['news']) and $_GET['news'] == $sm->article->get_id() and !empty($_GET['rev']) and $sm->user and ($sm->user->is('EDITOR', 'Categories', $category->get_id()) or count($sm->user->get_privilege_object_ids('WRITE', 'Categories')) and $sm->user->get_id() == $sm->article->get_user_id())) {
                    class_exists('ArticlesRevisions') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/ArticlesRevisions.class.php');
                    $revision = ArticlesRevisions_list::factory()->get_revision_by_article_id_ver($sm->article->get_id(), $_GET['rev'] << 0);
                    if ($revision) {
                        $sm->article->set_title($revision->get_title());
                        $sm->article->set_abstract($revision->get_abstract());
                        $sm->article->set_body($revision->get_body());
                    }
                }
                // end revision view
                // add this article to printed list
                $sm->printed_articles[] = $sm->article->get_id();
                $template->assign('article', $sm->article);
                if (!defined('VIVVO_ADMIN_MODE')) {
                    if (VIVVO_MODULES_FEED == 1) {
                        $header->add_rss(switch_format('rss', CURRENT_URL), $sm->article->get_title());
                        if (VIVVO_FRIENDY_URL) {
                            $header->add_rss(switch_format('rss', VIVVO_URL . $category->get_href()), $category->category_name);
                        } else {
                            $header->add_rss(switch_format('rss', $category->get_href()), $category->category_name);
                        }
                    }
                    $sm->page_title = $sm->article->get_title();
                    if ($um->isset_param('print')) {
                        $sm->set_theme($category->get_css(), true);
                    } else {
                        $sm->set_theme($category->get_css());
                    }
                }
                $sm->_template->assign('PAGE_TITLE', strval($sm->article->title));
                $um->set_param('search_cid', $category->id);
            } else {
                $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
                $template->assign('PAGE_TITLE', strval($sm->_lang->get_value('LNG_RESTRICTED_ACCESS')));
                $content_template = new template($sm, $template);
                $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/restricted.tpl');
                $template->assign_template('PAGE_CONTENT', $content_template);
            }
        } else {
            go_404();
        }
    } else {
        go_404();
    }
}
Esempio n. 11
0
 function get_article_absolute_href()
 {
     if (!$this->article_obj) {
         require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
         $al = new Articles_list(null, 'title,sefriendly,category_id');
         $this->article_obj = $al->get_article_by_id($this->article_id);
     }
     if ($this->article_obj) {
         return $this->article_obj->get_absolute_href();
     }
 }
Esempio n. 12
0
 /**
  * Add new comment
  *
  * @param	array	$in_article
  * @param	string	$captcha
  * @return	boolean	true on success or false on fail
  */
 function add_comment($in_comment, $captcha = '')
 {
     if (!vivvo_hooks_manager::call('comment_add', array(&$in_comment))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if (VIVVO_COMMENTS_ENABLE == 1) {
         if ($this->bad_ip_filter()) {
             $this->set_error_code(2201);
             return false;
         }
         $is_guest = !$sm->user && $sm->guest_group;
         if ($is_guest && $sm->guest_group->group_privileges['ARTICLE_COMMENT'] > 0 || $sm->user && $sm->user->privileges['ARTICLE_COMMENT'] > 0) {
             if ($sm->user) {
                 $in_comment['user_id'] = $sm->user->get_id();
                 $in_comment['author'] = $sm->user->get_name();
                 $in_comment['email'] = $sm->user->email_address;
                 $in_comment['www'] = $sm->user->www;
             }
             $in_comment['create_dt'] = date('Y-m-d H:i:s');
             $in_comment['ip'] = $_SERVER['REMOTE_ADDR'];
             if ($is_guest && $sm->guest_group->group_privileges['ARTICLE_COMMENT'] == 1 || $sm->user && $sm->user->privileges['ARTICLE_COMMENT'] == 1) {
                 $in_comment['status'] = '1';
             }
             if (VIVVO_COMMENTS_CAPTHA == 0 || is_array($_SESSION['vivvo']['comment_captcha']) && $_SESSION['vivvo']['comment_captcha'][$in_comment['article_id']] == $captcha) {
                 if (isset($_SESSION['vivvo']['comment_time']) && $_SESSION['vivvo']['comment_time'] + VIVVO_COMMENTS_FLOOD_PROTECTION > VIVVO_START_TIME) {
                     $this->set_error_code(2202);
                     return false;
                 } else {
                     array_walk($in_comment, 'array_htmlspecialchars');
                     $in_comment['description'] = $this->bad_words_filter($in_comment['description']);
                     $in_comment['description'] = trim($in_comment['description']);
                     if ($in_comment['description'] == '') {
                         $this->set_error_code(2221);
                         return false;
                     }
                     if (VIVVO_COMMENTS_ENABLE_BBCODE) {
                         if ($is_guest) {
                             $in_comment['description'] = preg_replace('/\\[url(.+?)?\\]|\\[\\/url\\]/', '', $in_comment['description']);
                         }
                         $in_comment['description_src'] = $in_comment['description'];
                         $in_comment['description'] = Comments::parse_bbcode($in_comment['description']);
                     }
                     if (VIVVO_COMMENTS_ENABLE_THREADED and empty($in_comment['root_comment']) and !empty($in_comment['reply_to'])) {
                         $in_comment['root_comment'] = $in_comment['reply_to'];
                     }
                     $comment = new Comments(null, $in_comment);
                     $this->_post_master->set_data_object($comment);
                     if ($this->_post_master->sql_insert()) {
                         $id = $this->_post_master->get_work_id();
                         $comment->set_id($id);
                         if (!vivvo_hooks_manager::call('comment_add_postinsert', array(&$comment))) {
                             return vivvo_hooks_manager::get_status();
                         }
                         if (is_array($_SESSION['vivvo']['comment_captcha'])) {
                             $key = array_search($captcha, $_SESSION['vivvo']['comment_captcha']);
                             unset($_SESSION['vivvo']['comment_captcha'][$key]);
                             class_exists('Articles') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php');
                             Articles_list::factory()->get_article_by_id($comment->get_article_id())->generate_captcha();
                         }
                         $_SESSION['vivvo']['comment_time'] = time();
                         return true;
                     } else {
                         $this->set_error_code(2203);
                         return false;
                     }
                 }
             } else {
                 $this->set_error_code(2204);
                 return false;
             }
         } else {
             $this->set_error_code(2205);
             return false;
         }
     } else {
         $this->set_error_code(2206);
         return false;
     }
 }
Esempio n. 13
0
 public function get_article_count()
 {
     if ($this->article_count === false) {
         class_exists('Articles_list') or (require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php');
         $list = Articles_list::factory();
         $list->search(array('search_cid' => $this->id), '', '', 0, 0, false);
         $this->article_count = $list->get_total_count();
     }
     return $this->article_count;
 }
Esempio n. 14
0
/**
 * 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;
}
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
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;
}
Esempio n. 17
0
 function set_content()
 {
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/box/vivvo_box.php';
     $header = $this->get_header_manager();
     $pm = $this->get_plugin_manager();
     $um = $this->get_url_manager();
     if ($um->get_param('404')) {
         $this->_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/404.tpl');
         $this->_template->assign('URL', htmlspecialchars($um->get_param('url')));
     } elseif ($um->get_param('plugin')) {
         $this->set_theme();
         $this->_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
         $content = $pm->get_content($um->get_param('plugin'));
         if ($content !== false) {
             $this->_template->assign('PAGE_CONTENT', $content);
         }
     } elseif ($um->get_param('url_module')) {
         $this->call_url_content_handler($um->get_param('url_module'));
     } else {
         if ($um->get_param('search_id')) {
             $this->call_url_content_handler('article');
         } else {
             require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
             //Article list page
             $cur_page = (int) $um->get_param('pg');
             if (empty($cur_page)) {
                 $cur_page = 1;
             }
             $this->article_list_params['search_options'] = array();
             if ($um->get_param('search_cid') && !$um->get_param('search_do_advanced')) {
                 $this->call_url_content_handler('category');
             } else {
                 if ($um->get_param('search_do_advanced')) {
                     if (VIVVO_MODULES_SEARCH == 1 || defined('VIVVO_ADMIN_MODE')) {
                         //Search results
                         $this->article_list_params = Articles_list::get_search_params_from_url($this);
                         $this->_template->assign('PAGE_TITLE', strval($this->_lang->get_value('LNG_SEARCH_RESULTS')));
                         if ($um->get_param('type') == 'rss') {
                             define('VIVVO_RSS_FEED', true);
                             $this->_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . 'templates/_syndication/rss2.0.tpl');
                         } elseif ($um->isset_param('force_template') && $this->user && $this->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'search_results/' . $um->get_param('force_template'))) {
                             $this->_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'search_results/' . $um->get_param('force_template'));
                         } else {
                             $this->_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'search_results/' . VIVVO_SEARCH_RESULT_LAYOUT);
                         }
                     } else {
                         go_404();
                     }
                 }
             }
             if (empty($this->article_list_params['search_limit'])) {
                 $this->article_list_params['search_limit'] = 10;
             }
             $this->article_list_params['pg'] = $cur_page;
             $this->article_list_params['offset'] = ($cur_page - 1) * $this->article_list_params['search_limit'];
             if ($um->isset_param('search_sort_by')) {
                 $this->article_list_params['search_sort_by'] = $um->get_param('search_sort_by');
             }
             if ($um->isset_param('search_order')) {
                 $this->article_list_params['search_order'] = $um->get_param('search_order');
             }
             if (empty($this->article_list_params['search_sort_by'])) {
                 $this->article_list_params['search_sort_by'] = 'order_num';
                 $this->article_list_params['search_order'] = 'descending';
             } else {
                 if (empty($this->article_list_params['search_order'])) {
                     $this->article_list_params['search_order'] = 'ascending';
                 }
             }
             if (!defined('VIVVO_ADMIN_MODE')) {
                 if (defined('VIVVO_CACHE_ENABLE') && VIVVO_CACHE_ENABLE == 1 && !isset($this->article_list_params['cache'])) {
                     $this->article_list_params['cache'] = 1;
                 }
             }
             $this->_template->assign('content_params', $this->article_list_params);
             if (isset($this->article_list_params['search_options'])) {
                 $this->_template->assign('CONTENT_PARAMS_OPTIONS', $this->article_list_params['search_options']);
             }
         }
     }
 }
Esempio n. 18
0
 function email_to_a_friend($article_id, $to, $bcc, $your_email, $message)
 {
     require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php';
     if (!vivvo_hooks_manager::call('article_mail', array(&$article_id, &$to, &$bcc, &$your_email, &$message))) {
         return vivvo_hooks_manager::get_status();
     }
     if (VIVVO_EMAIL_ENABLE == 1) {
         if (isset($_SESSION['vivvo']['email_to_friend_time']) && $_SESSION['vivvo']['email_to_friend_time'] + VIVVO_EMAIL_FLOOD_CHECK > VIVVO_START_TIME) {
             $this->set_error_code(2202);
             return false;
         }
         $article_list = new Articles_list();
         $article = $article_list->get_article_by_id($article_id);
         $lang = vivvo_lang::get_instance();
         if ($article !== false) {
             $to = strip_tags($to);
             $bcc = strip_tags($bcc);
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $your_email)) {
                 $this->set_error_code(2032);
                 return false;
             }
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $bcc)) {
                 $bcc = '';
             }
             if (VIVVO_EMAIL_SEND_BCC) {
                 if ($bcc) {
                     $bcc .= ', ' . VIVVO_EMAIL_SEND_BCC;
                 } else {
                     $bcc = VIVVO_EMAIL_SEND_BCC;
                 }
             }
             if (VIVVO_EMAIL_SEND_CC) {
                 $headers['Cc'] = VIVVO_EMAIL_SEND_CC;
             }
             if (preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $to)) {
                 $body_template = new template();
                 $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_TO_A_FRIEND_BODY);
                 $body_template->set_string_template($template_sting);
                 $body_template->assign('article', $article);
                 $body_template->assign('user_email_address', $your_email);
                 $body_template->assign('message', $message);
                 $body = $body_template->get_output() . "\n\n";
                 $headers['From'] = $your_email;
                 $recipients = array();
                 $recipients[] = $to;
                 if ($bcc != '') {
                     $headers['Bcc'] = $bcc;
                 }
                 $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_TO_A_FRIEND_SUBJECT) . "?=";
                 $headers['Content-Type'] = "text/plain; charset=UTF-8;";
                 if (VIVVO_EMAIL_SMTP_PHP == 1) {
                     $mail_object = new Mail();
                     $mail_object->send($to, $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_USERNAME;
                         $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                     } else {
                         $mail_options['auth'] = false;
                         $mail_options['username'] = '';
                         $mail_options['password'] = '';
                     }
                     $mail_object = Mail::factory('smtp', $mail_options);
                     $mail_object->send($to, $headers, $body);
                 }
                 $article->set_emailed($article->emailed + 1);
                 $this->_post_master->set_data_object($article);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['email_to_friend_time'] = time();
                     return true;
                 } else {
                     $this->set_error_code(2033);
                     return false;
                 }
             } else {
                 $this->set_error_code(2034);
                 return false;
             }
         } else {
             $this->set_error_code(2035);
             return false;
         }
     }
 }
Esempio n. 19
0
 function get_search_params_from_url($sm)
 {
     $um = $sm->get_url_manager();
     $params = Articles_list::get_search_params($sm, $um->list);
     return $params;
 }
Esempio n. 20
0
 public function generate_output($params = array())
 {
     static $data_provider = null;
     static $ga = null;
     $data_provider != null or $data_provider = new vivvo_ga_chart_provider();
     $ga != null or $ga = vivvo_ga::get_instance(array('email' => VIVVO_GA_EMAIL, 'password' => VIVVO_GA_PASSWORD, 'profileId' => VIVVO_GA_PROFILEID, 'no_auth' => true));
     $this->set_template($params);
     unset($params['template_string']);
     unset($params['template']);
     $params = $data_provider->filter_box_params($params);
     $cache_key = 'ga_box_data_' . md5(serialize($params));
     if (vivvo_cache::get_instance()->exists($cache_key)) {
         $report = vivvo_cache::get_instance()->get($cache_key);
     } else {
         $report = $ga->getReport($params);
         empty($params['data_handler']) and $params['data_handler'] = '';
         switch ($params['data_handler']) {
             case 'article_views':
                 class_exists('Articles') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php');
                 $article_ids = array();
                 foreach ($report as $row) {
                     $article_ids[$row['dimensions']['ga:eventLabel']] = 1;
                 }
                 $articles = Articles_list::factory()->get_articles_by_ids(array_keys($article_ids));
                 for ($i = 0, $count = count($report); $i < $count; $i++) {
                     if (!empty($articles[$report[$i]['dimensions']['ga:eventLabel']])) {
                         $report[$i]['article'] = $articles[$report[$i]['dimensions']['ga:eventLabel']];
                         $report[$i]['views'] = $report[$i]['metrics']['ga:totalEvents'];
                     } else {
                         unset($report[$i]);
                     }
                 }
                 $report = array_merge($report);
             default:
         }
         vivvo_cache::get_instance()->put($cache_key, $report, null, VIVVO_GA_CACHE_PERIOD);
     }
     $this->_template->assign('report', $report);
 }
Esempio n. 21
0
 function get_articles()
 {
     if (!is_array($this->articles)) {
         require_once dirname(__FILE__) . '/Articles.class.php';
         $articles_list = new Articles_list();
         $this->articles = $articles_list->get_articles_by_tag_id($this->id);
         if ($this->articles == false) {
             $this->articles = array();
         }
     }
     return $this->articles;
 }
 function web_statistics()
 {
     $content_template = $this->load_template($this->_template_root . 'web_statistics.xml');
     $sm = vivvo_lite_site::get_instance();
     $db =& $sm->get_db();
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Categories.class.php';
     $cat_list = new Categories_list();
     $content_template->assign('website_categories', strval($cat_list->get_count()));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
     $tag_list = new Tags_list();
     $content_template->assign('website_tags', strval($tag_list->get_count()));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
     $articles_list = new Articles_list();
     $content_template->assign('website_articles', strval($articles_list->get_count()));
     $content_template->assign('website_articles_active', strval($articles_list->get_count(array('search_status' => 1))));
     $res = $db->query('SELECT sum(times_read) as times_view FROM ' . VIVVO_DB_PREFIX . 'articles_stats');
     if (!PEAR::isError($res)) {
         if ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $times_view = $row['times_view'];
         }
     }
     $content_template->assign('website_articles_view', intval($times_view));
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Comments.class.php';
     $comments_list = new Comments_list();
     $content_template->assign('website_comments', strval($comments_list->get_count()));
     $user_mng = $sm->get_user_manager();
     $user_list = $user_mng->get_user_list();
     $content_template->assign('system_staff', strval($user_list->get_count(array('search_user_type' => 'staff'))));
     return $content_template->get_output();
 }
 /**
  * Returns article object
  *
  * @return	Articles
  */
 public function get_article()
 {
     if ($this->article === false) {
         class_exists('Articles') or (require VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php');
         $article_list = new Articles_list();
         $this->article = $article_list->get_article_by_id($this->article_id);
     }
     return $this->article;
 }