public function indexAction() { if ($this->session->get('successfu_edite')) { $this->view->successfu_edite = true; $this->session->clear('successfu_edite'); } if ($this->session->get('error_permision')) { $this->view->error_permision = $this->session->get('error_permision'); $this->session->clear('error_permision'); } $reques = $this->getRequest(); $this->view->sort = $reques->getRequest('sort', 'DESC'); $this->view->order = $reques->getRequest('order', 'u.sc_id'); $this->view->page_num = $page = $reques->getRequest('page', 1); $this->view->filter_email = $reques->getQuery('filter_email'); $this->view->filter_sent = ($reques->getQuery('filter_sent') > -1 and $reques->getQuery('filter_sent') < 4) ? $reques->getQuery('filter_sent') : 0; $url = ''; if ($this->view->filter_email) { $url .= '&filter_email=' . $this->view->filter_email; } if ($this->view->filter_sent) { $url .= '&filter_sent=' . $this->view->filter_sent; } $url1 = ''; if ($this->view->sort) { $url1 .= '&sort=' . $this->view->sort; } if ($this->view->order) { $url1 .= '&order=' . $this->view->order; } $url2 = '&page=' . $page; $data = array('start' => $page * Helper_Config::get('config_admin_limit') - Helper_Config::get('config_admin_limit'), 'limit' => Helper_Config::get('config_admin_limit'), 'sort' => $this->view->sort, 'order' => $this->view->order, 'filter_email' => $this->view->filter_email, 'filter_sent' => $this->view->filter_sent); $this->view->users = array(); $users = Model_Users::getWaiting($data); if ($users) { foreach ($users as $user) { $user['date_added'] = WM_Date::format($user['date_added'], Helper_Config::get('config_date_format_long_time')); $user['invite_href'] = $reques->getModule() . '/invites/invite/?id=' . $user['sc_id'] . $url . $url1 . $url2; // $user['items_href'] = WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=ads&user_id=' . $user['user_id'] ); // $user['items_href'] = $reques->getModule() . '/ads/?filter_user_id=' . $user['user_id']; $this->view->users[] = $user; } } $this->view->sort = strtolower($this->view->sort); $this->view->sort_id = $reques->getModule() . '/invites/?order=u.sc_id&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_email = $reques->getModule() . '/invites/?order=u.email&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $total_records = Model_Users::getTotalWaiting($data); $this->view->total_pages = ceil($total_records / Helper_Config::get('config_admin_limit')); $this->view->total_rows = $total_records; $pagination = new Model_Pagination(); $pagination->setLimit(Helper_Config::get('config_admin_limit')); $pagination->setPage($page); $pagination->setTotal($total_records); $pagination->setUrl($this->getRequest()->getModule() . '/invites/?page={page}' . $url . $url1); $this->view->pagination = $pagination->render(); }
public static function edit($event_id, $data) { $event_info = self::getEvent($event_id); if (!$event_info) { return; } $db = JO_Db::getDefaultAdapter(); $date_modified = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $db->update('events', array('last_action_datetime' => $date_modified, 'description' => $data['description'], 'website' => $data['website'], 'last_action_datetime' => new JO_Db_Expr('NOW()')), array('event_id = ?' => $event_id)); }
public static function edit($board_id, $data) { set_time_limit(0); $db = JO_Db::getDefaultAdapter(); $self = self::getBoard($board_id); if (!$self) { return false; } $update = Helper_Db::update('boards', $data, array('board_id = ?' => $board_id)); self::generateBoardQuery($board_id, array('title' => $data['title'], 'keyword' => $data['keyword'])); $pins = Model_Pins::getPins(array('filter_board_id' => $board_id)); if ($self['title'] != $data['title']) { if ($pins) { foreach ($pins as $pin) { Model_Pins::deleteCache($pin); } } } if ($self['category_id'] != $data['category_id']) { $db->update('pins', array('category_id' => $data['category_id'], 'date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('board_id = ?' => $board_id)); } return $update; }
public function indexAction() { if ($this->session->get('successfu_edite')) { $this->view->successfu_edite = true; $this->session->clear('successfu_edite'); } if ($this->session->get('error_permision')) { $this->view->error_permision = $this->session->get('error_permision'); $this->session->clear('error_permision'); } $reques = $this->getRequest(); $this->view->sort = $reques->getRequest('sort', 'DESC'); $this->view->order = $reques->getRequest('order', 'u.user_id'); $this->view->page_num = $page = $reques->getRequest('page', 1); $this->view->filter_id = $reques->getQuery('filter_id'); $this->view->filter_name = $reques->getQuery('filter_name'); $this->view->filter_username = $reques->getQuery('filter_username'); $this->view->filter_email = $reques->getQuery('filter_email'); $this->view->filter_delete_account = $reques->getQuery('filter_delete_account'); $url = ''; if ($this->view->filter_id) { $url .= '&filter_id=' . $this->view->filter_id; } if ($this->view->filter_name) { $url .= '&filter_name=' . $this->view->filter_name; } if ($this->view->filter_username) { $url .= '&filter_username='******'&filter_email=' . $this->view->filter_email; } if ($this->view->filter_delete_account) { $url .= '&filter_delete_account=' . $this->view->filter_delete_account; } $filter_delete_account = $this->view->filter_delete_account; if ($this->view->filter_delete_account == '*') { $filter_delete_account = null; } if (!$reques->issetQuery('filter_delete_account')) { $this->view->filter_delete_account = '*'; } $url1 = ''; if ($this->view->sort) { $url1 .= '&sort=' . $this->view->sort; } if ($this->view->order) { $url1 .= '&order=' . $this->view->order; } $url2 = '&page=' . $page; $data = array('start' => $page * Helper_Config::get('config_admin_limit') - Helper_Config::get('config_admin_limit'), 'limit' => Helper_Config::get('config_admin_limit'), 'sort' => $this->view->sort, 'order' => $this->view->order, 'filter_user_id' => $this->view->filter_id, 'filter_name' => $this->view->filter_name, 'filter_username' => $this->view->filter_username, 'filter_delete_account' => $filter_delete_account, 'filter_email' => $this->view->filter_email); $this->view->users = array(); $users = Model_Users::getUsers($data); if ($users) { foreach ($users as $user) { $user['edit_href'] = $reques->getModule() . '/users/edite/?id=' . $user['user_id'] . $url . $url1 . $url2; // $user['items_href'] = WM_Router::create( $this->getRequest()->getBaseUrl() . '?controller=ads&user_id=' . $user['user_id'] ); //$user['items_href'] = $reques->getModule() . '/ads/?filter_user_id=' . $user['user_id']; $user['username_href'] = $reques->getModule() . '/pins/?filter_user_id=' . $user['user_id']; $user['boards_href'] = $reques->getModule() . '/boards/?filter_user_id=' . $user['user_id']; $user['profile_url'] = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user['user_id']); $user['delete_account_date'] = $user['delete_account_date'] != '0000-00-00 00:00:00' ? WM_Date::format($user['delete_account_date'], Helper_Config::get('config_date_format_long_time')) : ''; $this->view->users[] = $user; } } $this->view->sort = strtolower($this->view->sort); $this->view->sort_id = $reques->getModule() . '/users/?order=u.user_id&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_name = $reques->getModule() . '/users/?order=u.firstname&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_username = $reques->getModule() . '/users/?order=u.username&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_pins = $reques->getModule() . '/users/?order=u.pins&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_boards = $reques->getModule() . '/users/?order=u.boards&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $this->view->sort_likes = $reques->getModule() . '/users/?order=u.likes&sort=' . ($this->view->sort == 'asc' ? 'DESC' : 'ASC') . $url . $url2; $total_records = Model_Users::getTotalUsers($data); $this->view->total_pages = ceil($total_records / Helper_Config::get('config_admin_limit')); $this->view->total_rows = $total_records; $pagination = new Model_Pagination(); $pagination->setLimit(Helper_Config::get('config_admin_limit')); $pagination->setPage($page); $pagination->setTotal($total_records); $pagination->setUrl($this->getRequest()->getModule() . '/users/?page={page}' . $url . $url1); $this->view->pagination = $pagination->render(); }
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 static function uploadUserAvatar($avatar, $user_id = 0) { try { $added_date = time(); $username = md5($user_id); $user_info = new Model_Users_User($user_id); if ($user_info->count()) { $added_date = $user_info['date_added']; $username = $user_info['username']; } if (($imageinfo = @getimagesize($avatar)) !== false) { $ext = JO_File_Ext::getExtFromMime($imageinfo['mime']); $name = $username . '_' . $user_id . '.' . $ext; $image_path = '/users/' . WM_Date::format($added_date, 'yy/mm/'); //$name = self::rename_if_exists($image_path, $name); if (!file_exists(BASE_PATH . '/uploads' . $image_path) || !is_dir(BASE_PATH . '/uploads' . $image_path)) { mkdir(BASE_PATH . '/uploads' . $image_path, 0777, true); } if (copy($avatar, BASE_PATH . '/uploads' . $image_path . $name)) { if (file_exists(BASE_PATH . '/uploads' . $image_path . $name)) { return array('store' => 'Model_Upload_Locale', 'image' => $image_path . $name, 'width' => 0, 'height' => 0); } else { return false; } } else { return false; } } else { return false; } } catch (JO_Exception $e) { self::$error = $e->getMessage(); return false; } return false; }
public function __construct($data) { $db = JO_Db::getDefaultAdapter(); try { $db->beginTransaction(); $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $data['date_added'] = $date_added; $data['last_login'] = $date_added; $data['status'] = 1; $data['last_action_datetime'] = $date_added; $data['ip_address'] = JO_Request_Server::encode_ip(JO_Request::getInstance()->getClientIp()); $data['new_email'] = $data['email']; $data['store'] = JO_Registry::get('default_upload_method'); if (!$data['store']) { $data['store'] = 'Model_Upload_Locale'; } /*$avatar = ''; if(isset($data['avatar']) && $data['avatar']) { $avatar = $data['avatar']; $data['avatar'] = ''; }*/ $rows = Helper_Db::describeTable('users'); $insert = array(); $avatar = ''; foreach ($rows as $row => $def) { if (isset($data[$row])) { if (in_array($row, array('password', 'new_password'))) { if ($data[$row]) { if ($data[$row] instanceof JO_Db_Expr) { $insert[$row] = $data[$row]; } else { $insert[$row] = md5($data[$row]); } } else { $insert[$row] = ''; } } elseif ($row == 'avatar') { $avatar = $data[$row]; $data[$row] = ''; } else { $insert[$row] = $data[$row]; } } else { $insert[$row] = $def; } } //create user $user_id = Helper_Db::create('users', $insert); if (!$user_id) { return $this; } //upload avatar if ($avatar) { $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($method_for_upload, 'getError')); if ($error) { $this->error[] = $error; } if ($image && isset($image['image']) && $image['image']) { Helper_Db::update('users', array('avatar' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('user_id = ?' => (string) $user_id)); } } } //create user alias new Model_Users_Autoseo($user_id); /*Helper_Db::insert('url_alias', array( 'query' => 'user_id=' . (string)$user_id, 'keyword' => $data['username'], 'path' => $data['username'], 'route' => 'users/profile' ));*/ //add default boards if (is_array(Helper_Config::get('default_boards'))) { foreach (Helper_Config::get('default_boards') as $def) { new Model_Boards_Create(array('category_id' => $def['category_id'], 'title' => $def['title'], 'user_id' => (string) $user_id)); } } //set following $config_private_boards = Helper_Config::get('config_private_boards'); if (isset($data['following_user']) && $data['following_user'] && $data['following_user'] != -1) { Helper_Db::insert('users_following_user', array('user_id' => (string) $user_id, 'following_id' => (string) $data['following_user'])); Helper_Db::insert('users_following_user', array('user_id' => (string) $data['following_user'], 'following_id' => (string) $user_id)); //update following user info 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 user_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) )')), array('user_id = ?' => (string) $data['following_user'])); } //update user info 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) )')), array('user_id = ?' => (string) $user_id)); $this->user_id = $user_id; $db->commit(); } catch (JO_Exception $e) { $this->error[] = $e->getMessage(); $db->rollBack(); } }
public function sendDailyAction() { $request = $this->getRequest(); $this->view->base_href = $request->getBaseUrl(); $this->view->site_name = JO_Registry::get('site_name'); $this->view->on_facebook = JO_Registry::get('config_on_facebook'); $this->view->site_logo = $this->view->base_href . 'data/images/logo.png'; if (JO_Registry::get('site_logo') && file_exists(BASE_PATH . '/uploads' . JO_Registry::get('site_logo'))) { $this->view->site_logo = $this->view->base_href . 'uploads' . JO_Registry::get('site_logo'); } $this->view->settings = WM_Router::create($this->view->base_href . '?controller=prefs'); $goodies = Model_Pages::getPage(JO_Registry::get('page_goodies')); if ($goodies) { $this->view->pin_it = WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_goodies')); } $this->view->pages = array(); $page = Model_Pages::getPage(JO_Registry::get('page_privacy_policy')); if ($page) { $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy'))); } $page = Model_Pages::getPage(JO_Registry::get('page_terms')); if ($page) { $this->view->pages[] = array('title' => $page['title'], 'href' => WM_Router::create($this->view->base_href . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_privacy_policy'))); } $histories = Model_History::getHistoryToday(array('today' => WM_Date::format($this->now, JO_Date::ATOM))); $no_avatar = JO_Registry::get('no_avatar'); if ($histories) { $model_images = new Helper_Images(); foreach ($histories as $history) { $avatar = Helper_Uploadimages::avatar($history, '_B'); $history['avatar'] = $avatar['image']; $history['user_followers'] = WM_Router::create($this->view->base_href . '?controller=users&action=followers&user_id=' . $history['user_id']); $history['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $history['user_id']); $history['history_comments_total'] = count($history['history_comments']); $history['history_follow_total'] = count($history['history_follow']); $history['history_like_total'] = count($history['history_like']); $history['history_repin_total'] = count($history['history_repin']); /////comments if ($history['history_comments_total']) { foreach ($history['history_comments'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_comments'][$k]['avatar'] = $avatar['image']; $history['history_comments'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////follow if ($history['history_follow_total']) { foreach ($history['history_follow'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_follow'][$k]['avatar'] = $avatar['image']; $history['history_follow'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////like if ($history['history_like_total']) { foreach ($history['history_like'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_like'][$k]['avatar'] = $avatar['image']; $history['history_like'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } /////repin if ($history['history_repin_total']) { foreach ($history['history_repin'] as $k => $v) { if (!isset($v['store'])) { continue; } $avatar = Helper_Uploadimages::avatar($v, '_A'); $history['history_repin'][$k]['avatar'] = $avatar['image']; $history['history_repin'][$k]['profile'] = WM_Router::create($this->view->base_href . '?controller=users&action=profile&user_id=' . $v['user_id']); } } $this->view->history = $history; $html = $this->view->render('sendDaily', 'crons'); Model_Email::send($history['email'], JO_Registry::get('noreply_mail'), sprintf($this->translate('Daily %s'), $this->view->site_name), $html); } } }
public function editItem($id, $data) { $db = JO_Db::getDefaultAdapter(); $info = self::getItem($id); if (!$info) { return; } if (isset($data['free_file'])) { // $db->update('items', array( // 'free_file' => 'false' // )); self::addUserStatus($id, 'freefile'); } $db->update('items', array('name' => $data['name'], 'description' => $data['description'], 'price' => $data['price'], 'free_file' => isset($data['free_file']) ? 'true' : 'false', 'demo_url' => $data['demo_url'], 'weekly_from' => $data['weekly_from'] ? WM_Date::format($data['weekly_from'], 'yy-mm-dd') : '0000-00-00', 'weekly_to' => $data['weekly_to'] ? WM_Date::format($data['weekly_to'], 'yy-mm-dd') : '0000-00-00'), array('id = ?' => (int) $id)); if (isset($data['set_status']) && $data['set_status'] == 'active') { $db->update('items', array('status' => $data['set_status']), array('id = ?' => (int) $id)); $db->update(Model_Users::getPrefixDB() . 'users', array('items' => new JO_Db_Expr('items + 1')), array('user_id = ?' => $info['user_id'])); /////////// send email if ($info['item_note'] == 'true') { $request = JO_Request::getInstance(); $translate = JO_Translate::getInstance(); $not_template = Model_Notificationtemplates::get('approval_item'); $mail = new JO_Mail(); if (JO_Registry::get('mail_smtp')) { $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password')); } $mail->setFrom('no-reply@' . $request->getDomain()); $href = '<a href="' . WM_Router::create($request->getBaseUrl() . '?module=' . $info['module'] . '&controller=items&item_id=' . $id) . '">' . $info['name'] . '</a>'; if ($not_template) { $user_info = Model_Users::getUser($info['user_id']); $title = $not_template['title']; $html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8'); $html = str_replace('{USERNAME}', $user_info['username'], $html); $html = str_replace('{ITEM}', $info['name'], $html); $html = str_replace('{URL}', $href, $html); } else { $title = "[" . $request->getDomain() . "] " . $data['name']; $html = nl2br($translate->translate('Item') . ' ' . $href . ' ' . $translate->translate('approval')); } $mail->setSubject($title); $mail->setHTML($html); $result = $mail->send(array($user_info['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail'); unset($mail); } ////////////////////// } if (isset($data['weekly_to']) && trim($data['weekly_to']) != '') { self::addUserStatus($id, 'featured'); } $db->delete('items_to_category', array('item_id = ?' => (int) $id)); if (isset($data['category_id'])) { foreach ($data['category_id'] as $category_id) { $categories = Model_Categories::getCategoryParents(Model_Categories::getCategories(array('filter_id_key' => true)), $category_id); $categories = explode(',', $categories); array_pop($categories); $categories = array_reverse($categories); $categories = ',' . implode(',', $categories) . ','; $db->insert('items_to_category', array('item_id' => (int) $id, 'categories' => $categories)); } } $db->delete('items_attributes', array('item_id = ?' => (int) $id)); if (isset($data['attributes']) && is_array($data['attributes'])) { foreach ($data['attributes'] as $cid => $value) { if (is_array($value)) { foreach ($value as $val) { $db->insert('items_attributes', array('item_id' => $id, 'attribute_id' => $val, 'category_id' => (int) $cid)); } } elseif ($value) { $db->insert('items_attributes', array('item_id' => $id, 'attribute_id' => $value, 'category_id' => (int) $cid)); } } } $db->delete('items_tags', array('item_id = ?' => (int) $id)); if (isset($data['tags']) && $data['tags']) { $tags = explode(',', $data['tags']); foreach ($tags as $tag) { $tag = trim($tag); if ($tag) { $tag_id = Model_Tags::getTagByTitleAndInsert($tag); if ($tag_id) { $db->insert('items_tags', array('item_id' => $id, 'tag_id' => (int) $tag_id, 'type' => '')); } } } } }
public function __construct($data = array()) { $db = JO_Db::getDefaultAdapter(); $data['category_id'] = 0; $data['public'] = 1; if (isset($data['board_id'])) { $board_info = new Model_Boards_Board($data['board_id']); if ($board_info->count()) { $data['board_id'] = $board_info['board_board_id']; $data['category_id'] = $board_info['board_category_id']; $data['public'] = $board_info['board_public']; } else { $data['board_id'] = 0; } } else { $data['board_id'] = 0; } $data['date_added'] = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $data['date_modified'] = $data['date_added']; $data['user_id'] = isset($data['user_id']) ? $data['user_id'] : (string) JO_Session::get('user[user_id]'); $data['store'] = Helper_Config::get('file_upload_method') ? Helper_Config::get('file_upload_method') : 'Model_Upload_Locale'; $data['source_id'] = 0; //sorce if (isset($data['from']) && $data['from']) { $source = new Model_Sources_GetSourceByUrl($data['from']); if ($source->source_id) { $data['source_id'] = $source->source_id; } } $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time()); /* price */ //$data['price'] = 0; if (isset($data['price']) && $data['price']) { $currencies = WM_Currency::getCurrencies(); $price_left = array(); $price_right = array(); if ($currencies) { foreach ($currencies as $currency) { if (trim($currency['symbol_left'])) { $price_left[] = preg_quote(trim($currency['symbol_left'])); } if (trim($currency['symbol_right'])) { $price_right[] = preg_quote(trim($currency['symbol_right'])); } } if ($price_left) { if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) { $price_tmp = trim(str_replace(trim($match[1]), '', $match[0])); $currency = self::getCurrencyBySimbol(trim($match[1])); if ($currency) { $data['price'] = round($price_tmp / $currency, 4); } } } if (!$data['price'] && $price_right) { if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) { $price_tmp = trim(str_replace(trim($match[2]), '', $match[0])); $currency = self::getCurrencyBySimbol(trim($match[2])); if ($currency) { $data['price'] = round($price_tmp / $currency, 4); } } } } } /* end price */ $from = isset($data['from']) ? $data['from'] : time(); $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0; if (!$data['is_video']) { $auto = new Helper_AutoEmbed(); if ($auto->parseUrl($from)) { $data['is_video'] = 1; } } /* is video */ ///////////////// Event onComplete ///////////////////// $on_add_call = Helper_Config::get('pin_onbefore_create'); if ($on_add_call) { foreach ($on_add_call as $call) { call_user_func($call, $data); } } ///////////////// upload image ///////////////////// $image = false; if (isset($data['media']) && !isset($data['image'])) { $image = $data['media']; } else { if (isset($data['image'])) { $image = $data['image']; } } if (!isset($data['gallery']) && !$image) { return $this; } $data['image'] = ''; //create pin $data['pin_id'] = Helper_Db::insert('pins', $data); if (!$data['pin_id']) { return $this; } if (isset($data['gallery'])) { if (is_array($data['gallery']) && count($data['gallery']) > 0) { $method_for_upload = Helper_Config::get('file_upload_method'); if ($method_for_upload) { foreach ($data['gallery'] as $row => $image_get) { if ($this->error) { return $this; } $image = call_user_func(array($method_for_upload, 'uploadPin'), $image_get, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']); $this->error = call_user_func(array($method_for_upload, 'getError')); if ($image && isset($image['image'])) { if ($row == 0) { Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id'])); } else { $gal_id = Helper_Db::insert('pins_gallery', array('image' => $image['image'], 'store' => $image['store'], 'pin_id' => $data['pin_id'], 'sort_order' => $row)); if (!$gal_id) { return $this; } } } else { return $this; } } } else { Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id'])); return $this; } } else { Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id'])); return $this; } } else { $method_for_upload = Helper_Config::get('file_upload_method'); if ($method_for_upload && $image) { $image = call_user_func(array($method_for_upload, 'uploadPin'), $image, isset($data['title']) && $data['title'] ? $data['title'] : $data['description'], $data['pin_id']); $this->error = call_user_func(array($method_for_upload, 'getError')); if ($image && isset($image['image'])) { Helper_Db::update('pins', array('image' => $image['image'], 'store' => $image['store'], 'height' => $image['height'], 'width' => $image['width']), array('pin_id = ?' => (string) $data['pin_id'])); } else { Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id'])); return $this; } } else { Helper_Db::delete('pins', array('pin_id = ?' => (string) $data['pin_id'])); return $this; } } ///////////////// update latest pins for board ///////////////////// if (isset($data['board_id']) && $data['board_id']) { new Model_Boards_UpdateLatestPins($data['board_id']); } ///////////////// update latest pins for user ///////////////////// new Model_Users_UpdateLatestPins($data['user_id']); ///////////////// Pin total repins ///////////////////// if (isset($data['repin_from']) && $data['repin_from']) { $pin_repin = new Model_Pins_Pin($data['repin_from']); if ($pin_repin->count()) { Helper_Db::update('pins', array('repins' => $db->fetchOne($db->select()->from('pins', 'COUNT(pin_id)')->where('repin_from = ?', $data['repin_from'])->limit(1))), array('pin_id = ?' => $data['repin_from'])); } } ///////////////// Word for search index's ///////////////////// $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght); $words = array(); foreach ($spl as $word) { $word = mb_strtolower($word, 'utf-8'); if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') { $words[$word] = $word; } } ///////////////// Word for search index's insert ///////////////////// foreach ($words as $word => $data1) { $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word)); if (!$dic_id) { $db->insert('pins_dictionary', array('word' => $word)); $dic_id = $db->lastInsertId(); } if ($dic_id) { $db->insert('pins_invert', array('pin_id' => $data['pin_id'], 'dic_id' => $dic_id)); } } Helper_Db::delete('pins_images', array('pin_id = ?' => $data['pin_id'])); ///////////////// Extension on create ////////////////// $extensions = Model_Extensions::getByMethod('pin_oncreate'); if ($extensions) { $front = JO_Front::getInstance(); foreach ($extensions as $id => $ext) { $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'oncreate'), $data['pin_id'], $data); if ($pin_data_ext && is_array($pin_data_ext)) { $data = array_merge(data, $pin_data_ext); } } } ///////////////// Event onComplete ///////////////////// $trigger = new Helper_Triggers_PinOnCreate(); $trigger->bind($data['pin_id']); $this->data = $data; // parent::__construct($data); }
public static function editBoard($board_id, $data) { $db = JO_Db::getDefaultAdapter(); $board_info = self::getBoard($board_id); if (!$board_info) { return; } $update = array('date_modified' => new JO_Db_Expr('NOW()')); if (isset($data['title'])) { $update['title'] = (string) $data['title']; } if (isset($data['category_id'])) { $update['category_id'] = (string) $data['category_id']; } $result = $db->update('boards', $update, array('board_id = ?' => (string) $board_id)); $usrd = $db->select()->from('users_boards')->where('board_id = ?', (string) $board_id); $usd = $db->fetchAll($usrd); $tmp = array(); if ($usd) { foreach ($usd as $e) { $tmp[$e['user_id']] = array('allow' => $e['allow'], 'sort_order' => $e['sort_order']); } } $db->delete('users_boards', array('board_id = ?' => (string) $board_id)); $ins = $db->insert('users_boards', array('user_id' => $board_info['user_id'], 'board_id' => $board_id, 'is_author' => 1, 'sort_order' => (int) (isset($tmp[$board_info['user_id']]['sort_order']) ? $tmp[$board_info['user_id']]['sort_order'] : 0))); if (isset($data['friends'])) { foreach ($data['friends'] as $fr) { $db->insert('users_boards', array('user_id' => $fr, 'board_id' => $board_id, 'allow' => (int) (isset($tmp[$fr]['allow']) ? $tmp[$fr]['allow'] : 0), 'sort_order' => (int) (isset($tmp[$fr]['sort_order']) ? $tmp[$fr]['sort_order'] : 0))); } } if ($result && isset($data['category_id']) && $board_info['category_id'] != $data['category_id']) { $db->update('pins', array('category_id' => $data['category_id'], 'date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('board_id = ?' => $board_id)); } else { $db->update('pins', array('date_modified' => WM_Date::format(time(), 'yy-mm-dd H:i:s')), array('board_id = ?' => $board_id)); } $db->update('boards', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE board_id = boards.board_id)'), 'followers' => new JO_Db_Expr('(SELECT COUNT(DISTINCT users_following_id) FROM users_following WHERE board_id = boards.board_id)')), array('board_id = ?' => $board_id)); self::generateBoardQuery($board_id, array('title' => $data['title'])); return true; }
public static function createMessage($data) { $db = JO_Db::getDefaultAdapter(); $rows = self::describeTable('users_messages'); $date_added = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $data['date_message'] = $date_added; $insert = array(); foreach ($rows as $row) { if (array_key_exists($row, $data)) { $insert[$row] = $data[$row]; } } if (!$insert) { return false; } $db->insert('users_messages', $insert); $message_id = $db->lastInsertId(); if (!$message_id) { return false; } return $message_id; }
public function commentsAction() { $request = $this->getRequest(); $this->view->currency = WM_Currency::getCurrency(); $itemID = $request->getRequest('comments'); $item = Model_Items::get($itemID); if (!is_array($item) || $item['status'] == 'deleted' || JO_Session::get('username') && $item['status'] == 'unapproved' && $item['user_id'] != $_SESSION['user']['user_id'] || $item['status'] == 'queue' || $item['status'] == 'extended_buy') { return $this->forward('error', 'error404'); } $this->view->item_link = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $faqs_data = Model_Faq::getAll($itemID); if (JO_Session::get('user_id') == $item['user_id'] || $faqs_data) { $this->view->faq_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=faq&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } if (JO_Session::get('user_id') == $item['user_id']) { $this->view->edit_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=edit&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->view->delete_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=delete&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); JO_Session::set('redirect', $this->view->comment_link); 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->msg_error = JO_Session::get('msg_error'); JO_Session::clear('msg_error'); } $user = $item['user'] = Model_Users::getUser($item['user_id']); $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Portfolio'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username']))), array('name' => $item['name'], 'href' => $this->view->item_link), array('name' => $this->translate('Comments'))); $model_images = new Model_Images(); $filter = ''; if ($request->getRequest('filter')) { $filter = ' AND items_comments.id = ' . (int) $request->getRequest('filter'); } $bayers = Model_Orders::getBayers($itemID); $comments = Model_Comments::getAll(0, 0, "item_id = '" . (int) $itemID . "' AND reply_to = 0" . $filter, true); $this->view->smiles = Model_Smiles::getSmilesImages(); $this->view->comments = array(); if ($comments) { $bbcode_parser = new WM_BBCode_Parser(); $bbcode_parser->loadDefaultCodes(); foreach ($comments as $comment) { if ($comment['avatar']) { $comment['avatar'] = $model_images->resize($comment['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $comment['avatar'] = 'data/themes/images/noavatar.png'; } $bbcode_parser->parse($comment['comment']); $comment['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml()); $comment['badges'] = Helper_Author::userBadges(Model_Users::getUser($comment['owner_id'])); $comment['datetime'] = WM_Date::format($comment['datetime'], 'dd M yy', true); $comment['is_buy'] = $bayers && in_array($comment['user_id'], $bayers); $comment['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username'])); $comment['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['id']); $comment['replyhref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=reply&c_id=' . $comment['id']); foreach ($comment['reply'] as $key => $reply) { if ($comment['reply'][$key]['avatar']) { $comment['reply'][$key]['avatar'] = $model_images->resize($comment['reply'][$key]['avatar'], 50, 50, true); } else { $comment['reply'][$key]['avatar'] = 'data/themes/images/small_noavatar.png'; } $bbcode_parser->parse($comment['reply'][$key]['comment']); $comment['reply'][$key]['comment'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml()); $comment['reply'][$key]['badges'] = Helper_Author::userBadges(Model_Users::getUser($comment['reply'][$key]['owner_id'])); $comment['reply'][$key]['datetime'] = WM_Date::format($reply['datetime'], 'dd M yy', true); $comment['reply'][$key]['is_buy'] = $bayers && in_array($reply['user_id'], $bayers); $comment['reply'][$key]['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'reply'][$key]['username'])); $comment['reply'][$key]['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=items&action=report/' . $comment['reply'][$key]['id']); } $this->view->comments[] = $comment; } } $this->view->add_comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=add_comment&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $this->getLayout()->meta_title = $item['name']; $this->getLayout()->meta_description = substr(strip_tags(html_entity_decode($item['description'], ENT_QUOTES, 'utf-8')), 0, 255); $this->view->item = $item; $this->view->user = $user; $this->view->children = array(); $this->view->children['rightside'] = 'items/rightside'; $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function feedAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_marker' => $request->getRequest('marker'), 'filter_user_id' => $request->getRequest('user_id')); if ($request->getQuery('filter') == 'likes') { unset($data['filter_user_id']); $data['filter_likes'] = $request->getRequest('user_id'); $this->view->active = 'likes'; } $event_data = Model_Users::getUser($request->getRequest('user_id')); if ($event_data) { JO_Registry::set('meta_title', $event_data['fullname'] . ' - ' . JO_Registry::get('meta_title')); $events = Model_Events::getEvents($data); $this->view->item = array(); if ($events) { $model_images = new Helper_Images(); foreach ($events as $event) { $data_img = Helper_Uploadimages::event($event, '_D'); if (!$data_img) { continue; } $enclosure = $data_img['image']; $category_info = Model_Categories::getCategory($event['category_id']); if ($category_info) { $event['sport_category'] = $category_info['title'] . ' >> ' . $event['sport_category']; } $this->view->item[] = array('guid' => $event['event_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($event['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($event['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=events&action=indexeventBoxDetail&event_id=' . $event['event_id']), 'author' => $event['user']['fullname'], 'pubDate' => WM_Date::format($event['date_added'], JO_Date::RSS_FULL), 'category' => $event['sport_category']); } } } echo $this->renderScript('rss'); }
public function indexAction() { //exit; $base_url = 'http://pinterest.com/moose44/horse-barns-stalls/'; $pages = 5; $enable_comments = false; $category_id = 29; $config_user_id = false; $enable_defaul_board_create = false; ///end config //exit; ini_set('memory_limit', '500M'); $this->noViewRenderer(true); ignore_user_abort(true); if (!$enable_defaul_board_create) { Helper_Config::set('default_boards', false); } for ($i = 1; $i < $pages; $i++) { $base_url_format = $base_url . (strpos($base_url, '?') !== false ? '&' : '?') . 'page=' . $i; $html = @file_get_contents($base_url_format); if ($html) { $dom = new JO_Html_Dom(); $dom->load($html); $hrefs = $dom->find('.PinImage'); if ($hrefs) { foreach ($hrefs as $href) { $price = 0; $url = JO_Url_Relativetoabsolute::toAbsolute($base_url_format, $href->href); $html2 = @file_get_contents($url); if ($html2) { $dom = new JO_Html_Dom(); $dom->load($html2); $board = $dom->find('h3.serif a', 0)->innertext; $image = $dom->find('#pinCloseupImage', 0)->src; $description = $dom->find('#PinCaption .description', 0)->innertext; $from = $dom->find('#PinSource a', 0)->href; $usernames = $dom->find('#PinnerName a', 0)->innertext; $avatar = $dom->find('#PinnerImage img', 0)->src; $ext = strtolower(strrchr($avatar, '.')); $avatar = preg_replace('/_60' . preg_quote($ext) . '$/i', '_600' . $ext, $avatar); if (!@getimagesize($avatar)) { $avatar = preg_replace('/' . preg_quote($ext) . '$/i', '_600' . $ext, $avatar); } $username = trim($dom->find('#PinnerName a', 0)->href, '/'); $price_o = $dom->find('.buyable', 0); if ($price_o) { $price = $price_o->innertext; } if (!$config_user_id) { $user_id = Model_Users_Spider_Users::getUserByName($username, $usernames, $avatar); if (!$user_id) { continue; } } else { $user_id = $config_user_id; } $board_data = new Model_Boards_BoardIdByTitle(trim($board), $user_id, $category_id); if (!$board_data->count()) { continue; } $board_id = $board_data['board_board_id']; $price_f = 0; if (preg_match('/([0-9.]{1,})/', $price, $m)) { $price_f = $m[1]; } $result = new Model_Pins_Create(array('board_id' => $board_id, 'description' => htmlspecialchars(strip_tags($description), ENT_QUOTES, 'utf-8'), 'image' => (string) $image, 'price' => (double) $price, 'from' => urldecode($from), 'public' => '1', 'user_id' => $user_id)); if (!$result->count()) { continue; } $pin_id = $result->data['pin_id']; //// get comments if ($enable_comments) { $commm = $dom->find('.PinComments .comment'); if ($commm) { foreach ($commm as $com) { $avatar = $com->find('.CommenterImage img', 0)->src; $usernames = $com->find('.CommenterName', 0)->innertext; $username = trim($com->find('.CommenterName', 0)->href, '/'); $text = explode('<br />', $com->find('.comment .CommenterMeta', 0)->innertext); $text = isset($text[1]) ? $text[1] : ''; if ($text) { $user_id = Model_Users_Spider_Users::getUserByName($username, $usernames, $avatar); if (!$user_id) { continue; } $result = new Model_Pins_AddComment(array('pin_id' => $pin_id, 'user_id' => $user_id, 'comment' => $text, 'date_added' => WM_Date::format(null, 'yy-mm-dd H:i:s'))); } } sleep(1); } } sleep(1); } } } } } exit; }
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 feedAction() { $request = $this->getRequest(); $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $pp = (int) Helper_Config::get('config_front_limit'); if (!(int) $pp) { $pp = 50; } if ((int) $request->getRequest('per_page') > 0 && (int) $request->getRequest('per_page') < 300) { $pp = (int) $request->getRequest('per_page'); } $data = array('start' => $pp * $page - $pp, 'limit' => $pp, 'filter_user_id' => $request->getRequest('user_id')); $user_data = new Model_Users_User($request->getRequest('user_id')); if ($user_data->count()) { JO_Registry::set('meta_title', $user_data['fullname'] . ' - ' . Helper_Config::get('meta_title')); if ($user_data['pins']) { $pins = new Model_Pins_Users($data); $this->view->item = array(); if ($pins->count()) { $formatObject = new Helper_Format(); foreach ($pins->data as $pin) { $pin = $formatObject->fromatList($pin); $category_info = Model_Categories::getCategory($pin['category_id']); if ($category_info) { $pin['text_board'] = $category_info['title'] . ' >> ' . $pin['text_board']; } $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $pin['images']['thumb_image_b'], 'description' => $pin['description'], 'title' => JO_Utf8::splitText($pin['description'], 60, '...'), 'link' => $pin['pin_url'], 'author' => $pin['author_profile']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['text_board']); } } } } echo $this->renderScript('rss'); }
public static function uploadEventImage1($avatar, $user_id = 0) { try { $added_date = time(); if (is_array($user_info = Model_Users::getUser($user_id))) { $added_date = $user_info['date_added']; } $date_added = WM_Date::format($added_date, 'yy-mm-dd H:i:s'); $s3 = new JO_Api_Amazon(JO_Registry::get('awsAccessKey'), JO_Registry::get('awsSecretKey')); $s3->putBucket(JO_Registry::get('bucklet'), JO_Api_Amazon::ACL_PUBLIC_READ); if ($s3->getBucketLogging(JO_Registry::get('bucklet'))) { if (($imageinfo = @getimagesize($avatar)) !== false) { $ext = strtolower(strrchr($avatar, ".")); $name = $user_id . $ext; $image_path = 'events/' . WM_Date::format($date_added, 'yy/mm/'); if (!file_exists(BASE_PATH . '/uploads/cache_events/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_events/' . $image_path)) { @mkdir(BASE_PATH . '/uploads/cache_events/' . $image_path, 0777, true); } @copy($avatar, BASE_PATH . '/uploads/cache_events/' . $image_path . $name); if (self::uploatToServer(BASE_PATH . '/uploads/cache_events/' . $image_path . $name, $image_path . $name)) { $model_images = new Helper_Images(); $temp_width = 0; $temp_height = 0; $sizes = self::userThumbSizes(); if ($sizes) { foreach ($sizes as $size => $prefix) { $sizes = explode('x', $size); $width = (int) isset($sizes[0]) ? $sizes[0] : 0; $height = (int) isset($sizes[1]) ? $sizes[1] : 0; $name_pref = basename($name, $ext) . $prefix . $ext; if ($width && $height) { $thumb_a = $model_images->resize('/cache_events/' . $image_path . $name, $width, $height, true); } else { if ($width && !$height) { $thumb_a = $model_images->resizeWidth('/cache_events/' . $image_path . $name, $width); } else { if ($height && !$width) { $thumb_a = $model_images->resizeHeight('/cache_events/' . $image_path . $name, $height); } } } if ($prefix == '_B') { $temp_width = $model_images->getSizes('width'); $temp_height = $model_images->getSizes('height'); } $thumb_a1 = explode('/uploads/', $thumb_a); if ($thumb_a1 && isset($thumb_a1[1])) { if (!self::uploatToServer(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name_pref)) { } } } } //$model_images->deleteImages('/cache_events/' . $image_path . $name); if ($temp_width) { return array('store' => 'amazons3', 'image' => $image_path . $name, 'width' => $temp_width, 'height' => $temp_height); } else { return false; } } else { return false; } } else { return false; } } } catch (JO_Exception $e) { return false; } return false; }
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 static function uploadUserAvatar($image, $user_id = 0) { if (($imageinfo = getimagesize($image)) !== false) { self::init(); if (self::$error) { return false; } $added_date = time(); $username = md5($user_id); $user_info = new Model_Users_User($user_id); if ($user_info->count()) { $added_date = $user_info['date_added']; $username = $user_info['username']; } $ext = strtolower(strrchr($image, ".")); if (!$ext) { $mime_ext = explode('/', $imageinfo['mime']); if (isset($mime_ext[1])) { $ext = '.' . $mime_ext[1]; } } $name = $username . '_' . $user_id . $ext; $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/'); if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) { @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true); } $user_agent = ini_get('user_agent'); ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9'); if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) { self::$error = self::translate('Unable to upload to the local server!'); return false; } ini_set('user_agent', $user_agent); $max_width = 0; $sizes = self::userThumbSizes(); $pin_sizes = array(); if ($sizes) { $model_images = new Helper_Images(); foreach ($sizes as $size => $prefix) { $sizes = explode('x', $size); $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext); $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0); } if ($max_width) { $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width); $thumb_a1 = explode('/uploads/', $thumb_a); if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) { self::upload(BASE_PATH . '/uploads/' . $thumb_a1[1], $image_path . $name); if (self::$error) { return false; } foreach ($pin_sizes as $s) { if (self::$error) { return false; } $thumb_b = ''; if ($s[0] && $s[1]) { $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true); } else { if ($s[0] && !$s[1]) { $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]); } else { if (!$s[0] && $s[1]) { $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]); } } } $thumb_b1 = explode('/uploads/', $thumb_b); if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) { self::upload(BASE_PATH . '/uploads/' . $thumb_b1[1], $image_path . $s[2]); if (self::$error) { return false; } } else { self::$error = self::translate('Unable to upload to the local server!'); return false; } } $model_images->deleteImages('/' . $thumb_a1[1]); $model_images->deleteImages('/cache_avatars/' . $image_path . $name); return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0); } else { self::$error = self::translate('Unable to upload to the local server!'); return false; } } else { self::$error = self::translate('Missing images sizes!'); return false; } } else { self::$error = self::translate('Missing images sizes!'); return false; } } else { self::$error = self::translate('Image format is not valid!'); return false; } self::$error = self::translate('Unknown server error!'); return false; }
public static function deleteCache($pin) { @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'author/' . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'viewer/' . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'not_loged/' . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'activity/author/' . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'activity/viewer/' . $pin['pin_id'] . '.cache'); @unlink(BASE_PATH . '/cache/data/pins/' . WM_Date::format($pin['date_added'], 'yy/mm/dd/') . 'activity/not_loged/' . $pin['pin_id'] . '.cache'); }
public function __construct($board_id, $data = array()) { $db = JO_Db::getDefaultAdapter(); try { $db->beginTransaction(); $board_info = new Model_Boards_Board($board_id); if (!$board_info->count()) { return $this; } $data['date_modified'] = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $result = Helper_Db::update('boards', $data, array('board_id = ?' => (string) $board_id)); $usrd = $db->select()->from('users_boards')->where('board_id = ?', (string) $board_id); $usd = $db->fetchAll($usrd); $tmp = array(); if ($usd) { foreach ($usd as $e) { $tmp[$e['user_id']] = array('allow' => $e['allow'], 'sort_order' => $e['sort_order']); } } Helper_Db::delete('users_boards', array('board_id = ?' => (string) $board_id)); $ins = Helper_Db::insert('users_boards', array('user_id' => $board_info['user_user_id'], 'board_id' => $board_id, 'is_author' => 1, 'sort_order' => (int) (isset($tmp[$board_info['user_user_id']]['sort_order']) ? $tmp[$board_info['user_user_id']]['sort_order'] : 0))); if (!$result) { $result = $ins; } if (isset($data['friends'])) { foreach ($data['friends'] as $fr) { $ins = Helper_Db::insert('users_boards', array('user_id' => $fr, 'board_id' => $board_id, 'allow' => (int) (isset($tmp[$fr]['allow']) ? $tmp[$fr]['allow'] : 0), 'sort_order' => (int) (isset($tmp[$fr]['sort_order']) ? $tmp[$fr]['sort_order'] : 0))); if (!$result) { $result = $ins; } } } if ($result && isset($data['category_id']) && $board_info['user_category_id'] != $data['category_id']) { $res = Helper_Db::update('pins', array('category_id' => $data['category_id'], 'date_modified' => $data['date_modified']), array('board_id = ?' => $board_id)); if (!$result) { $result = $res; } } else { $res = Helper_Db::update('pins', array('date_modified' => $data['date_modified']), array('board_id = ?' => $board_id)); if (!$result) { $result = $res; } } $res = Helper_Db::update('boards', array('pins' => new JO_Db_Expr('(SELECT COUNT(DISTINCT pin_id) FROM pins WHERE board_id = boards.board_id)'), 'followers' => new JO_Db_Expr('( (SELECT COUNT(DISTINCT user_id) FROM users_following_user WHERE following_id = boards.user_id AND user_id != boards.user_id LIMIT 1) + (SELECT COUNT(DISTINCT user_id) FROM users_following WHERE following_id = boards.user_id AND user_id != boards.user_id LIMIT 1) - (SELECT COUNT(DISTINCT user_id) FROM users_following_ignore WHERE following_id = boards.user_id AND board_id = boards.board_id AND user_id != boards.user_id LIMIT 1) )')), array('board_id = ?' => $board_id)); if (!$result) { $result = $res; } Helper_Db::update('users', array('boards' => new JO_Db_Expr("(SELECT COUNT(board_id) FROM boards WHERE user_id = '" . (isset($data['user_id']) ? (string) $data['user_id'] : JO_Session::get('user[user_id]')) . "')")), array('user_id = ?' => $board_info['user_user_id'])); //private $config_private_boards = Helper_Config::get('config_private_boards'); if (isset($data['public']) && $data['public'] != $board_info['board_public']) { Helper_Db::update('pins', array('public' => $data['public']), array('board_id = ?' => $board_id)); 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 user_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) )')), array('user_id = ?' => $board_info['user_user_id'])); } ////autoseo new Model_Boards_Autoseo($board_id); $this->affected_rows = $result; $db->commit(); } catch (JO_Exception $e) { $db->rollBack(); } }
public function __construct($pin_id, $data = array()) { $db = JO_Db::getDefaultAdapter(); try { $db->beginTransaction(); $pin_info = new Model_Pins_Pin($pin_id); if (!$pin_info->count()) { return $this; } $pin_info = $pin_info->data; if (isset($data['board_id'])) { $board_info = new Model_Boards_Board($data['board_id']); if ($board_info->count()) { $data['board_id'] = $board_info['board_board_id']; $data['category_id'] = $board_info['board_category_id']; $data['public'] = $board_info['board_public']; } else { $data['board_id'] = 0; } } $data['likes'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT user_id) FROM pins_likes WHERE pin_id = pins.pin_id)'); $data['comments'] = new JO_Db_Expr('(SELECT COUNT(DISTINCT comment_id) FROM pins_comments WHERE pin_id = pins.pin_id)'); $data['date_modified'] = WM_Date::format(time(), 'yy-mm-dd H:i:s'); $data['source_id'] = 0; //sorce if (isset($data['from']) && $data['from']) { $source = new Model_Sources_GetSourceByUrl($data['from']); if ($source->source_id) { $data['source_id'] = $source->source_id; } } $data['from_md5'] = md5(isset($data['from']) ? $data['from'] : time()); /* price */ //$data['price'] = 0; if (isset($data['price']) && $data['price']) { $currencies = WM_Currency::getCurrencies(); $price_left = array(); $price_right = array(); if ($currencies) { foreach ($currencies as $currency) { if (trim($currency['symbol_left'])) { $price_left[] = preg_quote(trim($currency['symbol_left'])); } if (trim($currency['symbol_right'])) { $price_right[] = preg_quote(trim($currency['symbol_right'])); } } if ($price_left) { if (preg_match('/(' . implode('|', $price_left) . ')([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) { $price_tmp = trim(str_replace(trim($match[1]), '', $match[0])); $currency = self::getCurrencyBySimbol(trim($match[1])); if ($currency) { $data['price'] = round($price_tmp / $currency, 4); } } } if (!$data['price'] && $price_right) { if (preg_match('/(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?([\\s]{0,2})?(' . implode('|', $price_right) . ')/', $data['price'], $match)) { $price_tmp = trim(str_replace(trim($match[2]), '', $match[0])); $currency = self::getCurrencyBySimbol(trim($match[2])); if ($currency) { $data['price'] = round($price_tmp / $currency, 4); } } } } } /* end price */ $from = isset($data['from']) ? $data['from'] : time(); $data['is_video'] = isset($data['is_video']) && $data['is_video'] == 'true' ? 1 : 0; if (!$data['is_video']) { $auto = new Helper_AutoEmbed(); if ($auto->parseUrl($from)) { $data['is_video'] = 1; } } /* is video */ ///////////////// Event onComplete ///////////////////// $on_add_call = Helper_Config::get('pin_onbefore_edit'); if ($on_add_call) { foreach ($on_add_call as $call) { call_user_func($call, $data); } } //edit pin $result = Helper_Db::update('pins', $data, array('pin_id = ?' => $pin_id)); ///////////////// update latest pins for board ///////////////////// if (isset($data['board_id']) && $data['board_id'] && $pin_info['pin_board_id'] != $data['board_id']) { new Model_Boards_UpdateLatestPins($data['board_id']); new Model_Boards_UpdateLatestPins($pin_info['pin_board_id']); $board_info = new Model_Boards_Board($data['board_id']); if ($board_info->count()) { if ($board_info['board_cover'] == $pin_id) { $res = Helper_Db::update('boards', array('cover' => 0), array('board_id = >' => $pin_info['pin_board_id'])); if (!$result && $res) { $result = $res; } } } } ///////////////// update latest pins for user ///////////////////// new Model_Users_UpdateLatestPins($pin_info['pin_user_id']); ///////////////// Word for search index's ///////////////////// $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght); $words = array(); foreach ($spl as $word) { $word = mb_strtolower($word, 'utf-8'); if (!in_array($word, self::blackWordsDictionary()) && $word[0] . $word[1] != '&#') { $words[$word] = $word; } } ///////////////// Word for search index's insert ///////////////////// Helper_Db::delete('pins_invert', array('pin_id = ?' => $pin_id)); foreach ($words as $word => $data1) { $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word)); if (!$dic_id) { $dic_id = Helper_Db::insert('pins_dictionary', array('word' => $word)); } if ($dic_id) { $res = Helper_Db::insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id)); if (!$result && $res) { $result = $res; } } } ///////////////// Extension on edit ////////////////// $extensions = Model_Extensions::getByMethod('pin_onedit'); if ($extensions) { $front = JO_Front::getInstance(); foreach ($extensions as $id => $ext) { $pin_data_ext = call_user_func(array($front->formatModuleName('model_' . $ext . '_pin'), 'onedit'), $pin_id, $data); if ($pin_data_ext && is_array($pin_data_ext)) { $data = array_merge(data, $pin_data_ext); } } } ///////////////// Event onComplete ///////////////////// $trigger = new Helper_Triggers_PinOnEdit(); $trigger->bind($pin_id); $this->affected_rows = $result; $db->commit(); } catch (JO_Exception $e) { echo $e; exit; $db->rollBack(); } }
public function v2addCommentAction() { $request = $this->getRequest(); $response = array(); if (JO_Session::get('user[user_id]')) { $key_com = md5(serialize($request->getPost())) . '_' . date('i'); if (JO_Session::get('post_comments_data') == $key_com) { exit; } $pin_info = new Model_Pins_Pin($request->getRequest('pin_id')); if ($pin_info->count()) { $pin_info = $pin_info->data; $data = array('pin_id' => $pin_info['pin_pin_id'], 'user_id' => JO_Session::get('user[user_id]'), 'comment' => $request->getPost('write_comment'), 'date_added' => WM_Date::format(null, 'yy-mm-dd H:i:s')); if ($request->issetPost('friends') && is_array($request->getPost('friends'))) { foreach ($request->getPost('friends') as $user_id => $fullname) { if (Model_Users::isFriendUser($user_id, JO_Session::get('user[user_id]'))) { $profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $user_id); $data['comment'] = preg_replace('/' . $fullname . '/i', ' <a class="link comment-user-profile" href="' . $profile . '">' . $fullname . '</a> ', $data['comment']); } } } $result = new Model_Pins_AddComment($data); if ($result->comment_id) { JO_Session::set('post_comments_data', $key_com); $pin_info = new Model_Pins_Pin($request->getRequest('pin_id')); $pin_info = $pin_info->data; new Model_History_AddHistory($pin_info['user_user_id'], Model_History_Abstract::COMMENTPIN, $pin_info['pin_pin_id'], 0, $request->getPost('write_comment')); $response = array('ok' => true, 'user' => array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')), 'avatars' => Helper_Uploadimages::userAvatars(JO_Session::get('user')), 'fullname' => JO_Session::get('user[fullname]')), 'total_comments' => $pin_info ? $pin_info['pin_comments'] : 0, 'comment' => $data['comment'], 'delete_comment' => WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $result->comment_id), 'url_delete' => WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $result->comment_id), 'text_delete_comment' => $this->translate('Delete Comment'), 'stats' => $this->getPinStat($request->getRequest('pin_id')), 'url_report' => false, 'text_delete' => $this->translate('Delete Comment'), 'text_report' => $this->translate('Report Comment')); //send email for comment pin if ($pin_info['user_user_id'] != JO_Session::get('user[user_id]')) { if ($pin_info && $pin_info['user_email_interval'] == 1 && $pin_info['user_comments_email']) { $template = Model_Notification::getTemplate('comment_pin'); if ($template) { $template_data = array('user_id' => $pin_info['user_user_id'], 'user_firstname' => $pin_info['user_firstname'], 'user_lastname' => $pin_info['user_lastname'], 'user_fullname' => $pin_info['user_fullname'], 'user_username' => $pin_info['user_username'], 'author_url' => $response['user']['profile'], 'author_fullname' => $response['user']['fullname'], 'pin_url' => WM_Router::pinAction($pin_info['pin_pin_id']), 'mail_footer' => html_entity_decode(Helper_Config::get('mail_footer'), ENT_QUOTES, 'utf-8')); if (!$template['title']) { $template['title'] = '${author_fullname} ' . $this->translate('comment your pin'); } $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); Model_Email::send($pin_info['user_email'], Helper_Config::get('noreply_mail'), $template['title'], $template['template']); } } } } else { $response['error'] = $this->translate('There was a problem with the record. Please try again!'); } } else { $response['error'] = $this->translate('There was a problem with the record. Please try again!'); } } else { $response['location'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); } $this->noViewRenderer(true); echo JO_Json::encode($response); }
public static function deleteUserImage($user_info) { try { $user_info['avatar'] = basename($user_info['avatar']); $ext = strtolower(strrchr($user_info['avatar'], ".")); $thumbs = array($user_info['avatar']); $sizes = self::pinThumbSizes(); if ($sizes) { foreach ($sizes as $size => $key) { $thumbs[] = preg_replace('/' . $ext . '$/i', $key . $ext, $user_info['avatar']); } } $auth = new JO_Api_Rackspace_Authentication(JO_Registry::get('rsUsername'), JO_Registry::get('rsApiKey')); if ($auth->authenticate()) { $container = 'users_' . WM_Date::format($user_info['date_added'], 'yy_mm'); $conn = new JO_Api_Rackspace_Connection($auth); $contaners = $conn->list_public_containers(); if ($contaners && in_array($container, $contaners)) { $images = $conn->get_container($container); foreach ($thumbs as $thumb) { $get = $images->exists_object($thumb); if ($get && $get->content_length) { $images->delete_object($thumb); } } } } } catch (JO_Exception $e) { } }
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 static function uploadUserAvatar($image, $user_id = 0) { if (($imageinfo = getimagesize($image)) !== false) { self::init(); if (self::$error) { return false; } $added_date = time(); $username = md5($user_id); $user_info = new Model_Users_User($user_id); if ($user_info->count()) { $added_date = $user_info['date_added']; $username = $user_info['username']; } $ext = strtolower(strrchr($image, ".")); if (!$ext) { $mime_ext = explode('/', $imageinfo['mime']); if (isset($mime_ext[1])) { $ext = '.' . $mime_ext[1]; } } $name = $username . '_' . $user_id . $ext; $image_path = 'avatars/' . WM_Date::format($added_date, 'yy/mm/'); if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $image_path) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $image_path)) { @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $image_path, 0777, true); } $user_agent = ini_get('user_agent'); ini_set('user_agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9'); if (!@copy($image, BASE_PATH . '/uploads/cache_avatars/' . $image_path . $name)) { self::$error = self::translate('Unable to upload to the local server!'); return false; } ini_set('user_agent', $user_agent); $max_width = 0; $sizes = self::userThumbSizes(); $pin_sizes = array(); if ($sizes) { $model_images = new Helper_Images(); foreach ($sizes as $size => $prefix) { $sizes = explode('x', $size); $pin_sizes[] = array((int) isset($sizes[0]) ? $sizes[0] : 0, (int) isset($sizes[1]) ? $sizes[1] : 0, basename($name, $ext) . $prefix . $ext); $max_width = max($max_width, (int) isset($sizes[0]) ? $sizes[0] : 0); } if ($max_width) { $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $image_path . $name, $max_width); $thumb_a1 = explode('/uploads/', $thumb_a); if ($thumb_a1 && isset($thumb_a1[1]) && $thumb_a1[1]) { $container = Helper_Config::get('rackspace_users_contaners'); try { $images = self::$connect->get_container($container); //$images->make_public(86400*365); //$images = self::$connect->get_container($container); //if(!$images->cdn_uri) { // self::$error = self::translate("Authentication response did not indicate CDN availability"); // return false; //} $object = $images->create_object($name); $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]); $image_info = $images->get_object($name); if (!$image_info->name) { self::$error = self::translate('Unable to upload to the server!'); return false; } foreach ($pin_sizes as $s) { $thumb_b = ''; if ($s[0] && $s[1]) { $thumb_b = $model_images->resize('/' . $thumb_a1[1], $s[0], $s[1], true); } else { if ($s[0] && !$s[1]) { $thumb_b = $model_images->resizeWidth('/' . $thumb_a1[1], $s[0]); } else { if (!$s[0] && $s[1]) { $thumb_b = $model_images->resizeHeight('/' . $thumb_a1[1], $s[1]); } } } $thumb_b1 = explode('/uploads/', $thumb_b); if ($thumb_b1 && isset($thumb_b1[1]) && $thumb_b1[1]) { $object = $images->create_object($s[2]); $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_b1[1]); $image_info1 = $images->get_object($s[2]); if (!$image_info1->name) { self::$error = self::translate('Unable to upload to the server!'); return false; } } else { self::$error = self::translate('Unable to upload to the local server!'); return false; } } return array('store' => 'Model_Upload_Rackspace', 'image' => trim(Helper_Config::get('rackspace_users_contaners_cdn'), '/') . '/' . $image_info->name, 'width' => 0, 'height' => 0); } catch (JO_Exception $e) { self::$error = $e->getMessage(); return false; } $model_images->deleteImages('/' . $thumb_a1[1]); $model_images->deleteImages('/cache_avatars/' . $image_path . $name); return array('store' => 'Model_Upload_Amazons3', 'image' => $image_path . $name, 'width' => 0, 'height' => 0); } else { self::$error = self::translate('Unable to upload to the local server!'); return false; } } else { self::$error = self::translate('Missing images sizes!'); return false; } } else { self::$error = self::translate('Missing images sizes!'); return false; } } else { self::$error = self::translate('Image format is not valid!'); return false; } self::$error = self::translate('Unknown server error!'); return false; }
public function daily_summary_mailAction() { $this->noViewRenderer(true); $request = $this->getRequest(); $users = Model_Users::getDailySummary(); if ($users) { $domain = $request->getDomain(); $mail = new JO_Mail(); if (JO_Registry::get('mail_smtp')) { $mail->setSMTPParams(JO_Registry::forceGet('mail_smtp_host'), JO_Registry::forceGet('mail_smtp_port'), JO_Registry::forceGet('mail_smtp_user'), JO_Registry::forceGet('mail_smtp_password')); } $mail->setFrom('no-reply@' . $domain); $not_template = Model_Notification::getNotification('daily_summary'); foreach ($users as $user) { $user['to_date'] = WM_Date::format($user['to_date'], 'Y-mm-dd H:i'); $user['from_date'] = WM_Date::format($user['from_date'], 'Y-mm-dd H:i'); if ($not_template) { $title = $not_template['title']; $html = html_entity_decode($not_template['template'], ENT_QUOTES, 'utf-8'); $html = str_replace('{USERNAME}', $user['username'], $html); $html = str_replace('{SALES}', $user['cnt'], $html); $html = str_replace('{SUM}', WM_Currency::format($user['daily_sum']), $html); $html = str_replace('{TO_DATE}', $user['to_date'], $html); $html = str_replace('{FROM_DATE}', $user['from_date'], $html); } else { $title = "[" . $domain . "] " . $this->translate('Daily summary'); $html = nl2br($this->translate('Daily summary') . ' from ' . $user['from_date'] . ' to ' . $user['to_date'] . ' Sales: ' . $user['cnt'] . ', Receive money: ' . WM_Currency::format($user['daily_sum']) . ' =============================================================================================== ' . JO_Registry::forceGet('meta_title') . ' '); } $mail->setSubject($title); $mail->setHTML($html); $mail->send(array($user['email']), JO_Registry::get('mail_smtp') ? 'smtp' : 'mail'); } } }
public function monthly_chartAction() { if (preg_match('/^20([0-9]{2})$/', $this->getRequest()->getQuery('year'))) { $year = $this->getRequest()->getQuery('year'); } else { $year = WM_Date::format(null, 'yy'); } $data = Model_Statistics::getStatistics(new JO_Db_Expr("`id` LIKE '" . $year . "%'")); $this->view->xAxis = array('categories' => array()); $this->view->series = array(array('name' => 'Pins', 'data' => array()), array('name' => 'Users', 'data' => array()), array('name' => 'Boards', 'data' => array())); $get_m = array(); if ($data) { foreach ($data as $t) { $get_m[$t['id']][$t['type']] = $t['total']; } } for ($i = 1; $i < 13; $i++) { if ($year == date('Y') && $i > date('m')) { continue; } $this->view->xAxis['categories'][] = WM_Date::format(date('Y') . '-' . sprintf('%02d', $i) . '-01', 'MM'); for ($r = 1; $r < 4; $r++) { if (isset($get_m[$year . sprintf('%02d', $i)][$r])) { $total = $get_m[$year . sprintf('%02d', $i)][$r]; } else { $total = 0; } $this->view->series[$r - 1]['data'][] = $total; } } echo $this->renderScript('json'); }
public function feedAction($data = array()) { $request = $this->getRequest(); if (!$data) { $this->forward('error', 'error404'); } else { $this->view->item = array(); $model_images = new Helper_Images(); foreach ($data['pins'] as $pin) { $image = call_user_func(array(Helper_Pin::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D'); if ($image) { $enclosure = $image['image']; } else { continue; } $category_info = Model_Categories::getCategory($pin['category_id']); if ($category_info) { $pin['board'] = $category_info['title'] . ' >> ' . $pin['board']; } $this->view->item[] = array('guid' => $pin['pin_id'], 'enclosure' => $enclosure, 'description' => Helper_Pin::descriptionFix($pin['description']), 'title' => Helper_Pin::descriptionFix(JO_Utf8::splitText($pin['description'], 60, '...')), 'link' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']), 'author' => $pin['user']['fullname'], 'pubDate' => WM_Date::format($pin['date_added'], JO_Date::RSS_FULL), 'category' => $pin['board']); } echo $this->renderScript('rss'); } }