Example #1
0
 static function index_action()
 {
     $model_task = new Model_Task();
     $tasks = $model_task->get_all(['status' => 2], 10);
     if ($tasks['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($tasks));
         $tasks = [];
     }
     $tasks = $tasks['data'];
     $ap_ids = [];
     $src_ids = [];
     foreach ($tasks as $_k => $_t) {
         $ap_ids[$_k] = isset($_t['ap_id']) ? $_t['ap_id'] : '';
         $src_ids[$_k] = isset($_t['src_id']) ? $_t['src_id'] : '';
     }
     $ap_model = new Model_AccessPoint();
     $aps = $ap_model->get_ap_by_ids($ap_ids);
     if ($aps['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($aps));
         $aps = [];
     }
     $aps = $aps['data'];
     $source_model = new Model_Source();
     $sources = $source_model->get_sources_by_ids($src_ids);
     if ($sources['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($sources));
         $sources = [];
     }
     $sources = $sources['data'];
     $gt_time = strtotime('-1 month');
     $source_model->set_table_name('t_src_statistics');
     $cond = ['update_time' => ['$gte' => $gt_time]];
     $source_statistics = $source_model->get_table()->get_all($cond, [], 0, 0, null, true);
     if ($source_statistics['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($source_statistics));
         $source_statistics = [];
     }
     $source_statistics = $source_statistics['data'];
     $statistics = [];
     foreach ($source_statistics as $v) {
         $day = date('m-d', $v['update_time']);
         $statistics[$day] = isset($statistics[$day]) ? $statistics[$day] : [];
         $statistics[$day]['total'] = isset($statistics[$day]['total']) ? $statistics[$day]['total'] : 0;
         $statistics[$day]['status_1'] = isset($statistics[$day]['status_1']) ? $statistics[$day]['status_1'] : 0;
         $statistics[$day]['status_other'] = isset($statistics[$day]['status_other']) ? $statistics[$day]['status_other'] : 0;
         $statistics[$day]['total'] += intval($v['total']);
         $statistics[$day]['status_1'] += intval($v['status_1']);
         $statistics[$day]['status_other'] = $statistics[$day]['total'] - $statistics[$day]['status_1'];
     }
     foreach ($statistics as $day => $v) {
         $source_statistics_min = isset($source_statistics_min) && $source_statistics_min < $v['status_1'] ? $source_statistics_min : $v['status_1'];
     }
     $_access = Module_Statistics_Action::get_index_month_charts();
     $access_date = $_access['access_date'];
     $receive_data = $_access['receive_data'];
     $send_data = $_access['send_data'];
     self::render('common/index', ['tasks' => $tasks, 'aps' => $aps, 'sources' => $sources, 'source_statistics' => $statistics, 'source_statistics_min' => $source_statistics_min, 'access_date' => $access_date, 'send_data' => $send_data, 'receive_data' => $receive_data]);
 }
Example #2
0
 public function countAction()
 {
     $request = $this->getRequest();
     $json = array('count' => 0);
     $url = urldecode($request->getQuery('url'));
     if ($url && JO_Validate::validateHost($url)) {
         $source_id = Model_Source::getSourceByUrl($url, false);
         if ($source_id) {
             $total_pins = Model_Pins::getTotalPinsLikes(array('filter_source_id' => $source_id, 'filter_from_md5' => md5($url)));
             $json['count'] = $total_pins;
         } else {
             $json['count'] = 0;
         }
     } else {
         $json['error'] = $this->translate('Invalid Url');
     }
     $json['url'] = $url;
     //		$json['count'] = 1212;
     //		$json['error'] = $this->translate('Invalid Url');
     if ($request->getQuery('callback')) {
         $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');
         echo 'receiveCount(' . JO_Json::encode($json) . ');';
         exit;
     } else {
         foreach ($json as $k => $v) {
             $this->view->{$k} = $v;
         }
         echo $this->renderScript('json');
     }
 }
Example #3
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $source_id = $request->getRequest('source_id');
     $source_info = Model_Source::getSource($source_id);
     if (!$source_info) {
         $this->forward('error', 'error404');
     }
     $this->getLayout()->meta_title = $source_info['source'];
     $this->view->source = $source_info;
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $data = array('start' => JO_Registry::get('config_front_limit') * $page - JO_Registry::get('config_front_limit'), 'limit' => JO_Registry::get('config_front_limit'), 'filter_source_id' => $request->getRequest('source_id'), 'filter_marker' => $request->getRequest('marker'));
     //		if((int)JO_Session::get('user[user_id]')) {
     //			$data['following_users_from_user_id'] = JO_Session::get('user[user_id]');
     //		}
     $this->view->pins = '';
     $pins = Model_Pins::getPins($data);
     if ($pins) {
         foreach ($pins as $pin) {
             $this->view->pins .= Helper_Pin::returnHtml($pin);
         }
         // 			JO_Registry::set('marker', Model_Pins::getMaxPin($data));
     }
     if ($request->isXmlHttpRequest()) {
         echo $this->view->pins;
         $this->noViewRenderer(true);
     } else {
         $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
     }
 }
Example #4
0
 public static function edit($pin_id, $data)
 {
     $pin_info = self::getPin($pin_id);
     if (!$pin_info) {
         return;
     }
     $db = JO_Db::getDefaultAdapter();
     $date_modified = WM_Date::format(time(), 'yy-mm-dd H:i:s');
     $board_info = Model_Boards::getBoard($data['board_id']);
     $source_id = Model_Source::getSourceByUrl($data['from']);
     /* price */
     $price = $pin_info['price'];
     if (preg_match('/(\\$|\\£|\\€|\\¥|\\₪|zł|\\฿)([\\s]{0,2})?(?:(?:\\d{1,5}(?:\\,\\d{3})+)|(?:\\d+))(?:\\.\\d{2})?/', $data['price'], $match)) {
         $price_tmp = trim(str_replace(trim($match[1]), '', $match[0]));
         $currency = self::getCurrencyBySimbol(trim($match[1]));
         if ($currency) {
             $price = round($price_tmp / $currency, 4);
         }
     }
     $data['is_video'] = 'false';
     $help_video = new Helper_AutoEmbed();
     if ($help_video->parseUrl($data['from'])) {
         $data['is_video'] = 'true';
     }
     $is_update = $db->update('pins', array('category_id' => (string) $board_info['category_id'], 'board_id' => $data['board_id'], 'date_modified' => $date_modified, 'from' => $data['from'], 'from_md5' => md5($data['from']), 'description' => $data['description'], 'price' => $price, 'is_video' => $data['is_video'] == 'true' ? 1 : 0, 'source_id' => isset($data['source_id']) ? $data['source_id'] : $source_id, 'date_modified' => new JO_Db_Expr('NOW()')), array('pin_id = ?' => $pin_id));
     $spl = JO_Utf8::str_word_split(strip_tags(html_entity_decode($data['description'], ENT_QUOTES, 'utf-8')), self::$searchWordLenght);
     $words = array();
     foreach ($spl as $word) {
         $word = mb_strtolower($word, 'utf-8');
         if (!in_array($word, self::common()) && $word[0] . $word[1] != '&#') {
             $words[$word] = $word;
         }
     }
     foreach ($words as $word => $data1) {
         $dic_id = $db->fetchOne($db->select()->from('pins_dictionary', 'dic_id')->where('word = ?', $word));
         if (!$dic_id) {
             $db->insert('pins_dictionary', array('word' => $word));
             $dic_id = $db->lastInsertId();
         }
         if ($dic_id) {
             $db->insert('pins_invert', array('pin_id' => $pin_id, 'dic_id' => $dic_id));
         }
     }
     if ($pin_info['board_id'] != $data['board_id']) {
         //mahame i slagame ot stariq i v noviq/////
         Model_Boards::updateLatestPins($pin_info['board_id']);
         Model_Boards::updateLatestPins($data['board_id']);
         $board_info2 = Model_Boards::getBoard($pin_info['board_id']);
         if ($board_info2['cover'] == $pin_id) {
             $db->update('boards', array('cover' => 0), array('board_id = >' => $pin_info['board_id']));
         }
     }
     Model_Users::updateLatestPins($pin_info['user_id']);
     self::deleteCache($pin_info);
 }
Example #5
0
 public function action_index()
 {
     $data = Model_Data::find(1);
     $sources = Model_Source::find()->where('meta_update_user', $this->user)->get();
     $monitor = array('iconw' => $data['iconw'], 'iconc' => $data['iconc'], 'iconu' => $data['iconu'], 'osdw' => $data['osdw'], 'osdu' => $data['osdu'], 'osdc' => $data['osdc'], 'soundw' => $data['soundw'], 'soundu' => $data['soundu'], 'soundc' => $data['soundc']);
     $s = array();
     foreach ($sources as $source) {
         $type = Model_Type::find($source->typeID);
         array_push($s, array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'content' => $source['content']));
     }
     echo json_encode(array('data' => $monitor, 'sources' => $s));
 }
Example #6
0
 public function action_index()
 {
     $elements = array();
     $total = array('hostTotals' => 0, 'hostTotalsUP' => 0, 'hostTotalsDOWN' => 0, 'hostTotalsCRITICAL' => 0, 'hostTotalsUNREACHABLE' => 0, 'hostTotalsPROBLEMS' => 0, 'serviceTotals' => 0, 'serviceTotalsOK' => 0, 'serviceTotalsWARNING' => 0, 'serviceTotalsCRITICAL' => 0, 'serviceTotalsUNKNOWN' => 0, 'serviceTotalsPROBLEMS' => 0, 'serviceTotals' => 0, 'nagiosCode' => array());
     $sources = Model_Source::find()->where('meta_update_user', $this->user)->get();
     foreach ($sources as $source) {
         $nagios = new \Nagios($source->content);
         $nagios->auth($source->user, $source->pass);
         $data = $nagios->getData($total);
         $elements = array_merge($elements, $data[0]);
         $total = $data[1];
     }
     echo json_encode(array('total' => $total, 'services' => $elements));
 }
Example #7
0
 public function action_index()
 {
     if ($_POST) {
         $val = \Validation::forge();
         $val->add_field('id', 'Action', 'required|min_length[1]|max_length[20]');
         $val->add_field('action', 'Value', 'required|min_length[1]|max_length[20]');
         if ($val->run()) {
             $source = Model_Source::find($val->validated('id'));
             if ($val->validated('action') == 'get') {
                 $type = Model_Type::find($source->typeID);
                 $out = array('id' => $source['id'], 'type' => array('id' => $source->typeID, 'name' => $type->name), 'user' => $source['user'], 'pass' => $source['pass'], 'content' => $source['content']);
             }
             if ($val->validated('action') == 'remove') {
             }
             echo json_encode(array('source' => $out));
         }
     }
 }
Example #8
0
 public function indexAction()
 {
     $request = $this->getRequest();
     $source_id = $request->getRequest('source_id');
     $source_info = Model_Source::getSource($source_id);
     if (!$source_info) {
         $this->forward('error', 'error404');
     }
     $this->getLayout()->meta_title = $source_info['source'];
     $this->view->source = $source_info;
     /*//get pins data
     		if($request->isXmlHttpRequest()) {
     			$this->forward('source', 'getPins');
     		}*/
     ///// get pins
     $page = (int) $request->getRequest('page');
     if ($page < 1) {
         $page = 1;
     }
     $this->view->result_data = '';
     if (!Helper_Config::get('config_disable_js')) {
         //get pins data
         if ($request->isXmlHttpRequest()) {
             $this->forward('source', 'getPins');
         }
     } else {
         if ($page > 1 && $request->isXmlHttpRequest()) {
             $this->forward('source', 'getPins');
         }
         $pins = (array) $this->getPinsAction(true);
         foreach ($pins as $pin) {
             $template = new Helper_Tmpl($pin['template'], $pin);
             $this->view->result_data .= $template->render($pin['template']);
         }
     }
     //call header and footer childrens
     $this->view->children = array('header_part' => 'layout/header_part', 'footer_part' => 'layout/footer_part');
 }
Example #9
0
 static function task_list_action()
 {
     $task_id = Lib_Request::get_int('task_id');
     $ap_name = Lib_Request::get_var('ap_name');
     $ap_name = trim($ap_name);
     $src_id = Lib_Request::get_var('sub_src');
     $src_id = trim($src_id);
     $status = Lib_Request::get_int('status');
     $time_begin = Lib_Request::get_var('time_begin');
     $time_begin = trim($time_begin);
     $time_end = Lib_Request::get_var('time_end');
     $time_end = trim($time_end);
     $cond = [];
     $search_vars = [];
     $ap_cond = [];
     if (!empty($task_id)) {
         $cond = ['_id' => $task_id];
         $search_vars = ['task_id' => $task_id];
     } else {
         if (strpos($src_id, ',')) {
             $src_ids = explode(',', $src_id);
             $int_src_ids = [];
             foreach ($src_ids as $k => $v) {
                 $int_src_ids[] = intval($v);
             }
             $cond['src_id'] = ['$in' => array_merge($src_ids, $int_src_ids)];
         } elseif (!empty($src_id)) {
             $cond['src_id'] = ['$in' => [$src_id, intval($src_id)]];
         }
         if (!empty($status)) {
             $cond['status'] = $status;
             $search_vars['status'] = $status;
         }
         if (!empty($time_begin) || !empty($time_end)) {
             $time_cond = [];
             if (!empty($time_begin)) {
                 $time_begin = strtotime($time_begin);
                 $time_cond['$gt'] = $time_begin;
             }
             if (!empty($time_end)) {
                 $time_end = strtotime($time_end);
                 $time_cond['$lte'] = $time_end;
             }
             if ($time_begin >= $time_end) {
                 unset($time_cond['$lte']);
             }
             if (!empty($time_cond)) {
                 $cond['create_time'] = $time_cond;
             }
         }
     }
     if (!Module_Account_User::has_perms([Module_Account_Perm::PERM_AP_ADMIN])) {
         $ap_cond['interface_people'] = new MongoRegex("/" . Module_Account_User::get_current_user() . "/");
     }
     if (!empty($ap_name)) {
         $ap_cond = ['ap_name' => new MongoRegex("/" . $ap_name . "/")];
     }
     if (!empty($ap_cond)) {
         $search_vars['ap_name'] = $ap_name;
         $ap_ids = [];
         $int_ap_ids = [];
         $model = new Model_AccessPoint();
         $ap_infos = $model->get_all($ap_cond);
         if ($ap_infos['errno'] == Const_Err_Base::ERR_OK) {
             foreach ($ap_infos['data'] as $k => $ap) {
                 $ap_ids[] = $ap['ap_id'];
                 $int_ap_ids[] = intval($ap['ap_id']);
             }
         }
         $cond['ap_id'] = ['$in' => array_merge($ap_ids, $int_ap_ids)];
     }
     $model_task = new Model_Task();
     $total_num = $model_task->get_tasks_count($cond);
     $current_page = Lib_Request::get_int('page');
     //当前页码,必须
     $total_size = isset($total_num['data']) ? intval($total_num['data']) : 0;
     //总记录数,必须
     $page_size = 15;
     //每页条数,必须
     $skip = ($current_page - 1) * $page_size;
     //跳过记录,必须
     $skip = $skip < 0 ? 0 : $skip;
     $mode = 2;
     //页码模式,决定页码个数,默认1
     $tasks = $model_task->get_all($cond, $page_size, $skip);
     if ($tasks['errno'] !== Const_Err_Base::ERR_OK) {
         Lib_Log::error(Lib_Helper::format_err_struct($tasks));
         $tasks = [];
         Lib_Request::flash('未获取到任务信息');
     }
     $tasks = $tasks['data'];
     $ap_infos = [];
     $ap_model = new Model_AccessPoint();
     foreach ($tasks as $_k => $_t) {
         $ap_info = $ap_model->get_ap_by_id($_t['ap_id']);
         $ap_info['ap_id'] = $_t['ap_id'];
         if ($ap_info['errno'] !== Const_Err_Base::ERR_OK) {
             Lib_Log::error(Lib_Helper::format_err_struct($ap_info));
             Lib_Request::flash('获取接入点信息失败');
             Module_HttpRequest_Router::redirect_to('/');
         }
         $ap_info = $ap_info[Const_DataAccess::MREK_DATA];
         $ap_infos[$_t['ap_id']] = $ap_info;
     }
     $source_model = new Model_Source();
     $all_sources = $source_model->get_all();
     $sources = $all_sources[Const_DataAccess::MREK_DATA];
     $all_src_type = [];
     foreach ($all_sources['data'] as $k => $v) {
         if (!in_array($v['src_type'], $all_src_type)) {
             $all_src_type[] = $v['src_type'];
         }
     }
     asort($all_src_type);
     $task_status_list = Module_ControlCentre_Main::$task_status_list;
     $pages = Module_View_Template::get_pages_html($current_page, $total_size, $page_size, $mode);
     Module_Page_Main::render('control_centre/task_list', ['ap_info' => $ap_infos, 'tasks' => $tasks, 'sources' => $sources, 'pages' => $pages, 'all_src_type' => $all_src_type, 'status_list' => $task_status_list, 'search_vars' => $search_vars]);
 }
Example #10
0
 public function init($graph, $dev, $port, $sourceID)
 {
     //$graph=Model_Graphing_Cacti::find()->where('graphID',$id)->where('deviceID',$dev);
     $this->port = $port;
     ob_start();
     $this->device = \Basic\Model_Device::find($dev);
     $this->heightlimit = 750;
     $this->_setTitle();
     $this->_AddPage();
     $this->zoom = 0.75;
     $source = Model_Source::find($sourceID);
     if ($source) {
         $this->cacti = new \Cacti($source->content);
         $code = $this->cacti->authentication($source->user, $source->pass);
         if ($code == 200) {
             $this->angle = 0;
             $this->SetFont('Verdana', '', 12);
             $this->SetTextColor(0, 0, 0);
             $this->_graph($graph, 5, 1, 20);
             ///$this->Ln(-180);
             $this->Rotate(90);
             $this->text(-80, 72, 'Daily');
             $this->Rotate(0);
             $this->_graph($graph, 5, 2, 205);
             $this->Rotate(90);
             $this->text(-265, 72, 'Weekly');
             $this->Rotate(0);
             $this->_graph($graph, 5, 3, 390);
             $this->Rotate(90);
             $this->text(-450, 72, 'Monthly');
             $this->Rotate(0);
             $this->_graph($graph, 5, 4, 575);
             $this->Rotate(90);
             $this->text(-635, 72, 'Yearly');
             $this->Rotate(0);
         }
     }
     /*
     		$this->setTypeOfDevice();
     		
     		$this->rack=Model_Rack::find($this->device->rack);
     		
     		$this->template=Model_Device_Template::find($this->device->get('type'));
     		
     		$this->heightlimit=750;
     			
     		$this->_setTitle();
     
     		$this->_AddPage();
     		$this->zoom=0.75;
     		
     		$this->rack_set(90,50,$this->rack->size);
     
     
     $this->device_general();
     		
     		if($this->action[0]==1)
     		$this->device_hardware();
     		
     		if($this->action[1]==1)
     		$this->device_network();
     		
     		if($this->action[2]==1)
     		$this->device_notes();
     		
     		$this->device_power();
     */
 }
Example #11
0
 public static function getPin($pin_id, $fields = array('*'))
 {
     $db = JO_Db::getDefaultAdapter();
     $query = $db->select()->from('pins', array('pins.*', 'gift' => new JO_Db_Expr('pins.price > 0.0000')))->where('pins.pin_id = ?', (string) $pin_id)->limit(1);
     $query->where('pins.store != ""');
     $result = $db->fetchRow($query);
     if (!$result) {
         return false;
     }
     $userinfo = Model_Users::getUser($result['user_id'], false, $fields);
     if (!$userinfo) {
         return false;
     }
     $result['user_via'] = Model_Users::getUser($result['via'], false, $fields);
     $result['source'] = Model_Source::getSource($result['source_id']);
     $result['user'] = $userinfo;
     $result['board'] = Model_Boards::getBoardTitle($result['board_id']);
     $result['board_data'] = Model_Boards::getBoard($result['board_id']);
     $result['latest_comments'] = $result['comments'] ? Model_Comments::getComments(array('filter_pin_id' => $pin_id)) : 0;
     $result['liked'] = $result['likes'] ? self::pinIsLiked($result['pin_id']) : 0;
     return $result;
 }
Example #12
0
 public static function returnHtmlDetail($pin, $banners = false)
 {
     //XPER: función que carga PIN
     static $view = null, $model_images = null, $request = null;
     if ($view === null) {
         $view = JO_View::getInstance();
     }
     if ($model_images === null) {
         $model_images = new Helper_Images();
     }
     if ($request === null) {
         $request = JO_Request::getInstance();
     }
     $next_pin = Model_Pins::getNextPin($pin['pin_id']);
     if ($next_pin) {
         $view->next_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $next_pin['pin_id']);
     }
     $prev_pin = Model_Pins::getPrevPin($pin['pin_id']);
     if ($prev_pin) {
         $view->prev_navigation_pin = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $prev_pin['pin_id']);
     }
     $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_B');
     if ($image) {
         $pin['thumb'] = $image['image'];
         $pin['thumb_width'] = $image['width'];
         $pin['thumb_height'] = $image['height'];
         $pin['original_image'] = $image['original'];
     } else {
         JO_Action::getInstance()->forward('error', 'error404');
     }
     $image = call_user_func(array(self::formatUploadModule($pin['store']), 'getPinImage'), $pin, '_D');
     if ($image) {
         $pin['popup'] = $image['image'];
         $pin['popup_width'] = $image['width'];
         $pin['popup_height'] = $image['height'];
         $pin['original_image'] = $image['original'];
     } else {
         JO_Action::getInstance()->forward('error', 'error404');
     }
     $pin_description = self::descriptionFix($pin['description']);
     $pin['real_description'] = self::descriptionFix($pin['description']);
     $pin['description'] = self::descriptionFix($pin['description']);
     $pin['href'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
     $pin['pinmarklet_href'] = WM_Router::create($request->getBaseUrl() . '?controller=pages&action=read&page_id=' . JO_Registry::get('page_pinmarklet'));
     $pin['onto_href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']);
     $pin['price_formated'] = WM_Currency::format($pin['price']);
     $view->author = $pin['user'];
     $avatar = Helper_Uploadimages::avatar($pin['user'], '_A');
     $view->author['avatar'] = $avatar['image'];
     $view->author['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['user_id']);
     $view->comments = array();
     if ($pin['latest_comments']) {
         foreach ($pin['latest_comments'] as $key => $comment) {
             if (!isset($comment['user']['store'])) {
                 unset($pin['latest_comments'][$key]);
                 continue;
             }
             $avatar = Helper_Uploadimages::avatar($comment['user'], '_A');
             $comment['user']['avatar'] = $avatar['image'];
             $comment['user']['profile'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $comment['user_id']);
             $comment['delete'] = '';
             if (!Model_Pins::commentIsReported($comment['comment_id'])) {
                 $comment['report'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=reportComment&comment_id=' . $comment['comment_id']);
             } else {
                 $comment['report'] = '';
             }
             if (JO_Session::get('user[user_id]')) {
                 if (JO_Session::get('user[is_admin]') || JO_Session::get('user[user_id]') == $comment['user_id'] || JO_Session::get('user[user_id]') == $pin['board_data']['user_id']) {
                     $comment['delete'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=deleteComment&comment_id=' . $comment['comment_id']);
                 }
             }
             $view->comments[] = $comment;
         }
     }
     $view->via = array();
     $view->via_repin = array();
     if ($pin['via'] && $pin['user_via']) {
         $view->via = array('profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $pin['via']), 'fullname' => $pin['user_via']['fullname']);
     }
     $view->replin_info = false;
     if ($request->isXmlHttpRequest()) {
         $view->target_repin = false;
         if ($pin['repin_from']) {
             $pin_repin = Model_Pins::getPin($pin['repin_from']);
             if ($pin_repin) {
                 $view->source = array();
                 $view->source['source'] = $pin_repin['board'];
                 $pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_id'] . '&board_id=' . $pin_repin['board_id']);
                 $view->target_repin = true;
             } else {
                 $view->source = Model_Source::getSource($pin['source_id']);
             }
         } else {
             $view->source = Model_Source::getSource($pin['source_id']);
         }
     } else {
         $view->source = Model_Source::getSource($pin['source_id']);
         if ($pin['repin_from']) {
             $repina = Model_Pins::getPin($pin['repin_from']);
             if ($repina) {
                 $view->replin_info = array('pin_href' => WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['repin_from']), 'profile' => WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $repina['user_id']), 'fullname' => $repina['user']['fullname']);
             }
         }
     }
     if ($pin['from'] && !preg_match('/^https?:\\/\\//', $pin['from'])) {
         $pin['from'] = 'http://' . $pin['from'];
     }
     if ($pin['from_repin'] && !preg_match('/^https?:\\/\\//', $pin['from_repin'])) {
         $pin['from_repin'] = 'http://' . $pin['from_repin'];
     }
     $pin['onto_board'] = $pin['onto_board2'] = array();
     $pin['originally_pinned'] = $pin['originally_pinned2'] = array();
     if ($request->isXmlHttpRequest()) {
         $pin['onto_board'] = self::getBoardPins($pin['board_id']);
         $pin['originally_pinned'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']);
     } else {
         $pin['onto_board2'] = self::getBoardPins($pin['board_id']);
         $pin['originally_pinned2'] = self::getOriginallyPinned($pin['via'] ? $pin['via'] : $pin['user_id']);
     }
     if ($view->source && $request->isXmlHttpRequest()) {
         $pin['source_pins'] = self::getSourcePins($pin['source_id']);
     } else {
         $pin['source_pins'] = array();
     }
     $pin['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $pin['board_id']));
     $pin['userIsFollow'] = Model_Users::isFollowUser($pin['user_id']);
     if ($pin['via']) {
         $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['via']);
     } else {
         $pin['userViaIsFollow'] = Model_Users::isFollowUser($pin['user_id']);
     }
     $pin['userFollowIgnore'] = $pin['user_id'] == JO_Session::get('user[user_id]');
     $pin['userViaFollowIgnore'] = ($pin['via'] ? $pin['via'] : $pin['user_id']) == JO_Session::get('user[user_id]');
     $view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $pin['user_id'] . '&board_id=' . $pin['board_id']);
     $view->follow_user = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_id']);
     if ($pin['via']) {
         $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['via']);
     } else {
         $view->follow_user_via = WM_Router::create($request->getBaseUrl() . '?controller=users&action=follow&user_id=' . $pin['user_id']);
     }
     $view->get_user_friends = WM_Router::create($request->getBaseUrl() . '?controller=users&action=friends');
     if (JO_Session::get('user[user_id]')) {
         $view->enable_follow = $pin['user_id'] != JO_Session::get('user[user_id]');
     } else {
         $view->enable_follow = false;
     }
     if (JO_Session::get('user[user_id]')) {
         $pin['url_like'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=like&pin_id=' . $pin['pin_id']);
         $pin['url_repin'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=repin&pin_id=' . $pin['pin_id']);
         $pin['url_comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']);
         $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=pin&action=comment&pin_id=' . $pin['pin_id']);
         $pin['edit'] = JO_Session::get('user[user_id]') == $pin['user_id'] ? WM_Router::create($request->getBaseUrl() . '?controller=pin&action=edit&pin_id=' . $pin['pin_id']) : false;
     } else {
         $pin['url_like'] = $pin['url_repin'] = $pin['url_comment'] = $pin['comment'] = WM_Router::create($request->getBaseUrl() . '?controller=landing');
         $pin['edit'] = false;
     }
     $likes = self::getPinLikes($pin['pin_id']);
     $pin['likes'] = $likes['data'];
     $pin['likes_total'] = $likes['total'];
     $pin['repins'] = self::getRePins($pin['pin_id']);
     $pin['pinIsReported'] = Model_Pins::pinIsReported($pin['pin_id']);
     $date_dif = array_shift(WM_Date::dateDiff($pin['date_added'], time()));
     $pin['date_dif'] = $date_dif;
     $view->loged = JO_Session::get('user[user_id]');
     $view->site_name = JO_Registry::get('site_name');
     if ($view->loged) {
         $avatar = Helper_Uploadimages::avatar(JO_Session::get('user'), '_A');
         $view->self_avatar = $avatar['image'];
         $view->self_profile = WM_Router::create($request->getBaseUrl() . '?controller=users&action=profile&user_id=' . $view->loged);
         $view->self_fullname = JO_Session::get('user[firstname]') . ' ' . JO_Session::get('user[lastname]');
     }
     if ($pin['is_video']) {
         $auto = new Helper_AutoEmbed();
         if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) {
             $auto->setWidth('100%');
             $auto->setHeight('350');
             $pin['video_code'] = $auto->getEmbedCode();
             $attr = $auto->getObjectAttribs();
             $pin['thumb_width'] = $attr['width'];
             $pin['thumb_height'] = $attr['height'];
         } else {
             if ($auto->parseUrl($pin['from'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['video_code'] = $auto->getEmbedCode();
                 $attr = $auto->getObjectAttribs();
                 $pin['thumb_width'] = $attr['width'];
                 $pin['thumb_height'] = $attr['height'];
             } else {
                 $pin['is_video'] = false;
             }
         }
     } else {
         $auto = new Helper_AutoEmbed();
         if ($pin['repin_from'] && $auto->parseUrl($pin['from_repin'])) {
             $auto->setWidth('100%');
             $auto->setHeight('350');
             $pin['video_code'] = $auto->getEmbedCode();
             $attr = $auto->getObjectAttribs();
             $pin['thumb_width'] = $attr['width'];
             $pin['thumb_height'] = $attr['height'];
             $pin['is_video'] = true;
         } else {
             if ($auto->parseUrl($pin['from'])) {
                 $auto->setWidth('100%');
                 $auto->setHeight('350');
                 $pin['video_code'] = $auto->getEmbedCode();
                 $attr = $auto->getObjectAttribs();
                 $pin['thumb_width'] = $attr['width'];
                 $pin['thumb_height'] = $attr['height'];
                 $pin['is_video'] = true;
             } else {
                 $pin['is_video'] = false;
             }
         }
     }
     $view->pin_url = WM_Router::create($request->getBaseUrl() . '?controller=pin&pin_id=' . $pin['pin_id']);
     $view->login_href = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login&next=' . urlencode($pin['href']));
     Model_Pins::updateViewed($pin['pin_id']);
     JO_Layout::getInstance()->meta_title = $pin['board'] . ' - ' . strip_tags(html_entity_decode($pin_description));
     JO_Layout::getInstance()->placeholder('pin_url', $view->replin_info ? $view->replin_info['pin_href'] : $view->pin_url);
     JO_Layout::getInstance()->placeholder('pin_description', $pin_description);
     $params = array();
     $params['content'] = html_entity_decode($pin['description'] . ' ' . $pin['board'], ENT_QUOTES, 'UTF-8');
     //page content
     $keywords = new WM_Keywords($params);
     $get_keywords = $keywords->get_keywords();
     if ($get_keywords) {
         JO_Layout::getInstance()->placeholder('keywords', $get_keywords);
     }
     JO_Layout::getInstance()->placeholder('pin_image', $pin['thumb']);
     JO_Layout::getInstance()->placeholder('board_title', $pin['board']);
     $view->banners = array();
     if ($banners) {
         foreach ($banners as $banner1) {
             foreach ($banner1 as $e) {
                 $e['html'] = html_entity_decode($e['html']);
                 $view->banners[] = $e;
             }
         }
     }
     $view->pin = $pin;
     return $view->render('pinBoxDetail', 'pin');
 }
Example #13
0
 private function getForm()
 {
     $request = $this->getRequest();
     $sources_id = $request->getRequest('id');
     $places_model = new Model_Source();
     if ($sources_id) {
         $sources_info = $places_model->getSource($sources_id);
     }
     $this->view->cancel_url = $request->getModule() . '/sources/';
     if ($request->getPost('source')) {
         $this->view->source = $request->getPost('source');
     } elseif (isset($sources_info)) {
         $this->view->source = $sources_info['source'];
     }
 }
Example #14
0
 public function left_partAction()
 {
     $request = $this->getRequest();
     $this->view->pin = JO_Registry::get('pin_info');
     //		$this->view->onto_board = Helper_Pin::getBoardPins( JO_Registry::getArray('pin_info[board_id]'), 9, 60 );
     $boards = Model_Boards::getBoards(array('start' => 0, 'limit' => 1, 'filter_id_in' => JO_Registry::getArray('pin_info[board_id]')));
     $this->view->has_edit_boards = true;
     $this->view->enable_sort = true;
     $this->view->onto_board = '';
     if ($boards) {
         $view = JO_View::getInstance();
         $view->loged = JO_Session::get('user[user_id]');
         $view->enable_sort = false;
         $model_images = new Helper_Images();
         foreach ($boards as $board) {
             $board['href'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             $board['thumbs'] = array();
             $get_big = false;
             for ($i = 0; $i < 5; $i++) {
                 $image = isset($board['pins_array'][$i]) ? $board['pins_array'][$i]['image'] : false;
                 if ($image) {
                     if ($get_big) {
                         $size = '_A';
                     } else {
                         $size = '_C';
                         $get_big = true;
                     }
                     $data_img = Helper_Uploadimages::pin($board['pins_array'][$i], $size);
                     if ($data_img) {
                         $board['thumbs'][] = $data_img['image'];
                     } else {
                         $board['thumbs'][] = false;
                     }
                 } else {
                     $board['thumbs'][] = false;
                 }
             }
             $board['boardIsFollow'] = Model_Users::isFollow(array('board_id' => $board['board_id']));
             $board['userFollowIgnore'] = $board['user_id'] != JO_Session::get('user[user_id]');
             $board['follow'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             $board['edit'] = false;
             if ($board['user_id'] == JO_Session::get('user[user_id]')) {
                 $board['edit'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=edit&user_id=' . $board['user_id'] . '&board_id=' . $board['board_id']);
             }
             $view->board = $board;
             $this->view->onto_board .= $view->render('box', 'boards');
         }
     }
     $this->view->source = Model_Source::getSource(JO_Registry::getArray('pin_info[source_id]'));
     if ($this->view->source) {
         $this->view->source_pins = Helper_Pin::getSourcePins(JO_Registry::getArray('pin_info[source_id]'), 6, 75);
         $this->view->pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=source&source_id=' . $this->view->pin['source_id']);
     } else {
         if (JO_Registry::getArray('pin_info[repin_from]')) {
             $pin_repin = Model_Pins::getPin(JO_Registry::getArray('pin_info[repin_from]'));
             if ($pin_repin) {
                 $this->view->source['source'] = $pin_repin['board'];
                 $this->view->pin['from'] = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=view&user_id=' . $pin_repin['user_id'] . '&board_id=' . $pin_repin['board_id']);
                 $this->view->source_pins = Helper_Pin::getBoardPins($pin_repin['board_id'], 9, 75);
             }
         }
     }
     $this->view->boardIsFollow = Model_Users::isFollow(array('board_id' => JO_Registry::getArray('pin_info[board_id]')));
     $this->view->follow = WM_Router::create($request->getBaseUrl() . '?controller=boards&action=follow&user_id=' . $this->view->pin['user_id'] . '&board_id=' . $this->view->pin['board_id']);
     $this->view->loged = JO_Session::get('user[user_id]');
     $this->view->pin['userFollowIgnore'] = ($this->view->pin['via'] ? $this->view->pin['via'] : $this->view->pin['user_id']) == JO_Session::get('user[user_id]');
     //		var_dump($this->view->onto_board);
     JO_Registry::set('pin_info', array());
 }