Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * Use this function for creating query
  * @author Howard <*****@*****.**>
  * @param array $vars
  * @param string $needle_str
  * @return string $query
  */
 public static function create_query($vars = '', $needle_str = 'sf_')
 {
     if (!$vars) {
         $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     }
     /** clean vars **/
     $vars = wpl_global::clean($vars);
     $query = '';
     /** this is to include any customized and special form fields conditions **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'create_query';
     $path_exists = wpl_folder::exists($path);
     $find_files = array();
     if ($path_exists) {
         $files = wpl_folder::files($path, '.php$');
     }
     foreach ($vars as $key => $value) {
         /** escape value **/
         $value = wpl_db::escape($value);
         if (strpos($key, $needle_str) === false) {
             continue;
         }
         $ex = explode('_', $key);
         $format = $ex[1];
         $table_column = str_replace($needle_str . $format . '_', '', $key);
         $done_this = false;
         /** using detected files **/
         if (isset($find_files[$format])) {
             include $path . DS . $find_files[$format];
             continue;
         }
         foreach ($files as $file) {
             include $path . DS . $file;
             if ($done_this) {
                 /** add to detected files **/
                 $find_files[$format] = $file;
                 break;
             }
         }
     }
     return $query = trim($query, ' ,');
 }
Beispiel #3
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;
 }
Beispiel #4
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;
 }
Beispiel #5
0
 /**
  * Get The List of Layouts in the Widget
  * @author Howard <*****@*****.**>
  * @static
  * @param string $widget_name
  * @return array
  */
 public static function get_layouts($widget_name)
 {
     $path = WPL_ABSPATH . 'widgets' . DS . $widget_name . DS . 'tmpl';
     return wpl_folder::files($path, '.php', false, false);
 }
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wpl_writable ? __('Yes', WPL_TEXTDOMAIN) : __('No', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
            	<i class="icon-<?php 
echo $wpl_writable ? 'confirm' : 'danger';
?>
"></i>
            </span>
		</li>
        <!-- WPL temporary directory permission -->
        <?php 
$wpl_tmp_writable = wpl_folder::exists(wpl_global::init_tmp_folder()) ? true : false;
?>
        <li>
        	<span class="wpl-requirement-name"><?php 
echo __('tmp directory', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-require"><?php 
echo __('Writable', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wpl_tmp_writable ? __('Yes', WPL_TEXTDOMAIN) : __('No', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
Beispiel #7
0
 /**
  * Generate search fields based on DBST fields
  * @author Steve A. <*****@*****.**>
  * @param  array  $fields
  * @param  array  $finds
  * @return array
  */
 public function generate_search_fields($fields, $finds = array())
 {
     $fields = json_decode(json_encode($fields), true);
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend';
     $files = array();
     $widget_id = '';
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     $rendered = array();
     foreach ($fields as $key => $field) {
         $type = $field['type'];
         $field_id = $field['id'];
         $field_data = $field;
         $options = json_decode($field['options'], true);
         $done_this = false;
         $html = '';
         if (isset($finds[$type])) {
             $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
             include $path . DS . $finds[$type];
             $html .= '</span> ';
             $rendered[$field_id]['id'] = $field_id;
             $rendered[$field_id]['field_options'] = json_decode($field['options'], true);
             $rendered[$field_id]['html'] = $html;
             $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
             continue;
         }
         $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             /** proceed to next field **/
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         $html .= '</span> ';
         $rendered[$field_id]['id'] = $field_id;
         $rendered[$field_id]['field_options'] = json_decode($field['options'], true);
         $rendered[$field_id]['html'] = $html;
         $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
     }
     return $rendered;
 }
Beispiel #8
0
/** no direct access **/
defined('_WPLEXEC') or die('Restricted access');
if ($type == 'locations' and !$done_this) {
    /** import library **/
    _wpl_import('libraries.locations');
    $location_settings = wpl_global::get_settings('3');
    # location settings
    switch ($field['type']) {
        case 'simple':
            if ($location_settings['location_method'] == 2) {
                $show = 'simple_location_database';
            } else {
                $show = 'simple_location_text';
            }
            break;
        default:
            $show = $field['type'];
            break;
    }
    /** Place-holder **/
    $placeholder = (isset($field['extoption']) and trim($field['extoption'])) ? $field['extoption'] : $location_settings['locationzips_keyword'] . ', ' . $location_settings['location3_keyword'] . ', ' . $location_settings['location1_keyword'];
    $location_path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend' . DS . 'location_items';
    $location_files = array();
    if (wpl_folder::exists($location_path)) {
        $location_files = wpl_folder::files($location_path, '.php$');
    }
    foreach ($location_files as $location_file) {
        include $location_path . DS . $location_file;
    }
}
Beispiel #9
0
 /**
  * Get layouts
  * @author Howard <*****@*****.**>
  * @static
  * @param string $view
  * @param array $exclude
  * @param string $client
  * @return array
  */
 public static function get_layouts($view = 'property_listing', $exclude = array('message.php'), $client = 'frontend')
 {
     $path = WPL_ABSPATH . 'views' . DS . $client . DS . $view . DS . 'tmpl';
     $files = wpl_folder::files($path, '.php', false, false);
     $layouts = array();
     foreach ($files as $file) {
         if (in_array($file, $exclude) or strpos($file, '_k') !== false) {
             continue;
         }
         $layouts[] = strtolower(basename($file, '.php'));
     }
     return $layouts;
 }
Beispiel #10
0
 public function render_search_fields($instance, $widget_id, $finds = array())
 {
     /** first validation **/
     if (!$instance) {
         return array();
     }
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend';
     $files = array();
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     $fields = $instance['data'];
     uasort($fields, array('wpl_global', 'wpl_array_sort'));
     $rendered = array();
     foreach ($fields as $key => $field) {
         /** proceed to next field if field is not enabled **/
         if (!isset($field['enable']) or isset($field['enable']) and $field['enable'] != 'enable') {
             continue;
         }
         /** Fix empty id issue **/
         if ((!isset($field['id']) or isset($field['id']) and !$field['id']) and $key) {
             $field['id'] = $key;
         }
         $field_data = (array) wpl_flex::get_field($field['id']);
         if (!$field_data) {
             continue;
         }
         $field['name'] = $field_data['name'];
         $type = $field_data['type'];
         $field_id = $field['id'];
         $options = json_decode($field_data['options'], true);
         $display = '';
         $done_this = false;
         $html = '';
         /** listing and property type specific **/
         if (trim($field_data['listing_specific']) != '') {
             $specified_listings = explode(',', trim($field_data['listing_specific'], ', '));
             $this->listing_specific_array[$field_data['id']] = $specified_listings;
         } elseif (trim($field_data['property_type_specific']) != '') {
             $specified_property_types = explode(',', trim($field_data['property_type_specific'], ', '));
             $this->property_type_specific_array[$field_data['id']] = $specified_property_types;
         }
         /** Accesses **/
         if (trim($field_data['accesses']) != '') {
             $accesses = explode(',', trim($field_data['accesses'], ', '));
             $cur_membership_id = wpl_users::get_user_membership();
             if (!in_array($cur_membership_id, $accesses)) {
                 continue;
             }
         }
         if (isset($finds[$type])) {
             $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
             include $path . DS . $finds[$type];
             $html .= '</div>';
             $rendered[$field_id]['id'] = $field_id;
             $rendered[$field_id]['field_data'] = $field_data;
             $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
             $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
             $rendered[$field_id]['html'] = $html;
             $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
             $rendered[$field_id]['display'] = $display;
             continue;
         }
         $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '" style="' . $display . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             /** proceed to next field **/
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         $html .= '</div>';
         $rendered[$field_id]['id'] = $field_id;
         $rendered[$field_id]['field_data'] = $field_data;
         $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
         $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
         $rendered[$field_id]['html'] = $html;
         $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
         $rendered[$field_id]['display'] = $display;
     }
     return $rendered;
 }
Beispiel #11
0
 /**
  * Returns item directory path. If it's not exist it creates the directory 
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $parent_id
  * @param int $kind
  * @return string
  */
 public static function get_path($parent_id, $kind = 0)
 {
     if ($kind == 2) {
         $path = wpl_global::get_upload_base_path() . 'users' . DS . $parent_id . DS;
     } else {
         $path = wpl_global::get_upload_base_path() . $parent_id . DS;
     }
     if (!wpl_folder::exists($path)) {
         wpl_folder::create($path);
     }
     return $path;
 }
Beispiel #12
0
 /**
 		@input void
 		@return available formats
 		@description use this function for getting available formats
 	**/
 public function get_formats()
 {
     $files = wpl_folder::files($this->get_formats_path(), '.php$', false, false);
     $commands = array();
     foreach ($files as $file) {
         $ex = explode('.', $file);
         $commands[] = $ex[0];
     }
     return $commands;
 }
Beispiel #13
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;
 }
Beispiel #14
0
 /**
  * Moves an uploaded file to a destination folder
  * @author Howard <*****@*****.**>
  * @param string $src
  * @param string $dest
  * @return boolean
  */
 public static function upload($src, $dest)
 {
     // Ensure that the path is valid and clean
     $dest = wpl_path::clean($dest);
     $baseDir = dirname($dest);
     if (!file_exists($baseDir)) {
         wpl_folder::create($baseDir);
     }
     if (is_writable($baseDir) && move_uploaded_file($src, $dest)) {
         // Short circuit to prevent file permission errors
         if (wpl_path::setPermissions($dest)) {
             $ret = true;
         } else {
             $ret = false;
         }
     } else {
         $ret = false;
     }
     return $ret;
 }
Beispiel #15
0
 /**
  * get All Activities in Activity folder and remove Backend Activity
  * @author Kevin J <*****@*****.**>
  * @return array list of Frontend activity list
  */
 public static function get_available_activities()
 {
     $activities_folders = wpl_folder::folders(wpl_activity::get_activity_folder());
     $frontend_activity = array();
     foreach ($activities_folders as $activity) {
         if (wpl_activity::check_activity($activity, wpl_activity::ACTIVITY_FRONTEND)) {
             $frontend_activity[] = $activity;
         }
     }
     return $frontend_activity;
 }