public static function initSession($user_id) { $db = JO_Db::getDefaultAdapter(); $query = $db->select()->from(self::getPrefixDB() . 'users')->where('user_id = ?', (int) $user_id)->limit(1, 0); $user_data = $db->fetchRow($query); if ($user_data && $user_data['status'] == 'activate') { $groups = unserialize($user_data['groups']); if (is_array($groups) && count($groups) > 0) { $query_group = $db->select()->from(self::getPrefixDB() . 'user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups)))); $fetch_all = $db->fetchAll($query_group); $user_data['access'] = array(); if ($fetch_all) { foreach ($fetch_all as $row) { $modules = unserialize($row['rights']); if (is_array($modules)) { foreach ($modules as $module => $ison) { $user_data['access'][$module] = $module; } } } } } if (isset($user_data['access']) && count($user_data['access'])) { $user_data['is_admin'] = true; } $db->update(self::getPrefixDB() . 'users', array('last_login_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request::getInstance()->getClientIp()), array('user_id = ?' => (int) $user_id)); JO_Session::set($user_data); } return $user_data; }
public function logoutAction() { $this->setInvokeArg('noViewRenderer', true); @setcookie('csrftoken_', md5(JO_Session::get('user[user_id]') . $this->getRequest()->getDomain() . JO_Session::get('user[date_added]')), time() - 100, '/', '.' . $this->getRequest()->getDomain()); JO_Session::set(array('user' => false)); $this->redirect(JO_Request::getInstance()->getBaseUrl()); }
public static function initSessionCookie($cookie) { $db = JO_Db::getDefaultAdapter(); $query = $db->select()->from('users', array('*', 'fullname' => "CONCAT(firstname,' ',lastname)"))->where("MD5(CONCAT(user_id,'" . JO_Request::getInstance()->getDomain() . "',date_added)) = ?", (string) $cookie)->limit(1); $user_data = $db->fetchRow($query); if ($user_data && $user_data['status']) { $groups = unserialize($user_data['groups']); if (is_array($groups) && count($groups) > 0) { $query_group = $db->select()->from('user_groups')->where("ug_id IN (?)", new JO_Db_Expr(implode(',', array_keys($groups)))); $fetch_all = $db->fetchAll($query_group); $user_data['access'] = array(); if ($fetch_all) { foreach ($fetch_all as $row) { $modules = unserialize($row['rights']); if (is_array($modules)) { foreach ($modules as $module => $ison) { foreach ($ison as $m => $on) { $user_data['access'][$module][$m] = $m; } } } } } } $db->update('users', array('last_action_datetime' => new JO_Db_Expr('NOW()'), 'ip_address' => JO_Request_Server::encode_ip(JO_Request::getInstance()->getClientIp())), array('user_id = ?' => (string) $user_data['user_id'])); } // foreach($user_data AS $key => $data) { // self::{$key} = $data; // } JO_Session::set(array('user' => $user_data)); return $user_data; }
public function get_avatarAction() { $this->noLayout(true); $request = $this->getRequest(); if (JO_Session::get('user[user_id]')) { $connectObject = new Model_Facebook_Login(); $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]')); $user_id = 0; if ($user_info) { $user_id = $user_info['oauth_uid']; } else { $facebookObject = new Helper_Modules_Facebook(); $user_data = $facebookObject->getUser(true); if ($user_data && isset($user_data['id'])) { $user_id = $user_data['id']; } } if ($user_id) { $ph = new WM_Facebook_Photo(); $image = $ph->getRealUrl('http://graph.facebook.com/' . $user_id . '/picture?type=large'); $image_info = @getimagesize($image); if ($image_info) { $image_data = @file_get_contents($image); if ($image_data) { JO_Session::set('upload_avatar', array('name' => basename($image), 'type' => $image_info['mime'], 'data' => $image_data)); $this->view->success = WM_Router::create($request->getBaseUrl() . '?controller=settings&action=temporary_avatar&hash=' . microtime(true)); } } } else { $this->view->error = $this->translate('There is no established connection with facebook!'); } } echo $this->renderScript('json'); }
private function loginInit($id) { $event_data = WM_Users::initSession($id); if ($event_data) { JO_Session::set(array('user' => $event_data)); } $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); }
public function connectAction() { $request = $this->getRequest(); $this->noLayout(true); $this->view->close_box = false; if (JO_Session::get('user[user_id]')) { $facebookObject = new Helper_Modules_Facebook(); if ($request->getQuery('scope')) { $facebookObject->scope = $request->getQuery('scope'); } $user_data = $facebookObject->getUser(true); $connectObject = new Model_Facebook_Login(); $connectObject->facebook = $facebookObject->facebook; $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]')); if ($user_data) { $connectObjectCheck = new Model_Facebook_Login($user_data['id']); if ($connectObjectCheck->row) { if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) { $enable_action = true; } else { $is_user = new Model_Users_User($connectObjectCheck->row['user_id']); if (!$is_user->count()) { $enable_action = true; $connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']); } else { $enable_action = $this->translate('There is another profile that is associated with your facebook account'); } } } else { $enable_action = true; } if ($enable_action === true) { if ($user_info) { if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) { $this->view->close_box = true; } else { $this->view->close_box = true; } } else { $res = $connectObject->insert(array('email' => isset($user_data['email']) ? $user_data['email'] : '', 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data['id'], 'access_token' => $facebookObject->facebook->getAccessToken())); if ($res) { $this->view->close_box = true; } else { $this->view->close_box = true; } } } else { JO_Session::set('connect_error', $enable_action); $this->view->close_box = true; } } else { $redirect = $facebookObject->getLoginUrl(WM_Router::create($request->getBaseUrl() . '?controller=settings'), 'modules_facebook_connect&action=connect'); $this->redirect($redirect); } } else { $this->view->close_box = true; } }
public function indexAction() { $request = $this->getRequest(); $settings = Model_Extensions::getSettingsPairs('facebook'); if (!isset($settings['facebook_login_with_facebook']) || !$settings['facebook_login_with_facebook']) { $this->forward('error', 'error404'); } elseif (!isset($settings['facebook_module_status_enable']) || !$settings['facebook_module_status_enable']) { $this->forward('error', 'error404'); } $facebook = new Helper_Modules_Facebook(); $user_data = $facebook->getUser(true); if ($user_data) { $modelLogin = new Model_Facebook_Login($user_data['id']); $error = true; if ($modelLogin->row) { $userObject = new Model_Users_User($modelLogin->row['user_id']); if ($userObject->count()) { if (JO_Session::get('user[user_id]')) { if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) { JO_Session::set('user', $userObject->toArray()); } } else { JO_Session::set('user', $userObject->toArray()); } new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()'))); $modelLogin->facebook = $facebook; $modelLogin->update($user_data); if ($request->getQuery('next')) { $this->redirect(urldecode($request->getQuery('next'))); } else { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } } } elseif (Helper_Config::get('enable_free_registration')) { $this->forward('modules_facebook_register'); } elseif (JO_Session::get('user[user_id]')) { $this->redirect($request->getBaseUrl()); } $this->setViewChange('no_account'); $page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } else { //not session $this->setViewChange('error_login'); $page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } }
public function __construct() { $request = JO_Request::getInstance(); parent::__construct(); if (Model_Allowips::getTotalWords()) { if (!Model_Allowips::getTotalWords(array('filete_ip' => $request->getClientIp()))) { if (!in_array($request->getController(), array('login', 'error'))) { $this->forward('error', 'noPermission'); } } } //set default timezone if is not set if (!ini_get('date.timezone')) { ini_set('date.timezone', 'UTC'); } WM_Users::initSession(JO_Session::get('user[user_id]')); if (!JO_Session::get('user[user_id]')) { JO_Session::set('user', array('user_id' => 0)); } //admin check login $login_page = $request->getController() != 'login'; if (JO_Session::get('user[is_developer]')) { $login_page = false; } else { if (JO_Session::get('user[is_admin]')) { $login_page = false; } } if (in_array($request->getController(), array('login', 'error'))) { $login_page = false; } if ($login_page) { $this->forward('login', 'index'); } //admin top menu Helper_Config::set('adminmenupermisions', WM_Users::initPermision()); //no permisions $controller_name = JO_Front::getInstance()->formatControllerName($request->getController()); if (!class_exists($controller_name, false)) { JO_Loader::loadFile(APPLICATION_PATH . '/modules/' . $request->getModule() . '/controllers/' . JO_Front::getInstance()->classToFilename($controller_name)); } if (method_exists($controller_name, 'config')) { $data = call_user_func(array($controller_name, 'config')); if (isset($data['has_permision']) && $data['has_permision'] && !WM_Users::allow('read', $request->getController())) { $this->forward('error', 'noPermission'); } } WM_Rebuild::getInformation(); WM_Licensecheck::checkIt(); }
public function indexAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } if (JO_Session::get('msg_success')) { $this->view->msg_error = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } if (JO_Session::get('msg_error')) { $this->view->msg_error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $this->view->questions = $questions = Model_Quiz::getAllQuestions(0, 0, '', 'RAND()'); $this->view->answers = $answers = Model_Quiz::getAllAnswers(0, 0, '', true); if ($request->isPost()) { $rightAnswers = 0; $user_answers = $request->getPost('answers'); if (is_array($user_answers)) { foreach ($user_answers as $question => $answer) { if (isset($answers[$question][$answer]) && $answers[$question][$answer]['right'] == 'true') { $rightAnswers++; } } } if ($rightAnswers > 0 && count($questions) == $rightAnswers) { $_SESSION['user']['quiz'] = 'true'; JO_Session::set('quiz', 'true'); Model_Users::updateQuiz(JO_Session::get('user_id'), 'true'); JO_Session::set('msg_success', 'You have successfully completed the quiz'); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=upload')); } else { JO_Session::set('msg_error', 'You have to answer all questions correctly. You have ' . $rightAnswers . ' right answers from ' . $question . ' questions'); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=quiz')); } } $this->view->usersCount = Model_Users::countUsers(); $this->view->itemsCount = Model_Items::countItems(); $this->getLayout()->meta_title = $this->translate('Quiz'); $this->getLayout()->meta_description = $this->translate('Quiz'); $this->view->page_name = $this->translate('Quiz'); /* CRUMBS */ $this->view->crumbs = array(); $this->view->crumbs[] = array('name' => $this->view->translate('Home'), 'href' => $request->getBaseUrl()); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function indexAction() { if (!WM_Users::allow('edit', 'modules')) { JO_Session::set('error_permision', $this->translate('You do not have permission to this action')); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth/'); } $request = $this->getRequest(); if (JO_Session::get('successfu_edite')) { $this->view->successfu_edite = true; JO_Session::clear('successfu_edite'); } if ($request->isPost()) { //validate app id $validate = new Helper_Modules_Facebook($request->getPost('facebook[facebook_oauth_key]'), $request->getPost('facebook[facebook_oauth_secret]')); if ($validate->checkValidAppId()) { Model_Settings::updateAll(array('facebook' => $request->getPost('facebook'))); JO_Session::set('successfu_edite', true); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_oauth_facebook/'); } else { $this->view->error = $this->translate('Invalid appID'); } } $this->view->modules_url = $this->getRequest()->getModule() . '/modules'; $this->view->modules_oauth_url = $this->getRequest()->getModule() . '/modules_oauth'; $methods = $this->getClassResources(); $this->view->methods = array(); $ignore = array('index', 'error404', 'install', 'uninstall'); foreach ($methods as $type => $mods) { foreach ($mods as $key => $value) { if (in_array($value, $ignore)) { continue; } if ($type == 'actions') { $this->view->methods[$type][] = array('title' => $this->translate($value), 'edit' => $this->getRequest()->getModule() . '/modules_oauth_facebook/' . strtolower($value)); } elseif ($type == 'radio') { $this->view->methods[$type][] = array('title' => $this->translate(str_replace('_', ' ', $value)), 'key' => 'facebook_' . strtolower($value)); } } } $store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'facebook')); foreach ($store_config as $key => $data) { if ($request->issetPost('facebook[' . $key . ']')) { $this->view->{$key} = $request->getPost('facebook[' . $key . ']'); } else { $this->view->{$key} = $data; } } }
public function indexAction() { $request = $this->getRequest(); if (JO_Session::get('user[user_id]')) { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } if (Helper_Config::get('enable_free_registration')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=register')); } $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); if (JO_Session::get('successfu_edite')) { $this->view->successfu_edite = true; JO_Session::clear('successfu_edite'); } if ($request->isPost()) { $validate = new Helper_Validate(); $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email'); if ($validate->_valid_form()) { $shared_contentObject = new Model_Users_Invate(); $shared_content = $shared_contentObject->isInvatedByEmail($request->getPost('email')); if ($shared_content == 1) { $this->view->error = $this->translate('This e-mail address is already registered'); } else { if ($shared_content == 2) { $this->view->error = $this->translate('This e-mail address is already registered'); } else { if (($key = Model_Users::addSharedContent($request->getPost('email'))) !== false) { JO_Session::set('successfu_edite', true); if (Helper_Config::get('not_ri')) { Model_Email::send(Helper_Config::get('report_mail'), Helper_Config::get('noreply_mail'), $this->translate('New invitation request'), $this->translate('Hello, there is new invitation request in ') . ' ' . Helper_Config::get('site_name')); } $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing')); } else { $this->view->error = $this->translate('There was an error. Please try again later!'); } } } } else { $this->view->error = $validate->_get_error_messages(); } } $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }
public function indexAction() { $request = $this->getRequest(); $rows = array('groups_pin_email', 'comments_email', 'likes_email', 'repins_email', 'follows_email', 'email_interval', 'digest_email', 'news_email'); $user_data = Model_Users::getUser(JO_Session::get('user[user_id]')); if ($request->isPost()) { $update = array(); foreach ($rows as $row) { $update[$row] = (int) $request->getRequest($row); } // var_dump($update);exit; Model_Users::edit(JO_Session::get('user[user_id]'), $update); JO_Session::set('successfu_edite', true); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=settings')); } $this->view->user_data = $user_data; $this->view->settings_href = WM_Router::create($request->getBaseUrl() . '?controller=settings'); $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }
public function sendWelcomeAction() { if (JO_Session::get('user[user_id]')) { new Model_Users_Edit(JO_Session::get('user[user_id]'), array('first_login' => '0')); JO_Session::clear('category_id'); $this->view->user_info = JO_Session::get('user'); $this->view->user_info['first_login'] = 0; JO_Session::set('user', $this->view->user_info); $template = Model_Notification::getTemplate('welcome'); if ($template) { $template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_username' => JO_Session::get('user[username]'), 'site_url' => $this->getRequest()->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8')); if (!$template['title']) { $template['title'] = $this->translate('Welcome to ${site_name}!'); } $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data); $body = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data); Model_Email::send(JO_Session::get('user[email]'), Helper_Config::get('noreply_mail'), $title, $body); } } $this->noViewRenderer(true); }
public function send_mailAction() { $this->noViewRenderer(true); $request = $this->getRequest(); if ($request->isPost()) { if ($this->validateForm()) { $issue_id = $request->getPost('issue_id'); if ($issue_id > 0) { $category_issue = Model_Contactscategories::getCategory($issue_id); $category = $category_issue['name']; } else { $category = $this->translate('Not selected'); } $request->setParams('issue', $category); $res = Model_Contacts::addContact($request->getParams()); JO_Session::set('msg_success', $this->translate('The mail is sent successfully')); } else { JO_Session::set('msg_error', $this->error); JO_Session::set('data', $request->getParams()); } } $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=contacts')); }
public function indexAction() { if (!WM_Users::allow('create', $this->getRequest()->getController())) { $this->forward('error', 'noPermission'); } $request = $this->getRequest(); $this->view->user = $request->getPost('user'); $this->view->title = $request->getPost('title'); $this->view->description = $request->getPost('description'); $this->view->users = Model_Users::getUsers(array('filter_email' => '@')); if (JO_Session::get('successfu_edite')) { $this->view->successfu_edite = true; JO_Session::clear('successfu_edite'); } $this->view->errors = array(); if ($request->isPost()) { if ($this->getRequest()->issetPost('user')) { $result = ''; if ($this->getRequest()->getPost('user') == 'all') { $email_list = Model_Users::getUsers(array('filter_email' => '@')); foreach ($email_list as $email) { if (JO_Validate::validateEmail($email["email"])) { $result = Model_Email::send($email["email"], Helper_Config::get('noreply_mail'), $this->getRequest()->getPost('title'), html_entity_decode($this->getRequest()->getPost('description'), ENT_QUOTES, 'utf-8')); } } } elseif (JO_Validate::validateEmail($this->getRequest()->getPost('user'))) { $result = Model_Email::send($this->getRequest()->getPost('user'), Helper_Config::get('noreply_mail'), $this->getRequest()->getPost('title'), html_entity_decode($this->getRequest()->getPost('description'), ENT_QUOTES, 'utf-8')); } if ($result) { JO_Session::set('successfu_edite', true); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/massmail/'); } else { $this->view->errors['no_emails'] = $this->translate('There was an error with sending the mail!'); } } } }
public function indexAction() { $this->noLayout(true); $request = $this->getRequest(); if ($request->getPost('submit')) { $users = new Model_Users(); $result = $users->checkLogin($request->getPost('username'), $request->getPost('password')); if (!$result) { $this->view->error = $this->translate('Please enter the correct username and password.'); } else { if ($result['status'] == 'activate') { if (isset($result['access']) && count($result['access'])) { $result['is_admin'] = true; } JO_Session::set($result); header('Location: ' . $request->getServer('HTTP_REFERER')); exit; } else { $this->view->error = $this->translate('This profile is not active.'); } } } $this->view->base_url = $request->getBaseUrl(); }
public function _initUserSession() { $request = JO_Request::getInstance(); if ($request->getModule() == 'install') { return ''; } WM_Users::initSession(JO_Session::get('user[user_id]')); if (!JO_Session::get('user[user_id]')) { /*if(!JO_Session::get('fb_check')) { $facebook = JO_Registry::get('facebookapi'); if( is_array($user_data = $facebook->api('/me')) ) { $user_data = WM_Users::checkLoginFacebookTwitter($user_data['id']); JO_Session::set(array('user' => $user_data)); } JO_Session::set('fb_check', true); } if(!JO_Session::get('user[user_id]')) { if( $request->getCookie('csrftoken_') ) { WM_Users::initSessionCookie($request->getCookie('csrftoken_')); } }*/ if (!JO_Session::get('user[user_id]')) { JO_Session::set('user', array('user_id' => 0)); } } }
public function indexAction() { $request = $this->getRequest(); $this->view->invate_limit = 5; if ($request->isPost()) { $emails = array(); $this->view->send = array(); for ($i = 1; $i < $this->view->invate_limit; $i++) { $this->view->send[$i] = array('success' => false, 'error' => false); $validate = new Helper_Validate(); if ($request->getPost('email-' . $i) != $this->translate('Email Adress ' . $i)) { $validate->_set_rules($request->getPost('email-' . $i), $this->translate('Email Adress ' . $i), 'not_empty;min_length[5];max_length[100];email'); if ($validate->_valid_form()) { $shared_content = Model_Users::sharedContentInvate($request->getPost('email-' . $i)); if ($shared_content == 1) { $this->view->send[$i]['error'] = $this->translate('With this email address is already registered users!'); } else { if ($shared_content == 2) { $this->view->send[$i]['error'] = $this->translate('To this email has been sent an invitation!'); } else { $inser_key = Model_Users::sharedContent($request->getPost('email-' . $i)); if ($inser_key == -1) { $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!'); } else { $template = Model_Notification::getTemplate('send_invate'); if ($template) { $template_data = array('user_id' => JO_Session::get('user[user_id]'), 'user_firstname' => JO_Session::get('user[firstname]'), 'user_lastname' => JO_Session::get('user[lastname]'), 'user_fullname' => JO_Session::get('user[fullname]'), 'user_message' => $request->getPost('note') != $this->translate('Add a personal note') ? $request->getPost('note') : '', 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'invate_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=register&user_id=' . JO_Session::get('user[user_id]') . '&key=' . $inser_key), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8')); if (!$template['title']) { $template['title'] = $this->translate('Join and create your own pinboards'); } $title = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data); $template = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data); $result = Model_Email::send($request->getPost('email-' . $i), Helper_Config::get('noreply_mail'), $title, $template); if ($result) { $this->view->send[$i]['success'] = $this->translate('The invitation was sent successfully!'); } else { $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!'); } } else { $this->view->send[$i]['error'] = $this->translate('There was an error. Please try again later!'); } } } } } else { $this->view->send[$i]['error'] = strip_tags($validate->_get_error_messages()); } } } if ($request->isXmlHttpRequest()) { echo $this->renderScript('json'); exit; } else { JO_Session::set('result_from_invate', $this->view->send); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=invites')); } } if (JO_Session::get('result_from_invate')) { $this->view->result_from_invate = JO_Session::get('result_from_invate'); JO_Session::clear('result_from_invate'); } $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part', 'methodsforinvates' => 'invates/methodsforinvates'); }
public function topicAction() { $request = $this->getRequest(); $thread_id = $request->getRequest('topic'); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Forum'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))); $thread = Model_Forum::getThread($thread_id); $this->view->sel_thread = $thread['thread_id']; $this->view->headline = $thread['name']; $this->view->mainCategories = array(); $this->view->mainCategories = Model_Forum::getAll(); foreach ($this->view->mainCategories as $k => $v) { $this->view->mainCategories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $this->view->mainCategories[$k]['id'] . '/' . WM_Router::clearName($this->view->mainCategories[$k]['name'])); } $this->view->mainCategories = array_merge(array(0 => array('id' => 0, 'name' => $this->translate('All Topics'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))), $this->view->mainCategories); if ($thread) { JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $model_images = new Model_Images(); $page = (int) $request->getRequest('page', 1); if ($page < 1) { $page = 1; } $limit = JO_Registry::get('front_limit'); if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } if (JO_Session::get('msg_error')) { $this->view->error = JO_Session::get('msg_error'); $this->view->data = JO_Session::get('data'); JO_Session::clear('msg_error'); JO_Session::clear('data'); } $this->view->crumbs[] = array('name' => $thread['name']); $threads = Model_Forum::getSubComments($thread['id']); $this->view->smiles = Model_Smiles::getSmilesImages(); if ($threads) { $total_records = count($threads); $start = $page * $limit - $limit; if ($start > $total_records) { $page = max(ceil($total_records / $limit), 1); $start = $page * $limit - $limit; } elseif ($start < 0) { $start = 0; } $threads = array_slice($threads, $start, $limit); $bbcode_parser = new WM_BBCode_Parser(); $bbcode_parser->loadDefaultCodes(); foreach ($threads as $th) { if ($th['avatar']) { $th['avatar'] = $model_images->resize($th['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $th['avatar'] = 'data/themes/images/noavatar.png'; } $th['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username'])); $th_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $th['id'] . '/' . WM_Router::clearName($th['name'])); $th['threadhref'] = $th_link; $th['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=report/' . $th['id']); $th['recent_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=recents_for_user&username='******'username'])); $th['threads_user_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=threads_for_user&username='******'username'])); $bbcode_parser->parse($th['comment']); $th['comment_formated'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml()); $last_page = ceil($total_records / $limit); $th['datetime'] = WM_Date::format($th['datetime'], 'dd M yy H:i'); $th['badges'] = Helper_Author::userBadges($th['badges']); $this->view->threads[] = $th; } } $pagination = new Model_Pagination(); $pagination->setLimit($limit); $pagination->setPage($page); $pagination->setText(array('text_prev' => $this->view->translate('Prev'), 'text_next' => $this->view->translate('Next'))); $pagination->setTotal($total_records); $pagination->setUrl(WM_Router::create($request->getBaseUrl() . '?controller=forum&action=index&page={page}')); $this->view->pagination = $pagination->render(); if (!empty($this->view->pagination)) { $this->view->pagination = str_replace('{of}', $this->view->translate('OF'), $this->view->pagination); } } $this->view->add_comment_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=add_new_comment'); $this->view->children = array(); $this->view->children['rightside'] = 'forum/rightside'; $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function indexAction() { $request = $this->getRequest(); $settings = Model_Extensions::getSettingsPairs('instagram'); if (!isset($settings['instagram_login_with_instagram']) || !$settings['instagram_login_with_instagram']) { $this->forward('error', 'error404'); } elseif (!isset($settings['instagram_module_status_enable']) || !$settings['instagram_module_status_enable']) { $this->forward('error', 'error404'); } $instagramoauth = null; $this->initInstagram($instagramoauth); $InstagramAccessToken = JO_Session::get('InstagramAccessToken'); $user_data = $this->user_data; $settings = Model_Extensions::getSettingsPairs('instagram'); if (!isset($settings['instagram_login_with_instagram']) || !$settings['instagram_login_with_instagram']) { $this->forward('error', 'error404'); } if ($user_data && isset($user_data['id']) && $user_data['id']) { $modelLogin = new Model_Instagram_Login($user_data['id']); if ($modelLogin->row) { $userObject = new Model_Users_User($modelLogin->row['user_id']); if ($userObject->count()) { if (JO_Session::get('user[user_id]')) { if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) { JO_Session::set('user', $userObject->toArray()); } } else { JO_Session::set('user', $userObject->toArray()); } new Model_Users_Edit($modelLogin->row['user_id'], array('last_login' => new JO_Db_Expr('NOW()'))); $up = $modelLogin->update(array('access_token' => $InstagramAccessToken, 'username' => $user_data['username'])); $next = JO_Session::get('instagram_next'); // JO_Session::clear('instagram_user_data'); // JO_Session::clear('instagram_next'); // JO_Session::clear('instagram_fnc'); if ($next) { $this->redirect(urldecode($next)); } else { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } } } if ((Helper_Config::get('enable_free_registration') || JO_Session::get('instagram_fnc') == 'connect') && JO_Session::get('instagram_next') && JO_Session::get('instagram_fnc')) { $this->redirect(urldecode(JO_Session::get('instagram_next'))); } if (Helper_Config::get('enable_free_registration')) { $this->forward('modules_instagram_register', 'index', $user_data); } $this->setViewChange('no_account'); $page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } else { if (JO_Session::get('instagram_fnc') == 'connect' && JO_Session::get('instagram_next')) { $this->redirect(urldecode(JO_Session::get('instagram_next'))); } elseif (Helper_Config::get('enable_free_registration')) { $this->forward('modules_instagram_register'); } //not session $this->setViewChange('error_login'); $page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } }
public function editHomeimage($user_id, $data) { $db = JO_Db::getDefaultAdapter(); $db->update(self::getPrefixDB() . 'users', array('homeimage' => $data), array('user_id = ?' => (int) $user_id)); JO_Session::set('homeimage', $data); if (JO_Registry::get('singlesignon_enable_login') == '1' and JO_Registry::get('singlesignon_status') == '1') { $query = $db->select()->from('system')->where('`group` = ?', 'single_sign_on'); foreach ($db->fetchAll($query) as $d) { $dat = unserialize($d['value']); if (is_writable($dat['home_dir']) and $dat['home_dir']) { $dir = explode('/', $data); unset($dir[count($dir) - 1]); $dir = implode('/', $dir); @mkdir($dat['home_dir'] . $dir, 0777, true); copy(realpath(BASE_PATH . '/uploads') . $data, $dat['home_dir'] . $data); } } } return true; }
public function callback_facebookAction() { $this->noViewRenderer(true); $request = $this->getRequest(); $facebook = new WM_Facebook_Api(array('appId' => JO_Registry::forceGet('facebook_appid'), 'secret' => JO_Registry::forceGet('facebook_secret'))); $fbData = $facebook->api('/me'); if ($fbData['verified'] == 'true' && isset($fbData['id'])) { $user = Model_Users::getFBuser($fbData['id']); if ($user) { $user['following'] = Model_Users::getFollowers($user['user_id']); $groups = unserialize($user['groups']); if (is_array($groups) and count($groups) > 1) { unset($user['groups']); $fetch_all = Model_Users::getGroups($groups); $user['access'] = array(); if ($fetch_all) { foreach ($fetch_all as $row) { $modules = unserialize($row['rights']); if (is_array($modules)) { foreach ($modules as $module => $ison) { $result['access'][$module] = $module; } } } } } if (isset($user['access']) && count($user['access'])) { $user['is_admin'] = true; } JO_Session::set($user); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=dashboard')); } else { $userData = array('fb_id' => $fbData['id'], 'firstname' => $fbData['first_name'], 'lastname' => $fbData['last_name'], 'email' => $fbData['email'], 'email_confirm' => $fbData['email'], 'username' => $fbData['username']); JO_Session::set('fb_data', $userData); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=registration')); } } else { JO_Session::set('msg_error', $this->translate('Facebook login error. Please try again later.')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } }
public function indexAction() { $request = $this->getRequest(); if (!JO_Session::get('user[user_id]')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&popup=true&next=' . urlencode($request->getFullUrl()))); } $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create'); $boards = Model_Boards::getBoards(array('filter_user_id' => JO_Session::get('user[user_id]'), 'order' => 'boards.sort_order', 'sort' => 'ASC', 'friendly' => JO_Session::get('user[user_id]'))); $this->view->boards = array(); if ($boards) { foreach ($boards as $board) { $this->view->boards[] = array('board_id' => $board['board_id'], 'title' => $board['title']); } } //////////// Categories //////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_status' => 1)); foreach ($categories as $category) { $category['subcategories'] = Model_Categories::getSubcategories($category['category_id']); $this->view->categories[] = $category; } $this->view->title = JO_Utf8::convertToUtf8($request->getQuery('title')); $this->view->url = JO_Utf8::convertToUtf8(urldecode($request->getQuery('url'))); $this->view->media = JO_Utf8::convertToUtf8($request->getQuery('media')); $this->view->is_video = JO_Utf8::convertToUtf8($request->getQuery('is_video')); $this->view->description = JO_Utf8::convertToUtf8($request->getQuery('description')); $this->view->charset = JO_Utf8::convertToUtf8($request->getQuery('charset')); if (!trim($this->view->description)) { $this->view->description = $this->view->title; } if (JO_Session::get('success_added')) { $this->view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . JO_Session::get('success_added')); $this->setViewChange('success'); JO_Session::clear('success_added'); } else { if ($request->isPost()) { $result = Model_Pins::create(array('title' => $this->view->title, 'from' => $this->view->url, 'image' => $this->view->media, 'is_video' => $this->view->is_video, 'description' => $request->getPost('message'), 'price' => $request->getPost('price'), 'board_id' => $request->getPost('board_id'), 'pinmarklet' => 1)); if ($result) { Model_History::addHistory(0, Model_History::ADDPIN, $result); $session_user = JO_Session::get('user[user_id]'); $group = Model_Boards::isGroupBoard($request->getPost('board_id')); if ($group) { $users = explode(',', $group); foreach ($users as $user_id) { if ($user_id != $session_user) { $user_data = Model_Users::getUser($user_id); if ($user_data && $user_data['email_interval'] == 1 && $user_data['groups_pin_email']) { $this->view->user_info = $user_data; $this->view->profile_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->full_name = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]'); $this->view->pin_href = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $result); $board_info = Model_Boards::getBoard($request->getPost('board_id')); if ($board_info) { $this->view->board_title = $board_info['title']; $this->view->board_href = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board_info['user_id'] . '&board_id=' . $board_info['board_id']); } Model_Email::send($user_data['email'], JO_Registry::get('noreply_mail'), JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]') . ' ' . $this->translate('added new pin to a group board'), $this->view->render('group_board', 'mail')); } } } } JO_Session::set('success_added', $result); $this->redirect($request->getBaseUrl() . '?controller=bookmarklet'); } } } }
public function logoutAction() { @setcookie('csrftoken_', md5(JO_Session::get('user[user_id]') . $this->getRequest()->getDomain() . JO_Session::get('user[date_added]')), time() - 100, '/', '.' . $this->getRequest()->getDomain()); JO_Session::set('user', array()); $url_logout = $this->getRequest()->getBaseUrl(); $this->redirect($url_logout); }
public function upload_imagesAction() { $request = $this->getRequest(); if (JO_Session::get('upload_from_file')) { @unlink(BASE_PATH . JO_Session::get('upload_from_file')); JO_Session::clear('upload_from_file'); JO_Session::clear('upload_from_file_name'); } $image = $request->getFile('file'); if (!$image) { $this->view->error = $this->translate('There is no file selected'); } else { $temporary = '/cache/review/'; $upload_folder = BASE_PATH . $temporary; $upload = new Helper_Upload(); $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder); $new_name = md5(time() . serialize($image)); if ($upload->upload($new_name)) { $info = $upload->getFileInfo(); if ($info) { $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin&action=fromfile'); // $this->view->file = $image['name']; // $this->view->full_path = $temporary . $info['name']; $this->view->success = 1; //$this->view->render('upload_images', 'addpin'); JO_Session::set('upload_from_file', $temporary . $info['name']); JO_Session::set('upload_from_file_name', $image['name']); } else { $this->view->error = $this->translate('An unknown error'); } } else { $this->view->error = $upload->getError(); } } $this->noViewRenderer(true); echo $this->renderScript('json'); }
public function uploadAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', 'You must be logged to view your collections'); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } $model_images = new Model_Images(); if ($request->isPost()) { $image = $request->getFile('file_upload'); $public = $request->getPost('publically_visible'); $id = Model_Collections::add(array('name' => $request->getPost('name') ? $request->getPost('name') : $this->translate('Bookmark Collection'), 'description' => $request->getPost('description'), 'publically_visible' => $public ? 'true' : 'false')); if ($image and $id) { $users_path = '/collections/' . date('Y/m') . '/' . $id . '/'; $upload_folder = realpath(BASE_PATH . '/uploads'); $upload_folder .= $users_path; $upload = new JO_Upload(); $upload->setFile($image)->setExtension(array('.jpg', '.jpeg', '.png', '.gif'))->setUploadDir($upload_folder); $new_name = md5(time() . serialize($image)); if ($upload->upload($new_name)) { $info = $upload->getFileInfo(); if ($info) { $file_path = $users_path . $info['name']; Model_Collections::editImage($id, $file_path); } else { JO_Session::set('msg_error', $this->translate('There was an unexpected error with uploading the file')); } } } if ($id && $request->issetPost('item_id')) { $itemID = $request->getPost('item_id'); Model_Collections::bookmark($itemID, $id); JO_Session::set('msg_success', 'You have successfully create collection and this item has been added to your collection'); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $itemID)); } if ($id) { JO_Session::set('msg_success', 'You have successfully create collection.'); } $url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'username')) . '/public/' . ($public ? '1' : '0')); $this->redirect($url); } }
public function indexAction($user_data = null) { $request = $this->getRequest(); if (!Helper_Config::get('enable_free_registration')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=landing')); } if (JO_Session::get('user[user_id]')) { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } $settings = Model_Extensions::getSettingsPairs('instagram'); if (!isset($settings['instagram_register_with_instagram']) || !$settings['instagram_register_with_instagram']) { $this->forward('error', 'error404'); } elseif (!isset($settings['instagram_module_status_enable']) || !$settings['instagram_module_status_enable']) { $this->forward('error', 'error404'); } $InstagramAccessToken = JO_Session::get('InstagramAccessToken'); $user_data = $user_data ? $user_data : JO_Session::get('instagram_user_data'); if ($user_data && isset($user_data['id']) && $user_data['id']) { $modelLogin = new Model_Instagram_Login($user_data['id']); if ($modelLogin->row) { $userObject = new Model_Users_User($modelLogin->row['user_id']); if ($userObject->count()) { if (JO_Session::get('user[user_id]')) { if ($modelLogin->row['user_id'] == JO_Session::get('user[user_id]')) { JO_Session::set('user', $userObject->toArray()); } } else { JO_Session::set('user', $userObject->toArray()); } $up = $modelLogin->update(array('access_token' => $InstagramAccessToken, 'username' => $user_data['username'])); $next = JO_Session::get('instagram_next'); if ($next) { $this->redirect(urldecode($next)); } else { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } } } if (isset($user_data['profile_picture']) && @getimagesize($user_data['profile_picture'])) { $image = $user_data['profile_picture']; $user_data['avatar'] = $image; } else { $image = 'uploads' . Helper_Config::get('no_image'); $user_data['avatar']; } $names = explode(' ', $user_data['full_name']); $user_data['first_name'] = array_shift($names); $user_data['last_name'] = implode(' ', $names); if ($request->isPost()) { $validate = new Helper_Validate(); $validate->_set_rules($request->getPost('username'), $this->translate('Username'), 'not_empty;min_length[3];max_length[100];username'); $validate->_set_rules($request->getPost('email'), $this->translate('Email'), 'not_empty;min_length[5];max_length[100];email'); $validate->_set_rules($request->getPost('password'), $this->translate('Password'), 'not_empty;min_length[4];max_length[30]'); if ($validate->_valid_form()) { if (Model_Users::isExistEmail($request->getPost('email'))) { $validate->_set_form_errors($this->translate('This e-mail address is already used')); $validate->_set_valid_form(false); } if (Model_Users::isExistUsername($request->getPost('username'))) { $validate->_set_form_errors($this->translate('This username is already used')); $validate->_set_valid_form(false); } } if ($validate->_valid_form()) { $result = new Model_Users_Create(array('avatar' => $user_data['avatar'], 'website' => isset($user_data['website']) ? $user_data['website'] : '', 'username' => $request->getPost('username'), 'firstname' => isset($user_data['first_name']) ? $user_data['first_name'] : '', 'lastname' => isset($user_data['last_name']) ? $user_data['last_name'] : '', 'email' => $request->getPost('email'), 'password' => $request->getPost('password'))); if (!$result->error) { $userObject = new Model_Users_User($result->user_id); JO_Session::set('user', $userObject->toArray()); $modelObject = new Model_Instagram_Login(); $modelObject->insert(array('username' => $user_data['username'], 'user_id' => $result->user_id, 'oauth_uid' => $user_data['id'], 'access_token' => JO_Session::get('InstagramAccessToken'))); $next = JO_Session::get('instagram_next'); JO_Session::clear('instagram_user_data'); JO_Session::clear('instagram_next'); JO_Session::clear('instagram_fnc'); if ($next) { $this->redirect(urldecode($next)); } else { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } } else { $this->view->error = implode('<br />', $result->error); //$this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $validate->_get_error_messages(); } } $this->view->avatar = $image; $this->view->baseUrl = $request->getBaseUrl(); if ($request->issetPost('email')) { $this->view->email = $request->getPost('email'); } else { if (isset($user_data['email'])) { $this->view->email = $user_data['email']; } else { $this->view->email = ''; } } if ($request->issetPost('username')) { $this->view->username = $request->getPost('username'); } else { if (isset($user_data['username'])) { $this->view->username = $user_data['username']; } else { $this->view->username = ''; } } $this->view->password = $request->getPost('password'); } else { //not session $this->setViewChange('../login/error_login'); $page_login_trouble = Model_Pages::getPage(Helper_Config::get('page_login_trouble')); if ($page_login_trouble) { $this->view->page_login_trouble = array('title' => $page_login_trouble['title'], 'href' => WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . $page_login_trouble['page_id'])); } } if ($this->getLayout()->meta_title) { $this->getLayout()->placeholder('title', $this->getLayout()->meta_title . ' - ' . Helper_Config::get('meta_title')); } else { $this->getLayout()->placeholder('title', Helper_Config::get('meta_title')); } if ($this->getLayout()->meta_description) { $this->getLayout()->placeholder('description', $this->getLayout()->meta_description); } else { $this->getLayout()->placeholder('description', Helper_Config::get('meta_description')); } if ($this->getLayout()->meta_keywords) { $this->getLayout()->placeholder('keywords', $this->getLayout()->meta_keywords); } else { $this->getLayout()->placeholder('keywords', Helper_Config::get('meta_keywords')); } $this->getLayout()->placeholder('site_name', Helper_Config::get('site_name')); $this->view->site_name = Helper_Config::get('site_name'); $this->view->meta_title = Helper_Config::get('meta_title'); $this->getLayout()->placeholder('google_analytics', html_entity_decode(Helper_Config::get('google_analytics'), ENT_QUOTES, 'utf-8')); $this->view->baseUrl = $request->getBaseUrl(); $this->view->site_logo = $request->getBaseUrl() . 'data/images/logo.png'; if (Helper_Config::get('site_logo') && file_exists(BASE_PATH . '/uploads' . Helper_Config::get('site_logo'))) { $this->view->site_logo = $request->getBaseUrl() . 'uploads' . Helper_Config::get('site_logo'); } $this->view->login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); $this->view->check_username = WM_Router::create($request->getBaseUrl() . '?controller=modules_instagram_register&action=check_username'); $this->view->check_email = WM_Router::create($request->getBaseUrl() . '?controller=modules_instagram_register&action=check_email'); $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }
public function connectAction() { $request = $this->getRequest(); $this->noLayout(true); $this->view->close_box = false; if (JO_Session::get('user[user_id]')) { $instagramoauth = null; $this->initInstagram($instagramoauth); $user_data = $this->user_data; $connectObject = new Model_Instagram_Login(); $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]')); if ($user_data) { $connectObjectCheck = new Model_Instagram_Login($user_data['id']); if ($connectObjectCheck->row) { if ($connectObjectCheck->row['user_id'] == JO_Session::get('user[user_id]')) { $enable_action = true; } else { $is_user = new Model_Users_User($connectObjectCheck->row['user_id']); if (!$is_user->count()) { $enable_action = true; $connectObject->deleteDataByUserId($connectObjectCheck->row['user_id']); } else { $enable_action = $this->translate('There is another profile that is associated with your instagram account'); } } } else { $enable_action = true; } if ($enable_action === true) { if ($user_info) { if ($connectObject->deleteDataByUserId(JO_Session::get('user[user_id]'))) { $this->view->close_box = true; } else { $this->view->close_box = true; } } else { $res = $connectObject->insert(array('username' => $user_data['username'], 'user_id' => JO_Session::get('user[user_id]'), 'oauth_uid' => $user_data['id'], 'access_token' => JO_Session::get('InstagramAccessToken'))); if ($res) { $this->view->close_box = true; } else { $this->view->close_box = true; } } } else { JO_Session::set('connect_error', $enable_action); $this->view->close_box = true; } } else { $instagramoauth->openAuthorizationUrl(); } } $this->view->close_box = true; }
public function indexAction() { $request = $this->getRequest(); $model_images = new Model_Images(); $this->view->usersCount = Model_Users::countUsers(); $this->view->itemsCount = Model_Items::countItems(); /* LAST ITEM */ $lastItem = Model_Items::getLastItem(); if ($lastItem) { $thumb = $model_images->resizeWidth($lastItem['theme_preview_thumbnail'], 200); $thumb_size = getimagesize($thumb); if ($thumb_size[1] > 161) { $image = new JO_GDThumb($thumb); $image->crop(0, 0, $thumb_size[0], 161); $image->save($thumb); } $this->view->lastItem = array('name' => $lastItem['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $lastItem['module'] . '&controller=items&item_id=' . $lastItem['id'] . '&name=' . $lastItem['name']), 'thumb' => $thumb); } /* FREE ITEM */ $this->view->freeItems = ''; $freeItems = Model_Items::getFreeFiles(); if ($freeItems) { foreach ($freeItems as $fi) { $cats = explode(',', $fi['categories']); $cat_name = Helper_Items::getCategory($cats[1]); $thumb = $model_images->resizeWidth($fi['theme_preview_thumbnail'], JO_Registry::forceGet($fi['module'] . '_items_thumb_width')); $thumb_size = getimagesize($thumb); if ($thumb_size[1] > JO_Registry::forceGet($fi['module'] . '_items_thumb_height')) { $image = new JO_GDThumb($thumb); $image->crop(0, 0, $thumb_size[0], JO_Registry::forceGet($fi['module'] . '_items_thumb_height')); $image->save($thumb); } $this->view->freeItems[] = array('href' => WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $fi['id'] . '&name=' . WM_Router::clearName($fi['name'])), 'thumb' => $thumb, 'cat_name' => $cat_name['name'], 'name' => $fi['name']); } } /* ITEMS */ $this->view->items = array(); $listType = $request->getParam('list_type'); if (is_null($listType)) { $listType = 'recent'; } $this->view->all_items = array('name' => $this->view->translate('View all items'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=categories&action=' . $listType)); switch ($listType) { case 'featured': JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $this->view->title_items = $this->view->translate('Featured Items'); $featuredItems = Model_Items::getWeekly($request->getParam('category_filter')); if ($featuredItems) { foreach ($featuredItems as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } break; case 'author': JO_Session::set('redirect', $request->getBaseUrl() . $request->getUri()); $this->view->title_items = $this->view->translate('Featured Author'); $this->view->author = Model_Users::getFeatUser(); if ($this->view->author) { $this->view->author['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']); $this->view->author['userhref_pf'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']); if ($this->view->author['avatar']) { $this->view->author['avatar'] = $model_images->resize($this->view->author['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $this->view->author['avatar'] = 'data/themes/images/avatar-author.png'; } $this->view->items = array(); $items = Model_Items::getByUser($this->view->author['user_id'], 0, 11, false); if (empty($items)) { $items = array(0 => array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes')); } if ($items) { foreach ($items as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } } $this->view->all_items = array('name' => $this->view->translate('View portfolio'), 'href' => $this->view->author['userhref_pf']); break; default: /* RECENT ITEMS */ JO_Session::set('redirect', $request->getBaseUrl()); $this->view->title_items = $this->view->translate('Recent Items'); $recentItems = Model_Items::getRecent($request->getParam('category_filter')); if ($recentItems) { foreach ($recentItems as $n => $item) { if (!empty($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=items&action=preview&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->items[] = Helper_Items::returnViewIndex($item); } } shuffle($this->view->items); } $this->view->listType = $listType; $this->view->recent_items = WM_Router::create($request->getBaseUrl() . '?controller=recent'); $this->view->featured = WM_Router::create($request->getBaseUrl() . '?controller=featured'); $this->view->featuredAuthor = WM_Router::create($request->getBaseUrl() . '?controller=author'); /* CATEGORIES */ $this->view->categories = Model_Categories::getMain(); $this->view->top_categories = $this->view->categories; if ($this->view->categories) { if ($this->view->categories) { foreach ($this->view->categories as $k => $v) { $this->view->categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=' . $listType . '&category_filter=' . $v['id']); } } } if ($this->view->top_categories) { foreach ($this->view->top_categories as $k => $v) { $this->view->top_categories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $v['id'] . '&name=' . $v['name']); } shuffle($this->view->top_categories); $this->view->top_categories = array_slice($this->view->top_categories, 0, 4); } $this->view->all_categories = WM_Router::create($request->getBaseUrl() . '?controller=categories&category_id=' . $listType); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function stepThreeAction() { $db = JO_Db::getDefaultAdapter(); JO_Session::set('deleted', array()); $queries = JO_Session::get('inserted'); $selected_tables = $this->getRequest()->getParam('tables'); $this->view->msg_error = array(); $this->view->msg_success = array(); $limit = 500; $page = (int) $this->getRequest()->getRequest('page', 0); if ($page < 0) { $page = 0; } $output = array(); for ($i = 0; $i < min(count($queries), $limit); $i++) { $output[] = array_shift($queries); } JO_Session::set('inserted', $queries); $query_error = JO_Session::get('query_error'); if ($output) { for ($i = 0; $i <= count($output); $i++) { if (isset($output[$i]) && count($output[$i]['data']) > 0) { $res = $db->insertIgnore($output[$i]['table'], $output[$i]['data']); $last_id = $db->lastInsertId(); if (!$last_id && !$res) { $query_error[] = array('query' => is_array($output[$i]) ? self::generateInsert($output[$i]['table'], $output[$i]['data']) : $output[$i], 'last_id' => $last_id . ' ' . $res); } } } if ($query_error) { JO_Session::set('query_error', $query_error); } $this->refresh(WM_Router::create($this->getRequest()->getBaseUrl() . '?module=update&controller=index&action=stepThree&page=' . ($page + 1)), 2); } else { if ($query_error) { $tmp = array(); foreach ($query_error as $err) { $tmp[] = "\n============================ " . $err['last_id'] . " ============================\n"; $tmp[] = $err['query']; } file_put_contents(BASE_PATH . '/cache/error_update.log', implode("\n", $tmp)); $this->view->msg_error = count($query_error) . ' Records were not imported. Please check ' . BASE_PATH . '/cache/error_update.log'; } else { $fordel = array(BASE_PATH . '/old_sys/', APPLICATION_PATH . '/modules/update/'); $this->view->msg_success = 'All data was successful imported. Your system is updated! Now please delete the following folders: <b>' . implode('</b>; <b>', $fordel) . '<b>'; } self::unlink(BASE_PATH . '/old_sys/', true); // self::unlink(APPLICATION_PATH . '/modules/update/', true); JO_Session::set('query_error', array()); JO_Session::set('inserted', array()); } // $this->refresh(WM_Router::create($this->getRequest()->getBaseUrl() . '?module=themes&controller=index'); }