Example #1
0
 protected function _doLogin()
 {
     $rules = array('email' => array('label' => __('email', 'users'), 'rules' => array('trim', 'required', 'max_length' => 255, 'callback__is_valid_login')), 'password' => array('label' => __('password', 'users'), 'rules' => array('trim', 'required', 'min_length' => 4, 'max_length' => 128)), 'remember' => array('label' => __('remember_me', 'users')));
     if (uri::segment(4) == 'license' && !input::demo(0, '', false)) {
         $rules['license'] = array('label' => __('license_new', 'system_license'), 'rules' => array('trim', 'required', 'callback__is_valid_license'));
     }
     validate::setRules($rules);
     if (!validate::run()) {
         return false;
     }
     if (!($user = $this->users_model->getUser(input::post('email'), false, false))) {
         validate::setFieldError('email', __((strpos(input::post('email'), '@') === false ? 'username' : 'email') . '_invalid', 'users_signup'));
         return false;
     }
     if (!$this->users_model->verifyPassword(input::post('password'), $user['password'], $user['user_id'])) {
         validate::setFieldError('password', __('password_invalid', 'users_signup'));
         return false;
     }
     if (uri::segment(4) == 'license' && !input::demo(0, '', false)) {
         $access = $this->users_model->getPermissions($user['group_id'], 'system', 'license_manage');
         if ($access) {
             loader::model('system/license');
             $this->license_model->changeLicense(input::post('license'));
         }
     }
     $this->users_model->login($user['user_id'], input::post('remember'), $user);
     if (uri::segment(4) == 'license') {
         router::redirect('cp/help/license');
     } else {
         router::redirect('cp');
     }
 }
Example #2
0
 public static function getTimeline($user = array(), $privacy = 2, $template = 'timeline/helpers/timeline')
 {
     loader::model('timeline/timeline');
     // Get actions
     $actions = codebreeder::instance()->timeline_model->getActions($user ? $user['user_id'] : 0, true, 0, config::item('actions_per_page', 'timeline'));
     $ratings = array();
     // Do we have actions and are we logged in?
     if ($actions && users_helper::isLoggedin()) {
         foreach ($actions as $action) {
             if ($action['rating']) {
                 $ratings[$action['relative_resource']][] = $action['item_id'];
             } else {
                 $ratings['timeline'][] = $action['action_id'];
             }
         }
         // Load votes and like models
         loader::model('comments/votes');
         loader::model('comments/likes');
         // Get likes and votes
         $likes = codebreeder::instance()->likes_model->getMultiLikes($ratings);
         $votes = codebreeder::instance()->votes_model->getMultiVotes($ratings);
         $ratings = $likes + $votes;
     }
     // Can we post messages?
     $post = session::permission('messages_post', 'timeline') && codebreeder::instance()->users_model->getPrivacyAccess($user['user_id'], $privacy, false) ? true : false;
     view::assign(array('actions' => $actions, 'user' => $user, 'post' => $post, 'ratings' => $ratings), '', $template);
     // Update comments pagination
     config::set('comments_per_page', config::item('comments_per_page', 'timeline'), 'comments');
     return view::load($template, array(), 1);
 }
Example #3
0
 public function view()
 {
     // Get URI vars
     $newsID = (int) uri::segment(3);
     // Get news entry
     if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) {
         error::show404();
     }
     // Do we have views enabled?
     if (config::item('news_views', 'news')) {
         // Update views counter
         $this->news_model->updateViews($newsID);
     }
     // Load ratings
     if (config::item('news_rating', 'news') == 'stars') {
         // Load votes model
         loader::model('comments/votes');
         // Get votes
         $news['user_vote'] = $this->votes_model->getVote('news', $newsID);
     } elseif (config::item('news_rating', 'news') == 'likes') {
         // Load likes model
         loader::model('comments/likes');
         // Get likes
         $news['user_vote'] = $this->likes_model->getLike('news', $newsID);
     }
     // Assign vars
     view::assign(array('newsID' => $newsID, 'news' => $news));
     // Set title
     view::setTitle($news['data_title']);
     // Set meta tags
     view::setMetaDescription($news['data_meta_description']);
     view::setMetaKeywords($news['data_meta_keywords']);
     // Load view
     view::load('news/view');
 }
Example #4
0
 public function deleteComments($resource, $itemID, $limit = false)
 {
     // Get resource ID
     if (!($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !$itemID) {
         return false;
     }
     if (!is_array($itemID)) {
         $itemID = array($itemID);
     }
     $commentIDs = array();
     // Get comment IDs
     $result = $this->db->query("SELECT * FROM `:prefix:core_comments` WHERE `resource_id`=? AND `item_id` IN (?)", array($resourceID, $itemID))->result();
     foreach ($result as $comment) {
         $commentIDs[] = $comment['comment_id'];
     }
     // Delete reports
     loader::model('reports/reports');
     $this->reports_model->deleteReports('comment', $commentIDs);
     // Delete comments
     if ($retval = $this->db->delete('core_comments', array('resource_id' => $resourceID, 'item_id' => $itemID), $limit)) {
         // Action hook
         hook::action('comments/delete_multiple', $resourceID, $itemID);
     }
     return $retval;
 }
Example #5
0
 function fetch($file, $templateid = null, $tpldir = null)
 {
     global $base_path;
     $output =& loader::lib('output');
     $params = $output->getAll();
     extract($params);
     if (!$templateid) {
         $templateid = TEMPLATEID;
     }
     $style_path = $base_path . TPLDIR . '/';
     $setting =& loader::model('setting');
     $theme_config = $setting->get_conf('theme_' . $templateid, array());
     if (isset($_config)) {
         if ($theme_config) {
             $_config = array_merge($_config, $theme_config);
         }
     } else {
         $_config = $theme_config;
     }
     $footer = '<script src="' . $statics_path . 'js/common.js" type="text/javascript"></script>';
     if (isset($loggedin) && $loggedin) {
         $footer .= '<script src="' . $statics_path . 'js/admin.js" type="text/javascript"></script>';
     }
     $footer .= 'Pow' . 'ered by <a href="http://mei' . 'upic.m' . 'eiu.cn/" target="_blank">Mei' . 'uPic ' . MPIC_VERSION . '</a> ';
     $footer .= safe_invert($setting->get_conf('site.footer'), true);
     $show_process_info = $setting->get_conf('system.show_process_info');
     ob_start();
     include $this->template($file, $templateid, $tpldir);
     $content = ob_get_clean();
     return $content;
 }
Example #6
0
 public function postBlog($items, $users)
 {
     $stream = array();
     loader::model('blogs/blogs');
     $params = array('select_users' => false);
     // Get blogs
     $columns = array('`b`.`blog_id` IN (' . implode(',', array_keys($items)) . ')');
     $blogs = codebreeder::instance()->blogs_model->getBlogs('in_list', $columns, array(), false, count($items), $params);
     foreach ($items as $itemID => $data) {
         if (isset($blogs[$itemID]) && isset($users[$blogs[$itemID]['user_id']])) {
             foreach ($data as $actionID => $item) {
                 $stream[$itemID][$actionID]['html'] = view::load('blogs/timeline/blog', array('user' => $users[$blogs[$itemID]['user_id']], 'blog' => $blogs[$itemID], 'params' => $item['params']), true);
                 $stream[$itemID][$actionID]['rating']['total_votes'] = $blogs[$itemID]['total_votes'];
                 $stream[$itemID][$actionID]['rating']['total_score'] = $blogs[$itemID]['total_score'];
                 $stream[$itemID][$actionID]['rating']['total_rating'] = $blogs[$itemID]['total_rating'];
                 $stream[$itemID][$actionID]['rating']['total_likes'] = $blogs[$itemID]['total_likes'];
                 $stream[$itemID][$actionID]['rating']['type'] = config::item('blog_rating', 'blogs');
                 $stream[$itemID][$actionID]['comments']['total_comments'] = $blogs[$itemID]['total_comments'];
                 $stream[$itemID][$actionID]['comments']['privacy'] = $blogs[$itemID]['comments'];
                 $stream[$itemID][$actionID]['comments']['post'] = $blogs[$itemID]['comments'] && codebreeder::instance()->users_model->getPrivacyAccess($blogs[$itemID]['user_id'], $blogs[$itemID]['comments'], false, $users[$blogs[$itemID]['user_id']]['friends'] ? 1 : 0) ? true : false;
             }
         }
     }
     return $stream;
 }
Example #7
0
 public static function getPictures($params = array())
 {
     if (!session::permission('users_groups_browse', 'users') && !session::permission('users_types_browse', 'users')) {
         return '';
     }
     loader::model('pictures/pictures');
     $template = isset($params['template']) ? $params['template'] : 'pictures/helpers/pictures';
     $user = isset($params['user']) && $params['user'] ? $params['user'] : array();
     $userID = $user ? $user['user_id'] : (isset($params['user_id']) ? $params['user_id'] : 0);
     $params['albums'] = true;
     if ($userID) {
         $params['join_columns'][] = '`p`.`user_id`=' . $userID;
     }
     if (!$userID || $userID != session::item('user_id')) {
         if ($userID) {
             $params['privacy'] = $userID;
         } else {
             $params['join_columns'][] = '`a`.`public`=1';
             $params['join_columns'][] = '`u`.`verified`=1';
             $params['join_columns'][] = '`u`.`active`=1';
             $params['join_columns'][] = '`u`.`group_id` IN (' . implode(',', session::permission('users_groups_browse', 'users')) . ')';
             $params['join_columns'][] = '`u`.`type_id` IN (' . implode(',', session::permission('users_types_browse', 'users')) . ')';
         }
     }
     $params['limit'] = isset($params['limit']) ? $params['limit'] : 10;
     $params['order'] = isset($params['order']) ? $params['order'] : '';
     $pictures = codebreeder::instance()->pictures_model->getPictures('in_list', $params['join_columns'], array(), $params['order'], $params['limit'], $params);
     view::assign(array('pictures' => $pictures, 'user' => $user, 'params' => $params), '', $template);
     return view::load($template, array(), 1);
 }
Example #8
0
 public function deleteEntry($newsID, $news)
 {
     // Delete entry
     $retval = $this->fields_model->deleteValues('news', $newsID);
     if ($retval) {
         // Delete comments
         if ($news['total_comments']) {
             loader::model('comments/comments');
             $this->comments_model->deleteComments('news', $newsID, $news['total_comments']);
         }
         // Delete likes
         if ($news['total_likes']) {
             loader::model('comments/likes');
             $this->likes_model->deleteLikes('news', $newsID, $news['total_likes']);
         }
         // Delete votes
         if ($news['total_votes']) {
             loader::model('comments/votes');
             $this->votes_model->deleteVotes('news', $newsID, $news['total_votes']);
         }
         // Action hook
         hook::action('news/delete', $newsID, $news);
     }
     return $retval;
 }
Example #9
0
 function copyselectedurl($config = array())
 {
     need_login('ajax_page');
     global $base_root;
     $ids = $this->getPost('sel_id');
     if (!$ids || count($ids) == 0) {
         ajax_box(lang('copyimg:pls_sel_photo_want_to_copy'));
     } else {
         $site_url = $this->setting->get_conf('site.url');
         $mdl_photo =& loader::model('photo');
         $ids = array_keys($ids);
         $html = '';
         $urls = '';
         $ubb = '';
         foreach ($ids as $id) {
             $pic = $mdl_photo->get_info($id);
             $img_path = img_path($pic['path']);
             $html_code = $config['tpl'];
             $html_code = str_replace('{thumbpath}', img_path($pic['thumb']), $html_code);
             $html_code = str_replace('{imgpath}', $img_path, $html_code);
             $html_code = str_replace('{imgname}', $pic['name'], $html_code);
             $html_code = str_replace('{detailurl}', $base_root . site_link('photos', 'view', array('id' => $pic['id'])), $html_code);
             $html .= $html_code . $config['split'];
             $urls .= $img_path . "\r\n";
             $ubb .= '[IMG]' . $img_path . "[/IMG]\r\n";
         }
         $this->output->set('img_url', $urls);
         $this->output->set('img_html', $html);
         $this->output->set('img_ubb', $ubb);
         loader::view('copyimg:copyurlall');
     }
 }
Example #10
0
 public function sendTemplate($keyword, $email, $tags = array(), $language = '')
 {
     loader::model('system/emailtemplates');
     if (!$language) {
         $language = config::item('language_id', 'system');
     }
     if (is_numeric($language)) {
         $language = config::item('languages', 'core', 'keywords', $language);
     } elseif (!in_array($language, config::item('languages', 'core', 'keywords'))) {
         return false;
     }
     if (!($template = config::item($keyword . '_' . $language, '_system_emails_cache'))) {
         if (!($template = $this->cache->item('core_email_template_' . $keyword . '_' . $language))) {
             $template = $this->emailtemplates_model->prepareTemplate($keyword, $language);
             if (count($template) == 3) {
                 if ($template[$keyword]['active']) {
                     $template = array('subject' => $template[$keyword]['subject'], 'message_html' => utf8::trim($template['header']['message_html'] . $template[$keyword]['message_html'] . $template['footer']['message_html']), 'message_text' => utf8::trim($template['header']['message_text'] . "\n\n" . $template[$keyword]['message_text'] . "\n\n" . $template['footer']['message_text']));
                 } else {
                     $template = 'none';
                 }
             } else {
                 error::show('Could not fetch email template from the database: ' . $keyword);
             }
             $this->cache->set('core_email_template_' . $keyword . '_' . $language, $template, 60 * 60 * 24 * 30);
         }
         config::set(array($keyword . '_' . $language => $template), '', '_system_emails_cache');
     }
     $retval = true;
     if (is_array($template) && $template) {
         $retval = $this->sendEmail($email, $template['subject'], $template['message_text'], $template['message_html'], $tags);
     }
     return $retval;
 }
Example #11
0
 protected function _savePluginSettings($keyword, $value)
 {
     // Toggle news
     if ($keyword == 'news_active') {
         loader::model('system/lists');
         $this->lists_model->toggleItemStatus('news', 'site_bottom_nav', 'site/news', $value);
     }
 }
Example #12
0
 public function usersSignup($userID, $user)
 {
     if (config::item('credits_signup_bonus', 'billing') && (!isset($user['total_credits']) || $user['total_credits'] == 0)) {
         loader::model('billing/credits');
         $this->credits_model->addCredits($userID, config::item('credits_signup_bonus', 'billing'));
     }
     return true;
 }
Example #13
0
 public function cronRun()
 {
     $this->counters_model->cleanup();
     $this->search_model->cleanup();
     loader::model('system/requests');
     $this->requests_model->cleanup();
     return true;
 }
Example #14
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('timeline_active', 'timeline') || !users_helper::isLoggedin()) {
         error::show404();
     }
     loader::model('timeline/notices', array(), 'timeline_notices_model');
 }
Example #15
0
 public function cronRun()
 {
     if (config::item('notices_cleanup_delay', 'timeline')) {
         loader::model('timeline/notices', array(), 'timeline_notices_model');
         $this->timeline_notices_model->cleanup();
     }
     return true;
 }
Example #16
0
 /**
  * 装载视图
  */
 function view($tplFile, $isDisplay = true)
 {
     $tpl =& loader::model('template');
     if ($isDisplay) {
         echo $tpl->fetch($tplFile);
     } else {
         return $tpl->fetch($tplFile);
     }
 }
Example #17
0
 public function click()
 {
     $bannerID = (int) uri::segment(3);
     if ($bannerID && $bannerID > 0) {
         loader::model('banners/banners');
         $this->banners_model->updateClicks($bannerID);
     }
     exit;
 }
Example #18
0
 function pagecore()
 {
     $this->output =& loader::lib('output');
     $this->db =& loader::database();
     $this->user =& loader::model('user');
     $this->setting =& loader::model('setting');
     $this->plugin =& loader::lib('plugin');
     $this->plugin->trigger('controller_init');
 }
Example #19
0
 public function usersDelete($userID, $user)
 {
     if (!($user['total_pictures'] + $user['total_pictures_i'])) {
         return true;
     }
     loader::model('pictures/albums', array(), 'pictures_albums_model');
     $retval = $this->pictures_albums_model->deleteUser($userID, $user);
     return $retval;
 }
Example #20
0
 public function cronRun()
 {
     $this->users_model->cleanup();
     if (config::item('cleanup_delay', 'users')) {
         loader::model('users/visitors', array(), 'users_visitors_model');
         $this->users_visitors_model->cleanup();
     }
     return true;
 }
Example #21
0
 public function usersDelete($userID, $user)
 {
     if (!($user['total_blogs'] + $user['total_blogs_i'])) {
         return true;
     }
     loader::model('blogs/blogs');
     $retval = $this->blogs_model->deleteUser($userID, $user);
     return $retval;
 }
Example #22
0
 public function __construct()
 {
     parent::__construct();
     // Is user logged in?
     if (users_helper::isLoggedin() && strtolower(uri::segment(3)) != 'out') {
         router::redirect(session::item('slug'));
     }
     loader::model('users/authentication', array(), 'users_authentication_model');
 }
Example #23
0
 function update_num($type, $id)
 {
     if ($type == 1) {
         $mdl_album =& loader::model('album');
         $mdl_album->update_comments_num($id);
     } elseif ($type == 2) {
         $mdl_photo =& loader::model('photo');
         $mdl_photo->update_comments_num($id);
     }
 }
Example #24
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('feedback_active', 'feedback')) {
         error::show404();
     } elseif (!session::permission('feedback_access', 'feedback')) {
         view::noAccess();
     }
     loader::model('feedback/feedback');
 }
Example #25
0
 public function usersDelete($userID, $user)
 {
     if (!($user['total_classifieds'] + $user['total_classifieds_i'])) {
         return true;
     }
     loader::model('classifieds/classifieds');
     loader::model('classifieds/pictures', array(), 'classifieds_pictures_model');
     $retval = $this->classifieds_model->deleteUser($userID, $user);
     return $retval;
 }
Example #26
0
 function remove($theme)
 {
     $theme_dir = ROOTDIR . 'themes/' . $theme;
     if (is_dir($theme_dir) && deldir($theme_dir)) {
         $setting_mdl =& loader::model('setting');
         $setting_mdl->remove_conf('theme_' . $theme, false);
         return true;
     } else {
         return false;
     }
 }
Example #27
0
 protected function _savePluginSettings($keyword, $value)
 {
     // Toggle classifieds
     if ($keyword == 'classifieds_active') {
         loader::model('system/lists');
         $this->lists_model->toggleItemStatus('classifieds', 'site_user_nav', 'user/classifieds', $value);
     } elseif ($keyword == 'ads_gallery') {
         loader::model('system/lists');
         $this->lists_model->toggleItemStatus('classifieds', 'site_top_nav', 'site/classifieds', input::post('classifieds_active') && $value ? 1 : 0);
     }
 }
Example #28
0
 public function __construct()
 {
     parent::__construct();
     if (!config::item('pictures_active', 'pictures')) {
         error::show404();
     } elseif (!session::permission('pictures_access', 'pictures')) {
         view::noAccess();
     }
     loader::model('pictures/pictures');
     loader::model('pictures/albums', array(), 'pictures_albums_model');
 }
Example #29
0
 public function __construct()
 {
     parent::__construct();
     // Is user loggedin ?
     if (!users_helper::isLoggedin()) {
         router::redirect('users/login');
     } elseif (!config::item('credits_active', 'billing')) {
         router::redirect('users/settings');
     }
     loader::model('billing/credits');
 }
Example #30
0
 public function __construct()
 {
     parent::__construct();
     // Is user loggedin ?
     if (!users_helper::isLoggedin()) {
         router::redirect('users/login');
     } elseif (!config::item('visitors_active', 'users')) {
         error::show404();
     }
     loader::model('users/visitors', array(), 'users_visitors_model');
 }