public function cache_imageAction() { $request = $this->getRequest(); $width = (int) $request->getParam('width'); $height = (int) $request->getParam('height'); $cached_file = $request->getParam('cached_file'); $file = $request->getParam('file') . $request->getParam('extension'); $extension = $request->getParam('extension'); $gray = $request->getParam('gray') == 'gray'; $crop = $request->getParam('crop') == 'crop'; $watermark = $request->getParam('watermark') == 'watermark' ? 'watermark.png' : false; $model_images = new Helper_Images(); $image = false; if ($width && $height) { $image = $model_images->resize('/' . $file, $width, $height, $crop, $watermark, $gray); } else { if ($width) { $image = $model_images->resizeWidth('/' . $file, $width, $watermark, $gray); } else { if ($height) { $image = $model_images->resizeHeight('/' . $file, $height, $watermark, $gray); } else { $this->forward('error', 'error404'); } } } if ($image) { $response = $this->getResponse(); $response->addHeader('Content-type:' . JO_File_Ext::getMimeFromFile($image)); $response->appendBody(file_get_contents($image)); exit; } else { $this->forward('error', 'error404'); } }
public function imageAction() { $this->setInvokeArg('noViewRenderer', true); $image = $this->getRequest()->getRequest('image'); if ($image !== null) { $models_images = new Helper_Images(); echo $models_images->resize($image, 100, 100); } }
public function deleteImage($image_id) { $db = JO_Db::getDefaultAdapter(); $query = $db->select()->from('gallery_images', array('image'))->where('image_id = ?', (int) $image_id); $result = $db->fetchOne($query); if (!$result) { return 'error'; } else { $mi = new Helper_Images(); $mi->deleteImages($result); $db->delete('gallery_images', array('image_id = ?' => (int) $image_id)); return 'ok'; } }
protected function getColectionThumb(&$item) { $model_images = new Helper_Images(); if (!empty($item['photo'])) { $height = JO_Registry::forceGet('user_public_collection_height'); $thumb = $model_images->resizeWidth($item['photo'], JO_Registry::forceGet('user_public_collection_width')); $thumb_size = getimagesize($thumb); if ($thumb_size[1] > $height) { $image = new JO_GDThumb($thumb); $image->crop(0, 0, $thumb_size[0], $height); $image->save($thumb); } $item['photo'] = $thumb; } else { $item['photo'] = 'data/themes/images/no_collection_image.png'; } }
public function ajaxReadAction() { if ($this->getRequest()->isXmlHttpRequest() || $this->getRequest()->issetQuery('popup')) { // $this->noLayout(true); } else { $this->forward('pages', 'read'); } $pageIDs = explode('_', $this->getRequest()->getRequest('page_id')); $pageID = end($pageIDs); $this->view->page = Model_Pages::getPage($pageID); if (!$this->view->page) { $this->forward('error', 'error404'); } $model_images = new Helper_Images(); $this->view->page['description'] = html_entity_decode($this->view->page['description'], ENT_QUOTES, 'utf-8'); if (JO_Registry::get('config_fix_image_thumb_editor')) { $this->view->page['description'] = $model_images->fixEditorText($this->view->page['description']); } if (JO_Registry::get('config_fix_external_urls')) { $this->view->page['description'] = $this->fixUrl($this->view->page['description']); } $this->view->full_url = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=pages&action=read&page_id=' . $pageID); }
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 static function returnViewIndex($item, $view_name = 'index') { if (!isset($item['module']) || !$item['module']) { return; } $view = JO_View::getInstance(); if (!isset($item['no_items'])) { static $results = array(); $model_images = new Helper_Images(); $request = JO_Request::getInstance(); if (mb_strlen($item['name'], 'UTF-8') > 35) { $item['name'] = JO_Utf8::mb_cut_text($item['name'], 0, 35, ' '); } $item['price'] = WM_Currency::format($item['price']); switch ($view_name) { case 'category': $height = JO_Registry::forceGet($item['module'] . '_items_preview_height'); $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width')); if (!empty($item['thumbnail'])) { $thumb_size = getimagesize($item['thumbnail']); if ($thumb_size[1] > $height) { $image = new JO_GDThumb($item['thumbnail']); $image->crop(0, 0, $thumb_size[0], $height); $image->save($item['thumbnail']); } } /* CATEGORIES */ $cats = array(); $categories = Model_Categories::getCategoriesByIds($item['categories']); foreach ($categories as $v) { $cats[] = array('name' => $v['name'], 'href' => WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=categories&category_id=' . $v['id'] . '&name=' . WM_Router::clearName($v['name']))); } $item['categories'] = $cats; break; case 'downloads': $height = JO_Registry::forceGet($item['module'] . '_items_preview_height'); $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_preview_width')); if (!empty($item['thumbnail'])) { $thumb_size = getimagesize($item['thumbnail']); if ($thumb_size[1] > $height) { $image = new JO_GDThumb($item['thumbnail']); $image->crop(0, 0, $thumb_size[0], $height); $image->save($item['thumbnail']); } } $item['rate'] = Model_Items::isRate($item['id']); break; default: $height = JO_Registry::forceGet($item['module'] . '_items_thumb_height'); $item['thumbnail'] = $model_images->resizeWidth($item['theme_preview_thumbnail'], JO_Registry::forceGet($item['module'] . '_items_thumb_width'), $height); if (!empty($item['thumbnail'])) { $thumb_size = getimagesize($item['thumbnail']); if ($thumb_size[1] > $height) { $image = new JO_GDThumb($item['thumbnail']); $image->crop(0, 0, $thumb_size[0], $height); $image->save($item['thumbnail']); } } } $item['href'] = WM_Router::create($request->getBaseUrl() . '?controller=items&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); $item['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])); } $view->item = $item; return $view->renderByModule('single_items/' . $view_name, 'items', $item['module']); }
public static function uploadUserAvatar($avatar, $user_id = 0) { //try { if (($imageinfo = getimagesize($avatar)) !== false) { if (!file_exists(BASE_PATH . '/uploads/cache_avatars/' . $user_id) || !is_dir(BASE_PATH . '/uploads/cache_avatars/' . $user_id)) { @mkdir(BASE_PATH . '/uploads/cache_avatars/' . $user_id, 0777, true); } $ext = strtolower(strrchr($avatar, ".")); if (!$ext) { $mime_ext = explode('/', $imageinfo['mime']); if (isset($mime_ext[1])) { $ext = '.' . $mime_ext[1]; } } $name = md5(time() . mt_rand()) . '_' . $user_id . $ext; if (@copy($avatar, BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/' . $name)) { $added_date = time(); if (is_array($user_info = Model_Users::getUser($user_id))) { $added_date = $user_info['date_added']; self::deleteUserImage($user_info); } $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'); $container = 'amatteur_users'; $auth = new JO_Api_Rackspace_Authentication(JO_Registry::get('rsUsername'), JO_Registry::get('rsApiKey')); if ($auth->authenticate()) { $conn = new JO_Api_Rackspace_Connection($auth); $contaners = $conn->list_public_containers(); if (!in_array($container, $contaners)) { $conn->create_container($container); $contaners[] = $container; } if ($contaners && in_array($container, $contaners)) { $images = $conn->get_container($container); $images->make_public(86400 * 365); $images = $conn->get_container($container); if (!$images->cdn_uri) { return false; } $object = $images->create_object($name); $object->load_from_filename(BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/' . $name); $image_info = $images->get_object($name); if (!$image_info->name) { return false; } $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_avatars/' . $user_id . '/' . $name, $width, $height, true); } else { if ($width && !$height) { $thumb_a = $model_images->resizeWidth('/cache_avatars/' . $user_id . '/' . $name, $width); } else { if ($height && !$width) { $thumb_a = $model_images->resizeHeight('/cache_avatars/' . $user_id . '/' . $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])) { $object = $images->create_object($name_pref); $object->load_from_filename(BASE_PATH . '/uploads/' . $thumb_a1[1]); } } } self::recursiveDelete(BASE_PATH . '/uploads/cache_avatars/' . $user_id . '/'); self::recursiveDelete(BASE_PATH . '/uploads/cache/cache_avatars/' . $user_id . '/'); if ($temp_width) { return array('store' => 'rackspace', 'image' => $images->cdn_uri . '/' . $image_info->name, 'width' => $temp_width, 'height' => $temp_height); } } } } } return false; /*} catch (JO_Exception $e) { return false; }*/ return false; }
private function getForm() { $request = $this->getRequest(); $categories_id = $request->getRequest('id'); $places_model = new Model_Categories(); if ($categories_id) { $categories_info = $places_model->getCategory($categories_id); } $this->view->cancel_url = $request->getModule() . '/categories/'; if ($request->getPost('status')) { $this->view->status = $request->getPost('status'); } elseif (isset($categories_info)) { $this->view->status = $categories_info['status']; } else { $this->view->status = 1; } if ($request->getPost('title')) { $this->view->title = $request->getPost('title'); } elseif (isset($categories_info)) { $this->view->title = $categories_info['title']; } if ($request->getPost('meta_title')) { $this->view->meta_title = $request->getPost('meta_title'); } elseif (isset($categories_info)) { $this->view->meta_title = $categories_info['meta_title']; } if ($request->getPost('meta_description')) { $this->view->meta_description = $request->getPost('meta_description'); } elseif (isset($categories_info)) { $this->view->meta_description = $categories_info['meta_description']; } if ($request->getPost('meta_keywords')) { $this->view->meta_keywords = $request->getPost('meta_keywords'); } elseif (isset($categories_info)) { $this->view->meta_keywords = $categories_info['meta_keywords']; } if ($request->getRequest('keyword')) { $this->view->keyword = $request->getRequest('keyword'); } elseif (isset($categories_info)) { $this->view->keyword = $categories_info['keyword']; } // image $image_model = new Helper_Images(); if ($request->getRequest('image')) { $this->view->image = $request->getRequest('image'); } elseif (isset($categories_info['image'])) { $this->view->image = $categories_info['image']; } else { $this->view->image = ''; } if ($this->view->image) { $this->view->preview_image = $image_model->resize($this->view->image, 100, 100); } else { $this->view->preview_image = $image_model->resize(Helper_Config::get('no_image'), 100, 100); } if (!$this->view->preview_image) { $this->view->preview_image = $image_model->resize(Helper_Config::get('no_image'), 100, 100); } }
public function indexAction() { $request = $this->getRequest(); if ($request->isPost()) { Model_Settings::updateAll($request->getParams()); $this->session->set('successfu_edite', true); $this->redirect($this->getRequest()->getBaseUrl() . $this->getRequest()->getModule() . '/payments/'); } $store_config = Model_Settings::getSettingsPairs(array('filter_group' => 'paypal')); $confog = $request->getPost('paypal'); if (isset($confog['paypal_sandbox_mode'])) { $this->view->paypal_sandbox_mode = $confog['paypal_sandbox_mode']; } elseif (isset($store_config['paypal_sandbox_mode'])) { $this->view->paypal_sandbox_mode = $store_config['paypal_sandbox_mode']; } else { $this->view->paypal_sandbox_mode = 0; } if (isset($confog['paypal_status'])) { $this->view->paypal_status = $confog['paypal_status']; } elseif (isset($store_config['paypal_status'])) { $this->view->paypal_status = $store_config['paypal_status']; } else { $this->view->paypal_status = 0; } if (isset($confog['paypal_email'])) { $this->view->paypal_email = $confog['paypal_email']; } elseif (isset($store_config['paypal_email'])) { $this->view->paypal_email = $store_config['paypal_email']; } else { $this->view->paypal_email = ''; } if (isset($confog['paypal_sort_order'])) { $this->view->paypal_sort_order = $confog['paypal_sort_order']; } elseif (isset($store_config['paypal_sort_order'])) { $this->view->paypal_sort_order = $store_config['paypal_sort_order']; } else { $this->view->paypal_sort_order = 0; } if (isset($confog['paypal_pdt_token'])) { $this->view->paypal_pdt_token = $confog['paypal_pdt_token']; } elseif (isset($store_config['paypal_pdt_token'])) { $this->view->paypal_pdt_token = $store_config['paypal_pdt_token']; } else { $this->view->paypal_pdt_token = ''; } /**************** STATUSES ****************/ /*if(isset($confog['config_order_status_id'])) { $this->view->config_order_status_id = $confog['config_order_status_id']; } elseif(isset($store_config['config_order_status_id'])) { $this->view->config_order_status_id = $store_config['config_order_status_id']; } else { $this->view->config_order_status_id = ''; }*/ if (isset($confog['pp_standard_canceled_reversal_status_id'])) { $this->view->pp_standard_canceled_reversal_status_id = $confog['pp_standard_canceled_reversal_status_id']; } elseif (isset($store_config['pp_standard_canceled_reversal_status_id'])) { $this->view->pp_standard_canceled_reversal_status_id = $store_config['pp_standard_canceled_reversal_status_id']; } else { $this->view->pp_standard_canceled_reversal_status_id = ''; } if (isset($confog['pp_standard_completed_status_id'])) { $this->view->pp_standard_completed_status_id = $confog['pp_standard_completed_status_id']; } elseif (isset($store_config['pp_standard_completed_status_id'])) { $this->view->pp_standard_completed_status_id = $store_config['pp_standard_completed_status_id']; } else { $this->view->pp_standard_completed_status_id = ''; } if (isset($confog['pp_standard_denied_status_id'])) { $this->view->pp_standard_denied_status_id = $confog['pp_standard_denied_status_id']; } elseif (isset($store_config['pp_standard_denied_status_id'])) { $this->view->pp_standard_denied_status_id = $store_config['pp_standard_denied_status_id']; } else { $this->view->pp_standard_denied_status_id = ''; } if (isset($confog['pp_standard_expired_status_id'])) { $this->view->pp_standard_expired_status_id = $confog['pp_standard_expired_status_id']; } elseif (isset($store_config['pp_standard_expired_status_id'])) { $this->view->pp_standard_expired_status_id = $store_config['pp_standard_expired_status_id']; } else { $this->view->pp_standard_expired_status_id = ''; } if (isset($confog['pp_standard_failed_status_id'])) { $this->view->pp_standard_failed_status_id = $confog['pp_standard_failed_status_id']; } elseif (isset($store_config['pp_standard_failed_status_id'])) { $this->view->pp_standard_failed_status_id = $store_config['pp_standard_failed_status_id']; } else { $this->view->pp_standard_failed_status_id = ''; } if (isset($confog['pp_standard_pending_status_id'])) { $this->view->pp_standard_pending_status_id = $confog['pp_standard_pending_status_id']; } elseif (isset($store_config['pp_standard_pending_status_id'])) { $this->view->pp_standard_pending_status_id = $store_config['pp_standard_pending_status_id']; } else { $this->view->pp_standard_pending_status_id = ''; } if (isset($confog['pp_standard_processed_status_id'])) { $this->view->pp_standard_processed_status_id = $confog['pp_standard_processed_status_id']; } elseif (isset($store_config['pp_standard_processed_status_id'])) { $this->view->pp_standard_processed_status_id = $store_config['pp_standard_processed_status_id']; } else { $this->view->pp_standard_processed_status_id = ''; } if (isset($confog['pp_standard_refunded_status_id'])) { $this->view->pp_standard_refunded_status_id = $confog['pp_standard_refunded_status_id']; } elseif (isset($store_config['pp_standard_refunded_status_id'])) { $this->view->pp_standard_refunded_status_id = $store_config['pp_standard_refunded_status_id']; } else { $this->view->pp_standard_refunded_status_id = ''; } if (isset($confog['pp_standard_reversed_status_id'])) { $this->view->pp_standard_reversed_status_id = $confog['pp_standard_reversed_status_id']; } elseif (isset($store_config['pp_standard_reversed_status_id'])) { $this->view->pp_standard_reversed_status_id = $store_config['pp_standard_reversed_status_id']; } else { $this->view->pp_standard_reversed_status_id = ''; } if (isset($confog['pp_standard_voided_status_id'])) { $this->view->pp_standard_voided_status_id = $confog['pp_standard_voided_status_id']; } elseif (isset($store_config['pp_standard_voided_status_id'])) { $this->view->pp_standard_voided_status_id = $store_config['pp_standard_voided_status_id']; } else { $this->view->pp_standard_voided_status_id = ''; } $this->view->statuses = WM_Orderstatuses::orderStatuses(); /////// logo $image_model = new Helper_Images(); if (isset($confog['paypal_logo']) && $confog['paypal_logo']) { $this->view->paypal_logo = $confog['paypal_logo']; } elseif (isset($store_config['paypal_logo']) && $store_config['paypal_logo']) { $this->view->paypal_logo = $store_config['paypal_logo']; } else { $this->view->paypal_logo = ''; } if ($this->view->paypal_logo) { $this->view->preview_logo = $image_model->resize($this->view->paypal_logo, 100, 100); } else { $this->view->preview_logo = $image_model->resize(JO_Registry::forceGet('no_image'), 100, 100); } if (!$this->view->preview_logo) { $this->view->preview_logo = $image_model->resize(JO_Registry::forceGet('no_image'), 100, 100); } if (!$this->view->preview_logo) { $this->view->preview_logo = $image_model->resize('/no_image.png', 100, 100); } $this->view->preview = $image_model->resize(JO_Registry::forceGet('no_image'), 100, 100); if (!$this->view->preview) { $this->view->preview = $image_model->resize('/no_image.png', 100, 100); } }
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 getForm() { $request = $this->getRequest(); $this->view->templates = $this->getTemplates(array('mobile')); $config = $request->getPost('config'); $images = $request->getPost('images'); $pages = $request->getPost('pages'); $store_config = Model_Settings::getSettingsPairs(); $this->view->pages = Model_Pages::getPagesFromParent(0); $this->view->pages_about = array(); $this->view->pages_about[] = array('title' => $this->translate('SEPARATOR MENU'), 'page_id' => -1); if ($this->view->pages) { foreach ($this->view->pages as $p) { $this->view->pages_about[] = array('title' => $p['title'], 'page_id' => $p['page_id']); } } $this->view->currencies = Model_Currency::getCurrencies(); $this->view->app_path = BASE_PATH; //////////////////////////////////////// GENERAL //////////////////////////////////////// if (isset($config['config_base_domain'])) { $this->view->config_base_domain = $config['config_base_domain']; } elseif (isset($store_config['config_base_domain'])) { $this->view->config_base_domain = $store_config['config_base_domain']; } else { $this->view->config_base_domain = $request->getBaseUrl(); } if (isset($config['config_on_facebook'])) { $this->view->config_on_facebook = $config['config_on_facebook']; } elseif (isset($store_config['config_on_facebook'])) { $this->view->config_on_facebook = $store_config['config_on_facebook']; } else { $this->view->config_on_facebook = ''; } if (isset($config['google_analytics'])) { $this->view->google_analytics = $config['google_analytics']; } elseif (isset($store_config['google_analytics'])) { $this->view->google_analytics = $store_config['google_analytics']; } if (isset($config['config_fix_image_thumb_editor'])) { $this->view->config_fix_image_thumb_editor = $config['config_fix_image_thumb_editor']; } elseif (isset($store_config['config_fix_image_thumb_editor'])) { $this->view->config_fix_image_thumb_editor = $store_config['config_fix_image_thumb_editor']; } if (isset($config['config_fix_external_urls'])) { $this->view->config_fix_external_urls = $config['config_fix_external_urls']; } elseif (isset($store_config['config_fix_external_urls'])) { $this->view->config_fix_external_urls = $store_config['config_fix_external_urls']; } //////////////////////////////////////// SEO //////////////////////////////////////// if (isset($config['site_name'])) { $this->view->site_name = $config['site_name']; } elseif (isset($store_config['site_name'])) { $this->view->site_name = $store_config['site_name']; } if (isset($config['meta_title'])) { $this->view->meta_title = $config['meta_title']; } elseif (isset($store_config['meta_title'])) { $this->view->meta_title = $store_config['meta_title']; } if (isset($config['meta_keywords'])) { $this->view->meta_keywords = $config['meta_keywords']; } elseif (isset($store_config['meta_keywords'])) { $this->view->meta_keywords = $store_config['meta_keywords']; } if (isset($config['meta_description'])) { $this->view->meta_description = $config['meta_description']; } elseif (isset($store_config['meta_description'])) { $this->view->meta_description = $store_config['meta_description']; } //////////////////////////////////////// Options //////////////////////////////////////// if (isset($config['config_admin_limit'])) { $this->view->config_admin_limit = $config['config_admin_limit']; } elseif (isset($store_config['config_admin_limit'])) { $this->view->config_admin_limit = $store_config['config_admin_limit']; } else { $this->view->config_admin_limit = 15; } if (isset($config['config_front_limit'])) { $this->view->config_front_limit = $config['config_front_limit']; } elseif (isset($store_config['config_front_limit'])) { $this->view->config_front_limit = $store_config['config_front_limit']; } else { $this->view->config_front_limit = 10; } if (isset($config['template'])) { $this->view->template = $config['template']; } elseif (isset($store_config['template'])) { $this->view->template = $store_config['template']; } if (isset($config['config_maintenance'])) { $this->view->config_maintenance = $config['config_maintenance']; } elseif (isset($store_config['config_maintenance'])) { $this->view->config_maintenance = $store_config['config_maintenance']; } else { $this->view->config_maintenance = 0; } if (isset($config['config_hide_brand'])) { $this->view->config_hide_brand = $config['config_hide_brand']; } elseif (isset($store_config['config_hide_brand'])) { $this->view->config_hide_brand = $store_config['config_hide_brand']; } else { $this->view->config_hide_brand = 0; } $this->view->data_timezones = JO_Date_Timezones::getTimezonse(); if (isset($config['phpSettings']['date.timezone'])) { $this->view->date_timezone = $config['phpSettings']['date.timezone']; } elseif (isset($store_config['phpSettings']['date.timezone'])) { $this->view->date_timezone = $store_config['phpSettings']['date.timezone']; } else { $this->view->date_timezone = 'UTC'; } if (isset($config['config_disable_js'])) { $this->view->config_disable_js = $config['config_disable_js']; } elseif (isset($store_config['config_disable_js'])) { $this->view->config_disable_js = $store_config['config_disable_js']; } else { $this->view->config_disable_js = 0; } if (isset($config['config_pin_prefix'])) { $this->view->config_pin_prefix = $config['config_pin_prefix']; } elseif (isset($store_config['config_pin_prefix'])) { $this->view->config_pin_prefix = $store_config['config_pin_prefix']; } else { $this->view->config_pin_prefix = 'pin'; } if (isset($config['config_user_view'])) { $this->view->config_user_view = $config['config_user_view']; } elseif (isset($store_config['config_user_view'])) { $this->view->config_user_view = $store_config['config_user_view']; } else { $this->view->config_user_view = 'fullname'; } if (isset($config['config_gallery_pin'])) { $this->view->config_gallery_pin = $config['config_gallery_pin']; } elseif (isset($store_config['config_gallery_pin'])) { $this->view->config_gallery_pin = $store_config['config_gallery_pin']; } else { $this->view->config_gallery_pin = 1; } if (isset($config['config_gallery_limit'])) { $this->view->config_gallery_limit = $config['config_gallery_limit']; } elseif (isset($store_config['config_gallery_limit'])) { $this->view->config_gallery_limit = $store_config['config_gallery_limit']; } else { $this->view->config_gallery_limit = 5; } if (isset($config['config_home_page_view_not_loged'])) { $this->view->config_home_page_view_not_loged = $config['config_home_page_view_not_loged']; } elseif (isset($store_config['config_home_page_view_not_loged'])) { $this->view->config_home_page_view_not_loged = $store_config['config_home_page_view_not_loged']; } else { $this->view->config_home_page_view_not_loged = 'randum'; } if (isset($config['config_home_page_view_loged'])) { $this->view->config_home_page_view_loged = $config['config_home_page_view_loged']; } elseif (isset($store_config['config_home_page_view_loged'])) { $this->view->config_home_page_view_loged = $store_config['config_home_page_view_loged']; } else { $this->view->config_home_page_view_loged = 'following'; } if (isset($config['config_image_minimum_size'])) { $this->view->config_image_minimum_size = $config['config_image_minimum_size']; } elseif (isset($store_config['config_image_minimum_size'])) { $this->view->config_image_minimum_size = $store_config['config_image_minimum_size']; } else { $this->view->config_image_minimum_size = 80; } /* v2.2 */ if (isset($config['config_enable_follow_private_profile'])) { $this->view->config_enable_follow_private_profile = $config['config_enable_follow_private_profile']; } elseif (isset($store_config['config_enable_follow_private_profile'])) { $this->view->config_enable_follow_private_profile = $store_config['config_enable_follow_private_profile']; } else { $this->view->config_enable_follow_private_profile = 0; } /* v2.2 */ //////////////////////////////////////// Storage //////////////////////////////////////// $this->view->upload_storage = array(); $this->view->upload_storage[] = array('key' => 'Model_Upload_Locale', 'active' => 'Model_Upload_Locale' == Helper_Config::get('file_upload_method'), 'name' => $this->translate('Locale')); /*$storage = (array)$this->view->callChildrenView('modules_storage'); if(isset($storage['modules']) && $storage['modules']) {*/ $storage_modules = $this->getUploadStorages(); if ($storage_modules) { foreach ($storage_modules as $mod) { if ($mod['is_installed']) { $key = 'Model_Upload_' . ucfirst(strtolower($mod['key'])); $this->view->upload_storage[] = array('key' => $key, 'active' => $key == Helper_Config::get('file_upload_method'), 'name' => $mod['name']); } } } if (isset($config['config_comments_list'])) { $this->view->config_comments_list = $config['config_comments_list']; } elseif (isset($store_config['config_comments_list'])) { $this->view->config_comments_list = $store_config['config_comments_list']; } else { $this->view->config_comments_list = 0; } /////////////////////////////// CURRENCY /////////////////////// $this->view->currencies = array(); $currencies = Model_Currency::getCurrencies(array('status' => 1)); //WM_Currency::getCurrencies(); if ($currencies) { $this->view->currencies = $currencies; } if (isset($config['config_currency'])) { $this->view->config_currency = $config['config_currency']; } elseif (isset($store_config['config_currency'])) { $this->view->config_currency = $store_config['config_currency']; } if (isset($config['config_currency_auto_update'])) { $this->view->config_currency_auto_update = $config['config_currency_auto_update']; } elseif (isset($store_config['config_currency_auto_update'])) { $this->view->config_currency_auto_update = $store_config['config_currency_auto_update']; } else { $this->view->config_currency_auto_update = 1; } if (isset($config['config_cache_live'])) { $this->view->config_cache_live = $config['config_cache_live']; } elseif (isset($store_config['config_cache_live'])) { $this->view->config_cache_live = $store_config['config_cache_live']; } else { $this->view->config_cache_live = 0; } if (isset($config['enable_free_registration'])) { $this->view->enable_free_registration = $config['enable_free_registration']; } elseif (isset($store_config['enable_free_registration'])) { $this->view->enable_free_registration = $store_config['enable_free_registration']; } else { $this->view->enable_free_registration = 0; } //////////////////////////////////////// Contacts //////////////////////////////////////// if (isset($config['admin_mail'])) { $this->view->admin_mail = $config['admin_mail']; } elseif (isset($store_config['admin_mail'])) { $this->view->admin_mail = $store_config['admin_mail']; } if (isset($config['report_mail'])) { $this->view->report_mail = $config['report_mail']; } elseif (isset($store_config['report_mail'])) { $this->view->report_mail = $store_config['report_mail']; } if (isset($config['noreply_mail'])) { $this->view->noreply_mail = $config['noreply_mail']; } elseif (isset($store_config['noreply_mail'])) { $this->view->noreply_mail = $store_config['noreply_mail']; } if (isset($config['mail_smtp'])) { $this->view->mail_smtp = $config['mail_smtp']; } elseif (isset($store_config['mail_smtp'])) { $this->view->mail_smtp = $store_config['mail_smtp']; } else { $this->view->mail_smtp = 0; } if (isset($config['mail_smtp_host'])) { $this->view->mail_smtp_host = $config['mail_smtp_host']; } elseif (isset($store_config['mail_smtp_host'])) { $this->view->mail_smtp_host = $store_config['mail_smtp_host']; } if (isset($config['mail_smtp_port'])) { $this->view->mail_smtp_port = $config['mail_smtp_port']; } elseif (isset($store_config['mail_smtp_port'])) { $this->view->mail_smtp_port = $store_config['mail_smtp_port']; } if (isset($config['mail_smtp_user'])) { $this->view->mail_smtp_user = $config['mail_smtp_user']; } elseif (isset($store_config['mail_smtp_user'])) { $this->view->mail_smtp_user = $store_config['mail_smtp_user']; } if (isset($config['mail_smtp_password'])) { $this->view->mail_smtp_password = $config['mail_smtp_password']; } elseif (isset($store_config['mail_smtp_password'])) { $this->view->mail_smtp_password = $store_config['mail_smtp_password']; } if (isset($config['mail_footer'])) { $this->view->mail_footer = $config['mail_footer']; } elseif (isset($store_config['mail_footer'])) { $this->view->mail_footer = $store_config['mail_footer']; } if (isset($config['not_rp'])) { $this->view->not_rp = $config['not_rp']; } elseif (isset($store_config['not_rp'])) { $this->view->not_rp = $store_config['not_rp']; } else { $this->view->not_rp = 0; } if (isset($config['not_rc'])) { $this->view->not_rc = $config['not_rc']; } elseif (isset($store_config['not_rc'])) { $this->view->not_rc = $store_config['not_rc']; } else { $this->view->not_rc = 0; } if (isset($config['not_ri'])) { $this->view->not_ri = $config['not_ri']; } elseif (isset($store_config['not_ri'])) { $this->view->not_ri = $store_config['not_ri']; } else { $this->view->not_ri = 0; } //////////////////////////////////////// Images //////////////////////////////////////// /////// logo $image_model = new Helper_Images(); if (isset($images['site_logo']) && $images['site_logo']) { $this->view->site_logo = $images['site_logo']; } elseif (isset($store_config['site_logo']) && $store_config['site_logo']) { $this->view->site_logo = $store_config['site_logo']; } else { $this->view->site_logo = ''; } if ($this->view->site_logo) { $this->view->preview_logo = $image_model->resize($this->view->site_logo, 100, 100); } else { $this->view->preview_logo = $image_model->resize('/logo.png', 100, 100); } if (!$this->view->preview_logo) { $this->view->preview_logo = $image_model->resize('/logo.png', 100, 100); } $this->view->preview = $image_model->resize('/logo.png', 100, 100); ////mobile logo if (isset($images['site_logo_mobile']) && $images['site_logo_mobile']) { $this->view->site_logo_mobile = $images['site_logo_mobile']; } elseif (isset($store_config['site_logo_mobile']) && $store_config['site_logo_mobile']) { $this->view->site_logo_mobile = $store_config['site_logo_mobile']; } else { $this->view->site_logo_mobile = ''; } if ($this->view->site_logo_mobile) { $this->view->preview_logo_mobile = $image_model->resize($this->view->site_logo_mobile, 100, 100); } else { $this->view->preview_logo_mobile = $image_model->resize('/logo.png', 100, 100); } if (!$this->view->preview_logo_mobile) { $this->view->preview_logo_mobile = $image_model->resize('/logo.png', 100, 100); } $this->view->preview_mobile = $image_model->resize('/logo.png', 100, 100); ////// no image if (isset($images['no_image']) && $images['no_image']) { $this->view->no_image = $images['no_image']; } elseif (isset($store_config['no_image']) && $store_config['no_image']) { $this->view->no_image = $store_config['no_image']; } else { $this->view->no_image = '/no_image.png'; } if ($this->view->no_image) { $this->view->preview_no_image = $image_model->resize($this->view->no_image, 100, 100); } else { $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); } if (!$this->view->preview_no_image) { $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); } ////// no avatar if (isset($images['no_avatar']) && $images['no_avatar']) { $this->view->no_avatar = $images['no_avatar']; } elseif (isset($store_config['no_avatar']) && $store_config['no_avatar']) { $this->view->no_avatar = $store_config['no_avatar']; } else { $this->view->no_avatar = '/no-avatar.png'; } if ($this->view->no_avatar) { $this->view->preview_no_avatar = $image_model->resize($this->view->no_avatar, 100, 100); } else { $this->view->preview_no_avatar = $image_model->resize('/no-avatar.png', 100, 100); } if (!$this->view->preview_no_avatar) { $this->view->preview_no_avatar = $image_model->resize('/no_image.png', 100, 100); } ////// favicon if (isset($images['favicon']) && $images['favicon']) { $this->view->favicon = $images['favicon']; } elseif (isset($store_config['favicon']) && $store_config['favicon']) { $this->view->favicon = $store_config['favicon']; } else { $this->view->favicon = ''; } if ($this->view->favicon) { $this->view->preview_favicon = $image_model->resize($this->view->favicon, 100, 100); } else { $this->view->preview_favicon = $image_model->resize($this->view->no_image, 100, 100); } if (!$this->view->preview_favicon) { $this->view->preview_favicon = $image_model->resize($this->view->no_image, 100, 100); } // $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); //////////////////////////////////////// PAGES //////////////////////////////////////// if (isset($pages['about_menu'])) { $this->view->about_menu = $pages['about_menu']; } elseif (isset($store_config['about_menu'])) { $this->view->about_menu = $store_config['about_menu']; } else { $this->view->about_menu = array(); } if (isset($pages['page_login_trouble'])) { $this->view->page_login_trouble = $pages['page_login_trouble']; } elseif (isset($store_config['page_login_trouble'])) { $this->view->page_login_trouble = $store_config['page_login_trouble']; } else { $this->view->page_login_trouble = 0; } if (isset($pages['page_terms'])) { $this->view->page_terms = $pages['page_terms']; } elseif (isset($store_config['page_terms'])) { $this->view->page_terms = $store_config['page_terms']; } else { $this->view->page_terms = 0; } if (isset($pages['page_contact'])) { $this->view->page_contact = $pages['page_contact']; } elseif (isset($store_config['page_contact'])) { $this->view->page_contact = $store_config['page_contact']; } else { $this->view->page_contact = 0; } if (isset($pages['page_goodies'])) { $this->view->page_goodies = $pages['page_goodies']; } elseif (isset($store_config['page_goodies'])) { $this->view->page_goodies = $store_config['page_goodies']; } else { $this->view->page_goodies = 0; } if (isset($pages['delete_account'])) { $this->view->delete_account = $pages['delete_account']; } elseif (isset($store_config['delete_account'])) { $this->view->delete_account = $store_config['delete_account']; } else { $this->view->delete_account = 0; } if (isset($pages['support_page'])) { $this->view->support_page = $pages['support_page']; } elseif (isset($store_config['support_page'])) { $this->view->support_page = $store_config['support_page']; } else { $this->view->support_page = 0; } if (isset($pages['page_pinmarklet'])) { $this->view->page_pinmarklet = $pages['page_pinmarklet']; } elseif (isset($store_config['page_pinmarklet'])) { $this->view->page_pinmarklet = $store_config['page_pinmarklet']; } else { $this->view->page_pinmarklet = 0; } if (isset($pages['page_privacy_policy'])) { $this->view->page_privacy_policy = $pages['page_privacy_policy']; } elseif (isset($store_config['page_privacy_policy'])) { $this->view->page_privacy_policy = $store_config['page_privacy_policy']; } else { $this->view->page_privacy_policy = 0; } if (isset($pages['page_private_boards'])) { $this->view->page_private_boards = $pages['page_private_boards']; } elseif (isset($store_config['page_private_boards'])) { $this->view->page_private_boards = $store_config['page_private_boards']; } else { $this->view->page_private_boards = 0; } //////////////////////////////////////// DATES //////////////////////////////////////// $this->view->short_dates = array('dd.mm.yy', 'yy-mm-dd'); $this->view->medium_dates = array('dd M yy', 'D, d M y', 'DD, dd-M-y', 'D, d M yy'); $this->view->long_dates = array('dd MM yy', 'D, d MM y', 'DD, dd-MM-y', 'D, d MM yy'); $this->view->long_dates_times = array('dd MM yy H:i:s', 'D, d MM y H:i:s', 'DD, dd-MM-y H:i:s', 'D, d MM yy H:i:s'); $this->view->news_dates = array('dd M yy', 'D, d M y', 'DD, dd-M-y', 'D, d M yy', 'dd MM yy', 'D, d MM y', 'DD, dd-MM-y', 'D, d MM yy', 'dd MM yy | H:i', 'D, d MM y | H:i', 'DD, dd-MM-y | H:i', 'D, d MM yy | H:i', 'dd MM yy | H:i:s', 'D, d MM y | H:i:s', 'DD, dd-MM-y | H:i:s', 'D, d MM yy | H:i:s'); if (isset($config['config_date_format_short'])) { $this->view->config_date_format_short = $config['config_date_format_short']; } elseif (isset($store_config['config_date_format_short'])) { $this->view->config_date_format_short = $store_config['config_date_format_short']; } else { $this->view->config_date_format_short = 'dd.mm.yy'; } if (isset($config['config_date_format_medium'])) { $this->view->config_date_format_medium = $config['config_date_format_medium']; } elseif (isset($store_config['config_date_format_medium'])) { $this->view->config_date_format_medium = $store_config['config_date_format_medium']; } else { $this->view->config_date_format_medium = 'dd M yy'; } if (isset($config['config_date_format_long'])) { $this->view->config_date_format_long = $config['config_date_format_long']; } elseif (isset($store_config['config_date_format_long'])) { $this->view->config_date_format_long = $store_config['config_date_format_long']; } else { $this->view->config_date_format_long = 'dd MM yy'; } if (isset($config['config_date_format_news'])) { $this->view->config_date_format_news = $config['config_date_format_news']; } elseif (isset($store_config['config_date_format_news'])) { $this->view->config_date_format_news = $store_config['config_date_format_news']; } else { $this->view->config_date_format_news = 'dd MM yy | H:i'; } if (isset($config['config_date_format_long_time'])) { $this->view->config_date_format_long_time = $config['config_date_format_long_time']; } elseif (isset($store_config['config_date_format_long_time'])) { $this->view->config_date_format_long_time = $store_config['config_date_format_long_time']; } else { $this->view->config_date_format_long_time = 'dd MM yy H:i:s'; } //////////////////////////////////////// DATES //////////////////////////////////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_without_children' => true)); if ($categories) { foreach ($categories as $category) { $this->view->categories[] = $category; } } if (isset($config['config_board_description_enable'])) { $this->view->config_board_description_enable = $config['config_board_description_enable']; } elseif (isset($store_config['config_board_description_enable'])) { $this->view->config_board_description_enable = $store_config['config_board_description_enable']; } else { $this->view->config_board_description_enable = 0; } if (isset($config['config_private_boards'])) { $this->view->config_private_boards = $config['config_private_boards']; } elseif (isset($store_config['config_private_boards'])) { $this->view->config_private_boards = $store_config['config_private_boards']; } else { $this->view->config_private_boards = 0; } if (isset($config['default_category_id'])) { $this->view->default_category_id = $config['default_category_id']; } elseif (isset($store_config['default_category_id'])) { $this->view->default_category_id = $store_config['default_category_id']; } else { $this->view->default_category_id = 0; } if (isset($config['default_boards'])) { $this->view->default_boards = $config['default_boards']; } elseif (isset($store_config['default_boards'])) { $this->view->default_boards = $store_config['default_boards']; } else { $this->view->default_boards = array(); } }
public static function deleteUser($user_id) { $db = JO_Db::getDefaultAdapter(); $user_info = self::getUser($user_id); if (!$user_info) { return; } if ($user_info['store'] == 's3') { self::deleteImagesAmazon($user_info['avatar']); } else { if ($user_info['avatar']) { $model_image = new Helper_Images(); $model_image->deleteImages($user_info['avatar']); } } $query = $db->select()->from('boards')->where('user_id = ?', (string) $user_id); $rows = $db->fetchAll($query); if ($rows) { foreach ($rows as $row) { Model_Boards::delete($row['board_id']); } } $db->query("DELETE FROM url_alias WHERE query = 'user_id=" . (string) $user_id . "'"); $db->delete('users_boards', array('user_id = ?' => (string) $user_id)); $db->delete('shared_content', array('user_id = ?' => (string) $user_id)); $db->delete('users_following', array('user_id = ?' => (string) $user_id)); $db->delete('users_following', array('following_id = ?' => (string) $user_id)); $db->delete('users_following_ignore', array('user_id = ?' => (string) $user_id)); $db->delete('users_following_ignore', array('following_id = ?' => (string) $user_id)); $db->delete('users_following_user', array('user_id = ?' => (string) $user_id)); $db->delete('users_following_user', array('following_id = ?' => (string) $user_id)); $db->delete('users_history', array('from_user_id = ?' => (string) $user_id)); $db->delete('users_history', array('to_user_id = ?' => (string) $user_id)); $db->delete('users_agenda', array('user_id = ?' => (string) $user_id)); $db->delete('users_activate', array('user_id = ?' => (string) $user_id)); $db->delete('users_location', array('user_id = ?' => (string) $user_id)); $db->delete('users_sports', array('user_id = ?' => (string) $user_id)); $db->delete('users_messages', array('from_user_id = ?' => (string) $user_id)); $db->delete('users_messages', array('to_user_id = ?' => (string) $user_id)); $db->delete('users_mails', array('from_user_id = ?' => (string) $user_id)); $db->delete('users_mails_to', array('user_id = ?' => (string) $user_id)); $db->delete('users_likes', array('user_id = ?' => (string) $user_id)); $db->delete('users', array('user_id = ?' => (string) $user_id)); }
public function rightsideAction() { $request = $this->getRequest(); $model_images = new Helper_Images(); if ($request->getRequest('item_id')) { $itemID = $request->getRequest('item_id'); } elseif ($request->getRequest('comments')) { $itemID = $request->getRequest('comments'); } else { $itemID = $request->getRequest('faq'); } $item = Model_Items::get($itemID); $user = Model_Users::getUser($item['user_id']); if ($user['avatar']) { $user['avatar'] = $model_images->resize($user['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $user['avatar'] = 'data/themes/images/noavatar.png'; } if (JO_Session::get('user_id')) { if ($item['user_id'] != JO_Session::get('user_id')) { if (Model_Orders::isBuyed($item['id'], JO_Session::get('user_id'))) { $item['is_buyed'] = $this->translate('You have already bought this item. You can download it from <a href="#">here</a>, but if you like you can buy it again.'); $replace = WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads'); $item['is_buyed'] = str_replace('#', $replace, $item['is_buyed']); } } else { $item['is_buyed'] = $this->translate('This is one of your files'); } } if (JO_Session::get('user_id') && JO_Session::get('user_id') == $item['user_id']) { $this->view->owner = true; } $item['price'] = WM_Currency::format($item['price']); if ($item['extended_price']) { $item['extended_price'] = WM_Currency::format($item['extended_price']); } $item['datetime'] = JO_Date::getInstance($item['datetime'], 'd M yy')->getDate(); $this->view->attributes = Model_Items::getAttributes($item['id']); $this->view->attributes_pic = array(); if ($this->view->attributes) { foreach ($this->view->attributes as $k => $v) { if ($v['search'] == 'true') { $this->view->attributes[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?module=' . $item['module'] . '&controller=search&action=attributes/' . urlencode(mb_strtolower($v['category'], 'UTF-8')) . '/' . urlencode(mb_strtolower($v['name'], 'UTF-8'))); } if (!empty($v['photo'])) { $this->view->attributes[$k]['photo'] = 'uploads/attributes/' . $v['photo']; $this->view->attributes_pic[] = $this->view->attributes[$k]; } if (empty($v['name'])) { $this->view->attributes[$k]['name'] = $v['attribute_id']; } } } $user['homeimage'] = $model_images->resize($user['homeimage'], JO_Registry::forceGet('user_profile_photo_width'), JO_Registry::forceGet('user_profile_photo_height'), true); $user['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'username'])); $comments = Model_Comments::getTotal("item_id=" . $item['id'] . ' AND reply_to = 0'); $item['comments'] = (int) $comments; $this->view->user_badges = Helper_Author::userBadges($user); if ($item['prepaid_price'] == '0.00') { $this->view->prepaid_price = false; } else { $this->view->prepaid_price = WM_Currency::format($item['prepaid_price']); } #COLLECTIONS $this->view->bookmark_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=add_to_collection'); $this->view->upload_link = WM_Router::create($request->getBaseUrl() . '?controller=collections&action=upload'); $this->view->base_url = urlencode($request->getBaseUrl()); $this->view->full_url = urlencode($request->getFullUrl()); if (JO_Session::get('user_id')) { $this->view->bookcollections = Model_Collections::getByUser(0, 0, JO_Session::get('user_id')); } $this->view->tags = array(); if (isset($item['tags'])) { foreach ($item['tags'] as $key => $tag) { if ($tag) { $this->view->tags[] = array('name' => $tag, 'href' => WM_Router::create($request->getBaseUrl() . '?controller=tags&tag=' . $tag)); } } } if ($request->getAction() != 'comments') { $this->view->comment_link = WM_Router::create($request->getBaseUrl() . '?controller=items&action=comments&item_id=' . $item['id'] . '&name=' . WM_Router::clearName($item['name'])); } if ($request->getAction() == 'index') { $this->view->is_index = true; } $this->view->free_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=downloads&item_id=' . $item['id']); $this->view->login_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login'); $user['license'] = unserialize($user['license']); $this->view->user = $user; $this->view->item = $item; }
public static function getEventImage($user, $prefix = null) { $sizes = self::userThumbSizes(); $format_size = false; if ($sizes) { foreach ($sizes as $val => $key) { if ($key == $prefix) { $format_size = $val; break; } } } if (!$format_size) { return false; } $model_images = new Helper_Images(); $sizes = explode('x', $format_size); $width = (int) isset($sizes[0]) ? $sizes[0] : 0; $height = (int) isset($sizes[1]) ? $sizes[1] : 0; if ($width && $height) { $img = $model_images->resize($user['avatar'], $width, $height, true); } else { if ($width && !$height) { $img = $model_images->resizeWidth($user['avatar'], $width); } else { if ($height && !$width) { $img = $model_images->resizeHeight($user['avatar'], $height); } } } if ($img) { return array('image' => $img, 'original' => $model_images->original($user['avatar']), 'width' => $model_images->getSizes('width'), 'height' => $model_images->getSizes('height'), 'mime' => JO_File_Ext::getMimeFromFile($img)); } return false; }
public function secondAction() { $request = $this->getRequest(); $this->view->total_following = Model_Boards_Follow::totalBoardFollow(JO_Session::get('user[user_id]')); if ($this->view->total_following < 5) { $this->redirect(WM_Router::create($request->getBaseUrl() . '?controller=welcome')); } //////////// Categories //////////// $this->view->categories = array(); /* v2.2 */ $config_enable_follow_private_profile = ''; if (Helper_Config::get('config_enable_follow_private_profile')) { $config_enable_follow_private_profile = ' AND user_id IN (SELECT user_id FROM users WHERE public = 1)'; } /* v2.2 */ $categories = Model_Categories::getCategories(array('filter_status' => 1, 'where' => new JO_Db_Expr('category.category_id IN (SELECT category_id FROM boards WHERE category_id = category.category_id AND pins > 0 ' . $config_enable_follow_private_profile . ')'))); $model_images = new Helper_Images(); foreach ($categories as $category) { if ($category['image']) { $category['thumb'] = $model_images->resize($category['image'], 113, 113, true); } else { $category['thumb'] = $model_images->resize(Helper_Config::get('no_image'), 113, 113); } $this->view->categories[] = $category; } $this->view->load_boards = WM_Router::create($this->getRequest()->getBaseUrl() . '?controller=welcome&action=boardsideas'); $this->view->next_step = WM_Router::create($request->getBaseUrl() . '?controller=welcome&action=third'); $this->view->createBoard = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=createboardwithoutcategory'); $this->view->createBoardWithCat = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=create'); //call header and footer childrens $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); }
public static function delete($event_id) { $db = JO_Db::getDefaultAdapter(); $event_info = self::getEvent($event_id); if (!$event_info) { return false; } if ($event_info['store'] == 's3') { self::deleteImagesAmazon($event_info['image']); } else { $model_image = new Helper_Images(); $model_image->deleteImages($event_info['image']); } $comments = Model_Events::getComments(array('filter_event_id' => $event_id)); if ($comments) { foreach ($comments as $comment) { $db->delete('events_comments', array('comment_id = ?' => $comment['comment_id'])); $db->delete('events_reports_comments', array('comment_id = ?' => $comment['comment_id'])); } } $del = $db->delete('events', array('event_id = ?' => $event_id)); if (!$del) { return false; } else { $db->delete('events_likes', array('event_id = ?' => $event_id)); $db->delete('events_reports', array('event_id = ?' => $event_id)); $db->delete('events_following', array('event_id = ?' => $event_id)); $db->delete('users_history', array('pin_id = ?' => $event_id)); self::deleteCache($event_info); return true; } }
public function paymentAction() { $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->title = $this->translate('Deposit pre-paid cash'); if ($request->isPost()) { if ($request->issetPost('amount')) { $amount = $request->getPost('amount'); $image_model = new Helper_Images(); $files = glob(dirname(__FILE__) . '/Payments/*.php'); if ($files) { foreach ($files as $file) { if (preg_match('/^([\\w]{1,})Controller$/i', basename($file, '.php'), $match)) { $key = mb_strtolower($match[1], 'utf-8'); if ($request->issetPost($key)) { $depositID = Model_Deposit::addDeposit($amount); if ($depositID) { JO_Session::set('deposit_id', $depositID); if (JO_Registry::forceGet($key . '_status')) { JO_Loader::loadFile($file); $form = $this->view->callChildren('payments_' . $key . '/depositForm'); if ($form) { $logo = JO_Registry::forceGet($key . '_logo'); if ($logo) { list($width) = getimagesize('uploads/' . $logo); if ($width > 300) { $logo = $image_model->resizeWidth($logo, 300); } else { $logo = 'uploads/' . $logo; } } else { $logo = ''; } $this->view->payment = array('key' => $key, 'edit' => $request->getModule() . '/payments_' . $key, 'name' => $this->translate($match[1]), 'logo' => $logo, 'description' => $this->view->callChildren('payments_' . $key . '/description'), 'form' => $form); break; } } } } } } } } } $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('Deposit'))); $this->view->total = WM_Currency::format(JO_Session::get('total')); $this->view->children = array(); $this->view->children['header_part'] = 'layout/header_part'; $this->view->children['footer_part'] = 'layout/footer_part'; }
public function deleteAction() { $json = array(); $pathp = $this->getRequest()->getPost('path'); if ($pathp !== null) { $path = rtrim($this->upload_folder . str_replace('../', '', $pathp), '/'); if (!file_exists($path)) { $json['error'] = $this->translate('Path not found'); } if (rtrim($path, '/') == rtrim($this->upload_folder, '/')) { $json['error'] = $this->translate('You can not delete the base path'); } } else { $json['error'] = $this->translate('No path is selected'); } if (!isset($json['error'])) { if (is_file($path)) { $images = new Helper_Images(); $images->deleteImages($pathp); } elseif (is_dir($path)) { $this->recursiveDelete($path); $cache_folder = $this->upload_folder . DS . 'cache' . $pathp; $this->recursiveDelete($cache_folder); } $json['success'] = $this->translate('Deletion is successful'); } $response = $this->getResponse(); $response->addHeader('Cache-Control: no-cache, must-revalidate'); $response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); $response->addHeader('Content-type: application/json'); $this->setInvokeArg('noViewRenderer', true); echo JO_Json::encode($json); }
public function getForm() { $request = $this->getRequest(); $this->view->templates = $this->getTemplates(array('mobile')); $config = $request->getPost('config'); $images = $request->getPost('images'); $pages = $request->getPost('pages'); $store_config = Model_Settings::getSettingsPairs(); $this->view->pages = Model_Pages::getPagesFromParent(0); $this->view->pages_about = array(); $this->view->pages_about[] = array('title' => $this->translate('SEPARATOR MENU'), 'page_id' => -1); if ($this->view->pages) { foreach ($this->view->pages as $p) { $this->view->pages_about[] = array('title' => $p['title'], 'page_id' => $p['page_id']); } } $this->view->currencies = Model_Currency::getCurrencies(); $this->view->app_path = BASE_PATH; //////////////////////////////////////// OAUTH //////////////////////////////////////// //facebook if (isset($config['oauth_fb_key'])) { $this->view->oauth_fb_key = $config['oauth_fb_key']; } elseif (isset($store_config['oauth_fb_key'])) { $this->view->oauth_fb_key = $store_config['oauth_fb_key']; } if (isset($config['oauth_fb_secret'])) { $this->view->oauth_fb_secret = $config['oauth_fb_secret']; } elseif (isset($store_config['oauth_fb_secret'])) { $this->view->oauth_fb_secret = $store_config['oauth_fb_secret']; } if (isset($config['og_namespace'])) { $this->view->og_namespace = $config['og_namespace']; } elseif (isset($store_config['og_namespace'])) { $this->view->og_namespace = $store_config['og_namespace']; } if (isset($config['og_recipe'])) { $this->view->og_recipe = $config['og_recipe']; } elseif (isset($store_config['og_recipe'])) { $this->view->og_recipe = $store_config['og_recipe']; } //twitter if (isset($config['oauth_tw_key'])) { $this->view->oauth_tw_key = $config['oauth_tw_key']; } elseif (isset($store_config['oauth_tw_key'])) { $this->view->oauth_tw_key = $store_config['oauth_tw_key']; } if (isset($config['oauth_tw_secret'])) { $this->view->oauth_tw_secret = $config['oauth_tw_secret']; } elseif (isset($store_config['oauth_tw_secret'])) { $this->view->oauth_tw_secret = $store_config['oauth_tw_secret']; } ///instagram if (isset($config['oauth_in_key'])) { $this->view->oauth_in_key = $config['oauth_in_key']; } elseif (isset($store_config['oauth_in_key'])) { $this->view->oauth_in_key = $store_config['oauth_in_key']; } if (isset($config['oauth_in_secret'])) { $this->view->oauth_in_secret = $config['oauth_in_secret']; } elseif (isset($store_config['oauth_in_secret'])) { $this->view->oauth_in_secret = $store_config['oauth_in_secret']; } //////////////////////////////////////// GENERAL //////////////////////////////////////// if (isset($config['config_base_domain'])) { $this->view->config_base_domain = $config['config_base_domain']; } elseif (isset($store_config['config_base_domain'])) { $this->view->config_base_domain = $store_config['config_base_domain']; } else { $this->view->config_base_domain = $request->getBaseUrl(); } if (isset($config['config_on_facebook'])) { $this->view->config_on_facebook = $config['config_on_facebook']; } elseif (isset($store_config['config_on_facebook'])) { $this->view->config_on_facebook = $store_config['config_on_facebook']; } else { $this->view->config_on_facebook = ''; } if (isset($config['google_analytics'])) { $this->view->google_analytics = $config['google_analytics']; } elseif (isset($store_config['google_analytics'])) { $this->view->google_analytics = $store_config['google_analytics']; } if (isset($config['config_fix_image_thumb_editor'])) { $this->view->config_fix_image_thumb_editor = $config['config_fix_image_thumb_editor']; } elseif (isset($store_config['config_fix_image_thumb_editor'])) { $this->view->config_fix_image_thumb_editor = $store_config['config_fix_image_thumb_editor']; } if (isset($config['config_fix_external_urls'])) { $this->view->config_fix_external_urls = $config['config_fix_external_urls']; } elseif (isset($store_config['config_fix_external_urls'])) { $this->view->config_fix_external_urls = $store_config['config_fix_external_urls']; } //////////////////////////////////////// SEO //////////////////////////////////////// if (isset($config['site_name'])) { $this->view->site_name = $config['site_name']; } elseif (isset($store_config['site_name'])) { $this->view->site_name = $store_config['site_name']; } if (isset($config['meta_title'])) { $this->view->meta_title = $config['meta_title']; } elseif (isset($store_config['meta_title'])) { $this->view->meta_title = $store_config['meta_title']; } if (isset($config['meta_keywords'])) { $this->view->meta_keywords = $config['meta_keywords']; } elseif (isset($store_config['meta_keywords'])) { $this->view->meta_keywords = $store_config['meta_keywords']; } if (isset($config['meta_description'])) { $this->view->meta_description = $config['meta_description']; } elseif (isset($store_config['meta_description'])) { $this->view->meta_description = $store_config['meta_description']; } //////////////////////////////////////// Options //////////////////////////////////////// if (isset($config['config_admin_limit'])) { $this->view->config_admin_limit = $config['config_admin_limit']; } elseif (isset($store_config['config_admin_limit'])) { $this->view->config_admin_limit = $store_config['config_admin_limit']; } else { $this->view->config_admin_limit = 15; } if (isset($config['config_front_limit'])) { $this->view->config_front_limit = $config['config_front_limit']; } elseif (isset($store_config['config_front_limit'])) { $this->view->config_front_limit = $store_config['config_front_limit']; } else { $this->view->config_front_limit = 10; } if (isset($config['template'])) { $this->view->template = $config['template']; } elseif (isset($store_config['template'])) { $this->view->template = $store_config['template']; } if (isset($config['config_maintenance'])) { $this->view->config_maintenance = $config['config_maintenance']; } elseif (isset($store_config['config_maintenance'])) { $this->view->config_maintenance = $store_config['config_maintenance']; } else { $this->view->config_maintenance = 0; } if (isset($config['config_hide_brand'])) { $this->view->config_hide_brand = $config['config_hide_brand']; } elseif (isset($store_config['config_hide_brand'])) { $this->view->config_hide_brand = $store_config['config_hide_brand']; } else { $this->view->config_hide_brand = 0; } $this->view->data_timezones = JO_Date_Timezones::getTimezonse(); if (isset($config['phpSettings']['date.timezone'])) { $this->view->date_timezone = $config['phpSettings']['date.timezone']; } elseif (isset($store_config['phpSettings']['date.timezone'])) { $this->view->date_timezone = $store_config['phpSettings']['date.timezone']; } else { $this->view->date_timezone = 'UTC'; } /////////////////////////////// CURRENCY /////////////////////// $this->view->currencies = array(); $currencies = Model_Currency::getCurrencies(array('status' => 1)); //WM_Currency::getCurrencies(); if ($currencies) { $this->view->currencies = $currencies; } if (isset($config['config_currency'])) { $this->view->config_currency = $config['config_currency']; } elseif (isset($store_config['config_currency'])) { $this->view->config_currency = $store_config['config_currency']; } if (isset($config['config_currency_auto_update'])) { $this->view->config_currency_auto_update = $config['config_currency_auto_update']; } elseif (isset($store_config['config_currency_auto_update'])) { $this->view->config_currency_auto_update = $store_config['config_currency_auto_update']; } else { $this->view->config_currency_auto_update = 1; } if (isset($config['config_cache_live'])) { $this->view->config_cache_live = $config['config_cache_live']; } elseif (isset($store_config['config_cache_live'])) { $this->view->config_cache_live = $store_config['config_cache_live']; } else { $this->view->config_cache_live = 0; } if (isset($config['enable_free_registration'])) { $this->view->enable_free_registration = $config['enable_free_registration']; } elseif (isset($store_config['enable_free_registration'])) { $this->view->enable_free_registration = $store_config['enable_free_registration']; } else { $this->view->enable_free_registration = 0; } //////////////////////////////////////// Contacts //////////////////////////////////////// if (isset($config['admin_mail'])) { $this->view->admin_mail = $config['admin_mail']; } elseif (isset($store_config['admin_mail'])) { $this->view->admin_mail = $store_config['admin_mail']; } if (isset($config['report_mail'])) { $this->view->report_mail = $config['report_mail']; } elseif (isset($store_config['report_mail'])) { $this->view->report_mail = $store_config['report_mail']; } if (isset($config['noreply_mail'])) { $this->view->noreply_mail = $config['noreply_mail']; } elseif (isset($store_config['noreply_mail'])) { $this->view->noreply_mail = $store_config['noreply_mail']; } if (isset($config['mail_smtp'])) { $this->view->mail_smtp = $config['mail_smtp']; } elseif (isset($store_config['mail_smtp'])) { $this->view->mail_smtp = $store_config['mail_smtp']; } else { $this->view->mail_smtp = 0; } if (isset($config['mail_smtp_host'])) { $this->view->mail_smtp_host = $config['mail_smtp_host']; } elseif (isset($store_config['mail_smtp_host'])) { $this->view->mail_smtp_host = $store_config['mail_smtp_host']; } if (isset($config['mail_smtp_port'])) { $this->view->mail_smtp_port = $config['mail_smtp_port']; } elseif (isset($store_config['mail_smtp_port'])) { $this->view->mail_smtp_port = $store_config['mail_smtp_port']; } if (isset($config['mail_smtp_user'])) { $this->view->mail_smtp_user = $config['mail_smtp_user']; } elseif (isset($store_config['mail_smtp_user'])) { $this->view->mail_smtp_user = $store_config['mail_smtp_user']; } if (isset($config['mail_smtp_password'])) { $this->view->mail_smtp_password = $config['mail_smtp_password']; } elseif (isset($store_config['mail_smtp_password'])) { $this->view->mail_smtp_password = $store_config['mail_smtp_password']; } if (isset($config['mail_footer'])) { $this->view->mail_footer = $config['mail_footer']; } elseif (isset($store_config['mail_footer'])) { $this->view->mail_footer = $store_config['mail_footer']; } if (isset($config['not_rp'])) { $this->view->not_rp = $config['not_rp']; } elseif (isset($store_config['not_rp'])) { $this->view->not_rp = $store_config['not_rp']; } else { $this->view->not_rp = 0; } if (isset($config['not_rc'])) { $this->view->not_rc = $config['not_rc']; } elseif (isset($store_config['not_rc'])) { $this->view->not_rc = $store_config['not_rc']; } else { $this->view->not_rc = 0; } if (isset($config['not_ri'])) { $this->view->not_ri = $config['not_ri']; } elseif (isset($store_config['not_ri'])) { $this->view->not_ri = $store_config['not_ri']; } else { $this->view->not_ri = 0; } //////////////////////////////////////// AMAZON //////////////////////////////////////// $uploads_methods = $this->uploadsMethods(); $this->view->uploads_methods = array(); foreach ($uploads_methods as $method) { $this->view->uploads_methods[] = $this->view->callChildren('upload_' . $method); } //////////////////////////////////////// Images //////////////////////////////////////// /////// logo $image_model = new Helper_Images(); if (isset($images['site_logo']) && $images['site_logo']) { $this->view->site_logo = $images['site_logo']; } elseif (isset($store_config['site_logo']) && $store_config['site_logo']) { $this->view->site_logo = $store_config['site_logo']; } else { $this->view->site_logo = ''; } if ($this->view->site_logo) { $this->view->preview_logo = $image_model->resize($this->view->site_logo, 100, 100); } else { $this->view->preview_logo = $image_model->resize('/logo.png', 100, 100); } if (!$this->view->preview_logo) { $this->view->preview_logo = $image_model->resize('/logo.png', 100, 100); } $this->view->preview = $image_model->resize('/logo.png', 100, 100); ////mobile logo if (isset($images['site_logo_mobile']) && $images['site_logo_mobile']) { $this->view->site_logo_mobile = $images['site_logo_mobile']; } elseif (isset($store_config['site_logo_mobile']) && $store_config['site_logo_mobile']) { $this->view->site_logo_mobile = $store_config['site_logo_mobile']; } else { $this->view->site_logo_mobile = ''; } if ($this->view->site_logo_mobile) { $this->view->preview_logo_mobile = $image_model->resize($this->view->site_logo_mobile, 100, 100); } else { $this->view->preview_logo_mobile = $image_model->resize('/logo.png', 100, 100); } if (!$this->view->preview_logo_mobile) { $this->view->preview_logo_mobile = $image_model->resize('/logo.png', 100, 100); } $this->view->preview_mobile = $image_model->resize('/logo.png', 100, 100); ////// no image if (isset($images['no_image']) && $images['no_image']) { $this->view->no_image = $images['no_image']; } elseif (isset($store_config['no_image']) && $store_config['no_image']) { $this->view->no_image = $store_config['no_image']; } else { $this->view->no_image = '/no_image.png'; } if ($this->view->no_image) { $this->view->preview_no_image = $image_model->resize($this->view->no_image, 100, 100); } else { $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); } if (!$this->view->preview_no_image) { $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); } ////// no avatar if (isset($images['no_avatar']) && $images['no_avatar']) { $this->view->no_avatar = $images['no_avatar']; } elseif (isset($store_config['no_avatar']) && $store_config['no_avatar']) { $this->view->no_avatar = $store_config['no_avatar']; } else { $this->view->no_avatar = '/no-avatar.png'; } if ($this->view->no_avatar) { $this->view->preview_no_avatar = $image_model->resize($this->view->no_avatar, 100, 100); } else { $this->view->preview_no_avatar = $image_model->resize('/no-avatar.png', 100, 100); } if (!$this->view->preview_no_avatar) { $this->view->preview_no_avatar = $image_model->resize('/no_image.png', 100, 100); } ////// favicon if (isset($images['favicon']) && $images['favicon']) { $this->view->favicon = $images['favicon']; } elseif (isset($store_config['favicon']) && $store_config['favicon']) { $this->view->favicon = $store_config['favicon']; } else { $this->view->favicon = ''; } if ($this->view->favicon) { $this->view->preview_favicon = $image_model->resize($this->view->favicon, 100, 100); } else { $this->view->preview_favicon = $image_model->resize($this->view->no_image, 100, 100); } if (!$this->view->preview_favicon) { $this->view->preview_favicon = $image_model->resize($this->view->no_image, 100, 100); } // $this->view->preview_no_image = $image_model->resize('/no_image.png', 100, 100); //////////////////////////////////////// PAGES //////////////////////////////////////// if (isset($pages['about_menu'])) { $this->view->about_menu = $pages['about_menu']; } elseif (isset($store_config['about_menu'])) { $this->view->about_menu = $store_config['about_menu']; } else { $this->view->about_menu = array(); } if (isset($pages['page_login_trouble'])) { $this->view->page_login_trouble = $pages['page_login_trouble']; } elseif (isset($store_config['page_login_trouble'])) { $this->view->page_login_trouble = $store_config['page_login_trouble']; } else { $this->view->page_login_trouble = 0; } if (isset($pages['page_terms'])) { $this->view->page_terms = $pages['page_terms']; } elseif (isset($store_config['page_terms'])) { $this->view->page_terms = $store_config['page_terms']; } else { $this->view->page_terms = 0; } if (isset($pages['page_contact'])) { $this->view->page_contact = $pages['page_contact']; } elseif (isset($store_config['page_contact'])) { $this->view->page_contact = $store_config['page_contact']; } else { $this->view->page_contact = 0; } if (isset($pages['page_goodies'])) { $this->view->page_goodies = $pages['page_goodies']; } elseif (isset($store_config['page_goodies'])) { $this->view->page_goodies = $store_config['page_goodies']; } else { $this->view->page_goodies = 0; } if (isset($pages['delete_account'])) { $this->view->delete_account = $pages['delete_account']; } elseif (isset($store_config['delete_account'])) { $this->view->delete_account = $store_config['delete_account']; } else { $this->view->delete_account = 0; } if (isset($pages['support_page'])) { $this->view->support_page = $pages['support_page']; } elseif (isset($store_config['support_page'])) { $this->view->support_page = $store_config['support_page']; } else { $this->view->support_page = 0; } if (isset($pages['page_pinmarklet'])) { $this->view->page_pinmarklet = $pages['page_pinmarklet']; } elseif (isset($store_config['page_pinmarklet'])) { $this->view->page_pinmarklet = $store_config['page_pinmarklet']; } else { $this->view->page_pinmarklet = 0; } if (isset($pages['page_privacy_policy'])) { $this->view->page_privacy_policy = $pages['page_privacy_policy']; } elseif (isset($store_config['page_privacy_policy'])) { $this->view->page_privacy_policy = $store_config['page_privacy_policy']; } else { $this->view->page_privacy_policy = 0; } //////////////////////////////////////// DATES //////////////////////////////////////// $this->view->short_dates = array('dd.mm.yy', 'yy-mm-dd'); $this->view->medium_dates = array('dd M yy', 'D, d M y', 'DD, dd-M-y', 'D, d M yy'); $this->view->long_dates = array('dd MM yy', 'D, d MM y', 'DD, dd-MM-y', 'D, d MM yy'); $this->view->long_dates_times = array('dd MM yy H:i:s', 'D, d MM y H:i:s', 'DD, dd-MM-y H:i:s', 'D, d MM yy H:i:s'); $this->view->news_dates = array('dd M yy', 'D, d M y', 'DD, dd-M-y', 'D, d M yy', 'dd MM yy', 'D, d MM y', 'DD, dd-MM-y', 'D, d MM yy', 'dd MM yy | H:i', 'D, d MM y | H:i', 'DD, dd-MM-y | H:i', 'D, d MM yy | H:i', 'dd MM yy | H:i:s', 'D, d MM y | H:i:s', 'DD, dd-MM-y | H:i:s', 'D, d MM yy | H:i:s'); if (isset($config['config_date_format_short'])) { $this->view->config_date_format_short = $config['config_date_format_short']; } elseif (isset($store_config['config_date_format_short'])) { $this->view->config_date_format_short = $store_config['config_date_format_short']; } else { $this->view->config_date_format_short = 'dd.mm.yy'; } if (isset($config['config_date_format_medium'])) { $this->view->config_date_format_medium = $config['config_date_format_medium']; } elseif (isset($store_config['config_date_format_medium'])) { $this->view->config_date_format_medium = $store_config['config_date_format_medium']; } else { $this->view->config_date_format_medium = 'dd M yy'; } if (isset($config['config_date_format_long'])) { $this->view->config_date_format_long = $config['config_date_format_long']; } elseif (isset($store_config['config_date_format_long'])) { $this->view->config_date_format_long = $store_config['config_date_format_long']; } else { $this->view->config_date_format_long = 'dd MM yy'; } if (isset($config['config_date_format_news'])) { $this->view->config_date_format_news = $config['config_date_format_news']; } elseif (isset($store_config['config_date_format_news'])) { $this->view->config_date_format_news = $store_config['config_date_format_news']; } else { $this->view->config_date_format_news = 'dd MM yy | H:i'; } if (isset($config['config_date_format_long_time'])) { $this->view->config_date_format_long_time = $config['config_date_format_long_time']; } elseif (isset($store_config['config_date_format_long_time'])) { $this->view->config_date_format_long_time = $store_config['config_date_format_long_time']; } else { $this->view->config_date_format_long_time = 'dd MM yy H:i:s'; } //////////////////////////////////////// DATES //////////////////////////////////////// $this->view->categories = array(); $categories = Model_Categories::getCategories(array('filter_without_children' => true)); if ($categories) { foreach ($categories as $category) { $this->view->categories[] = $category; } } if (isset($config['default_category_id'])) { $this->view->default_category_id = $config['default_category_id']; } elseif (isset($store_config['default_category_id'])) { $this->view->default_category_id = $store_config['default_category_id']; } else { $this->view->default_category_id = 0; } if (isset($config['default_boards'])) { $this->view->default_boards = $config['default_boards']; } elseif (isset($store_config['default_boards'])) { $this->view->default_boards = $store_config['default_boards']; } else { $this->view->default_boards = array(); } }
public function eventsHistoryAction() { $request = $this->getRequest(); $user_data = $this->profileHelp(); $this->setViewChange('profile'); $this->view->active = 'events'; $page = (int) $request->getRequest('page'); if ($page < 1) { $page = 1; } $this->view->boards = ''; $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'sort' => 'DESC', 'order' => 'history_id'); $history = Model_History::getHistory($data, 'from_user_id', $user_data['user_id']); if ($history) { $view = JO_View::getInstance(); $view->loged = JO_Session::get('user[user_id]'); $model_images = new Helper_Images(); foreach ($history as $key => $data) { $data['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $data['to_user_id']); $event = Model_Events::getEventSolo($data['pin_id']); $avatar = Helper_Uploadimages::event($event, '_B'); $data['thumb'] = $avatar['image']; $data['thumb_width'] = $avatar['width']; $data['thumb_height'] = $avatar['height']; if (!@getimagesize($data['thumb'])) { $data['thumb'] = $model_images->resize(JO_Registry::get('no_avatar'), 180, 180); $data['thumb_width'] = $model_images->getSizes('width'); $data['thumb_height'] = $model_images->getSizes('height'); } $view->history = $data; if ($data['history_action'] == Model_History::FOLLOW_EVENT) { $view->history['eventIsFollow'] = Model_Events::isFollowEvent("", $view->history['to_user_id']); $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&event_id=' . $view->history['pin_id'] . '&userio_id=' . $view->history['to_user_id']); $view->history['fullname'] = $data['user']['fullname']; $view->history['avatar'] = $avatar['image']; $this->view->boards .= $view->render('history/follow_event', 'users'); } elseif ($data['history_action'] == Model_History::UNFOLLOW_EVENT) { $view->history['eventIsFollow'] = Model_Events::isFollowEvent("", $view->history['to_user_id']); $view->history['follow_event'] = WM_Router::create($request->getBaseUrl() . '?controller=events&action=follow&event_id=' . $view->history['pin_id'] . '&userio_id=' . $view->history['to_user_id']); $view->history['fullname'] = $data['user']['fullname']; $view->history['avatar'] = $avatar['image']; $this->view->boards .= $view->render('history/unfollow_event', 'users'); } } } $agendas = Model_Users::getUserAgenda(array('filter_user_id' => $user_data['user_id'])); $this->view->has_agendas = false; $this->view->agendas_users = ""; if ($agendas) { $this->view->has_agendas = true; foreach ($agendas as $agenda) { $agenda['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopupDelete&agenda_id=' . $agenda['agenda_id'] . '&user_id=' . $user_data['user_id']); $this->view->agenda = $agenda; $this->view->agendas_users .= $this->view->render('agenda', 'users'); } } $session_user = JO_Session::get('user[user_id]'); $this->view->popup_agenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agendaPopup&user_id=' . $user_data['user_id']); //no mover de esta ubicación $messages = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => 0)); $this->view->has_messages = false; $this->view->messages_users = ""; if ($messages) { $this->view->has_messages = true; foreach ($messages as $message) { $avatar = Helper_Uploadimages::avatar($message, '_A'); $message['avatar'] = $avatar['image']; $message['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $message['user_id']); $message['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $message['message_id'] . '&user_id=' . $user_data['user_id']); $message['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $message['message_id']); $this->view->message = $message; $this->view->messages_users .= $this->view->render('message', 'users'); //ahora vamos a consultar las respuestas a este: $messagesHijos = Model_Users::getUserMessages(array('start' => 0, 'limit' => 100, 'filter_user_id' => $user_data['user_id'], 'idPadre' => $message['message_id'])); if ($messagesHijos) { foreach ($messagesHijos as $messageHijo) { $avatar = Helper_Uploadimages::avatar($messageHijo, '_A'); $messageHijo['avatar'] = $avatar['image']; $messageHijo['href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $messageHijo['user_id']); $messageHijo['hrefDelete'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopupDelete&message_id=' . $messageHijo['message_id'] . '&user_id=' . $user_data['user_id']); $messageHijo['hrefResponder'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=' . $messageHijo['message_id']); $this->view->message = $messageHijo; $this->view->messages_users .= $this->view->render('message', 'users'); } } } } $session_user = JO_Session::get('user[user_id]'); $this->view->popup_messages = WM_Router::create($request->getBaseUrl() . '?controller=users&action=messagePopup&user_from=' . $session_user . '&user_to=' . $user_data['user_id'] . '&board_user='******'user_id'] . '&message_from_id=0'); //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activatePopup'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0' ); //$this->view->popup_activate = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=activateDetail'); //&user_from=' . $session_user . '&user_to=' . $user_data['user_id'].'&board_user='******'user_id'] .'&message_from_id=0' ); $_SESSION["activate_url"] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . JO_Session::get('user[user_id]')); $this->view->popup_activate = WM_Router::create($request->getBaseUrl() . '?controller=users&action=activate'); $this->view->search_url = WM_Router::create($request->getBaseUrl() . '?controller=search&action=advanced?id=activate'); //$this->view->deportes = WM_Router::create( $request->getBaseUrl() . '?controller=users&action=deportes'); $this->view->addMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=create'); $this->view->stateMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=state'); $this->view->viewMail = WM_Router::create($request->getBaseUrl() . '?controller=mails&action=view'); $activate = Model_Users::getActivateUser(JO_Session::get('user[user_id]')); if ($activate) { $this->view->userIsActivate = $activate["activate"]; } if ($user_data['type_user']) { $this->view->userCanActivate = Model_Users::getUserTypeNotOthers($user_data['type_user']); } if (JO_Registry::get('isMobile')) { $this->view->urlagenda = WM_Router::create($request->getBaseUrl() . '?controller=users&action=agenda&user_id=' . $user_data['user_id']); $this->view->urlmensajes = WM_Router::create($request->getBaseUrl() . '?controller=users&action=mensajes&user_id=' . $user_data['user_id']); } if ($request->isXmlHttpRequest()) { echo $this->view->boards; $this->noViewRenderer(true); } else { $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part'); } }
public static function delete($pin_id) { $db = JO_Db::getDefaultAdapter(); $pin_info = self::getPin($pin_id); if (!$pin_info) { return false; } if ($pin_info['store'] == 's3') { self::deleteImagesAmazon($pin_info['image']); } else { $model_image = new Helper_Images(); $model_image->deleteImages($pin_info['image']); } $comments = Model_Comments::getComments(array('filter_pin_id' => $pin_id)); if ($comments) { foreach ($comments as $comment) { $db->delete('pins_comments', array('comment_id = ?' => $comment['comment_id'])); $db->delete('pins_reports_comments', array('comment_id = ?' => $comment['comment_id'])); } } $del = $db->delete('pins', array('pin_id = ?' => $pin_id)); if (!$del) { return false; } else { $latest_pins = array(); $pins_query = $db->select()->from('pins', array('pin_id', 'pin_id'))->where('user_id = ?', $pin_info['user_id'])->order('pin_id DESC')->limit(15); $latest = $db->fetchPairs($pins_query); if ($latest) { $latest_pins = $latest; } $update = array('pins' => new JO_Db_Expr('pins-1'), 'latest_pins' => implode(',', $latest_pins)); $update['likes'] = new JO_Db_Expr('likes-' . (int) $db->fetchOne($db->select()->from('pins_likes', 'COUNT(like_id)')->where('pin_id = ?', $pin_id))); $db->update('users', $update, array('user_id=?' => $pin_info['user_id'])); $latest_pins = array(); $pins_query = $db->select()->from('pins', array('pin_id', 'pin_id'))->where('board_id = ?', $pin_info['board_id'])->order('pin_id DESC')->limit(15); $latest = $db->fetchPairs($pins_query); if ($latest) { $latest_pins = $latest; } $update = array('pins' => new JO_Db_Expr('pins-1'), 'latest_pins' => implode(',', $latest_pins)); $update['latest_pins'] = implode(',', $latest_pins); $db->update('boards', $update, array('board_id=?' => $pin_info['board_id'])); $db->delete('pins_invert', array('pin_id = ?' => $pin_id)); $db->delete('pins_likes', array('pin_id = ?' => $pin_id)); $db->delete('pins_reports', array('pin_id = ?' => $pin_id)); $db->delete('pins_views', array('pin_id = ?' => $pin_id)); $db->delete('users_history', array('pin_id = ?' => $pin_id)); self::deleteCache($pin_info); return true; } }
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 static function getUserImage($user, $prefix = null) { if (!$user['avatar']) { $user['avatar'] = Helper_Config::get('no_avatar'); } $sizes = self::userThumbSizes(); $format_size = false; if ($sizes) { foreach ($sizes as $val => $key) { if ($key == $prefix) { $format_size = $val; break; } } } if (!$format_size) { return false; } $user['user_id'] = $user['user_id'] ? $user['user_id'] : -1; $image_stored = self::userAvatarExist($user['user_id'], $prefix); if ($image_stored) { return $image_stored; } $model_images = new Helper_Images(); $sizes = explode('x', $format_size); $width = (int) isset($sizes[0]) ? $sizes[0] : 0; $height = (int) isset($sizes[1]) ? $sizes[1] : 0; if ($width && $height) { $img = $model_images->resize($user['avatar'], $width, $height, true); } else { if ($width && !$height) { $img = $model_images->resizeWidth($user['avatar'], $width); } else { if ($height && !$width) { $img = $model_images->resizeHeight($user['avatar'], $height); } } } if ($img) { $data = array('image' => $img, 'original' => $model_images->original($user['avatar']), 'width' => $model_images->getSizes('width'), 'height' => $model_images->getSizes('height'), 'mime' => JO_File_Ext::getMimeFromFile($img), 'size' => $prefix, 'user_id' => $user['user_id']); self::userAvatarCreate($data); return $data; } return false; }
public function upload_imagesAction() { $request = $this->getRequest(); if (JO_Session::get('user[user_id]')) { $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 . '*.*'); $imageObject = new Helper_Images(); if ($files_delete) { for ($i = 0; $i < min(count($files_delete), 250); $i++) { if (filemtime($files_delete[$i]) + 86400 < time()) { $imageObject->deleteImages('/../' . $temporary . basename($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) { $files = JO_Session::get('gallery_upload_images'); if (!$files) { $files = array(); } $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) { $imageObject->resize('/../' . $temporary . $info['name'], 75, 75, true); $files[] = array('name' => $image['name'], 'tmp_name' => $info['name'], 'path' => $temporary); JO_Session::set('gallery_upload_images', $files); $this->view->success = 1; } else { $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 deleteAction() { $request = $this->getRequest(); $collectionID = $request->getRequest('delete'); if (!$collectionID || !is_numeric($collectionID)) { return $this->forward('error', 'error404'); } $image = new Helper_Images(); $referer = $request->getServer('HTTP_REFERER'); if ($collectionID) { $collection = Model_Collections::get($collectionID); if (!$collection) { return $this->forward('error', 'error404'); } if (JO_Session::get('user_id') == $collection['user_id']) { $itemID = $request->getParam('item'); if ($itemID) { Model_Collections::deleteBookmark($collectionID, $itemID); JO_Session::set('msg_success', 'You have successfully delete this item!'); } else { Model_Collections::deleteCollection($collectionID); $image->deleteImages($collection['photo']); JO_Session::set('msg_success', 'You have successfully delete this collection!'); if (stripos($referer, 'view_collection') !== false) { $referer = WM_Router::create($request->getBaseUrl() . '?controller=users&action=collections&username='******'username')) . '/public/' . ($collection['public'] == 'true' ? 1 : 0)); } } } } $this->redirect($referer); }
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; }
private function getPageForm() { $request = $this->getRequest(); $page_id = $request->getQuery('id'); $pages_module = new Model_Pages(); if ($page_id) { $page_info = $pages_module->getPage($page_id); } $parent_id = (int) $request->getQuery('parent_id'); $parent_info = Model_Pages::getPage($parent_id); if ($parent_info) { $this->view->parent_title = $parent_info['title']; } $this->view->page_id = $page_id; $this->view->cancel_url = $request->getModule() . '/pages/' . ($parent_id ? '?parent_id=' . $parent_id : ''); if ($request->getPost('in_footer')) { $this->view->in_footer = $request->getPost('in_footer'); } elseif (isset($page_info)) { $this->view->in_footer = $page_info['in_footer']; } else { $this->view->in_footer = 0; } if ($request->getPost('status')) { $this->view->status = $request->getPost('status'); } elseif (isset($page_info)) { $this->view->status = $page_info['status']; } else { $this->view->status = 1; } if ($request->getPost('title')) { $this->view->title = $request->getPost('title'); } elseif (isset($page_info)) { $this->view->title = $page_info['title']; } if ($request->getPost('description')) { $this->view->description = $request->getPost('description'); } elseif (isset($page_info)) { $this->view->description = $page_info['description']; } if ($request->getPost('meta_title')) { $this->view->meta_title = $request->getPost('meta_title'); } elseif (isset($page_info)) { $this->view->meta_title = $page_info['meta_title']; } if ($request->getPost('meta_description')) { $this->view->meta_description = $request->getPost('meta_description'); } elseif (isset($page_info)) { $this->view->meta_description = $page_info['meta_description']; } if ($request->getPost('meta_keywords')) { $this->view->meta_keywords = $request->getPost('meta_keywords'); } elseif (isset($page_info)) { $this->view->meta_keywords = $page_info['meta_keywords']; } if ($request->getRequest('keyword')) { $this->view->keyword = $request->getRequest('keyword'); } elseif (isset($page_info)) { $this->view->keyword = $page_info['keyword']; } if (isset($page_info)) { $images = Model_Gallery::getGalleryImages($page_id, 'pages'); if ($images) { $model_images = new Helper_Images(); $this->view->images = array(); foreach ($images as $image) { $this->view->images[] = array('image_id' => $image['image_id'], 'image' => 'uploads' . $image['image'], 'thumb' => $model_images->resize($image['image'], 100, 100), 'title' => $image['title']); } } } else { $temporary_images = JO_Session::get('temporary_images'); if ($temporary_images) { $model_images = new Helper_Images(); $this->view->images = array(); foreach ($temporary_images as $key => $image) { $this->view->images[] = array('image_id' => $key, 'image' => 'uploads' . $image['image'], 'thumb' => $model_images->resize($image['image'], 100, 100), 'title' => isset($image[JO_Registry::get('config_language_id')]['title']) ? $image[JO_Registry::get('config_language_id')]['title'] : ''); } } } }
public static function returnFollowing($follower, $owner, $followers = false) { $view = JO_View::getInstance(); $model_images = new Helper_Images(); $request = JO_Request::getInstance(); $list_type = $request->getParam('list_type'); $user = Model_Users::getByUsername($follower['username']); $view->badges = self::userBadges($user); if ($user['avatar']) { $user['avatar'] = $model_images->resize($user['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true); } else { $user['avatar'] = 'data/themes/images/noavatar.png'; } $user['portfolio_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&username='******'&', '-', $user['username'])); $log_user = JO_Session::get('user_id'); if ($log_user) { $following = JO_Array::multi_array_search(JO_Session::get('following'), 'follow_id', $user['user_id']); if ($following) { $user['follow_href_name'] = $view->translate('Unfollow'); $user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=unfollow&username='******'&', '-', $user['username'])); } elseif ($log_user != $user['user_id']) { $user['follow_href_name'] = $view->translate('Follow'); $user['follow_href'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&username='******'&', '-', $user['username'])); } } $view->user = $user; $user_items = Model_Items::getByUser($user['user_id'], 0, 3, 'rand()'); if (empty($user_items)) { $user_items = array(array('no_items' => true, 'thumbnail' => 'data/themes/images/missing-item.png', 'module' => 'themes')); } $view->user_items = array(); if ($user_items) { foreach ($user_items as $item) { if (isset($item['demo_url'])) { $item['demo_url'] = WM_Router::create($request->getBaseUrl() . '?controller=demo&href=' . $item['demo_url']); } $view->user_items[] = Helper_Items::returnViewIndex($item); } } return $view->renderByModule('single_user/following', 'users', 'themes'); }