Esempio n. 1
0
function usercp_url_handler(&$sm, $url_array)
{
    if (VIVVO_USER_SOURCE != 'vivvo@localhost') {
        go_404();
    }
    return array('url_module' => 'usercp.html');
}
Esempio n. 2
0
function search_url_handler(&$sm, $url_array)
{
    if (VIVVO_MODULES_SEARCH != 1) {
        go_404();
    }
    return array('url_module' => 'search.html');
}
Esempio n. 3
0
 /**
  * test the url cleaner
  */
 public function test_clean_and_validate_url()
 {
     $url = '/report/how-the-paas-market-is-moving-beyond-deployment-and-scaling/\'+trackingPixel+\'`';
     $this->assertNull(go_404()->clean_and_validate_url($url));
     // now add a post with the correct slug
     register_post_type('go-report', array('public' => TRUE));
     $post_id = wp_insert_post(array('post_content' => 'lalala', 'post_name' => 'how-the-paas-market-is-moving-beyond-deployment-and-scaling', 'post_title' => 'How the PAAS Market Is Moving Beyond Deployment And Scaling', 'post_status' => 'publish', 'post_type' => 'go-report'));
     $cleaned_url = go_404()->clean_and_validate_url($url);
     $this->assertFalse(empty($cleaned_url));
     $this->assertTrue(0 < strpos($cleaned_url, '/go-report/'));
     $this->assertTrue(0 < strpos($cleaned_url, '/how-the-paas-market-is-moving-beyond-deployment-and-scaling'));
     $this->assertFalse(strpos($cleaned_url, '\'+trackingPixel+\'`'));
 }
Esempio n. 4
0
function page_url_handler(&$sm, $url_array)
{
    $um = $sm->get_url_manager();
    if ($url_array[0] != '404') {
        require_once dirname(__FILE__) . '/Pages.class.php';
        $page_list = new Pages_list($sm);
        $page = $page_list->get_pages_by_sefriendly(str_replace('.html', '', $url_array[0]));
        if ($page) {
            return array('url_module' => $url_array[0], 'search_page' => $page->id);
        } else {
            go_404();
        }
    }
    return false;
}
Esempio n. 5
0
function topic_content_handler(&$sm)
{
    $template = $sm->get_template();
    $header = $sm->get_header_manager();
    $um = $sm->get_url_manager();
    if (!$um->isset_param('search_tid')) {
        go_404();
    }
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php';
    $tags_groups_list = new TagsGroups_list($sm);
    $tags_group = $tags_groups_list->get_group_by_id($um->get_param('search_tid'));
    if (!$tags_group) {
        go_404();
    }
    $tag = false;
    if ($um->isset_param('search_lid')) {
        require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
        $tags_list = new Tags_list($sm);
        $tag = $tags_list->get_tag_by_id($um->get_param('search_lid'));
        if (!$tag) {
            go_404();
        }
        $tag->set_group_url($tags_group->get_href());
        $tag->set_group_name($tags_group->get_name());
    }
    $template->assign('topic', $tags_group);
    $template->assign('tag', $tag);
    $template->assign('label', $tag);
    // @deprecated
    if ($um->isset_param('pg')) {
        $template->assign('pg', $um->get_param('pg'));
    }
    if ($tag) {
        $dir = 'label/';
        $file = $tags_group->get_tag_template();
    } else {
        $dir = 'topic/';
        $file = $tags_group->get_template();
    }
    $base = VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR;
    if (!is_file($tpl = $base . $dir . $file)) {
        $tpl = $base . $dir . 'default.tpl';
    }
    $template->set_template_file($tpl);
}
Esempio n. 6
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. 7
0
if (!file_exists(RELATIVE_PATH_TO_ROOT . $filepath)) {
    go_404('error3');
}
# output a mediatype header
$ext = array_pop(explode('.', RELATIVE_PATH_TO_ROOT . $filepath));
switch ($ext) {
    case 'css':
        header("Content-type: text/css");
        break;
    case 'js':
        header("Content-type: text/javascript");
        break;
        // script is currently called only for js and css files!
    // script is currently called only for js and css files!
    default:
        go_404('error4');
        break;
        /*    
            case 'gif':
              header("Content-type: image/gif");
              break;
            case 'jpg':
              header("Content-type: image/jpeg");
              break;
            case 'png':
              header("Content-type: image/png");
              break;
            default:
              header("Content-type: text/plain");
        */
}
Esempio n. 8
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. 9
0
function category_content_handler(&$sm)
{
    $template =& $sm->get_template();
    $header =& $sm->get_header_manager();
    $categories =& $sm->get_categories();
    $um =& $sm->get_url_manager();
    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;
    }
    $sm->article_list_params['search_options'] = array();
    //Category page
    $category =& $categories->get_category($um->get_param('search_cid'));
    if ($category->redirect) {
        header('Location:' . $category->redirect);
        exit;
    }
    if ($category) {
        $sm->article_list_params['search_options']['search_cid'] = $um->get_param('search_cid');
        if (VIVVO_MODULES_FEED == 1) {
            $header->add_rss(switch_format('rss', CURRENT_URL), $category->category_name);
        }
        define('VIVVO_CURENT_CATEGORY', $um->get_param('search_cid'));
        $template->assign('CURRENT_CATEGORY', $category);
        if ($um->isset_param('force_template') && $sm->user && $sm->user->is_admin() && file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $um->get_param('force_template'))) {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $um->get_param('force_template'));
        } else {
            $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'category/' . $category->get_template());
        }
        $sm->article_list_params['search_limit'] = $category->article_num;
        $template->assign('PAGE_TITLE', strval($category->get_category_name()));
        $sm->set_theme($category->get_css());
    } else {
        go_404();
    }
    if (empty($sm->article_list_params['search_limit'])) {
        $sm->article_list_params['search_limit'] = 10;
    }
    $sm->article_list_params['pg'] = $cur_page;
    $sm->article_list_params['offset'] = ($cur_page - 1) * $sm->article_list_params['search_limit'];
    if ($um->isset_param('search_sort_by')) {
        $sm->article_list_params['search_sort_by'] = $um->get_param('search_sort_by');
    }
    if ($um->isset_param('search_order')) {
        $sm->article_list_params['search_order'] = $um->get_param('search_order');
    }
    if (empty($sm->article_list_params['search_sort_by'])) {
        $sm->article_list_params['search_sort_by'] = 'order_num';
        $sm->article_list_params['search_order'] = 'descending';
    } else {
        if (empty($sm->article_list_params['search_order'])) {
            $sm->article_list_params['search_order'] = 'ascending';
        }
    }
    if (!defined('VIVVO_ADMIN_MODE')) {
        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);
    if (isset($sm->article_list_params['search_options'])) {
        $template->assign('CONTENT_PARAMS_OPTIONS', $sm->article_list_params['search_options']);
    }
}
Esempio n. 10
0
 function parse_url($force = false)
 {
     //TODO srediti non friendly urls
     $sm = vivvo_lite_site::get_instance();
     if (!$force && (defined('VIVVO_ADMIN_MODE') || defined('VIVVO_SKIP_URL_PARSING'))) {
         return;
     }
     if (preg_match('/[a-zA-Z0-9_]*\\.php/', $this->_url_array[0])) {
         return;
     } elseif (strtolower($this->_url_array[0]) == '404.html') {
         $this->list['404'] = true;
     } elseif ($sm->is_registered_url($this->_url_array[0] . $this->list['output_type'])) {
         $res = $sm->call_url_handler($this->_url_array[0] . $this->list['output_type'], $this->_url_array);
         if ($res === false) {
             go_404();
         } else {
             if (is_array($res) && !empty($res)) {
                 $this->list = array_merge($this->list, $res);
             }
         }
         return;
     } elseif ($sm->is_registered_url($this->_url_array[0])) {
         $res = $sm->call_url_handler($this->_url_array[0], $this->_url_array);
         if ($res === false) {
             go_404();
         } else {
             if (is_array($res) && !empty($res)) {
                 $this->list = array_merge($this->list, $res);
             }
         }
         return;
         // Plugin URL
     } elseif (strtolower($this->_url_array[0]) == 'app') {
         if (isset($this->_url_array[1])) {
             $this->list['plugin'] = $this->_url_array[1];
             $pm = $sm->get_plugin_manager();
             $plagin_name = $this->_url_array[1];
             array_shift($this->_url_array);
             array_shift($this->_url_array);
             $parsed_url = $pm->url_handler($plagin_name, $this->_url_array);
             if (is_array($parsed_url) && !empty($parsed_url)) {
                 foreach ($parsed_url as $k => $v) {
                     $this->list[$k] = $v;
                 }
             }
         }
     }
 }
Esempio n. 11
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. 12
0
function error_not_found()
{
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/vivvo_lite_site.php';
    go_404();
}
Esempio n. 13
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. 14
0
 /**
  * Handles chart url
  *
  * @param	array	$url_array
  */
 public static function route($url_array)
 {
     is_array($url_array) or go_404();
     if (count($url_array) == 2 and $url_array[1] == 'export') {
         include VIVVO_FS_INSTALL_ROOT . 'flash/amline/export.php';
         exit;
     }
     count($url_array) == 3 or go_404();
     if (isset($_SESSION['vivvo'], $_SESSION['vivvo']['chart'], $_SESSION['vivvo']['chart'][$url_array[1]])) {
         $chart = $_SESSION['vivvo']['chart'][$url_array[1]];
         $data_provider = false;
         if (is_array($chart['provider'])) {
             $data_provider = self::load_data_provider($chart['provider']);
         }
         $data_provider instanceof vivvo_chart_data_provider or go_404();
         if ($url_array[2] == 'settings') {
             header('Content-Type: text/xml');
             echo self::get_settings($data_provider, $chart['params']);
             exit;
         } elseif ($url_array[2] == 'data') {
             header('Content-Type: text/csv');
             echo self::get_data($data_provider, $chart['params']);
             exit;
         }
     }
     go_404();
 }
Esempio n. 15
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. 16
0
                if (strtolower($ext) == 'gif') {
                    header('Content-type: image/gif');
                } elseif (strtolower($ext) == 'jpg' || strtolower($ext) == 'jpeg') {
                    header("Content-type: image/jpeg");
                } elseif (strtolower($ext) == 'png') {
                    header("Content-type: image/png");
                } elseif (strtolower($ext) == 'flv') {
                    header("Content-type: video/x-FLV");
                } elseif (strtolower($ext) == 'avi') {
                    header("Content-type: video/x-msvideo");
                } elseif (strtolower($ext) == 'wmf') {
                    header("Content-type: application/x-msmetafile");
                } elseif (strtolower($ext) == 'mov' || strtolower($ext) == 'qt') {
                    header("Content-type: video/quicktime");
                } elseif (strtolower($ext) == 'swf') {
                    header("Content-type: application/x-shockwave-flash");
                } else {
                    header("Content-type: application/force-download");
                    header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
                }
                readfile($file);
            } else {
                header("Content-type: application/force-download");
                header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
                readfile($file);
            }
        } else {
            go_404();
        }
    }
}
Esempio n. 17
0
 function parse_url($force = false)
 {
     //TODO srediti non friendly urls
     if (vivvo_hooks_manager::call('url_parse_pre', array(&$this, &$force)) == false) {
         return;
     }
     if (!$force && (defined('VIVVO_ADMIN_MODE') || defined('VIVVO_SKIP_URL_PARSING'))) {
         return;
     }
     $sm = vivvo_lite_site::get_instance();
     $pm = $sm->get_plugin_manager();
     $user = $sm->user;
     empty($this->_url_array) and $this->_url_array[0] = 'index.php';
     // default is index
     // Fix for #594 (plain text version on article preview)
     if ($user and $user->can('ACCESS_ADMIN') and count($this->_url_array) == 1 and $this->_url_array[0] == 'index.php' and !empty($_GET['news']) and !empty($this->list['output_type']) and $this->list['output_type'] != 'php') {
         $this->_url_array = array('feed', 'index.' . $this->list['output_type']);
     }
     if (preg_match('/[a-zA-Z0-9_]*\\.php/', $this->_url_array[0])) {
         return;
     } elseif (strtolower($this->_url_array[0]) == '404.html') {
         $this->list['404'] = true;
     } elseif ($sm->is_registered_url($this->_url_array[0] . $this->list['output_type'])) {
         if (vivvo_hooks_manager::call('url_parse_handler_pre', array(&$this, $this->_url_array[0] . $this->list['output_type']))) {
             $res = $sm->call_url_handler($this->_url_array[0] . $this->list['output_type'], $this->_url_array);
             vivvo_hooks_manager::call('url_parse_handler_post', array(&$this, $this->_url_array[0] . $this->list['output_type'], &$res));
             if ($res === false) {
                 go_404();
             } else {
                 if (is_array($res) && !empty($res)) {
                     $this->list = array_merge($this->list, $res);
                 }
             }
         }
         return;
     } elseif ($sm->is_registered_url($this->_url_array[0])) {
         if (vivvo_hooks_manager::call('url_parse_handler_pre', array(&$this, $this->_url_array[0]))) {
             $res = $sm->call_url_handler($this->_url_array[0], $this->_url_array);
             vivvo_hooks_manager::call('url_parse_handler_post', array(&$this, $this->_url_array[0], &$res));
             if ($res === false) {
                 go_404();
             } else {
                 if (is_array($res) && !empty($res)) {
                     $this->list = array_merge($this->list, $res);
                 }
             }
         }
         return;
     } elseif (strtolower($this->_url_array[0]) == 'app') {
         if (isset($this->_url_array[1])) {
             $this->list['plugin'] = $this->_url_array[1];
             $plagin_name = $this->_url_array[1];
             array_shift($this->_url_array);
             array_shift($this->_url_array);
             $parsed_url = $pm->url_handler($plagin_name, $this->_url_array);
             if (is_array($parsed_url) && !empty($parsed_url)) {
                 foreach ($parsed_url as $k => $v) {
                     $this->list[$k] = $v;
                 }
             }
         }
     } elseif (count($this->_url_array) > 0) {
         $last_chunk = end($this->_url_array);
         $url_count = count($this->_url_array);
         if ($url_count == 1) {
             //all news
             if (preg_match('/^index\\.(\\d+)?.*' . $this->list['output_type'] . '?$/i', $last_chunk, $filename)) {
                 if (!empty($filename[1])) {
                     $this->list['pg'] = $filename[1];
                 }
                 array_pop($this->_url_array);
             } else {
                 if (vivvo_hooks_manager::call('url_parse_default_pre', array(&$this))) {
                     $res = $sm->call_url_handler('category', $this->_url_array);
                     if ($res === false) {
                         go_404();
                     } else {
                         if (is_array($res) && !empty($res)) {
                             $this->list = array_merge($this->list, $res);
                         }
                         vivvo_hooks_manager::call('url_parse_default_post');
                     }
                 }
             }
         } else {
             if (vivvo_hooks_manager::call('url_parse_default_pre', array(&$this))) {
                 $res = $sm->call_url_handler('category', $this->_url_array);
                 if ($res === false) {
                     go_404();
                 } else {
                     if (is_array($res) && !empty($res)) {
                         $this->list = array_merge($this->list, $res);
                     }
                 }
                 //article URL
                 if (!empty($this->list['output_type'])) {
                     if (isset($this->list['search_cid']) && !preg_match('/^index\\.(\\d+)?.*' . $this->list['output_type'] . '?$/i', $last_chunk)) {
                         if (VIVVO_URL_FORMAT != 0 && $sm->is_registered_url('article' . VIVVO_URL_FORMAT)) {
                             $res = $sm->call_url_handler('article' . VIVVO_URL_FORMAT, $this->_url_array);
                         } else {
                             $res = $sm->call_url_handler('article', $this->_url_array);
                         }
                         if ($res === false) {
                             go_404();
                         } else {
                             if (is_array($res) && !empty($res)) {
                                 $this->list = array_merge($this->list, $res);
                             }
                         }
                     }
                 }
                 vivvo_hooks_manager::call('url_parse_default_post');
             }
         }
     }
 }