예제 #1
0
 /**
  * Use this function for applying any filter
  * @author Howard <*****@*****.**>
  * @param string $trigger
  * @param array $params
  * @return mixed
  */
 public static function apply($trigger, $params = array())
 {
     /** fetch filters **/
     $filters = self::get_filters($trigger, 1);
     if (count($filters) == 0) {
         return $params;
     }
     foreach ($filters as $filter) {
         /** generate all params **/
         $all_params = array();
         $all_params[0] = $params;
         $all_params[1] = json_decode($filter->params, true);
         $all_params[2] = $filter;
         /** import class **/
         $path = _wpl_import($filter->class_location, true, true);
         if (!wpl_file::exists($path)) {
             continue;
         }
         include_once $path;
         /** call function **/
         $filter_obj = new $filter->class_name();
         $params = call_user_func(array($filter_obj, $filter->function_name), $all_params);
     }
     return $params;
 }
예제 #2
0
 /**
  * How to display the widget on the screen.
  */
 public function widget($args, $instance)
 {
     $this->widget_id = $this->number;
     if ($this->widget_id < 0) {
         $this->widget_id = abs($this->widget_id) + 1000;
     }
     $this->widget_uq_name = 'wpls' . $this->widget_id;
     $widget_id = $this->widget_id;
     $target_id = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0;
     $this->kind = isset($instance['kind']) ? $instance['kind'] : 0;
     /** add main scripts **/
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-slider');
     wp_enqueue_script('jquery-ui-button');
     wp_enqueue_script('jquery-ui-datepicker');
     echo $args['before_widget'];
     $title = apply_filters('widget_title', isset($instance['title']) ? $instance['title'] : '');
     if (trim($title) != '') {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $layout = 'widgets.search.tmpl.' . (isset($instance['layout']) ? $instance['layout'] : 'default');
     $layout = _wpl_import($layout, true, true);
     $find_files = array();
     /** render search fields **/
     $this->rendered = $this->render_search_fields($instance, $widget_id, $find_files);
     if (!wpl_file::exists($layout)) {
         $layout = _wpl_import('widgets.search.tmpl.default', true, true);
     }
     if (wpl_file::exists($layout)) {
         require $layout;
     } else {
         echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN);
     }
     echo $args['after_widget'];
 }
예제 #3
0
 /**
  * How to display the widget on the screen.
  */
 public function widget($args, $instance)
 {
     $this->widget_id = $this->number;
     if ($this->widget_id < 0) {
         $this->widget_id = abs($this->widget_id) + 1000;
     }
     $this->widget_uq_name = 'wpla' . $this->widget_id;
     $this->instance = $instance;
     $widget_id = $this->widget_id;
     $this->css_class = isset($instance['data']['css_class']) ? $instance['data']['css_class'] : '';
     /** render properties **/
     $query = self::query($instance);
     $model = new wpl_users();
     $profiles = $model->search($query);
     /** return if no property found **/
     if (!count($profiles)) {
         return;
     }
     $plisting_fields = $model->get_plisting_fields();
     $wpl_profiles = array();
     $render_params['wpltarget'] = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0;
     $params = array();
     foreach ($profiles as $profile) {
         $wpl_profiles[$profile->id] = $model->full_render($profile->id, $plisting_fields, $profile, $render_params);
         $params['image_parentid'] = $profile->id;
         /** profile picture **/
         if (isset($wpl_profiles[$profile->id]['profile_picture']['url'])) {
             $params['image_name'] = isset($wpl_profiles[$profile->id]['profile_picture']['name']) ? $wpl_profiles[$profile->id]['profile_picture']['name'] : '';
             $profile_picture_path = isset($wpl_profiles[$profile->id]['profile_picture']['path']) ? $wpl_profiles[$profile->id]['profile_picture']['path'] : '';
             $wpl_profiles[$profile->id]['profile_picture']['url'] = wpl_images::create_profile_images($profile_picture_path, $instance['data']['image_width'], $instance['data']['image_height'], $params);
             $wpl_profiles[$profile->id]['profile_picture']['image_width'] = isset($instance['data']['image_width']) ? $instance['data']['image_width'] : '';
             $wpl_profiles[$profile->id]['profile_picture']['image_height'] = isset($instance['data']['image_height']) ? $instance['data']['image_height'] : '';
         }
         /** company logo **/
         if (isset($wpl_profiles[$profile->id]['company_logo']['url'])) {
             $params['image_name'] = isset($wpl_profiles[$profile->id]['company_logo']['name']) ? $wpl_profiles[$profile->id]['company_logo']['name'] : '';
             $company_logo_path = isset($wpl_profiles[$profile->id]['company_logo']['path']) ? $wpl_profiles[$profile->id]['company_logo']['path'] : '';
             $wpl_profiles[$profile->id]['company_logo']['url'] = wpl_images::create_profile_images($company_logo_path, $instance['data']['image_width'], $instance['data']['image_height'], $params);
         }
     }
     echo $args['before_widget'];
     $title = apply_filters('widget_title', $instance['title']);
     if (trim($title) != '') {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $layout = 'widgets.agents.tmpl.' . $instance['layout'];
     $layout = _wpl_import($layout, true, true);
     if (!wpl_file::exists($layout)) {
         $layout = _wpl_import('widgets.agents.tmpl.default', true, true);
     } elseif (wpl_file::exists($layout)) {
         require $layout;
     } else {
         echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN);
     }
     echo $args['after_widget'];
 }
예제 #4
0
 public function get_qr_image($qrfile_prefix = 'qr_', $size = 4, $outer_margin = 2)
 {
     $url = wpl_global::get_full_url();
     $file_name = $qrfile_prefix . md5($url) . '.png';
     $file_path = wpl_global::get_upload_base_path() . 'qrcode' . DS . $file_name;
     if (!wpl_file::exists($file_path)) {
         if (!wpl_file::exists(dirname($file_path))) {
             wpl_folder::create(dirname($file_path));
         }
         $QRcode = new QRcode();
         $QRcode->png($url, $file_path, 'L', $size, $outer_margin);
     }
     return wpl_global::get_upload_base_url() . 'qrcode/' . $file_name;
 }
예제 #5
0
 public function show_tips()
 {
     $page = wpl_request::getVar('page', '');
     /** First Validation **/
     if (!trim($page)) {
         return false;
     }
     $tips = array();
     $path = _wpl_import('assets.tips.' . $page, true, true);
     if (wpl_file::exists($path)) {
         $tips = (include_once $path);
     }
     /** Generate script **/
     $this->generate_scripts($tips);
 }
예제 #6
0
 /**
  * How to display the widget on the screen.
  */
 public function widget($args, $instance)
 {
     $this->instance = $instance;
     $this->widget_id = $this->number;
     if ($this->widget_id < 0) {
         $this->widget_id = abs($this->widget_id) + 1000;
     }
     $this->widget_uq_name = 'wplc' . $this->widget_id;
     $widget_id = $this->widget_id;
     $this->css_class = isset($instance['data']['css_class']) ? $instance['data']['css_class'] : '';
     /** add main scripts **/
     wp_enqueue_script('jquery-ui-core');
     wp_enqueue_script('jquery-ui-slider');
     /** render properties **/
     $query = self::query($instance);
     $model = new wpl_property();
     $properties = $model->search($query);
     /** return if no property found **/
     if (!count($properties)) {
         return;
     }
     $plisting_fields = $model->get_plisting_fields();
     $wpl_properties = array();
     $render_params['wpltarget'] = isset($instance['wpltarget']) ? $instance['wpltarget'] : 0;
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $model->full_render($property->id, $plisting_fields, $property, $render_params);
     }
     echo $args['before_widget'];
     $title = apply_filters('widget_title', $instance['title']);
     if (trim($title) != '') {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     $layout = 'widgets.carousel.tmpl.' . $instance['layout'];
     $layout = _wpl_import($layout, true, true);
     if (!wpl_file::exists($layout)) {
         $layout = _wpl_import('widgets.carousel.tmpl.default', true, true);
     } elseif (wpl_file::exists($layout)) {
         require $layout;
     } else {
         echo __('Widget Layout Not Found!', WPL_TEXTDOMAIN);
     }
     echo $args['after_widget'];
 }
예제 #7
0
 private function update_package()
 {
     $sid = wpl_request::getVar('sid');
     $tmp_directory = wpl_global::init_tmp_folder();
     $dest = $tmp_directory . 'package.zip';
     $zip_file = wpl_global::get_web_page('http://billing.realtyna.com/index.php?option=com_rls&view=downloadables&task=download&sid=' . $sid . '&randomkey=' . rand(1, 100));
     if (!$zip_file) {
         $this->response(array('success' => '0', 'error' => __('Error: #U202, Could not download the update package!', WPL_TEXTDOMAIN), 'message' => ''));
     }
     if (!class_exists('ZipArchive')) {
         $this->response(array('success' => '0', 'error' => __('Error: #U205, Your PHP has no ZipArchive support enabled!', WPL_TEXTDOMAIN), 'message' => ''));
     }
     if (!wpl_file::write($dest, $zip_file)) {
         $this->response(array('success' => '0', 'error' => __('Error: #U203, Could not create the update file!', WPL_TEXTDOMAIN), 'message' => ''));
     }
     if (!wpl_global::zip_extract($dest, $tmp_directory)) {
         $this->response(array('success' => '0', 'error' => __('Error: #U204, Could not extract the update file!', WPL_TEXTDOMAIN), 'message' => ''));
     }
     $script_file = $tmp_directory . 'installer.php';
     if (!wpl_file::exists($script_file)) {
         $this->response(array('error' => __("Installer file doesn't exist!", WPL_TEXTDOMAIN), 'message' => ''));
     }
     if (!is_writable(WPL_ABSPATH . 'WPL.php')) {
         $this->response(array('error' => __("PHP doesn't have write access to the files and directories!", WPL_TEXTDOMAIN), 'message' => ''));
     }
     /** including installer and run the install method **/
     include $script_file;
     if (!class_exists('wpl_installer')) {
         $this->response(array('error' => __("Installer class doesn't exist!", WPL_TEXTDOMAIN), 'message' => ''));
     }
     /** run install script **/
     $wpl_installer = new wpl_installer();
     $wpl_installer->path = $tmp_directory;
     if (!$wpl_installer->run()) {
         $this->response(array('error' => $wpl_installer->error, 'message' => ''));
     }
     /** Trigger Event **/
     wpl_global::event_handler('package_updated', array('package_id' => isset($wpl_installer->addon_id) ? $wpl_installer->addon_id : 0));
     $message = $wpl_installer->message ? $wpl_installer->message : __('Addon Updated.', WPL_TEXTDOMAIN);
     $this->response(array('error' => '', 'message' => $message));
 }
예제 #8
0
 /**
  * save notification data
  * @author Kevin J <*****@*****.**> 
  * @static
  * @param array $data notification data to save reperesantion in arrray
  * @return boolean
  */
 public static function save_notification($data)
 {
     wpl_file::write(self::get_template_path($data['template_path'], true), $data['template']);
     $data = wpl_db::escape($data);
     $query = "UPDATE #__wpl_notifications SET `description` = '{$data['description']}',`template` = '{$data['template_path']}',";
     $query .= "`additional_emails` = '{$data['include_email']}',`additional_memberships` = '{$data['include_membership']}',`additional_users` = '{$data['include_user']}',`subject` = '{$data['subject']}' ";
     $query .= "WHERE id = {$data['id']}";
     return wpl_db::q($query);
 }
예제 #9
0
 /**
  * For rendering and returning section contents
  * @author Howard <*****@*****.**>
  * @param string $include
  * @param boolean $override
  * @param boolean $once
  * @return string
  */
 protected function _wpl_render($include, $override = true, $once = false)
 {
     $path = _wpl_import($include, $override, true);
     /** check exists **/
     if (!wpl_file::exists($path)) {
         return;
     }
     ob_start();
     if (!$once) {
         include $path;
     } else {
         include_once $path;
     }
     return ob_get_clean();
 }
예제 #10
0
 public function encode($intext, $outfile = false)
 {
     $code = new QRcode();
     if ($this->eightbit) {
         $code->encodeString8bit($intext, $this->version, $this->level);
     } else {
         $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive);
     }
     QRtools::markTime('after_encode');
     if ($outfile !== false) {
         wpl_file::write($outfile, join("\n", QRtools::binarize($code->data)));
     } else {
         return QRtools::binarize($code->data);
     }
 }
예제 #11
0
 /**
  * Delete a folder.
  * @author Howard <*****@*****.**>
  * @param string $path
  * @return boolean
  */
 public static function delete($path)
 {
     @set_time_limit(ini_get('max_execution_time'));
     // Sanity check
     if (!$path) {
         return false;
     }
     // Check to make sure the path valid and clean
     $path = wpl_path::clean($path);
     // Is this really a folder?
     if (!is_dir($path)) {
         return false;
     }
     // Remove all the files in folder if they exist; disable all filtering
     $files = self::files($path, '.', false, true, array(), array());
     if (!empty($files)) {
         if (wpl_file::delete($files) !== true) {
             return false;
         }
     }
     // Remove sub-folders of folder; disable all filtering
     $folders = self::folders($path, '.', false, true, array(), array());
     foreach ($folders as $folder) {
         if (is_link($folder)) {
             if (wpl_file::delete($folder) !== true) {
                 return false;
             }
         } elseif (self::delete($folder) !== true) {
             return false;
         }
     }
     // In case of restricted permissions we zap it one way or the other
     // as long as the owner is either the webserver or the ftp.
     if (@rmdir($path)) {
         $ret = true;
     } else {
         $ret = false;
     }
     return $ret;
 }
예제 #12
0
 private function delete_file($field_id, $user_id, $output = true)
 {
     $field_data = (array) wpl_db::get('*', 'wpl_dbst', 'id', $field_id);
     $user_data = (array) wpl_users::get_wpl_user($user_id);
     $path = wpl_items::get_path($user_id, $field_data['kind']) . $user_data[$field_data['table_column']];
     /** delete file and reset db **/
     wpl_file::delete($path);
     wpl_db::set('wpl_users', $user_id, $field_data['table_column'], '');
     /** delete thumbnails **/
     wpl_users::remove_thumbnails($user_id);
     /** called from other functions (upload function) **/
     if (!$output) {
         return;
     }
     $res = 1;
     $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
예제 #13
0
 /**
  * Creates profile image
  * @author Howard <*****@*****.**>
  * @param string $source
  * @param int $width
  * @param int $height
  * @param array $params
  * @param int $watermark
  * @param int $rewrite
  * @param int $crop
  * description: resize and watermark images specially
  */
 public static function create_profile_images($source, $width, $height, $params, $watermark = 0, $rewrite = 0, $crop = '')
 {
     /** first validation **/
     if (!trim($source)) {
         return NULL;
     }
     $image_name = wpl_file::stripExt($params['image_name']);
     $image_ext = wpl_file::getExt($params['image_name']);
     $resized_image_name = 'th' . $image_name . '_' . $width . 'x' . $height . '.' . $image_ext;
     $image_dest = wpl_items::get_path($params['image_parentid'], 2) . $resized_image_name;
     $image_url = wpl_items::get_folder($params['image_parentid'], 2) . $resized_image_name;
     /** check resized files existance and rewrite option **/
     if ($rewrite or !wpl_file::exists($image_dest)) {
         if ($watermark) {
             self::resize_watermark_image($source, $image_dest, $width, $height);
         } else {
             self::resize_image($source, $image_dest, $width, $height, $crop);
         }
     }
     return $image_url;
 }
예제 #14
0
 /**
  * Returns js validation code
  * @author Howard R <*****@*****.**>
  * @static
  * @param object $field
  * @return string
  */
 public static function generate_js_validation($field)
 {
     $field = (object) $field;
     $label = $field->name;
     $mandatory = $field->mandatory;
     $js_string = '';
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'dbst_wizard' . DS . 'js_validation' . DS . $field->type . '.php';
     $override_path = WPL_ABSPATH . DS . 'libraries' . DS . 'dbst_wizard' . DS . 'js_validation' . DS . 'overrides' . DS . $field->type . '.php';
     if (wpl_file::exists($override_path)) {
         $path = $override_path;
     }
     /** include file **/
     if (wpl_file::exists($path)) {
         include $path;
     }
     return $js_string;
 }
예제 #15
0
 /**
  * 
  * @author Howard R. <*****@*****.**>
  * @param string $wplpath
  * @param string $tpl
  * @param int $user_type
  * @return string
  */
 public static function get_user_type_tpl($wplpath, $tpl = NULL, $user_type = NULL)
 {
     if (!trim($tpl)) {
         $tpl = 'default';
     }
     if (is_null($user_type)) {
         return $tpl;
     }
     /** Create User Type tpl such as default_ut1.php etc. **/
     $user_type_tpl = $tpl . '_ut' . $user_type;
     $wplpath = rtrim($wplpath, '.') . '.' . $user_type_tpl;
     $path = _wpl_import($wplpath, true, true);
     if (wpl_file::exists($path)) {
         return $user_type_tpl;
     } else {
         return $tpl;
     }
 }
예제 #16
0
 /**
  * Import Settings from a file
  * @author Steve A. <*****@*****.**>
  * @static
  * @param  string  $file Settings File
  * @return boolean		 Result
  */
 public static function import_settings($file)
 {
     $content = wpl_file::read($file);
     $ext = wpl_file::getExt($file);
     if ($ext == 'json') {
         $settings = json_decode($content);
         if (!$settings) {
             return false;
         }
     } elseif ($ext == 'xml') {
         $settings = simplexml_load_string($content);
         if (!$settings) {
             return false;
         }
         $settings = (array) $settings;
     } else {
         return false;
     }
     foreach ($settings as $name => $value) {
         self::update_setting($name, $value);
     }
     return true;
 }
예제 #17
0
 /**
  * for importing internal files in object mode
  * @author Howard <*****@*****.**>
  * @param string $include
  * @param boolean $override
  * @param boolean $set_footer
  * @param boolean $once
  * @return void
  */
 protected function _wpl_import($include, $override = true, $set_footer = false, $once = false)
 {
     $path = _wpl_import($include, $override, true);
     /** check exists **/
     if (!wpl_file::exists($path)) {
         return;
     }
     if (!$set_footer) {
         if (!$once) {
             include $path;
         } else {
             include_once $path;
         }
     } else {
         ob_start();
         if (!$once) {
             include $path;
         } else {
             include_once $path;
         }
         wpl_html::set_footer(ob_get_clean());
     }
 }
예제 #18
0
 /**
  * Removes WPL cached data
  * @author Howard <*****@*****.**>
  * @static
  * @param type $cache_type
  * @return boolean
  */
 public static function clear_cache($cache_type = 'all')
 {
     /** first validation **/
     $cache_type = strtolower($cache_type);
     if (trim($cache_type) == '') {
         return false;
     }
     /** import libraries **/
     _wpl_import('libraries.property');
     _wpl_import('libraries.items');
     if ($cache_type == 'unfinalized_properties' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id` FROM `#__wpl_properties` WHERE `finalized`='0'", 'loadAssocList');
         foreach ($properties as $property) {
             wpl_property::purge($property['id']);
         }
     }
     if ($cache_type == 'properties_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`='', `alias`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('alias', 'location_text', 'rendered'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'location_texts' or $cache_type == 'all') {
         $q = " `location_text`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'listings_thumbnails' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id`, `kind` FROM `#__wpl_properties` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($properties as $property) {
             $path = wpl_items::get_path($property['id'], $property['kind']);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     if ($cache_type == 'users_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text', 'rendered'), 'wpl_users');
         }
         $query = "UPDATE `#__wpl_users` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'users_thumbnails' or $cache_type == 'all') {
         $users = wpl_db::select("SELECT `id` FROM `#__wpl_users` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($users as $user) {
             $path = wpl_items::get_path($user['id'], 2);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     /** trigger event **/
     wpl_global::event_handler('cache_cleared', array('cache_type' => $cache_type));
     return true;
 }
예제 #19
0
 /**
  * Renders videos
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $videos
  * @return array
  */
 public static function render_videos($videos = array())
 {
     /** force to array **/
     $videos = (array) $videos;
     $return = array();
     $i = 0;
     foreach ($videos as $video) {
         /** force to array **/
         $video = (array) $video;
         $return[$i]['item_id'] = $video['id'];
         $return[$i]['category'] = $video['item_cat'];
         if ($video['item_cat'] == 'video') {
             $video_path = self::get_path($video['parent_id'], $video['parent_kind']) . $video['item_name'];
             $video_url = self::get_folder($video['parent_id'], $video['parent_kind']) . $video['item_name'];
             /** existance check **/
             if (!wpl_file::exists($video_path)) {
                 continue;
             }
             $pathinfo = @pathinfo($video_path);
             $return[$i]['path'] = $video_path;
             $return[$i]['url'] = $video_url;
             $return[$i]['size'] = @filesize($video_path);
             $return[$i]['title'] = (string) $video['item_extra1'];
             $return[$i]['description'] = (string) $video['item_extra2'];
             $return[$i]['ext'] = $pathinfo['extension'];
         } elseif ($video['item_cat'] == 'video_embed') {
             $return[$i]['path'] = '';
             $return[$i]['url'] = (string) $video['item_extra2'];
             $return[$i]['size'] = '';
             $return[$i]['title'] = (string) $video['item_name'];
             $return[$i]['description'] = (string) $video['item_extra1'];
             $return[$i]['ext'] = '';
         }
         $return[$i]['raw'] = $video;
         $i++;
     }
     return $return;
 }
예제 #20
0
 /**
  * Compile SCSS file and convert it to CSS file
  * @author Howard <*****@*****.**>
  * @param string $input
  * @param string $output
  * @return boolean
  */
 public function compile_file($input, $output)
 {
     if (!trim($input) or !wpl_file::exists($input)) {
         return false;
     }
     if (!trim($output)) {
         return false;
     }
     $CSS = $this->scssc->compile(wpl_file::read($input));
     wpl_file::write($output, $CSS);
     return $CSS;
 }
예제 #21
0
 /**
 		@input $cmd string format name
 		@return format path
 	**/
 public function get_format_path($format)
 {
     $path = WPL_ABSPATH . 'libraries' . DS . 'io' . DS . $this->formats_folder . DS . 'overrides' . DS . $format . '.php';
     if (!wpl_file::exists($path)) {
         $path = WPL_ABSPATH . 'libraries' . DS . 'io' . DS . $this->formats_folder . DS . $format . '.php';
     }
     return $path;
 }
예제 #22
0
 private function remove_upload()
 {
     $setting_name = wpl_request::getVar('setting_name', '');
     $settings_value = wpl_settings::get($setting_name);
     $upload_src = wpl_global::get_wpl_asset_url('img/system/' . $settings_value);
     wpl_settings::save_setting($setting_name, NULL);
     wpl_file::delete($upload_src);
     /** Remove Thumbnails **/
     wpl_settings::clear_cache('listings_thumbnails');
     wpl_settings::clear_cache('users_thumbnails');
     $response = array('success' => 1, 'message' => __('Uploaded file removed successfully!', WPL_TEXTDOMAIN));
     echo json_encode($response);
     exit;
 }
예제 #23
0
 /**
  * Get language .mo path
  * @author Howard <*****@*****.**>
  * @static
  * @param string $locale
  * @return string
  */
 public static function get_language_mo_path($locale = NULL)
 {
     if (!$locale) {
         $locale = wpl_global::get_current_language();
     }
     $path = WP_LANG_DIR . DS . WPL_BASENAME . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo';
     if (!wpl_file::exists($path)) {
         $path = wpl_global::get_wpl_root_path() . 'languages' . DS . WPL_TEXTDOMAIN . '-' . $locale . '.mo';
     }
     return $path;
 }
예제 #24
0
 private function uploader()
 {
     $settings_key = wpl_request::getVar('settings_key', '');
     $file = wpl_request::getVar($settings_key, NULL, 'FILES');
     $filename = wpl_global::normalize_string($file['name']);
     $ext_array = array('jpg', 'png', 'gif', 'jpeg');
     $error = '';
     $message = '';
     if (!empty($file['error']) or (empty($file['tmp_name']) or $file['tmp_name'] == 'none')) {
         $error = __('An error ocurred uploading your file.', WPL_TEXTDOMAIN);
     } else {
         // check the extention
         $extention = strtolower(wpl_file::getExt($file['name']));
         if (!in_array($extention, $ext_array)) {
             $error = __('File extension should be jpg, png or gif.', WPL_TEXTDOMAIN);
         }
         if ($error == '') {
             $dest = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'system' . DS . $filename;
             wpl_file::upload($file['tmp_name'], $dest);
             wpl_settings::save_setting($settings_key, $filename);
         }
     }
     $response = array('error' => $error, 'message' => $message);
     echo json_encode($response);
     exit;
 }
예제 #25
0
 /**
  * Uninstalling WPL
  * @author Howard <*****@*****.**>
  * @return boolean
  */
 public function uninstall_wpl()
 {
     $tables = wpl_db::select('SHOW TABLES');
     $database = wpl_db::get_DBO();
     foreach ($tables as $table_name => $table) {
         if (strpos($table_name, $database->prefix . 'wpl_') !== false) {
             /** drop table **/
             wpl_db::q("DROP TABLE `{$table_name}`");
         }
     }
     /** delete options **/
     wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete');
     /** remove WPL upload directory **/
     if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) {
         $original_blog_id = wpl_global::get_current_blog_id();
         // Get all blogs
         $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn');
         foreach ($blogs as $blog) {
             if (!isset($blog->blog_id)) {
                 continue;
             }
             switch_to_blog($blog->blog_id);
             $upload_path = wpl_global::get_upload_base_path($blog->blog_id);
             if (wpl_folder::exists($upload_path)) {
                 wpl_folder::delete($upload_path);
             }
         }
         switch_to_blog($original_blog_id);
     } else {
         $upload_path = wpl_global::get_upload_base_path();
         if (wpl_file::exists($upload_path)) {
             wpl_file::delete($upload_path);
         }
     }
     return true;
 }
 private function gicon_delete($icon)
 {
     if (trim($icon) == '') {
         $icon = wpl_request::getVar('icon');
     }
     $dest = WPL_ABSPATH . 'assets' . DS . 'img' . DS . 'listing_types' . DS . 'gicon' . DS . $icon;
     if (wpl_file::exists($dest)) {
         wpl_file::delete($dest);
     }
     /** trigger event **/
     wpl_global::event_handler('gicon_removed', array('icon' => $icon));
     exit;
 }
예제 #27
0
 /**
  * Removes user thumbnails
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @return boolean
  */
 public static function remove_thumbnails($user_id)
 {
     /** first validation **/
     if (!trim($user_id)) {
         return false;
     }
     $ext_array = array('jpg', 'jpeg', 'gif', 'png');
     $path = wpl_items::get_path($user_id, 2);
     $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
     foreach ($thumbnails as $thumbnail) {
         wpl_file::delete($thumbnail);
     }
     return true;
 }
예제 #28
0
 /**
  * Executes all cronjobs
  * @author Howard <*****@*****.**>
  * @param array $params
  * @return boolean
  */
 public static function do_cronjobs($params = array())
 {
     $cronjobs = self::get_cronjobs(1);
     foreach ($cronjobs as $cronjob) {
         /** generate all params **/
         $all_params = array();
         $all_params[0] = $params;
         $all_params[1] = json_decode($cronjob->params, true);
         $all_params[2] = $cronjob;
         /** import class **/
         $path = _wpl_import($cronjob->class_location, true, true);
         if (!wpl_file::exists($path)) {
             continue;
         }
         include_once $path;
         /** call function **/
         $cron_obj = new $cronjob->class_name();
         call_user_func(array($cron_obj, $cronjob->function_name), $all_params);
         /** update cronjob latest run **/
         self::update_cronjob_latest_run($cronjob->id);
     }
     return true;
 }