public function steponeAction($error = null) { $this->noLayout(true); $request = $this->getRequest(); $this->view->form_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin_gallery&action=steptwo'); $this->view->upload_action = WM_Router::create($request->getBaseUrl() . '?controller=addpin_gallery&action=upload_images'); $this->view->js_i18n = WM_Router::create($request->getBaseUrl() . '?controller=addpin_gallery&action=i18n'); $this->view->steptwo = WM_Router::create($request->getBaseUrl() . '?controller=addpin_gallery&action=steptwo'); $this->view->files_limit = (int) Helper_Config::get('config_gallery_limit'); if (JO_Session::get('user[user_id]')) { $files = JO_Session::get('gallery_upload_images'); if ($files) { $imageObject = new Helper_Images(); foreach ($files as $file) { $imageObject->deleteImages('/../' . $file['path'] . $file['tmp_name']); } JO_Session::clear('gallery_upload_images'); } if ($error) { $this->view->error_upload_image = $error; } } else { $this->view->redirect = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); } }
public function forwardAction() { $request = $this->getRequest(); JO_Session::clear('instagram_user_data'); JO_Session::clear('instagram_fnc'); JO_Session::clear('instagram_next'); /** * @var Helper_Modules_Instagram */ $instagramoauth = null; $this->initInstagram($instagramoauth); if ($request->issetQuery('next')) { JO_Session::set('instagram_next', urlencode(html_entity_decode($request->getQuery('next')))); } if ($request->getQuery('instagram_fnc')) { JO_Session::set('instagram_fnc', $request->getQuery('instagram_fnc')); } if (!$this->user_data) { $instagramoauth->openAuthorizationUrl(); } else { if (JO_Session::get('instagram_fnc')) { $this->redirect(urldecode(JO_Session::get('instagram_next'))); } else { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=modules_instagram_login')); } } $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'])); } }
public function forwardAction() { JO_Session::clear('user_info_twitteroauth'); JO_Session::clear('user_info_twitteroauth'); JO_Session::clear('access_token_twitteroauth'); JO_Session::get('twitter_oauth'); $request = $this->getRequest(); $next = ''; if ($request->issetQuery('next')) { $next = '&next=' . urlencode(html_entity_decode($request->getQuery('next'))); } if ($request->getQuery('twitter_fnc')) { $next .= '&twitter_fnc=' . $request->getQuery('twitter_fnc'); } $twitteroauth = new Helper_Modules_Twitter(); $request_token = $twitteroauth->getRequestToken(WM_Router::create($request->getBaseUrl() . '?controller=modules_twitter_login' . $next)); $request_token_url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']); if ($twitteroauth->http_code == 200) { if (isset($request_token['oauth_token']) && $request_token['oauth_token_secret']) { JO_Session::set('twitter_oauth', $request_token); $this->redirect($request_token_url); } } $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'])); } }
public function indexAction() { $this->getLayout()->meta_title = $this->translate('Contacts'); $this->getLayout()->meta_description = $this->translate('Contacts'); $request = $this->getRequest(); if (JO_Session::issetKey('msg_success')) { $this->view->is_send = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } elseif (JO_Session::issetKey('msg_error')) { $this->view->error = JO_Session::get('msg_error'); $this->view->user = JO_Session::get('data'); JO_Session::clear('msg_error'); JO_Session::clear('data'); } $this->view->categories = array(); $categories = Model_Contactscategories::getCategories(); if ($categories) { foreach ($categories as $category) { $this->view->categories[$category['id']] = array('id' => $category['id'], 'name' => $category['name'], 'text' => html_entity_decode($category['text'], ENT_QUOTES, 'utf-8')); } } if (empty($this->view->user['username'])) { $this->view->user['username'] = JO_Session::get('username'); } if (empty($this->view->user['email'])) { $this->view->user['email'] = JO_Session::get('email'); } $this->view->contact_link = WM_Router::create($request->getBaseUrl() . '?controller=contacts&action=send_mail'); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function upload_imagesAction() { $request = $this->getRequest(); if (JO_Session::get('user[user_id]')) { 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(); $files_delete = glob($upload_folder . '*.*'); if ($files_delete) { for ($i = 0; $i < min(count($files_delete), 250); $i++) { if (filemtime($files_delete[$i]) + 86400 < time()) { @unlink($files_delete[$i]); } } } $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) { $config_image_minimum_size = (int) Helper_Config::get('config_image_minimum_size'); if (!$config_image_minimum_size) { $config_image_minimum_size = 80; } if (isset($info['image_dimension']['x']) && $info['image_dimension']['x'] >= $config_image_minimum_size && $info['image_dimension']['y'] >= $config_image_minimum_size) { $this->view->from_url = WM_Router::create($request->getBaseUrl() . '?controller=addpin_fromfile&action=stepone'); $this->view->success = 1; JO_Session::set('upload_from_file', $temporary . $info['name']); JO_Session::set('upload_from_file_name', $image['name']); } else { @unlink($upload_folder . $info['name']); $this->view->error = sprintf($this->translate('Photo size must be larger width and height of %s px'), $config_image_minimum_size); } } else { $this->view->error = $this->translate('An unknown error'); } } else { $this->view->error = $upload->getError(); } } } else { $this->view->location = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); } echo $this->renderScript('json'); }
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 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 indexAction() { if (JO_Session::get('successfu_edite')) { $this->view->successfu_edite = JO_Session::get('successfu_edite'); JO_Session::clear('successfu_edite'); } if (JO_Session::get('error_permision')) { $this->view->error_permision = JO_Session::get('error_permision'); JO_Session::clear('error_permision'); } $files = glob(dirname(__FILE__) . '/Modules/*.php'); $this->view->modules = array(); if ($files) { foreach ($files as $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $key = mb_strtolower($match[1], 'utf-8'); $this->view->modules[] = array('key' => $key, 'edit' => $this->getRequest()->getModule() . '/modules_' . $key, 'name' => $this->translate($match[1]), 'is_installed' => Model_Extensions_Install::isInstalled($key), 'install' => $this->getRequest()->getModule() . '/modules_' . $key . '/install', 'uninstall' => $this->getRequest()->getModule() . '/modules_' . $key . '/uninstall'); } } } }
public function indexAction($next = null) { $this->noLayout(true); JO_Session::clear('facebook_user_data_register'); $settings = Model_Extensions::getSettingsPairs('facebook'); if (isset($settings['facebook_module_status_enable']) && $settings['facebook_module_status_enable']) { if (Helper_Config::get('enable_free_registration') && isset($settings['facebook_register_with_facebook']) && $settings['facebook_register_with_facebook']) { $request = $this->getRequest(); $facebook = new Helper_Modules_Facebook(); if ($facebook->checkValidAppId()) { $this->view->login_url = $facebook->getLoginUrl($next, 'modules_facebook_register'); } else { $this->noViewRenderer(true); } } else { $this->noViewRenderer(true); } } else { $this->noViewRenderer(true); } }
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 static function createPage($data) { $db = JO_Db::getDefaultAdapter(); $db->insert('pages', array('date_added' => new JO_Db_Expr('NOW()'), 'date_modified' => new JO_Db_Expr('NOW()'), 'parent_id' => (int) (isset($data['parent_id']) ? $data['parent_id'] : 0), 'status' => (int) $data['status'], 'in_footer' => (int) $data['in_footer'], 'title' => $data['title'], 'description' => $data['description'], 'meta_title' => $data['meta_title'], 'meta_description' => $data['meta_description'], 'meta_keywords' => $data['meta_keywords'])); $page_id = $db->lastInsertId(); if (isset($data['keyword']) && $data['keyword']) { self::generatePage($page_id, $data['keyword']); } else { self::generatePage($page_id); } $temporary_images = JO_Session::get('temporary_images'); if ($temporary_images && is_array($temporary_images)) { $page_info = self::getPage($page_id); if ($page_info) { $gallery_path = '/gallery/' . date("Y/m/", strtotime($page_info['date_added'])); $upload_folder = realpath(BASE_PATH . '/uploads'); $upload_folder .= $gallery_path; foreach ($temporary_images as $image) { $image_name = basename($image['image']); if (!file_exists($upload_folder) || !is_dir($upload_folder)) { mkdir($upload_folder, 0777, true); } if (copy(BASE_PATH . '/uploads/' . $image['image'], $upload_folder . $image_name)) { $image_id = Model_Gallery::createImage(array('gallery_id' => $page_id, 'controller' => 'pages', 'image' => $gallery_path . $image_name)); if ($image_id && isset($image['title'])) { Model_Gallery::updateImageInfo($image_id, $image['title']); } } $mi = new Helper_Images(); $mi->deleteImages($image['image']); } } JO_Session::clear('temporary_images'); } return $page_id; }
public function createAction() { if (!WM_Users::allow('create', $this->getRequest()->getController())) { $this->forward('error', 'noPermission'); } $this->setViewChange('form_pages'); if ($this->getRequest()->isPost()) { Model_Pages::createPage($this->getRequest()->getParams()); $this->session->set('successfu_edite', true); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/pages/' . ($this->getRequest()->getQuery('parent_id') ? '?parent_id=' . $this->getRequest()->getQuery('parent_id') : '')); } if (JO_Session::get('come_from_index') === true) { $temporary_images = JO_Session::get('temporary_images'); if ($temporary_images) { foreach ($temporary_images as $key => $image) { $mi = new Helper_Images(); $mi->deleteImages($image['image']); } } JO_Session::clear('come_from_index'); JO_Session::clear('temporary_images'); } $this->getPageForm(); }
public function threads_for_userAction() { $request = $this->getRequest(); $this->setViewChange('index'); $username = $request->getRequest('threads_for_user'); $username = trim(mb_strtolower(urldecode($username), 'UTF-8')); $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')), array('name' => $username)); $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('name' => $this->translate('All Topics'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))), $this->view->mainCategories); $this->view->headline = $this->translate('All Topics'); $this->view->sel_thread = -1; $this->view->headline = $this->translate('Threads') . ': ' . $username; $threads = Model_Forum::getThreadsByUser($username); $total_records = count($threads); if ($threads) { $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'); } $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); foreach ($threads as $thread) { if ($thread['avatar']) { $thread['avatar'] = $model_images->resize($thread['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $thread['avatar'] = 'data/themes/images/noavatar.png'; } $thread['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'owner'])); $thread_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $thread['id'] . '/' . WM_Router::clearName($thread['name'])); $thread['threadhref'] = $thread_link; $thread['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=report/' . $thread['id']); $thread['badges'] = Helper_Author::userBadges($thread['badges']); $thread['first_date'] = WM_Date::format($thread['datetime'], 'dd M yy H:i'); $last_page = ceil($thread['cnt'] / $limit); if (!empty($thread['lusername'])) { if ($thread['lavatar']) { $thread['lavatar'] = $model_images->resize($thread['lavatar'], 50, 50, true); } else { $thread['lavatar'] = 'data/themes/images/small_noavatar.png'; } $thread['lasthref'] = $thread_link . ($last_page > 1 ? '/page/' . $last_page : ''); $thread['lhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'lusername'])); $thread['last_date'] = WM_Date::format($thread['last_post'], 'dd M yy H:i'); } $this->view->threads[] = $thread; } $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->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(); 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 twitAction() { $request = $this->getRequest(); $this->noLayout(true); $this->setViewChange('connect'); $this->view->close_box = false; if (JO_Session::get('user[user_id]')) { $connectObject = new Model_Twitter_Login(); $user_info = $connectObject->getDataByUserId(JO_Session::get('user[user_id]')); if ($user_info) { $user_data = JO_Session::get('user_info_twitteroauth'); if ($user_info['twit']) { $res = $connectObject->updateTwitByUserId(JO_Session::get('user[user_id]'), array('twit' => 0, 'twitter_oauth_token' => JO_Session::get('twitter_oauth[oauth_token]'), 'twitter_oauth_token_secret' => JO_Session::get('twitter_oauth[oauth_token_secret]'), 'username' => $user_data->screen_name)); } else { $res = $connectObject->updateTwitByUserId(JO_Session::get('user[user_id]'), array('twit' => 1, 'twitter_oauth_token' => JO_Session::get('twitter_oauth[oauth_token]'), 'twitter_oauth_token_secret' => JO_Session::get('twitter_oauth[oauth_token_secret]'), 'username' => $user_data->screen_name)); } } } JO_Session::clear('user_info_twitteroauth'); JO_Session::clear('access_token_twitteroauth'); JO_Session::get('twitter_oauth'); $this->view->close_box = true; }
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 indexActivateAction() { $request = $this->getRequest(); $this->view->register_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=register'); $this->view->activate_url = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate'); $this->view->search_services = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=services'); $this->view->search_activate = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate'); $user_data = Model_Users::getUser(JO_Session::get('user[user_id]')); if ($user_data['type_user']) { $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']); } $upload = new JO_Upload_SessionStore(); $upload->setName('upload_avatar'); $info = $upload->getFileInfo(); if (JO_Session::get('successfu_edite')) { $this->view->successfu_edite = true; JO_Session::clear('successfu_edite'); } $this->view->user_data = $user_data; $this->view->children = array('header_part' => 'layout/header_part', '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_storage/'); } $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 $auth = new JO_Api_Rackspace_Authentication($request->getPost('rackspace[rackspace_api_username]'), $request->getPost('rackspace[rackspace_api_key]'), $request->getPost('rackspace[rackspace_account_name]') ? $request->getPost('rackspace[rackspace_account_name]') : NULL, $request->getPost('rackspace[rackspace_authentication_service_uri]') == 'UK' ? JO_Api_Rackspace_Authentication::UK_AUTHURL : JO_Api_Rackspace_Authentication::US_AUTHURL); $loged = false; try { $loged = $auth->authenticate(); $connect = new JO_Api_Rackspace_Connection($auth); try { $images = $connect->get_container($request->getPost('rackspace[rackspace_pins_contaners]')); if (!$images->cdn_uri) { $this->view->error = sprintf(self::translate('Authentication response did not indicate CDN availability for "%s"'), $request->getPost('rackspace[rackspace_pins_contaners]')); $loged = false; } } catch (JO_Exception $e) { $this->view->error = sprintf($this->translate('Container "%s" not found.'), $request->getPost('rackspace[rackspace_pins_contaners]')); $loged = false; } try { $images = $connect->get_container($request->getPost('rackspace[rackspace_users_contaners]')); if (!$images->cdn_uri) { $this->view->error = sprintf(self::translate('Authentication response did not indicate CDN availability for "%s"'), $request->getPost('rackspace[rackspace_pins_contaners]')); $loged = false; } } catch (JO_Exception $e) { $this->view->error = sprintf($this->translate('Container "%s" not found.'), $request->getPost('rackspace[rackspace_pins_contaners]')); $loged = false; } } catch (JO_Exception $e) { $this->view->error = $e->getMessage(); $loged = false; } if ($loged) { Model_Settings::updateAll(array('rackspace' => $request->getPost('rackspace'))); JO_Session::set('successfu_edite', true); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/modules_storage_rackspace/'); } else { //$this->view->error = $this->translate('Invalid App configuration'); } } $this->view->modules_url = $this->getRequest()->getModule() . '/modules'; $this->view->modules_storage_url = $this->getRequest()->getModule() . '/modules_storage'; $store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'rackspace')); if (!isset($store_config['rackspace_api_username'])) { $store_config['rackspace_api_username'] = ''; } if (!isset($store_config['rackspace_api_key'])) { $store_config['rackspace_api_key'] = ''; } if (!isset($store_config['rackspace_pins_contaners'])) { $store_config['rackspace_pins_contaners'] = ''; } if (!isset($store_config['rackspace_pins_contaners_cdn'])) { $store_config['rackspace_pins_contaners_cdn'] = ''; } if (!isset($store_config['rackspace_users_contaners'])) { $store_config['rackspace_users_contaners'] = ''; } if (!isset($store_config['rackspace_users_contaners_cdn'])) { $store_config['rackspace_users_contaners_cdn'] = ''; } if (!isset($store_config['rackspace_account_name'])) { $store_config['rackspace_account_name'] = ''; } if (!isset($store_config['rackspace_authentication_service_uri'])) { $store_config['rackspace_authentication_service_uri'] = ''; } foreach ($store_config as $key => $data) { if ($request->issetPost('rackspace[' . $key . ']')) { $this->view->{$key} = $request->getPost('rackspace[' . $key . ']'); } else { $this->view->{$key} = $data; } } }
public function indexAction() { $request = $this->getRequest(); $update_for = 'themes'; $db = JO_Db::getDefaultAdapter(); $this->view->msg_error = array(); $this->view->msg_success = array(); //begin updater $old_sys_config = BASE_PATH . '/old_sys/data/uploads/language/config.php'; if (!file_exists($old_sys_config)) { $this->view->msg_error['old_sys'] = 'Please move the "data" folder of your old system into folder: <strong>' . BASE_PATH . '/old_sys/</strong>'; } if (!$this->view->msg_error && $request->isPost()) { self::unlink(BASE_PATH . '/uploads/items/', true); self::unlink(BASE_PATH . '/uploads/attributes/', true); self::unlink(BASE_PATH . '/uploads/cache/', true); self::unlink(BASE_PATH . '/uploads/countries/', true); $db_queries = array(); include_once $old_sys_config; $old_config = $db->getConfig(); $db_config = $old_config; $db_config['host'] = $configArr['mysql_host']; $db_config['username'] = $configArr['mysql_user']; $db_config['password'] = $configArr['mysql_pass']; $db_config['dbname'] = $configArr['mysql_db']; $old_db_tables = $db->listTables(); $new_db = JO_Db::setAdapterConfig($db_config); $new_db_tables = $new_db->listTables(); // other tables $all_arr = array('bulletin', 'bulletin_emails', 'collections', 'collections_rates', 'contacts', 'contacts_categories', 'deposit', 'history', 'percents', 'quiz', 'quiz_answers', 'users_emails', 'users_followers', 'users_referals_count', 'users_status', 'user_groups', 'withdraw', 'items_attributes', 'items_collections', 'items_comments', 'items_faqs', 'items_rates', 'items_tags', 'items_to_category'); foreach ($all_arr as $table) { if (!in_array($table, $old_db_tables) || !in_array($table, $new_db_tables)) { continue; } $query = $new_db->select()->from($table); $attributes_categories = $new_db->fetchAll($query); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => $table, 'where' => null); foreach ($attributes_categories as $key => $val) { $vals = array(); foreach ($val as $k => $d) { if (self::is_serialized($d)) { $vals[$k] = $d; } else { $vals[$k] = htmlspecialchars($d, ENT_QUOTES, 'utf-8'); } } if (count($vals) > 0) { $db_queries[$table][] = $vals; } } } } //attributes_categories $attributes_categories = $new_db->fetchAll("SELECT * FROM `attributes_categories`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'attributes_categories', 'where' => null); foreach ($attributes_categories as $data) { // $db_queries[] = "INSERT INTO `attributes_categories` (`id`, `name`, `type`, `categories`, `visible`, `order_index`,`required`) VALUES ('".(int)$data['id'] ."', '".htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['categories'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8') ."', '".(int)$data['order_index'] ."',1);"; $db_queries['attributes_categories'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8'), 'categories' => htmlspecialchars($data['categories'], ENT_QUOTES, 'utf-8'), 'visible' => 'true', 'order_index' => (int) $data['order_index'], 'required' => 1); } } //attributes $attributes_categories = $new_db->fetchAll("SELECT * FROM `attributes`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'attributes', 'where' => null); foreach ($attributes_categories as $data) { $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/attributes/' . $data['photo'], '/attributes/' . $data['photo']); $db_queries['attributes'][] = array('id' => (int) $data['id'], 'category_id' => (int) $data['category_id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => 'true', 'order_index' => (int) $data['order_index']); } } //attributes $attributes_categories = $new_db->fetchAll("SELECT * FROM `badges`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'badges', 'where' => null); foreach ($attributes_categories as $data) { $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/badges/' . $data['photo'], '/badges/' . $data['photo']); $db_queries['badges'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'from' => htmlspecialchars($data['from'], ENT_QUOTES, 'utf-8'), 'to' => htmlspecialchars($data['to']), 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8'), 'sys_key' => htmlspecialchars($data['sys_key'], ENT_QUOTES, 'utf-8')); } } //categories $attributes_categories = $new_db->fetchAll("SELECT * FROM `categories`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'categories', 'where' => null); $db_queries['TRUNCATE'][] = array('table' => 'categories_description', 'where' => null); foreach ($attributes_categories as $data) { $db_queries['categories'][] = array('id' => (int) $data['id'], 'sub_of' => (int) $data['sub_of'], 'meta_title' => htmlspecialchars($data['meta_title'], ENT_QUOTES, 'utf-8'), 'meta_keywords' => htmlspecialchars($data['meta_keywords'], ENT_QUOTES, 'utf-8'), 'meta_description' => htmlspecialchars($data['meta_description'], ENT_QUOTES, 'utf-8'), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'order_index' => (int) $data['order_index'], 'module' => $update_for); $db_queries['categories_description'][] = array('id' => (int) $data['id'], 'lid' => 1, 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8')); } } //countries $attributes_categories = $new_db->fetchAll("SELECT * FROM `countries`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'countries', 'where' => null); foreach ($attributes_categories as $data) { $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/countries/' . $data['photo'], '/countries/' . $data['photo']); $db_queries['countries'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'order_index' => (int) $data['order_index']); } } //items $attributes_categories = $new_db->fetchAll("SELECT * FROM `items`"); $temp_items = array(); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'items', 'where' => null); foreach ($attributes_categories as $data) { $weekly_from = '0000-00-00'; $weekly_to = '0000-00-00'; if ($data['weekly_to'] && $data['weekly_to'] != '0000-00-00') { $weekly_from = $data['weekly_to']; $weekly_to = JO_Date::getInstance($data['weekly_to'], 'yy-mm-dd', true)->setInterval('+7 days')->toString(); } $old_path = BASE_PATH . '/old_sys/data/uploads/items/' . $data['id'] . '/'; $item_path = '/items/' . JO_Date::getInstance($data['datetime'], 'yy/mm/', true)->toString() . $data['id'] . '/'; //self::recursiveCopy($old_path . 'preview/', BASE_PATH . '/uploads/' . $item_path . 'preview/'); $thumbnail = self::copyFile($old_path . $data['thumbnail'], $item_path . $data['thumbnail']); $main_file = self::copyFile($old_path . $data['main_file'], $item_path . $data['main_file']); $theme_preview = self::copyFile($old_path . $data['theme_preview'], $item_path . $data['theme_preview']); $theme_preview_thumbnail = self::copyFromArchive($theme_preview); $temp_items[(int) $data['id']] = array('id' => (int) $data['id'], 'user_id' => (int) $data['user_id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'description' => htmlspecialchars($data['description'], ENT_QUOTES, 'utf-8'), 'thumbnail' => $thumbnail, 'theme_preview_thumbnail' => $theme_preview_thumbnail, 'theme_preview' => $theme_preview, 'main_file' => $main_file, 'main_file_name' => htmlspecialchars($data['main_file_name'], ENT_QUOTES, 'utf-8'), 'categories' => htmlspecialchars($data['categories'], ENT_QUOTES, 'utf-8'), 'demo_url' => htmlspecialchars($data['demo_url'], ENT_QUOTES, 'utf-8'), 'price' => (double) $data['price'], 'suggested_price' => (double) $data['suggested_price'], 'sales' => (double) $data['sales'], 'earning' => (double) $data['earning'], 'rating' => (double) $data['rating'], 'votes' => (double) $data['votes'], 'score' => (double) $data['score'], 'comments' => (double) $data['comments'], 'free_request' => htmlspecialchars($data['free_request'], ENT_QUOTES, 'utf-8'), 'free_file' => htmlspecialchars($data['free_file'], ENT_QUOTES, 'utf-8'), 'weekly_from' => $weekly_from, 'weekly_to' => $weekly_to, 'reviewer_comment' => htmlspecialchars($data['reviewer_comment'], ENT_QUOTES, 'utf-8'), 'datetime' => htmlspecialchars($data['datetime'], ENT_QUOTES, 'utf-8'), 'status' => htmlspecialchars($data['status'], ENT_QUOTES, 'utf-8'), 'module' => $update_for, 'video_file' => htmlspecialchars(isset($data['video_file']) ? $data['video_file'] : '', ENT_QUOTES, 'utf-8'), 'item_tags_string' => htmlspecialchars(isset($data['item_tags_string']) ? $data['item_tags_string'] : '', ENT_QUOTES, 'utf-8'), 'preview' => htmlspecialchars(isset($data['preview']) ? $data['preview'] : '', ENT_QUOTES, 'utf-8')); $db_queries['items'][] = $temp_items[(int) $data['id']]; } } //orders $attributes_categories = $new_db->fetchAll("SELECT * FROM `orders`"); if ($attributes_categories) { JO_Db::setAdapterConfig($old_config); $db_queries['TRUNCATE'][] = array('table' => 'orders', 'where' => null); foreach ($attributes_categories as $data) { $db_queries['orders'][] = array('id' => (int) $data['id'], 'order_id' => (int) (isset($data['order_id']) ? $data['order_id'] : 0), 'user_id' => (int) $data['user_id'], 'owner_id' => (int) $data['owner_id'], 'item_id' => (int) $data['item_id'], 'item_name' => htmlspecialchars($data['item_name'], ENT_QUOTES, 'utf-8'), 'price' => (double) $data['price'], 'receive' => (double) $data['receive'], 'datetime' => htmlspecialchars($data['datetime'], ENT_QUOTES, 'utf-8'), 'paid' => htmlspecialchars($data['paid'], ENT_QUOTES, 'utf-8'), 'paid_datetime' => htmlspecialchars($data['paid_datetime'], ENT_QUOTES, 'utf-8'), 'extended' => htmlspecialchars($data['extended'], ENT_QUOTES, 'utf-8'), 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8'), 'currency_code' => WM_Currency::getCurrencyCode(), 'currency_value' => '1.00000000', 'domain' => htmlspecialchars(isset($data['domain']) ? $data['domain'] : '', ENT_QUOTES, 'utf-8'), 'module' => $update_for, 'size_id' => htmlspecialchars(isset($data['size_id']) ? $data['size_id'] : '', ENT_QUOTES, 'utf-8'), 'main_file' => isset($temp_items[$data['item_id']]['main_file']) ? $temp_items[$data['item_id']]['main_file'] : '', 'main_file_info' => htmlspecialchars(isset($data['main_file_info']) ? $data['main_file_info'] : '', ENT_QUOTES, 'utf-8')); } } $new_db = JO_Db::setAdapterConfig($db_config); //temp_items $attributes_categories = $new_db->fetchAll("SELECT * FROM `temp_items`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'temp_items', 'where' => null); foreach ($attributes_categories as $data) { if (!isset($temp_items[$data['item_id']])) { continue; } $old_path = BASE_PATH . '/old_sys/data/uploads/items/' . $data['item_id'] . '/temp/'; $item_path = '/items/' . JO_Date::getInstance($data['datetime'], 'yy/mm/', true)->toString() . $data['item_id'] . '/temp/'; //self::recursiveCopy($old_path . 'preview/', BASE_PATH . '/uploads/' . $item_path . 'preview/'); $thumbnail = self::copyFile($old_path . $data['thumbnail'], $item_path . $data['thumbnail']); $main_file = self::copyFile($old_path . $data['main_file'], $item_path . $data['main_file']); $theme_preview = self::copyFile($old_path . $data['theme_preview'], $item_path . $data['theme_preview']); $theme_preview_thumbnail = self::copyFromArchive($theme_preview); $db_queries['temp_items'][] = array('id' => (int) $data['id'], 'item_id' => (int) $data['item_id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'thumbnail' => $thumbnail, 'theme_preview_thumbnail' => $theme_preview_thumbnail, 'theme_preview' => $theme_preview, 'main_file' => $main_file, 'main_file_name' => htmlspecialchars($data['main_file_name'], ENT_QUOTES, 'utf-8'), 'reviewer_comment' => htmlspecialchars($data['reviewer_comment'], ENT_QUOTES, 'utf-8'), 'datetime' => htmlspecialchars($data['datetime'], ENT_QUOTES, 'utf-8'), 'video_file' => htmlspecialchars(isset($data['video_file']) ? $data['video_file'] : '', ENT_QUOTES, 'utf-8'), 'preview' => htmlspecialchars(isset($data['preview']) ? $data['preview'] : '', ENT_QUOTES, 'utf-8')); } } //temp_items_tags $attributes_categories = $new_db->fetchAll("SELECT * FROM `temp_items_tags`"); if ($attributes_categories) { foreach ($attributes_categories as $data) { if (!isset($temp_items[$data['item_id']])) { continue; } $db_queries['TRUNCATE'][] = array('table' => 'items_tags', 'where' => "`item_id` = '" . (int) $data['item_id'] . "'"); $db_queries['items_tags'][] = array('item_id' => (int) $data['item_id'], 'item_id' => (int) $data['item_id'], 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8')); } } /* if(in_array('slider', $old_db_tables) && in_array('slider', $new_db_tables)) { //slider $attributes_categories = $new_db->fetchAll("SELECT * FROM `slider`"); if($attributes_categories) { $db_queries['TRUNCATE'][] = array( 'table' => 'slider', 'where' => null ); foreach($attributes_categories AS $data) { $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/slider/'.$data['photo'], '/slider/'.$data['photo']); $db_queries['slider'][] = array( 'id' => (int)$data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'url' => htmlspecialchars($data['url'], ENT_QUOTES, 'utf-8'), 'photo' => ($photo), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'order_index' => (int)$data['order_index'] ); } } } */ //users $attributes_categories = $new_db->fetchAll("SELECT * FROM `users`"); if ($attributes_categories) { $db_queries['TRUNCATE'][] = array('table' => 'users', 'where' => null); foreach ($attributes_categories as $data) { $old_path = BASE_PATH . '/old_sys/data/uploads/users/' . $data['user_id'] . '/'; $item_path = '/users/' . JO_Date::getInstance($data['register_datetime'], 'yy/mm/', true)->toString() . $data['user_id'] . '/'; $avatar = self::copyFile($old_path . $data['avatar'], $item_path . $data['avatar']); $homeimage = self::copyFile($old_path . $data['homeimage'], $item_path . $data['homeimage']); $db_queries['users'][] = array('user_id' => (int) $data['user_id'], 'username' => htmlspecialchars($data['username'], ENT_QUOTES, 'utf-8'), 'password' => htmlspecialchars($data['password'], ENT_QUOTES, 'utf-8'), 'email' => htmlspecialchars($data['email'], ENT_QUOTES, 'utf-8'), 'firstname' => htmlspecialchars($data['firstname'], ENT_QUOTES, 'utf-8'), 'lastname' => htmlspecialchars($data['lastname'], ENT_QUOTES, 'utf-8'), 'featured_item_id' => htmlspecialchars($data['featured_item_id'], ENT_QUOTES, 'utf-8'), 'exclusive_author' => htmlspecialchars($data['exclusive_author'], ENT_QUOTES, 'utf-8'), 'license' => $data['license'], 'avatar' => $avatar, 'homeimage' => $homeimage, 'firmname' => htmlspecialchars($data['firmname'], ENT_QUOTES, 'utf-8'), 'profile_title' => htmlspecialchars($data['profile_title'], ENT_QUOTES, 'utf-8'), 'profile_desc' => htmlspecialchars($data['profile_desc'], ENT_QUOTES, 'utf-8'), 'live_city' => htmlspecialchars($data['live_city'], ENT_QUOTES, 'utf-8'), 'country_id' => htmlspecialchars($data['country_id'], ENT_QUOTES, 'utf-8'), 'freelance' => htmlspecialchars($data['freelance'], ENT_QUOTES, 'utf-8'), 'social' => $data['social'], 'quiz' => htmlspecialchars($data['quiz'], ENT_QUOTES, 'utf-8'), 'deposit' => htmlspecialchars($data['deposit'], ENT_QUOTES, 'utf-8'), 'earning' => htmlspecialchars($data['earning'], ENT_QUOTES, 'utf-8'), 'total' => htmlspecialchars($data['total'], ENT_QUOTES, 'utf-8'), 'sold' => htmlspecialchars($data['sold'], ENT_QUOTES, 'utf-8'), 'items' => htmlspecialchars($data['items'], ENT_QUOTES, 'utf-8'), 'sales' => htmlspecialchars($data['sales'], ENT_QUOTES, 'utf-8'), 'buy' => htmlspecialchars($data['buy'], ENT_QUOTES, 'utf-8'), 'rating' => htmlspecialchars($data['rating'], ENT_QUOTES, 'utf-8'), 'score' => htmlspecialchars($data['score'], ENT_QUOTES, 'utf-8'), 'votes' => htmlspecialchars($data['votes'], ENT_QUOTES, 'utf-8'), 'referals' => htmlspecialchars($data['referals'], ENT_QUOTES, 'utf-8'), 'referal_money' => htmlspecialchars($data['referal_money'], ENT_QUOTES, 'utf-8'), 'featured_author' => htmlspecialchars($data['featured_author'], ENT_QUOTES, 'utf-8'), 'register_datetime' => htmlspecialchars($data['register_datetime'], ENT_QUOTES, 'utf-8'), 'last_login_datetime' => htmlspecialchars($data['last_login_datetime'], ENT_QUOTES, 'utf-8'), 'ip_address' => htmlspecialchars($data['ip_address'], ENT_QUOTES, 'utf-8'), 'status' => htmlspecialchars($data['status'], ENT_QUOTES, 'utf-8'), 'groups' => $data['groups'], 'remember_key' => htmlspecialchars($data['remember_key'], ENT_QUOTES, 'utf-8'), 'activate_key' => htmlspecialchars($data['activate_key'], ENT_QUOTES, 'utf-8'), 'referal_id' => htmlspecialchars($data['referal_id'], ENT_QUOTES, 'utf-8'), 'commission_percent' => htmlspecialchars($data['commission_percent'], ENT_QUOTES, 'utf-8'), 'badges' => htmlspecialchars($data['badges'], ENT_QUOTES, 'utf-8')); } } JO_Session::clear('inserted'); JO_Session::clear('deleted'); if (isset($db_queries['TRUNCATE'])) { $truncate = $db_queries['TRUNCATE']; unset($db_queries['TRUNCATE']); JO_Session::set('deleted', $truncate); } $tmp = array(); $checked = array(); foreach ($db_queries as $table => $data) { foreach ($data as $key => $res) { $key = md5(var_export(array($table, $res), true)); if (!isset($checked[$key])) { $tmp[] = array('table' => $table, 'data' => $res); } $checked[$key] = true; } } JO_Session::set('inserted', $tmp); JO_Session::set('query_error', array()); $this->redirect(WM_Router::create($request->getBaseUrl() . '?module=update&controller=index&action=stepTwo')); } }
public function withdrawalAction() { $request = $this->getRequest(); if (!JO_Session::get('user_id')) { JO_Session::set('msg_error', $this->translate('You must be logged to access that page!')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } $this->view->user = Model_Users::getUser(JO_Session::get('user_id')); if (!$this->view->user) { return $this->forward('error', 'error404'); } if ($request->isPost()) { $error = array(); if (!is_numeric($request->getPost('amount'))) { $error['amount'] = $this->translate('You have entered wrong amount'); } else { if ($request->getPost('service') == 'swift') { if ($request->getPost('amount') < 500) { $error['amount'] = $this->translate('The amount you have entered is bellow the minimum'); } $maxAmount = $this->view->user['earning'] - 35; } else { if ($request->getPost('amount') < 50) { $error['amount'] = $this->translate('The amount you have entered is bellow the minimum'); } $maxAmount = $this->view->user['earning']; } if ($request->getPost('amount') > $maxAmount) { $error['amount'] = $this->translate('The amount you have entered is bellow the minimum'); } } if (!$request->getPost('service')) { $error['service'] = $this->translate('You have selected wrong service'); } else { if ($request->getPost('service') == 'swift' && trim($request->getPost('instructions_from_author')) == '') { $error['service2'] = $this->translate('There is an error with your details'); } if ($request->getPost('service') != 'swift' && (!$request->getPost('payment_email_address') || !$request->getPost('payment_email_address_confirmation') || trim($request->getPost('payment_email_address')) == '' || $request->getPost('payment_email_address') !== $request->getPost('payment_email_address_confirmation'))) { $error['service2'] = $this->translate('There is an error with your payment address'); } } if (count($error) > 0) { JO_Session::set('msg_error', $error); } else { $data = array(); /* if(!$request->getPost('taxable_australian_resident')) { $data['taxable_australian_resident'] = 'false'; } else { if($request->getPost('hobbyist') == 'true') { $data['taxable_australian_resident'] = 'iam'; } elseif($request->getPost('hobyist') == 'false') { $data['taxable_australian_resident'] = 'iamnot'; } } */ if (!$request->getPost('abn')) { $data['abn'] = ''; } if (!$request->getPost('acn')) { $data['acn'] = ''; } $text = ''; if ($request->getPost('service') == 'swift') { $text = $request->getPost('instructions_from_author'); } else { $text = $request->getPost('payment_email_address'); } if ($request->getPost('maximum_at_period_end') == 'true') { $data['amount'] = $this->view->user['earning']; } Model_Deposit::addWithdrawal(array('user_id' => JO_Session::get('user_id'), 'amount' => isset($data['amount']) ? $data['amount'] : $request->getPost('amount'), 'method' => $request->getPost('service'), 'text' => $text, 'australian' => isset($data['taxable_australian_resident']) ? $data['taxable_australian_resident'] : $this->getRequest()->getPost('taxable_australian_resident'), 'abn' => $data['abn'], 'acn' => $data['acn'])); JO_Session::set('msg_success', $this->translate('Your request has been submitted')); } $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=withdrawal')); } if (JO_Session::get('msg_success')) { $this->view->msg_success = JO_Session::get('msg_success'); JO_Session::clear('msg_success'); } elseif (JO_Session::get('msg_error')) { $this->view->error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $this->getLayout()->meta_title = $this->translate('Withdrawal'); $this->getLayout()->meta_description = $this->translate('Withdrawal'); $this->view->author_header = Helper_Author::authorHeader($this->view->user); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Profile'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])), array('name' => $this->translate('Withdrawal'))); $this->view->user['earning'] = WM_Currency::normalize($this->view->user['earning']); $this->view->user['total'] = WM_Currency::format($this->view->user['total']); $this->view->user['total_f'] = WM_Currency::format($this->view->user['total']); $this->view->user['deposit_f'] = WM_Currency::format($this->view->user['deposit']); $this->view->user['earning_f'] = WM_Currency::format($this->view->user['earning']); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public static function edit2($user_id, $data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('users'); $user_info_get = self::getUser($user_id); $date_added = WM_Date::format($user_info_get['date_added'], 'yy-mm-dd H:i:s'); $update = array(); $avatar = ''; foreach ($rows as $row) { if (array_key_exists($row, $data)) { if ($row == 'avatar') { if ($data[$row]) { JO_Session::clear('upload_avatar'); $avatar = $data[$row]; } else { //$update[$row] = $data[$row]; } } elseif ($row == 'password' || $row == 'new_password') { $update[$row] = md5($data[$row]); } else { $update[$row] = $data[$row]; } } } if (!$update) { return false; } $rebuild = $result = $db->update('users', $update, array('user_id = ?' => (string) $user_id)); }
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 static function edit($user_id, $data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('users'); $user_info_get = self::getUser($user_id); $date_added = WM_Date::format($user_info_get['date_added'], 'yy-mm-dd H:i:s'); $update = array(); $avatar = ''; foreach ($rows as $row) { if (array_key_exists($row, $data)) { if ($row == 'avatar') { if ($data[$row]) { JO_Session::clear('upload_avatar'); $avatar = $data[$row]; } else { //$update[$row] = $data[$row]; } } elseif ($row == 'password' || $row == 'new_password') { $update[$row] = md5($data[$row]); } else { $update[$row] = $data[$row]; } } } if (!$update) { if (!$avatar) { return false; } } $rebuild = $result = $db->update('users', $update, array('user_id = ?' => (string) $user_id)); if ($avatar) { $image = false; //$error = false; $method_for_upload = Helper_Config::get('file_upload_method'); if ($method_for_upload) { $image = call_user_func(array($method_for_upload, 'uploadUserAvatar'), $avatar, $user_id); //$error = call_user_func(array($upload_model, 'getError') ); } if ($image) { $result = $db->update('users', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ?' => (string) $user_id)); $db->delete('users_avatars', array('user_id = ?' => (string) $user_id)); if ($user_info_get && $user_info_get['avatar']) { if ($user_info_get['avatar'] != $image['image']) { call_user_func(array($user_info_get['store'], 'deleteUserImage'), $user_info_get); } } if (!$rebuild) { $rebuild = $result; } } } if (isset($data['username'])) { $db->query("DELETE FROM url_alias WHERE query = 'user_id=" . (string) $user_id . "'"); $db->insert('url_alias', array('query' => 'user_id=' . (string) $user_id, 'keyword' => $data['username'], 'path' => $data['username'], 'route' => 'users/profile')); } if ($rebuild) { $total = $db->update('pins', array('date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('user_id = ? OR (pin_id IN (SELECT DISTINCT pin_id FROM pins_comments WHERE user_id = ?))' => (string) $user_id)); } $config_private_boards = Helper_Config::get('config_private_boards'); Helper_Db::update('users', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND public = 1' : '') . ')'), 'boards' => new JO_Db_Expr('(SELECT COUNT(DISTINCT board_id) FROM boards WHERE user_id = users.user_id ' . ($config_private_boards ? ' AND public = 1' : '') . ')'), 'likes' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins_likes WHERE user_id = users.user_id)'), 'following' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT following_id) FROM users_following_user WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT following_id) FROM users_following WHERE user_id = users.user_id AND following_id != users.user_id LIMIT 1) )'), 'followers' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) + (SELECT COUNT(DISTINCT user_id) FROM users_following WHERE following_id = users.user_id AND user_id != users.user_id LIMIT 1) )'), 'latest_pins' => new JO_Db_Expr('( SUBSTRING_INDEX( (SELECT GROUP_CONCAT(pin_id ORDER BY `pin_id` DESC) FROM `pins` WHERE user_id = users.user_id), \',\', 15 ) )')), array('user_id = ?' => $user_id)); return true; }
public function loginAction() { $request = $this->getRequest(); if ($request->getQuery('verify')) { $user_data = new Model_Users_User($request->getParam('user_id')); $error = false; if ($user_data->count() && $user_data['new_email_key'] == $request->getQuery('verify')) { $result = new Model_Users_Edit($user_data['user_id'], array('new_email_key' => '', 'email' => $user_data['new_email'])); if ($result->affected_rows) { JO_Session::set('user', array()); JO_Session::set('successful', $this->translate('You verifying your email. Now you can access with the data from e-mail!')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } else { $error = true; } } else { $error = true; } if ($error) { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { if (!$request->getParam('user_id') || !$request->getQuery('key')) { if (JO_Session::get('user[user_id]')) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]'))); } } } $this->view->successful = false; if (JO_Session::get('successful')) { $this->view->successful = JO_Session::get('successful'); JO_Session::clear('successful'); } $this->view->error = false; if ($request->getParam('user_id') && $request->getQuery('key')) { $user_data = new Model_Users_User($request->getParam('user_id')); $error = false; if ($user_data->count() && $user_data['new_password_key'] == $request->getQuery('key')) { $result = new Model_Users_Edit($user_data['user_id'], array('password' => new JO_Db_Expr('`new_password`'), 'new_password' => '', 'new_password_key' => '')); if ($result->affected_rows) { JO_Session::set('user', array()); JO_Session::set('successful', $this->translate('You verifying forgotten password. Now you can access with the data from e-mail!')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } else { $error = true; } } else { $error = true; } if ($error) { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } $referer = $request->getServer('HTTP_REFERER'); $this->view->next = urlencode($request->getBaseUrl()); if ($referer) { $data = parse_url($referer); if (isset($data['host'])) { if (str_replace('www.', '', $data['host']) == $request->getDomain()) { $this->view->next = urlencode($referer); } } } if ($request->issetPost('next')) { $this->view->next = html_entity_decode($request->getPost('next')); } elseif ($request->getQuery('popup') == 'true' && $request->issetQuery('next')) { $this->view->next = urlencode(html_entity_decode($request->getQuery('next'))); } $this->view->is_forgot_password = (int) $request->getPost('forgot_password'); if (JO_Session::issetKey('forgot_password')) { $this->view->is_forgot_password = JO_Session::get('forgot_password'); JO_Session::clear('forgot_password'); } if ($request->isPost() && $request->issetPost('login')) { $validate = new Helper_Validate(); $validate->_set_rules($request->getPost('email'), $this->translate('Email Address'), 'not_empty;min_length[5];max_length[100];email'); if ($request->getPost('forgot_password') != 1) { $validate->_set_rules($request->getPost('password'), $this->translate('Password'), 'not_empty;min_length[4];max_length[30]'); } if ($validate->_valid_form()) { if ($request->getPost('forgot_password') == 1) { $result = new Model_Users_UserByEmail($request->getPost('email')); if ($result->count()) { if ($result['status']) { $new_password = JO_Rand::generateRandumString(8); $key_forgot = md5($result['user_id'] . md5($new_password)); $add_new_pass = new Model_Users_Edit($result['user_id'], array('new_password' => $new_password, 'new_password_key' => $key_forgot)); if ($add_new_pass->affected_rows) { $template = Model_Notification::getTemplate('send_forgot_password_request'); if ($template) { $template_data = array('user_id' => $result['user_id'], 'user_firstname' => $result['firstname'], 'user_lastname' => $result['lastname'], 'user_fullname' => $result['fullname'], 'user_username' => $result['username'], 'site_url' => $request->getBaseUrl(), 'site_name' => Helper_Config::get('site_name'), 'forgot_password_url' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&user_id=' . $result['user_id'] . '&key=' . $key_forgot), 'new_password' => $new_password, 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8')); if (!$template['title']) { $template['title'] = $this->translate('Your new password in') . ' ${site_name}'; } $template['title'] = Model_Notification::parseTemplate(html_entity_decode($template['title'], ENT_QUOTES, 'utf-8'), $template_data); $template['template'] = Model_Notification::parseTemplate(html_entity_decode($template['template'], ENT_QUOTES, 'utf-8'), $template_data); $result_send = Model_Email::send($result['email'], Helper_Config::get('noreply_mail'), $template['title'], $template['template']); if ($result_send) { JO_Session::set('forgot_password', $this->view->is_forgot_password); JO_Session::set('successful', $this->translate('Was sent the e-mail with instructions for the new password!')); $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=users&action=login')); } else { $this->view->error = $this->translate('There was an error. Please try again later!'); } } else { $this->view->error = $this->translate('There was an error. Please try again later!'); } } else { $this->view->error = $this->translate('There was a problem with the record. Please try again!'); } } else { $this->view->error = $this->translate('This profile is not active.'); } } else { $this->view->error = $this->translate('E-mail address was not found!'); } } else { $result = new Model_Users_Login($request->getPost('email'), $request->getPost('password')); if ($result->count()) { if ($result['status']) { //@setcookie('csrftoken_', md5($result['user_id'] . $request->getDomain() . $result['date_added'] ), (time() + ((86400*366)*5)), '/', '.'.$request->getDomain()); JO_Session::set(array('user' => $result->toArray())); $this->redirect(urldecode($this->view->next)); } else { $this->view->error = $this->translate('This profile is not active.'); } } else { $this->view->error = $this->translate('E-mail address and password do not match'); } } } else { $this->view->error = $validate->_get_error_messages(); } } $this->view->login_login = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); //extensions $this->view->user_login_buttons = array(); $user_login_buttons = Model_Extensions::getByMethod('user_login'); foreach ($user_login_buttons as $id => $login) { $this->view->user_login_buttons[] = array('html' => $this->view->callChildren('modules_' . $login . '_loginbutton', $this->view->next), 'view' => $this->view->callChildrenView('modules_' . $login . '_loginbutton', $this->view->next), 'key' => $login); } if ($request->getQuery('popup') == 'true') { $this->view->site_name = Helper_Config::get('site_name'); $this->view->meta_title = Helper_Config::get('meta_title'); $this->view->popup = true; $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->setViewChange('loginPopup'); $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } else { $this->view->loginPopup = $this->view->render('loginPopup', 'users'); $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public static function createEvent($user_id, $event_id, $data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('events'); //$user_info_get = self::getUser($user_id); //$created = WM_Date::format($user_info_get['created'], 'yy-mm-dd H:i:s'); $update = array(); $avatar = ''; $followers = false; foreach ($rows as $row) { if (array_key_exists($row, $data)) { if ($row == 'avatar') { if ($data[$row]) { JO_Session::clear('upload_avatar'); $avatar = $data[$row]; } else { //$update[$row] = $data[$row]; } } else { $update[$row] = $data[$row]; if ($row == 'compartir' && $data[$row] == 'followers') { $followers = true; } if ($row == 'date_event') { $fecha = str_replace("/", "-", $data[$row]); $update[$row] = WM_Date::format($fecha, 'yy-mm-dd H:i:s'); } } } } if (!$update) { if (!$avatar) { return false; } } $user_data = ""; if ($event_id) { $user_data = Model_Events::getEventUser((string) $user_id, $event_id); if (!$user_data) { $db->insert('events', $update); $event_id = $db->lastInsertId(); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$event_id) { return false; } } else { $result = $db->update('events', $update, array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id)); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$result) { return false; } } } else { $db->insert('events', $update); $event_id = $db->lastInsertId(); if ($followers) { $users = Model_Users::getUsers(array('filter_following_user_id' => (string) $user_id)); if ($users) { foreach ($users as $key => $user) { Model_History::addHistory($user['user_id'], Model_History::CREATE_EVENT, $event_id); //self::FollowEvent($event_id, $user['user_id']); } } } if (!$event_id) { return false; } } if ($avatar) { ///// upload images //error_log("Vamos a subir la imagen"); $front = JO_Front::getInstance(); $request = JO_Request::getInstance(); $upload_model = Helper_Pin::formatUploadModule(JO_Registry::get('default_upload_method')); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); if (!file_exists($upload_model_file)) { $upload_model = Helper_Pin::formatUploadModule('locale'); $upload_model_file = $front->getModuleDirectoryWithDefault($request->getModule()) . '/' . $front->classToFilename($upload_model); } $image = false; if (file_exists($upload_model_file)) { //error_log("EXISTE FILE"); $image = call_user_func(array($upload_model, 'uploadEventImage'), $avatar, $event_id); } if ($image) { //error_log("EXISTE FILE"); $result = $db->update('events', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('user_id = ' . (string) $user_id . ' AND event_id = ' . (string) $event_id)); if ($user_data) { if ($user_data['avatar']) { if ($user_data['avatar'] != $image['image']) { call_user_func(array(Helper_Pin::formatUploadModule($user_data['store']), 'deleteEventImage'), $user_data); } } } } } return true; }
public function logoutAction() { $this->setInvokeArg('noViewRenderer', true); JO_Session::clear(); $this->redirect(JO_Request::getInstance()->getBaseUrl()); }
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'); }
private function loginInit($id, $session = null) { $user_data = WM_Users::checkLoginFacebookTwitter($id, 'twitter', $session); if ($user_data) { JO_Session::set(array('user' => $user_data)); JO_Session::clear('user_info_twitteroauth'); JO_Session::clear('access_token_twitteroauth'); if (JO_Session::issetKey('next') && JO_Session::get('next')) { $this->redirect(urldecode(JO_Session::get('next'))); } else { $this->redirect(WM_Router::create($this->getRequest()->getBaseUrl())); } } return $user_data; }