function _default_view()
 {
     $template = vivvo_lite_site::get_instance()->get_template();
     $template->assign_template('content', $this->load_template($this->_template_root . 'content.xml'));
     $template->assign_template('left', $this->load_template($this->_template_root . 'tabs.xml'));
     return $template;
 }
 function check_token()
 {
     if (!vivvo_lite_site::get_instance()->check_token()) {
         //TODO: error number
         $this->set_error_code(2121);
         return false;
     }
     return true;
 }
 function _list_output()
 {
     $um = vivvo_lite_site::get_instance()->get_url_manager();
     $template = $this->load_template($this->_template_root . 'list.xml');
     foreach (array('search_article_id', 'search_author_name') as $filter) {
         if ($um->isset_param($filter)) {
             $template->assign($filter, $um->get_param($filter));
         }
     }
     return $template;
 }
 function num_tagged_articles($tag_id, $topic_id)
 {
     $tag_id = (int) $tag_id;
     $topic_id = (int) $topic_id;
     $sql = 'SELECT COUNT(*) FROM ' . VIVVO_DB_PREFIX . "ArticlesTags WHERE tag_id = {$tag_id} AND tags_group_id = {$topic_id}";
     $res = vivvo_lite_site::get_instance()->get_db()->query($sql);
     if (!PEAR::isError($sql) && ($total = $res->fetchOne())) {
         return $total;
     }
     return 0;
 }
 /**
  * Load configuration data from database
  */
 function load_configuration($force = false)
 {
     if (!$force and ($data = vivvo_cache::get_instance()->get('configuration')) !== false) {
         if (!empty($data)) {
             $this->_config_data = $data;
             return;
         }
     }
     $db = vivvo_lite_site::get_instance()->get_db();
     $res = $db->query('SELECT * FROM ' . VIVVO_DB_PREFIX . 'configuration');
     $this->_config_data = array();
     if (!PEAR::isError($res)) {
         while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $this->_config_data[] = $row;
         }
         $res->free();
     }
     vivvo_cache::get_instance()->put('configuration', $this->_config_data);
 }
Example #6
0
 function get_view()
 {
     $sm = vivvo_lite_site::get_instance();
     $template = $sm->get_template();
     $um = $sm->get_url_manager();
     $pm = $sm->get_plugin_manager();
     $dm = $sm->get_dump_manager();
     $template->assign('DUMP_MESSAGES', $dm->_dump_pool);
     $this->_default_assignments();
     $um_keys = array_keys($um->list);
     $views = array_intersect($this->views, $um_keys);
     $default_view = false;
     if (!empty($views)) {
         $view = current($views);
         if (method_exists($this, '_' . $view)) {
             $tpl = call_user_func(array($this, '_' . $view));
         } elseif (file_exists($this->_template_root . $view . '.xml')) {
             $tpl = $this->load_template($this->_template_root . $view . '.xml');
         } else {
             die('No such view');
         }
         echo $tpl->get_output();
     } else {
         if ($this->_default_view) {
             $tpl =& call_user_func(array($this, $this->_default_view));
             echo $tpl->get_output();
         } else {
             $tpl = $this->_default_view();
             echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
             echo $sm->get_output();
         }
     }
     if ($sm->user && $sm->user->is_admin()) {
         $sm->fb_debug_output();
     }
 }
 /**
  * Autocomplete box feed
  */
 public function _autocomplete_links()
 {
     $sm = vivvo_lite_site::get_instance();
     $template = $sm->get_template();
     $um = $sm->get_url_manager();
     $pm = $sm->get_plugin_manager();
     $content_template = new template(null, $template);
     $content_template->set_template_file($this->_template_root . 'autocomplete_links.xml');
     $hrefs = array();
     $db = $sm->get_db();
     $name = secure_sql($um->get_param('name'));
     $sql = "(SELECT id, category_name AS title, sefriendly, '' AS category_id,  'Categories' AS type FROM " . VIVVO_DB_PREFIX . "categories WHERE category_name LIKE '{$name}%')\n\t\t\t\t\t UNION\n\t\t\t\t    (SELECT id, title, sefriendly, category_id, 'Articles' AS type FROM " . VIVVO_DB_PREFIX . "articles WHERE title LIKE '{$name}%')";
     if ($pm->is_installed('pages')) {
         $sql .= "UNION (SELECT id, title, sefriendly, '' AS category_id, 'Pages' AS type FROM " . VIVVO_DB_PREFIX . "pages WHERE title LIKE '{$name}%')";
     }
     $sql .= "UNION (SELECT t.id, CONCAT(tg.name,': ',t.name) AS title, t.sefriendly AS sefriendly, tg.url AS category_id, 'Tags' AS type FROM " . VIVVO_DB_PREFIX . "tags AS t INNER JOIN " . VIVVO_DB_PREFIX . "tags_to_tags_groups AS ttg ON ttg.tag_id = t.id INNER JOIN " . VIVVO_DB_PREFIX . "tags_groups AS tg ON ttg.tags_group_id = tg.id WHERE t.name LIKE '{$name}%' GROUP BY t.id, tg.id) " . "UNION (SELECT id, name AS title, url AS sefriendly, '' AS category_id,  'Topics' AS type FROM " . VIVVO_DB_PREFIX . "tags_groups WHERE name LIKE '{$name}%')";
     $res = $db->query($sql);
     if (!PEAR::isError($res)) {
         $i = 0;
         while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $hrefs[$i] = array();
             $hrefs[$i]['title'] = $row['title'];
             $hrefs[$i]['id'] = $row['id'];
             $hrefs[$i]['type'] = $row['type'];
             switch ($row['type']) {
                 case 'Articles':
                     if (!$article) {
                         require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
                         $article = new Articles();
                     }
                     $article->id = $row['id'];
                     $article->title = $row['title'];
                     $article->sefriendly = $row['sefriendly'];
                     $article->category_id = $row['category_id'];
                     $hrefs[$i]['href'] = $article->get_href();
                     break;
                 case 'Categories':
                     if (!$cat) {
                         $cat = $sm->get_categories();
                     }
                     $hrefs[$i]['href'] = $cat->list[$row['id']]->get_href();
                     break;
                 case 'Pages':
                     if (!$page) {
                         require_once VIVVO_FS_PLUGIN_ROOT . 'plugins/pages/Pages.class.php';
                         $page = new Pages();
                     }
                     $page->id = $row['id'];
                     $page->title = $row['title'];
                     $page->sefriendly = $row['sefriendly'];
                     $hrefs[$i]['href'] = $page->get_href();
                     break;
                 case 'Tags':
                     if (!$tag) {
                         require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Tags.class.php';
                         $tag = new Tags();
                     }
                     $tag->id = $row['id'];
                     $tag->name = $row['title'];
                     $tag->sefriendly = $row['sefriendly'];
                     $tag->group_url = $row['category_id'] . '/';
                     $hrefs[$i]['href'] = $tag->get_href();
                     break;
                 case 'Topics':
                     if (!$topic) {
                         require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/TagsGroups.class.php';
                         $topic = new TagsGroups();
                     }
                     $topic->id = $row['id'];
                     $topic->name = $row['title'];
                     $topic->url = $row['sefriendly'];
                     $hrefs[$i]['href'] = rtrim($topic->get_href(), '/');
                     break;
             }
             $i++;
         }
     }
     $content_template->assign('link_list', $hrefs);
     return $content_template;
 }
Example #8
0
 /**
  * Cascade delete
  */
 function on_delete($post_master)
 {
     $post_master->sql_delete_list('articles_tags', "article_id={$this->id}");
     $post_master->sql_delete_list('articles_schedule', "article_id={$this->id}");
     $post_master->sql_delete_list('articles_revisions', "article_id={$this->id}");
     $post_master->sql_delete_list('articles_stats', "article_id={$this->id}");
     $post_master->sql_delete_list('comments', "article_id={$this->id}");
     $post_master->sql_delete_list('article_attachments', "article_id={$this->id}");
     $post_master->sql_delete_list('article_images', "article_id={$this->id}");
     admin_log(vivvo_lite_site::get_instance()->user->get_username(), 'Deleted article #' . $this->id);
 }
 function _list_output($assign_list = true)
 {
     $sm = vivvo_lite_site::get_instance();
     $pm = $sm->get_plugin_manager();
     require_once dirname(__FILE__) . '/poll.class.php';
     $content_template =& $this->load_template($this->_template_root . 'list.xml');
     $content_template->assign('PLUGIN_ROOT', $pm->plugins['poll']['root_dir']);
     $um = $sm->get_url_manager();
     if ($um->isset_param('action') && $um->isset_param('cmd') && $um->get_param('cmd') == 'add' && $sm->action_status === false) {
         $in_poll_question = $um->get_param_regexp('/^PLUGIN_POLL_/');
         $current_poll_question = new vivvo_poll_question(null, $in_poll_question);
         $content_template->assign('poll', $current_poll_question);
     } elseif ($um->isset_param('search_pid') && $um->get_param('search_pid') != '') {
         $poll_list = new vivvo_poll_question_list();
         $poll =& $poll_list->get_question($um->get_param('search_pid'));
         $content_template->assign('poll', $poll);
         $content_template->assign('answer_list', $poll->answer->list);
     } else {
         $poll_list = new vivvo_poll_question_list();
         $poll =& $poll_list->get_question_by_status(1);
         $content_template->assign('poll', $poll);
         $content_template->assign('answer_list', $poll->answer->list);
     }
     if ($um->isset_param('action') && $um->isset_param('cmd') && ($um->get_param('cmd') == 'delete' or $um->get_param('cmd') == 'deactivate' or $um->get_param('cmd') == 'activate')) {
         $content_template->assign('list_output', strval(1));
     }
     return $content_template;
 }
Example #10
0
    header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . 'installer/install.html');
    exit;
}
define('CURRENT_URL', htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
// leave query part of URL only for revision preview pages (cache each revision separately)
if (preg_match('/index\\.php\\?news=\\d+&rev=\\d+$/', $_SERVER['REQUEST_URI'])) {
    define('CACHE_URL', CURRENT_URL);
} else {
    define('CACHE_URL', htmlspecialchars('http://' . $_SERVER['HTTP_HOST'] . preg_replace('/\\?.*$/', '', $_SERVER['REQUEST_URI'])));
}
require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/framework/full_page_cache.functions.php';
list($output, $uncached_boxes) = full_page_cache_load();
require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/vivvo_lite_site.php';
require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/box/vivvo_box.php';
require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/functions.php';
$sm = vivvo_lite_site::get_instance();
$sm->output = $output;
$um = $sm->get_url_manager();
$dm = $sm->get_dump_manager();
if (defined('VIVVO_ROOT_CATEGORY')) {
    $cat = $sm->get_categories();
    define('VIVVO_FORCE_CATEGORY_RESTRICTION', implode(',', $cat->root_category->get_descendent_ids()));
}
$cat = $sm->get_categories();
$template = $sm->get_template();
$template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'homepage/' . VIVVO_HOMEPAGE_LAYOUT);
if (!$um->isset_param('cmd') && $um->get_param('cmd') != 'forgotMail' && !$um->isset_param('activation_key')) {
    check_close_site($sm);
}
$action = $sm->execute_action();
if ($um->isset_param('action') && $um->get_param('action')) {
 /**
  * Delete user filter
  *
  * @param	integer	$filter_id
  * @return	boolean	true on success or false on fail
  */
 function delete_UserFilters($filter_id)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('UserFilter_delete', array(&$filter_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     if ($sm->user) {
         $filter_list = new UserFilters_list();
         $filter_list->get_UserFilter_by_id($filter_id);
         if ($filter_list->sql_delete_list($this->_post_master)) {
             admin_log($sm->user->get_username(), 'Deleted user filter #' . $filter_id);
             return true;
         } else {
             $this->set_error_code(2503);
             return false;
         }
     } else {
         $this->set_error_code(2504);
         return false;
     }
 }
 public function _force_import()
 {
     require_once dirname(__FILE__) . '/tasks/auto_import_feeds.php';
     define('VIVVO_FEED_IMPORTER_ADMIN_VIEW', true);
     auto_import_feeds(vivvo_lite_site::get_instance());
     header('Content-Type: application/json');
     exit;
 }
Example #13
0
 function on_delete($post_master)
 {
     $poll_answer_list =& new vivvo_poll_answer_list(vivvo_lite_site::get_instance());
     $poll_answer_list->get_answers_by_poll_id($this->id);
     $poll_answer_list->sql_delete_list($post_master);
 }
Example #14
0
 /**
  * Performs db search based on parameters from url manager
  *
  * @return	array
  */
 public static function search_from_url()
 {
     $sm = vivvo_lite_site::get_instance();
     $params = self::get_search_params_from_url($sm);
     $list = new self($sm);
     return $list->search($params['search_options'], $params['search_sort_by'], $params['search_order'], $params['search_limit'], $params['offset']);
 }
Example #15
0
 function get_hrefs($ids)
 {
     $hrefs = array();
     if (is_array($ids)) {
         $ids = implode(',', $ids);
     }
     $sm = vivvo_lite_site::get_instance();
     $sql = 'SELECT id, category_name FROM ' . VIVVO_DB_PREFIX . $this->_sql_table . ' WHERE id IN (' . secure_sql_in($ids) . ')';
     $res = $sm->get_db()->query($sql);
     if (!PEAR::isError($res)) {
         while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $hrefs[$row['id']] = array();
             $hrefs[$row['id']]['title'] = $row['category_name'];
             $hrefs[$row['id']]['href'] = Categories::format_href($sm, $row['id']);
         }
     }
     return $hrefs;
 }
Example #16
0
 /**
  * Generate box output
  *
  * @param array $params Parameters
  */
 function generate_output($params)
 {
     $this->set_template($params);
     if (isset($params['max_page'])) {
         $max_page = (int) $params['max_page'];
     } else {
         $max_page = 10;
     }
     if (isset($params['list']) && is_a($params['list'], 'vivvo_db_list')) {
         $paging_params = $params['list']->get_pagination();
         $this->pagination = new pagination($paging_params['pg_records_per_page'], $max_page, $paging_params['pg_href']);
         $this->pagination->set_template($this->_template);
         $this->pagination->generate_pagelist($paging_params['pg_total'], $paging_params['pg_current']);
     } elseif (isset($params['list']) && is_a($params['list'], 'vivvo_file_paged_list')) {
         $paging_params = $params['list']->get_pagination();
         $this->pagination = new pagination($paging_params['pg_records_per_page'], $max_page, $paging_params['pg_href']);
         $this->pagination->set_template($this->_template);
         $this->pagination->generate_pagelist($paging_params['pg_total'], $paging_params['pg_current']);
     } else {
         $um = vivvo_lite_site::get_instance()->get_url_manager();
         $this->pagination = new pagination($um->get_param('pg_records_per_page'), $max_page, $um->get_param('pg_href'));
         $this->pagination->set_template($this->_template);
         $this->pagination->generate_pagelist($um->get_param('pg_total'), $um->get_param('pg_current'));
     }
     if (isset($params['title'])) {
         $this->_template->assign('title', $params['title']);
     }
     $this->_template->assign('box_id', $params['box_id']);
 }
Example #17
0
 /**
  * Remove tag from tag group
  *
  * @param	int		$tag_id
  * @param	int		$group_id
  */
 public function remove_tag_from_group($tag_id, $group_id)
 {
     if (!vivvo_hooks_manager::call('tag_removeTagFromGroup', array(&$tag_id, &$group_id))) {
         return vivvo_hooks_manager::get_status();
     }
     $user = vivvo_lite_site::get_instance()->user;
     if ($user && $user->can('MANAGE_TAGS')) {
         $tag_group_rel = new TagsToTagsGroups_list();
         $tag_group_rel->get_rel($tag_id, $group_id);
         if ($tag_group_rel->sql_delete_list($this->_post_master)) {
             return true;
         }
         $this->set_error_code(2416);
         return false;
     }
     $this->set_error_code(2410);
     return false;
 }
Example #18
0
 /**
  * Returns chart data
  *
  * @param 	array		$params
  * @return	array
  */
 public function get_chart_data(array $params = array())
 {
     $sm = vivvo_lite_site::get_instance();
     if (!$sm->user) {
         return array();
     }
     $cache_key = 'ga_chart_data_' . md5(serialize($params));
     if (vivvo_cache::get_instance()->exists($cache_key)) {
         return vivvo_cache::get_instance()->get($cache_key);
     }
     $ga = vivvo_ga::get_instance(array('email' => VIVVO_GA_EMAIL, 'password' => VIVVO_GA_PASSWORD, 'profileId' => VIVVO_GA_PROFILEID, 'no_auth' => true));
     $report = $ga->getReport($params);
     if (empty($report)) {
         return array(0);
     }
     $data = array();
     empty($params['data_handler']) and $params['data_handler'] = '';
     $min = $max = 0;
     switch ($params['data_handler']) {
         case 'article_views':
             $labels = array();
             foreach ($report as $row) {
                 $labels[$row['dimensions']['ga:eventLabel']] = 1;
             }
             $labels = array_keys($labels);
             foreach ($report as $result) {
                 if (isset($result['dimensions']['ga:date']) && preg_match('/^(\\d{4})(\\d{2})(\\d{2})$/', $result['dimensions']['ga:date'], $part)) {
                     if (isset($result['dimensions']['ga:hour'])) {
                         $hour = $result['dimensions']['ga:hour'] << 0;
                         $format = 'd M Y H\\h';
                         $step = 3600;
                     } else {
                         $hour = 0;
                         $format = 'd M Y';
                         $step = 86400;
                     }
                     $time = mktime($hour, 0, 0, $part[2], $part[3], $part[1]);
                     $time > $max and $max = $time;
                     if ($time < $min or $min == 0) {
                         $min = $time;
                     }
                     $key = format_date(date('Y-m-d H:00:00', $time), $format);
                     if (!isset($data[$key])) {
                         $data[$key] = array_fill(0, count($labels), 0);
                     }
                     $data[$key][array_search($result['dimensions']['ga:eventLabel'], $labels)] = $result['metrics']['ga:totalEvents'];
                 }
             }
             break;
         case 'article_overall_stats':
         case 'article_stats':
             $labels = array();
             foreach ($report as $row) {
                 $labels[$row['dimensions']['ga:eventAction']] = 1;
             }
             $labels = array_keys($labels);
             foreach ($report as $result) {
                 if (isset($result['dimensions']['ga:date']) && preg_match('/^(\\d{4})(\\d{2})(\\d{2})$/', $result['dimensions']['ga:date'], $part)) {
                     if (isset($result['dimensions']['ga:hour'])) {
                         $hour = $result['dimensions']['ga:hour'] << 0;
                         $format = 'd M Y H\\h';
                         $step = 3600;
                     } else {
                         $hour = 0;
                         $format = 'd M Y';
                         $step = 86400;
                     }
                     $time = mktime($hour, 0, 0, $part[2], $part[3], $part[1]);
                     $time > $max and $max = $time;
                     if ($time < $min or $min == 0) {
                         $min = $time;
                     }
                     $key = format_date(date('Y-m-d H:00:00', $time), $format);
                     if (!isset($data[$key])) {
                         $data[$key] = array_fill(0, count($labels), 0);
                     }
                     $data[$key][array_search($result['dimensions']['ga:eventAction'], $labels)] = $result['metrics']['ga:totalEvents'];
                 }
             }
             break;
         default:
             foreach ($report as $result) {
                 if (isset($result['dimensions']['ga:date']) && preg_match('/^(\\d{4})(\\d{2})(\\d{2})$/', $result['dimensions']['ga:date'], $part)) {
                     if (isset($result['dimensions']['ga:hour'])) {
                         $hour = $result['dimensions']['ga:hour'] << 0;
                         $format = 'd M Y H\\h';
                         $step = 3600;
                     } else {
                         $hour = 0;
                         $format = 'd M Y';
                         $step = 86400;
                     }
                     $time = mktime($hour, 0, 0, $part[2], $part[3], $part[1]);
                     $time > $max and $max = $time;
                     if ($time < $min or $min == 0) {
                         $min = $time;
                     }
                     $key = format_date(date('Y-m-d H:00:00', $time), $format);
                     $data[$key] = array();
                     foreach ($result['metrics'] as $metric => $value) {
                         $data[$key][] = $value;
                     }
                 }
             }
     }
     $sample = reset($data);
     if (is_array($sample)) {
         $empty = array_fill(0, count($sample), 0);
     } else {
         $empty = 0;
     }
     for ($i = $min; $i < $max; $i += $step) {
         $key = format_date(date('Y-m-d H:00:00', $i), $format);
         if (!isset($data[$key])) {
             $data[$key] = $empty;
         }
     }
     uksort($data, array(self, 'date_string_compare'));
     $ret = array();
     foreach ($data as $date => $values) {
         array_unshift($values, $date);
         $ret[] = $values;
     }
     vivvo_cache::get_instance()->put($cache_key, $ret, null, VIVVO_GA_CACHE_PERIOD);
     return $ret;
 }
 /**
  * Update all objects from list
  *
  * @param	vivvo_post_master	$post_master	(not used)
  * @param 	array 				$params 		Params to change assoc array
  * @param 	array 				$restiction		Restriction ids
  *
  * @return	bool
  */
 public function sql_update_list($post_master, $params, $restriction = NULL, $all_matching = false)
 {
     $ids = $this->get_list_ids();
     if ($ids && is_array($restriction) && !empty($restriction)) {
         $ids = array_intersect($ids, $restriction);
     }
     if ($ids) {
         $where = $this->id_key . ' IN (' . secure_sql_in($ids) . ')';
     } elseif ($all_matching === true) {
         $where = str_replace('WHERE', ' ', $this->_query->get_where());
     }
     $updates = array();
     foreach ($params as $name => $value) {
         $updates[] = "{$name} = {$value}";
     }
     $updates = implode(', ', $updates);
     $query = 'UPDATE ' . VIVVO_DB_PREFIX . "articles_schedule SET {$updates} WHERE {$where}";
     $sm = vivvo_lite_site::get_instance();
     $sm->debug_push('sql:', $query);
     $sm->get_db()->exec($query);
     return true;
 }
Example #20
0
 /**
  * Confirmation procedure
  *
  * @param	string	$ack
  * @return	boolean	true on success or false on fail
  */
 function confirm($ack)
 {
     if (!vivvo_hooks_manager::call('login_confirm', array(&$ack))) {
         return vivvo_hooks_manager::get_status();
     }
     $user_list = new Users_list();
     $user = $user_list->get_user_by_md5($ack);
     if ($user === false) {
         $this->set_error_code(2710);
         return false;
     } else {
         $user->set_activated('1');
         vivvo_lite_site::get_instance()->get_template()->assign('CONFIRMED', 1);
         $this->_post_master->set_data_object($user);
         if ($this->_post_master->sql_update()) {
             return true;
         } else {
             $this->set_error_code(2711);
             return false;
         }
     }
 }
Example #21
0
 function set__file_manager()
 {
     $this->_file_manager = vivvo_lite_site::get_instance()->get_file_manager();
 }
 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();
 }
 function group_edit($group_id, $in_group)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('vivvoCore_groupEdit', array(&$group_id, &$in_group))) {
         return vivvo_hooks_manager::get_status();
     }
     if ($this->_user && $this->_user->is_admin()) {
         $sm = vivvo_lite_site::get_instance();
         $user_manager = $sm->get_user_manager();
         $group = $user_manager->get_group_by_id($group_id);
         if ($group) {
             if (VIVVO_USER_SOURCE == 'vivvo@localhost') {
                 $group->name = $in_group['name'];
                 $this->_post_master->set_data_object($group);
                 if (!$this->_post_master->sql_update()) {
                     $this->set_error_code(5115);
                     return false;
                 }
             }
             if ($user_manager->save_group_privileges($group, $in_group['privileges'])) {
                 admin_log($sm->user->get_username(), 'Edited group #' . $group_id);
                 return true;
             } else {
                 $this->set_error_code(5116);
                 return false;
             }
         } else {
             $this->set_error_code(5117);
             return false;
         }
     } else {
         $this->set_error_code(5118);
         return false;
     }
 }
Example #24
0
 /**
  * Populate object properties
  *
  * @param	array	$data
  * @param	bool	$dump
  * @return	bool
  */
 public function populate($data, $dump = null)
 {
     if ($status = parent::populate($data, $dump) and $this->user_id) {
         $user = vivvo_lite_site::get_instance()->get_user_manager()->get_user_by_id($this->user_id);
         if ($user) {
             $this->set_author($user->get_name());
             $this->set_www($user->get_www());
             $this->set_email($user->get_email_address());
             $this->author_href = $user->get_href();
             $this->avatar_url = $user->get_picture();
             if ($this->avatar_url and !preg_match('/^[^:\\/\\.\\?]+:/', $this->avatar_url)) {
                 $this->avatar_url = VIVVO_STATIC_URL . 'thumbnail.php?size=avatar&file=' . $this->avatar_url;
             }
         }
     }
     return $status;
 }
 function _default_view()
 {
     return vivvo_lite_site::get_instance()->get_template();
 }
 function _autocomplete_tags()
 {
     $sm = vivvo_lite_site::get_instance();
     $um = $sm->get_url_manager();
     $output = '';
     if ($um->isset_param('name')) {
         $name = escape_sql_like(secure_sql($um->get_param('name')));
         $res = $sm->get_db()->query('SELECT name FROM ' . VIVVO_DB_PREFIX . "tags WHERE name LIKE '{$name}%'");
         if (!PEAR::isError($res)) {
             $attributes[] = ENT_QUOTES;
             $attributes[] = 'UTF-8';
             $tags = array_map('html_entity_decode', $res->fetchCol(), $attributes);
             $res->free();
             $output = '<ul><li>' . implode('</li><li>', $tags) . '</li></ul>';
         }
     }
     echo $output;
     exit;
 }
 /**
  * Mail form
  *
  * @param	integer	$form_id
  * @param	array	$data
  * @return	boolean	true on succes, or false on fail
  */
 function mail($form_id, $data)
 {
     $sm = vivvo_lite_site::get_instance();
     if (!vivvo_hooks_manager::call('form_builder_mail', array(&$form_id, &$delete))) {
         return vivvo_hooks_manager::get_status();
     }
     require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php';
     $form_list = new FormBuilderForms_list();
     $form = $form_list->get_form_by_id($form_id);
     $data = array_map('urldecode', $data);
     $attachments = array();
     if ($form !== false) {
         $form_element_list = new FormBuilderFields_list($this->_site_manager);
         $form_element_list->get_elements_by_form_id($form->id);
         $message = '';
         foreach ($form_element_list->list as $field) {
             if ($field->required && !key_exists($field->name, $data) && $data[$field->name] !== '' && $field->type != 'file_upload') {
                 $this->set_error_code(10712);
                 return false;
             } else {
                 if ($field->required && $field->type == 'file_upload' && empty($_FILES['PFB_' . $field->name]['name'])) {
                     $this->set_error_code(10712);
                     return false;
                 }
             }
             if (key_exists($field->name, $data)) {
                 if ($field->reg_exp) {
                     if (!preg_match('/^' . $field->reg_exp . '$/', $data[$field->name])) {
                         $this->set_error_code(10713);
                         return false;
                     }
                 }
                 if ($field->type != 'submit') {
                     if ($field->label != '') {
                         $message .= $field->label . ': ' . $data[$field->name] . "\n";
                     } else {
                         $message .= $field->name . ': ' . $data[$field->name] . "\n";
                     }
                 }
             }
             if ($field->type == 'file_upload' && isset($_FILES['PFB_' . $field->name])) {
                 $attachments[] = 'PFB_' . $field->name;
             }
         }
         if ($form->email) {
             $files = array();
             if (count($attachments)) {
                 foreach ($attachments as $attachment) {
                     if ($_FILES[$attachment]['error'] == 0 && $_FILES[$attachment]['size'] > 0 && $_FILES[$attachment]['size'] <= 2 * 1024 * 1024 && in_array(substr($_FILES[$attachment]['name'], strrpos($_FILES[$attachment]['name'], '.') + 1), array_map('trim', explode(',', VIVVO_ALLOWED_EXTENSIONS))) && is_uploaded_file($_FILES[$attachment]['tmp_name'])) {
                         $filename = VIVVO_FS_INSTALL_ROOT . 'cache/' . md5(uniqid(mt_rand(), true)) . basename($_FILES[$attachment]['name']);
                         if (move_uploaded_file($_FILES[$attachment]['tmp_name'], $filename)) {
                             $files[] = array($filename, basename($_FILES[$attachment]['name']));
                         }
                     }
                 }
             }
             $headers['From'] = VIVVO_ADMINISTRATORS_EMAIL;
             $headers['Subject'] = "=?UTF-8?B?" . base64_encode($form->title) . "?=";
             if (!count($files)) {
                 $headers['Content-Type'] = "text/plain; charset=UTF-8;";
             } else {
                 require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/framework/PEAR/Mail/mime.php';
                 $mime = new Mail_mime();
                 $mime->setTXTBody($message);
                 foreach ($files as $file) {
                     $mime->addAttachment($file[0], 'application/octet-stream', $file[1]);
                 }
                 $message = $mime->get();
                 $headers = $mime->headers($headers);
                 foreach ($files as $file) {
                     @unlink($file[0]);
                 }
             }
             if (VIVVO_EMAIL_SMTP_PHP == 1) {
                 $mail_object = new Mail();
                 $mail_object->send($form->email, $headers, $message);
             } 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($form->email, $headers, $message);
             }
         }
         if ($form->message) {
             return $form->message;
         } else {
             return ' ';
         }
     }
 }
Example #28
0
 function get_assets_quick_search($keyword)
 {
     $keyword = secure_sql($keyword);
     $dir = VIVVO_ASSETS_DIRTYPE_ID;
     $sql = "(SELECT * FROM " . VIVVO_DB_PREFIX . "asset_files WHERE name LIKE '{$keyword}%' AND filetype_id != {$dir})\n\t\t\t\t\tUNION ALL\n\t\t\t\t\t(SELECT f.* FROM " . VIVVO_DB_PREFIX . "asset_files as f, " . VIVVO_DB_PREFIX . "asset_keywords as k\n\t\t\t\t\t\tWHERE f.id=k.asset_id AND k.keyword LIKE '{$keyword}%')\n\t\t\t\t\tUNION ALL\n\t\t\t\t\t(SELECT * FROM " . VIVVO_DB_PREFIX . "asset_files\n\t\t\t\t\t\tWHERE MATCH (info) AGAINST ('\"{$keyword}\"' IN BOOLEAN MODE) AND filetype_id != {$dir})\n\t\t\t\t\tORDER BY path ASC\n\t\t\t\t\t";
     $sm = vivvo_lite_site::get_instance();
     $res = $sm->get_db()->query($sql);
     $this->list = array();
     if (!is_a($res, 'mdb2_error')) {
         $class = $this->post_object_type;
         while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             if ($sm->_object_cache_manager->is_cached($class, $row[$this->id_key])) {
                 $this->list[$row[$this->id_key]] = $sm->_object_cache_manager->retrive($class, $row[$this->id_key]);
                 $this->list[$row[$this->id_key]]->populate($row);
             } else {
                 $object = new $class(null, $row);
                 $sm->_object_cache_manager->add($class, $row[$this->id_key], $object);
                 $this->list[$row[$this->id_key]] = $object;
             }
         }
         $res->free();
     } else {
         $sm->debug_push("sql:", $query, 1);
         $sm->debug_push("sql:", $res->getMessage(), 1);
     }
     return empty($this->list) ? false : $this->list;
 }
Example #29
0
 /**
  * Edit comment
  *
  * @param	integer		$comment_id
  * @param	array		$data
  * @return	boolean		true on succes, or false on fail
  */
 function vote($comment_id, $vote)
 {
     if (!vivvo_hooks_manager::call('comment_vote', array(&$comment_id, &$vote))) {
         return vivvo_hooks_manager::get_status();
     }
     $sm = vivvo_lite_site::get_instance();
     $dm = $sm->get_dump_manager();
     if (!$sm->user && $sm->guest_group && $sm->guest_group->group_privileges['ARTICLE_COMMENT'] > 0 || $sm->user && $sm->user->privileges['ARTICLE_COMMENT'] > 0) {
         if (!isset($_SESSION['vivvo']['comment'])) {
             $_SESSION['vivvo']['comment'] = array();
         }
         if (in_array($comment_id, $_SESSION['vivvo']['comment'])) {
             $this->set_error_code(2222);
             return false;
         } else {
             if ($vote != 1 and $vote != -1) {
                 $this->set_error_code(2223);
                 return false;
             }
             $comment_list = new Comments_list();
             $comment = $comment_list->get_comments_by_id($comment_id);
             if ($comment !== false) {
                 $vote += $comment->get_vote();
                 $comment->set_vote($vote);
                 $this->_post_master->set_data_object($comment);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['comment'][] = $comment->id;
                     $dm->add_dump('info', 0, $vote);
                     return true;
                 } else {
                     $this->set_error_code(2224);
                     return false;
                 }
             } else {
                 $this->set_error_code(2225);
                 return false;
             }
         }
     } else {
         $this->set_error_code(2226);
         return false;
     }
 }
Example #30
0
/**
 * Handles cronjob.php --touch
 */
function action_touch($options)
{
    defined('VIVVO_START_TIME') or define('VIVVO_START_TIME', time());
    $cron_flag = VIVVO_FS_ROOT . 'cache/.cron.lock';
    // call cron only if it's been at least a minute since the last
    if (file_exists($cron_flag) and VIVVO_START_TIME - filemtime($cron_flag) < 60) {
        cronjob_error('Cron manager has already been called less than a minute ago.');
    }
    // reset flag
    @unlink($cron_flag);
    touch($cron_flag);
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/vivvo_lite_site.php';
    require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/framework/vivvo_cron.php';
    error_reporting(E_ERROR);
    define('VIVVO_SKIP_URL_PARSING', true);
    $sm = vivvo_lite_site::get_instance();
    $cm = new vivvo_cron_manager($sm);
    $cm->execute();
    echo 'Cron manager executed successfully.' . PHP_EOL;
}