function get_quotes($params = array()) { if (is_string($params)) { $params = parse_params($params); } $params['table'] = "ez_quotes"; return db_get($params); }
public function get($params = array()) { if (is_string($params)) { $params = parse_params($params); } $table = $this->table; $params['table'] = $table; $get = $this->app->database_manager->get($params); return $get; }
public function save($params) { $table = $this->table; $params = parse_params($params); $params['user_ip'] = MW_USER_IP; $params['table'] = $table; $save = $this->app->database_manager->save($params); $id = $save; $this->app->cache_manager->delete('log' . DIRECTORY_SEPARATOR . 'global'); return $id; }
public function save($params) { if (is_string($params)) { $params = parse_params($params); } if ($params == false) { return; } $table = $this->table; $params['table'] = $table; $save = $this->app->database_manager->save($params); return $save; }
public function save($params) { if (is_string($params)) { $params = parse_params($params); } if ($params == false) { return; } if (!$this->has_permission($params)) { return; } $table = $this->table; $params['table'] = $table; $save = parent::save($params); return $save; }
public function save($data) { if (!is_array($data)) { $data = parse_params($data); } if (!isset($data['id'])) { if (!isset($data['attribute_name'])) { return array('error' => "You must set 'field' parameter"); } if (!isset($data['attribute_value'])) { return array('error' => "You must set 'value' parameter"); } } if (!isset($data['rel_type']) and isset($data['content_id'])) { $data['rel_type'] = 'content'; $data['rel_id'] = $data['content_id']; } if (isset($data['attribute_name']) and isset($data['rel_id']) and isset($data['rel_type'])) { $is_existing_data = array(); $is_existing_data['attribute_name'] = $data['attribute_name']; $is_existing_data['rel_id'] = $data['rel_id']; $is_existing_data['rel_type'] = $data['rel_type']; $is_existing_data['one'] = true; $is_existing = $this->get($is_existing_data); if (is_array($is_existing) and isset($is_existing['id'])) { $data['id'] = $is_existing['id']; } } if (isset($data['content_id'])) { $data['rel_id'] = intval($data['content_id']); } if (isset($data['attribute_value']) and is_array($data['attribute_value'])) { $data['attribute_value'] = json_encode($data['attribute_value']); $data['attribute_type'] = 'array'; } if (!isset($data['rel_type'])) { $data['rel_type'] = 'content'; } if (isset($data['rel_type']) and $data['rel_type'] == 'content') { if (isset($data['rel_id'])) { $data['content_id'] = $data['rel_id']; } } $save = parent::save($data); return $save; }
function link_to($link, $text, $title, $params) { $link = '<a href="' . $link . '" '; if ($title) { $link .= 'title="' . $title . '" '; } else { $link .= 'title="' . $text . '"'; } if (is_array($params)) { foreach ($params as $param) { $link .= parse_params($param); } } else { $link .= parse_params($params); } $link .= '>' . $text . '</a>'; return $link; }
/** * array( 'method' => 'foo', 'params' => array( 'a' => null, ), 'is_public'=>1, 'is_return'=>0, 'testcase' => array( array('input'=>array('a'=>1), 'output'=>null), ), ) */ function main($args) { if (empty($args[1])) { echo "filepath is require\n"; return; } $class_path = $args[1]; if (!file_exists($class_path)) { echo sprintf("path %s is not exits!\n", $class_path); return; } $buf = file_get_contents($class_path); $n = preg_match_all('/([a-z|\\s]+)function\\s+([^\\s|\\(|\\{)]+)\\s*\\(([^)]+)\\)/', $buf, $match); $methods = array(); $method_empty = array('method' => '', 'params' => array(), 'is_public' => 0, 'is_return' => 0, 'is_static' => 0, 'testcase' => array()); if ($n > 0) { for ($i = 0; $i < $n; $i++) { $row = $method_empty; $row['method'] = $match[2][$i]; $row['params'] = parse_params($match[3][$i]); //var_dump($row); } } }
/** * Generic save data function, it saves data to the database * * @param $table * @param $data * @param bool $data_to_save_options * @return string|int The id of the saved row. * * @example * <code> * $table = $this->table_prefix.'content'; * $data = array(); * $data['id'] = 0; //if 0 will create new content * $data['title'] = 'new title'; * $data['content'] = '<p>Something</p>'; * $save = save($table, $data); * </code> * @package Database */ public function save($table, $data = false, $data_to_save_options = false) { if (is_array($table) and isset($table['table'])) { $data = $table; $table = $table['table']; unset($data['table']); } if (is_string($data)) { $data = parse_params($data); } if (!is_array($data)) { return false; } $original_data = $data; $is_quick = isset($original_data['quick_save']); $skip_cache = isset($original_data['skip_cache']); if (!isset($params['skip_timestamps'])) { if (!isset($params['id']) or isset($params['id']) and $params['id'] == 0) { if (!isset($params['created_at'])) { $params['created_at'] = date("Y-m-d H:i:s"); } } if (!isset($params['updated_at'])) { $params['updated_at'] = date("Y-m-d H:i:s"); } } if ($is_quick == false) { if (isset($data['updated_at']) == false) { $data['updated_at'] = date("Y-m-d H:i:s"); } } if ($skip_cache == false and isset($data_to_save_options) and !empty($data_to_save_options)) { if (isset($data_to_save_options['delete_cache_groups']) and !empty($data_to_save_options['delete_cache_groups'])) { foreach ($data_to_save_options['delete_cache_groups'] as $item) { $this->app->cache_manager->delete($item); } } } $user_sid = mw()->user_manager->session_id(); $the_user_id = mw()->user_manager->id(); if (!isset($data['session_id']) and $user_sid) { $data['session_id'] = $user_sid; } if (!isset($data['id'])) { $data['id'] = 0; } if (isset($data['cf_temp'])) { $cf_temp = $data['cf_temp']; } $allow_html = false; $allow_scripts = false; if (isset($data['allow_html']) and !isset($_REQUEST['allow_html'])) { $allow_html = $data['allow_html']; } if (isset($data['allow_scripts']) and !isset($_REQUEST['allow_scripts'])) { $allow_scripts = $data['allow_scripts']; } if (isset($data['debug']) and $data['debug'] == true) { $dbg = 1; unset($data['debug']); } else { $dbg = false; } if ($dbg != false) { var_dump($data); } $data['user_ip'] = MW_USER_IP; if (isset($data['id']) == false or $data['id'] == 0) { $data['id'] = 0; $l = $this->last_id($table); $data['new_id'] = intval($l + 1); $original_data['new_id'] = $data['new_id']; } if (!isset($the_user_id)) { $the_user_id = 0; } if (intval($data['id']) == 0) { if (isset($data['created_at']) == false) { $data['created_at'] = date("Y-m-d H:i:s"); } if ($the_user_id) { $data['created_by'] = $the_user_id; } if ($the_user_id) { $data['edited_by'] = $the_user_id; } } else { if ($the_user_id) { $data['edited_by'] = $the_user_id; } } if (isset($data['position'])) { $data['position'] = intval($data['position']); } $table_assoc_name = $this->assoc_table_name($table); $criteria_orig = $data; $criteria = $this->map_array_to_table($table, $data); if ($allow_html == false) { $criteria = $this->app->format->clean_html($criteria); } else { if ($allow_scripts == false) { $criteria = $this->clean_input($criteria); } } $table = $this->app->format->clean_html($table); $criteria = $this->app->url_manager->replace_site_url($criteria); if ($data_to_save_options['use_this_field_for_id'] != false) { $criteria['id'] = $criteria_orig[$data_to_save_options['use_this_field_for_id']]; } if ($dbg != false) { var_dump($criteria); } if (!isset($criteria['id'])) { $criteria['id'] = 0; } $criteria['id'] = intval($criteria['id']); if (intval($criteria['id']) == 0) { unset($criteria['id']); $id_to_return = $this->table($table_assoc_name)->insert($criteria); $id_to_return = $this->last_id($table); } else { $id_to_return = $this->table($table_assoc_name)->where('id', $criteria['id'])->update($criteria); $id_to_return = $criteria['id']; } if ($id_to_return == false) { $id_to_return = $this->last_id($table); } $id_to_return = intval($id_to_return); $original_data['table'] = $table; $original_data['id'] = $id_to_return; $cache_group = $this->assoc_table_name($table); $this->app->cache_manager->delete($cache_group); if ($skip_cache == false) { $cache_group = $this->assoc_table_name($table); $this->app->cache_manager->delete($cache_group . '/global'); $this->app->cache_manager->delete($cache_group . '/' . $id_to_return); if (isset($criteria['parent_id'])) { $this->app->cache_manager->delete($cache_group . '/' . intval($criteria['parent_id'])); } } return $id_to_return; }
public function get($params) { $table = $this->tables['media']; if ($params != false and !is_array($params) and intval($params) > 0) { $params2 = array(); $params2['rel_type'] = 'content'; $params2['rel_id'] = intval($params); $params = $params2; } else { $params = parse_params($params); } if (!isset($params['rel_type']) and isset($params['for'])) { $params['rel_type'] = $this->app->database_manager->assoc_table_name($params['for']); } if (!isset($params['rel_type'])) { $params['rel_type'] = 'content'; } if (!isset($params['limit'])) { $params['limit'] = "nolimit"; } $params['table'] = $table; $params['order_by'] = 'position ASC'; $data = $this->app->database_manager->get($params); if (media_base_url()) { if (!empty($data)) { $return = array(); foreach ($data as $item) { if (isset($item['filename']) and $item['filename'] != false) { if (!stristr($item['filename'], '{SITE_URL}') and !stristr($item['filename'], '{MEDIA_URL}') and !stristr($item['filename'], '://') and !stristr($item['filename'], media_base_url())) { $item['filename'] = media_base_url() . $item['filename']; } } if (isset($item['title']) and $item['title'] != '') { $item['title'] = html_entity_decode($item['title']); $item['title'] = strip_tags($item['title']); $item['title'] = $this->app->format->clean_html($item['title']); } $return[] = $item; } $data = $return; } } return $data; }
public function get($table, $id = 0, $return_full = false, $field_for = false, $debug = false, $field_type = false, $for_session = false) { $params = array(); $no_cache = false; $table_assoc_name = false; // $id = intval ( $id ); if (is_string($table)) { $params = $params2 = parse_params($table); if (!is_array($params2) or is_array($params2) and count($params2) < 2) { $id = trim($id); $table = $this->app->database_manager->escape_string($table); if ($table != false) { $table_assoc_name = $this->app->database_manager->assoc_table_name($table); } else { $table_assoc_name = 'MW_ANY_TABLE'; } if ($table_assoc_name == false) { $table_assoc_name = $this->app->database_manager->assoc_table_name($table_assoc_name); } $params['rel_type'] = $table_assoc_name; } else { $params = $params2; } } elseif (is_array($table)) { $params = $table; } $params = $this->unify_params($params); if (!isset($table_assoc_name)) { if (isset($params['for'])) { $params['rel_type'] = $table_assoc_name = $this->app->database_manager->assoc_table_name($params['for']); } } else { // $params['rel_type'] = $table_assoc_name; } if (isset($params['debug'])) { $debug = $params['debug']; } if (isset($params['for'])) { if (!isset($params['rel_type']) or $params['rel_type'] == false) { $params['for'] = $params['rel_type']; } } if (isset($params['for_id'])) { $params['rel_id'] = $id = $this->app->database_manager->escape_string($params['for_id']); } if (isset($params['field_type'])) { $params['type'] = $params['field_type']; } if (isset($params['field_value'])) { $params['value'] = $params['field_value']; } if (isset($params['no_cache'])) { $no_cache = $params['no_cache']; } if (isset($params['return_full'])) { $return_full = $params['return_full']; } if (isset($params['is_active']) and strtolower(trim($params['is_active'])) == 'any') { } elseif (isset($params['is_active']) and $params['is_active'] == 0) { $custom_field_is_active = 0; } else { $custom_field_is_active = 1; } $table_custom_field = $this->table; $params['table'] = $table_custom_field; if (isset($custom_field_is_active)) { $params['is_active'] = $custom_field_is_active; } if (strval($table_assoc_name) != '') { if ($field_for != false) { $field_for = trim($field_for); $field_for = $this->app->database_manager->escape_string($field_for); $params['name'] = $field_for; } if (isset($params['rel_type']) and $params['rel_type'] == 'MW_ANY_TABLE') { unset($params['rel_type']); } $sidq = ''; if (intval($id) == 0 and $for_session != false) { if (is_admin() != false) { $sid = mw()->user_manager->session_id(); $params['session_id'] = $sid; } } if ($id != 'all' and $id != 'any') { $id = $this->app->database_manager->escape_string($id); $params['rel_id'] = $id; } } if (isset($params['content'])) { unset($params['content']); } if (!isset($params['order_by']) and !isset($params['orderby'])) { $params['order_by'] = 'position asc'; } if (empty($params)) { return false; } $q = $this->app->database_manager->get($params); if (!empty($q)) { $get_values = array(); $fields = array(); foreach ($q as $k => $v) { $get_values[] = $v['id']; } $vals = $this->get_values($get_values); foreach ($q as $k => $v) { if (isset($v['options']) and is_string($v['options'])) { $v['options'] = $this->_decode_options($v['options']); } $default_values = $v; $default_values['values_plain'] = ''; $default_values['value'] = ''; $default_values['values'] = array(); if (!empty($vals)) { foreach ($vals as $val) { if ($val['custom_field_id'] == $v['id']) { $default_values['value'][] = $val['value']; $default_values['values'][] = $val['value']; } } } if (!empty($default_values['value'])) { $default_values['value_plain'] = implode(',', $default_values['value']); if (count($default_values['value']) == 1) { $default_values['value'] = reset($default_values['value']); } } else { $default_values['value'] = false; } $fields[$k] = $default_values; } $q = $fields; } if (isset($params['fields'])) { return $q; } if (!empty($q)) { $the_data_with_custom_field__stuff = array(); if ($return_full == true) { $to_ret = array(); $i = 1; foreach ($q as $it) { $it = $this->decode_array_vals($it); // $it['type'] = $it['type']; $it['position'] = $i; if (isset($it['options']) and is_string($it['options'])) { // $it['options'] = $this->_decode_options($it['options']); } $it['title'] = $it['name']; $to_ret[] = $it; ++$i; } return $to_ret; } $append_this = array(); if (is_array($q) and !empty($q)) { foreach ($q as $q2) { $i = 0; $the_name = false; $the_val = false; foreach ($q2 as $cfk => $cfv) { if ($cfk == 'name') { $the_name = $cfv; } if ($cfk == 'value') { $the_val = $cfv; } ++$i; } if ($the_name != false and $the_val !== null) { if ($return_full == false) { $the_name = strtolower($the_name); $the_data_with_custom_field__stuff[$the_name] = $the_val; } else { $the_data_with_custom_field__stuff[$the_name] = $q2; } } } } $result = $the_data_with_custom_field__stuff; //$result = (array_change_key_case($result, CASE_LOWER)); $result = $this->app->url_manager->replace_site_url_back($result); // return $result; } return $q; }
function mw_send_anonymous_server_data($params) { only_admin_access(); $update_api = mw('update'); if ($params != false) { $params = parse_params($params); } if (method_exists($update_api, 'send_anonymous_server_data')) { $iudates = $update_api->send_anonymous_server_data($params); return $iudates; } else { $params['site_url'] = site_url(); $result = $update_api->call('send_anonymous_server_data', $params); return $result; } }
} // true for nginx } $doc_path = 'http' . (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); $base_path = MOD_REWRITE ? $doc_path : $doc_path . '/' . SCRIPT_NAME; ini_set('session.gc_maxlifetime', 7776000); ini_set('session.cookie_lifetime', 7776000); session_set_cookie_params(7776000); session_start(); //if( $_SERVER['HTTP_HOST'] == 'localhost' ) $userid = 'test'; if (isset($_SESSION['user_id'])) { $userid = $_SESSION['user_id']; } $message = ''; $api = isset($_REQUEST['api']); $params = parse_params(); $action = $params['action']; $bbcode = $params['bbcode']; $title = $params['title']; if (isset($params['id'])) { $scodeid = $params['id']; } if (isset($params['editid'])) { $seditid = $params['editid']; } $data = false; if (isset($scodeid)) { $data = get_data($scodeid); if (!$data) { if ($api) { return_json(array('error' => 'No such code: ' . $scodeid));
/** * \Files\Api::get * * Get an array that represents directory and files * * @package modules * @subpackage files * @subpackage files\api * @category files module api * @version 1.0 * @since 0.320 * @return mixed Array with files * * @param array $params = array() the params * @param string $params['directory'] The directory * @param string $params['keyword'] If set it will seach the dir and subdirs */ static function get($params) { if (is_admin() == false) { mw_error("Must be admin"); } $params = parse_params($params); if (!isset($params['directory'])) { mw_error("You must define directory"); } else { $directory = $params['directory']; } $from_search = 0; $arrayItems = array(); if (isset($params['search']) and strval($params['search']) != '') { $from_search = 1; $arrayItems_search = rglob($pattern = DS . '*' . $params['search'] . '*', $flags = 0, $directory); } else { //$paths = glob($directory . DS . '*', GLOB_ONLYDIR | GLOB_NOSORT); //$files = glob($directory . DS . '*', 0); //$arrayItems_search = array_merge($paths, $files); if (!is_dir($directory . DS)) { return false; } $arrayItems_search = array(); $myDirectory = opendir($directory . DS); // get each entry while ($entryName = readdir($myDirectory)) { if ($entryName != '..' and $entryName != '.') { $arrayItems_search[] = $entryName; } } // close directory closedir($myDirectory); } if (!empty($arrayItems_search)) { if (isset($params['sort_by']) and strval($params['sort_by']) != '') { if (isset($params['sort_order']) and strval($params['sort_order']) != '') { $ord = SORT_DESC; if (strtolower($params['sort_order']) == 'asc') { $ord = SORT_ASC; } array_multisort(array_map($params['sort_by'], $arrayItems_search), SORT_NUMERIC, $ord, $arrayItems_search); // d($arrayItems_search); } } //usort($myarray, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); $arrayItems_f = array(); $arrayItems_d = array(); foreach ($arrayItems_search as $file) { if ($from_search == 0) { $file = $directory . DS . $file; } if (is_file($file)) { $df = normalize_path($file, false); if (!in_array($df, $arrayItems_f)) { $arrayItems_f[] = $df; } } else { $df = normalize_path($file, 1); if (!in_array($df, $arrayItems_d)) { $arrayItems_d[] = $df; } } } $arrayItems['files'] = $arrayItems_f; $arrayItems['dirs'] = $arrayItems_d; } return $arrayItems; }
public function get($params = false) { $params = parse_params($params); $return = array(); $is_sys_log = false; if (isset($params['id'])) { $is_log = substr(strtolower($params['id']), 0, 4); if ($is_log == 'log_') { $is_sys_log = 1; $is_log_id = str_ireplace('log_', '', $params['id']); $log_entr = $this->app->log_manager->get_entry_by_id($is_log_id); if ($log_entr != false and isset($params['one'])) { return $log_entr; } else { if ($log_entr != false) { $return[] = $log_entr; } } } } if (isset($params['rel'])) { $params['rel_type'] = $params['rel']; } if ($is_sys_log == false) { $table = $this->table; $params['table'] = $table; $params['order_by'] = 'id desc'; $return = $this->app->database_manager->get($params); } return $return; }
/** * update_order * * updates order by parameters * * @package modules * @subpackage shop * @subpackage shop\orders * @category shop module api */ public function update_order($params = false) { $params2 = array(); if ($params == false) { $params = array(); } if (is_string($params)) { $params - parse_params($params); } if (isset($params['is_paid'])) { if ($params['is_paid'] == 'y') { $params['is_paid'] = 1; } elseif ($params['is_paid'] == 'n') { $params['is_paid'] = 0; } } $table = $this->tables['cart_orders']; $params['table'] = $table; $this->app->cache_manager->delete('cart_orders'); return $this->app->database_manager->save($table, $params); }
public function get_lists($params) { $params = parse_params($params); $table = MW_DB_TABLE_FORMS_LISTS; $params['table'] = $table; return $this->app->database_manager->get($params); }
public function get_saved_modules_as_template($params) { $params = parse_params($params); if ($this->app->user_manager->is_admin() == false) { return false; } $table = MW_DB_TABLE_MODULE_TEMPLATES; $params['table'] = $table; $data = $this->app->database_manager->get($params); return $data; }
function template_save_css($params) { $is_admin = $this->app->user_manager->is_admin(); if ($is_admin == false) { return false; } if (is_string($params)) { $params = parse_params($params); } $ref_page = false; if (!isset($params['active_site_template'])) { if (!isset($params['content_id'])) { if (isset($_SERVER['HTTP_REFERER'])) { $ref_page_url = $_SERVER['HTTP_REFERER']; if ($ref_page_url != '') { $ref_page_url_rel = str_ireplace(site_url(), '', $ref_page_url); if ($ref_page_url_rel == '') { $ref_page1 = $this->app->content_manager->homepage(); } else { $ref_page1 = $this->app->content_manager->get_by_url($ref_page_url, true); } if (isset($ref_page1['id'])) { $ref_page = $this->app->content_manager->get_by_id(intval($ref_page1['id'])); } } } } else { $ref_page = $this->app->content_manager->get_by_id(intval($params['content_id'])); } if (isset($ref_page['id']) and isset($ref_page['content_type']) and $ref_page['content_type'] != 'page') { $ref_page_parent = $this->app->content_manager->get_by_id(intval($ref_page['id'])); if (isset($ref_page_partent['parent']) and intval($ref_page_partent['parent']) != 0) { $ref_page = $this->app->content_manager->get_by_id(intval($ref_page_partent['id'])); } else { $ref_page_parents = $this->app->content_manager->get_parents(intval($ref_page['id'])); if (!empty($ref_page_parents)) { $ref_page_parent = array_pop($ref_page_parents); $ref_page = $this->app->content_manager->get_by_id($ref_page_parent); } } } } else { $ref_page = $params; } if (!is_array($ref_page) or empty($ref_page)) { return false; } $pd = $ref_page; if ($is_admin == true and is_array($pd)) { $save_page = $pd; if (isset($save_page["layout_file"]) and $save_page["layout_file"] == 'inherit') { $inherit_from_id = $this->app->content_manager->get_inherited_parent($save_page["id"]); $inherit_from = $this->app->content_manager->get_by_id($inherit_from_id); if (is_array($inherit_from) and isset($inherit_from['active_site_template'])) { $save_page['active_site_template'] = $inherit_from['active_site_template']; $save_page['layout_file'] = $inherit_from['layout_file']; } } $template = false; if (!isset($save_page['active_site_template']) or $save_page['active_site_template'] == '') { $template = 'default'; } else { if (isset($save_page['active_site_template'])) { $template = $save_page['active_site_template']; } } if ($template == 'default') { $site_template_settings = $this->app->option_manager->get('current_template', 'template'); if ($site_template_settings != false and $site_template_settings != 'default') { $template = $site_template_settings; } } $final_file_blocks = array(); if ($template != false) { if (isset($_POST['save_template_settings'])) { $json = json_encode($_POST); $option = array(); $option['option_value'] = $json; $option['option_key'] = 'template_settings'; $option['option_group'] = 'template_' . $template; save_option($option); } $template_folder = templates_path() . $template . DS; $template_url = templates_url() . $template . '/'; $this_template_url = THIS_TEMPLATE_URL; $template_folder = userfiles_path() . 'css' . DS . $template . DS; if (!is_dir($template_folder)) { mkdir_recursive($template_folder); } $live_edit_css = $template_folder . 'live_edit.css'; $fcont = ''; if (is_file($live_edit_css)) { $fcont = file_get_contents($live_edit_css); } $css_cont = $fcont; $css_cont_new = $css_cont; //@import on top $sort_params = array(); $sort_params2 = array(); foreach ($params as $item) { if (isset($item['selector']) and trim($item['selector']) == '@import' and isset($item["value"])) { if ($item['value'] != 'reset') { $sort_params[] = $item; } } else { $sort_params2[] = $item; } } $params = array_merge($sort_params, $sort_params2); foreach ($params as $item) { $curr = ""; if (!isset($item["css"]) and isset($item["property"]) and isset($item['value'])) { if ($item['value'] == 'reset') { $item["css"] = 'reset'; } else { if (isset($item['selector']) and trim($item['selector']) == '@import' and isset($item["value"])) { $props = explode(',', $item['property']); foreach ($props as $prop) { $curr .= $prop . " " . $item['value'] . ";"; } } else { $props = explode(',', $item['property']); $curr = ""; foreach ($props as $prop) { if (isset($item["value"]) and trim($item["value"]) != '') { $curr .= $prop . ":" . $item['value'] . ";"; } } } if ($curr != '') { $item["css"] = $curr; } } } if (isset($item['selector']) and trim($item['selector']) != '' and isset($item["css"])) { $item["selector"] = str_ireplace('.element-current', '', $item["selector"]); $item["selector"] = str_ireplace('.mwfx', '', $item["selector"]); $item["selector"] = str_ireplace('.mw_image_resizer', '', $item["selector"]); $item["selector"] = str_ireplace('.ui-resizable', '', $item["selector"]); $item["selector"] = str_ireplace('.ui-draggable', '', $item["selector"]); $item["css"] = str_ireplace('background:url(;', '', $item["css"]); $item["css"] = str_ireplace('background:;', '', $item["css"]); $item["css"] = str_ireplace('background-image:url(;', '', $item["css"]); $item["css"] = str_ireplace('background-image: url("");', 'background-image: none;', $item["css"]); $sel = trim($item['selector']); $css = trim($item["css"]); if (trim($sel) != '' and strlen($sel) > 2 and strlen($css) > 2) { $delim = "\n /* {$sel} */ \n"; //$item["css"] = str_ireplace($this_template_url, '', $item["css"]); //$item["css"] = str_ireplace($template_url, '', $item["css"]); $item["css"] = str_ireplace('http://', '//', $item["css"]); $item["css"] = str_ireplace('https://', '//', $item["css"]); $is_existing = explode($delim, $css_cont_new); if (!empty($is_existing)) { $srings = $this->app->format->string_between($css_cont_new, $delim, $delim); if ($srings != false) { $css_cont_new = str_ireplace($srings, '', $css_cont_new); $css_cont_new = str_ireplace($delim, '', $css_cont_new); } } if (trim($item["css"]) != 'reset' and trim($item["css"]) != 'reset;') { $css_cont_new .= $delim; if (isset($sel) and trim($sel) == '@import') { $css_cont_new .= $sel . ' ' . $item["css"] . ' '; } else { $css_cont_new .= $sel . ' { ' . $item["css"] . ' }'; } $css_cont_new .= $delim; } } } } $resp = array(); $resp['url'] = $this->app->url_manager->link_to_file($live_edit_css); if ($css_cont_new != '' and $css_cont != $css_cont_new) { file_put_contents($live_edit_css, $css_cont_new); // print $css_cont_new; } $resp['content'] = $css_cont_new; return $resp; } } }
/** * Figure out the page to load, and put it in $this->pages and ROSTER_PAGE_NAME */ function get_page_name() { // cmslink function to resolve SEO linking etc. parse_params(); // --[ Determine the module request ]-- if (isset($_GET[ROSTER_PAGE]) && !empty($_GET[ROSTER_PAGE])) { $page = $_GET[ROSTER_PAGE]; } elseif (!strpos($this->config['default_page'], '&')) { $page = $this->config['default_page']; } else { // --[ Insert directly into GET request ]-- list($page, $gets) = explode('&', $this->conf['default_page'], 2); foreach (explode('&', $gets) as $get) { list($key, $value) = explode('=', $get, 2); $_GET[$key] = $value; } } // --[ We only accept certain characters in our page ]-- if (preg_match('/[^a-zA-Z0-9_-]/', $page)) { roster_die($this->locale->act['invalid_char_module'], $this->locale->act['roster_error']); } define('ROSTER_PAGE_NAME', $page); $this->pages = explode('-', $page); if (in_array($this->pages[0], array('util', 'user', 'realm', 'guild', 'char'))) { $this->scope = $this->pages[0]; } else { $this->scope = 'page'; } }
public function get_menu_items($params = false) { $table = $this->tables['menus']; if (is_string($params)) { $params = parse_params($params); } $params['table'] = $table; $params['item_type'] = 'menu_item'; return $this->app->database_manager->get($params); }
/** * * You can use this function to store options in the database. * * @param $data array|string * Example usage: * * $option = array(); * $option['option_value'] = 'my value'; * $option['option_key'] = 'my_option'; * $option['option_group'] = 'my_option_group'; * mw()->option_manager->save($option); * * * */ public function save($data) { if (defined('MW_API_CALL')) { $is_admin = $this->app->user_manager->is_admin(); if ($is_admin == false) { return false; } } if (is_string($data)) { $data = parse_params($data); } $option_group = false; if (is_array($data)) { if (strval($data['option_key']) != '') { if (strstr($data['option_key'], '|for_module|')) { $option_key_1 = explode('|for_module|', $data['option_key']); if (isset($option_key_1[0])) { $data['option_key'] = $option_key_1[0]; } if (isset($option_key_1[1])) { $data['module'] = $option_key_1[1]; if (isset($data['id']) and intval($data['id']) > 0) { $chck = $this->get('limit=1&module=' . $data['module'] . '&option_key=' . $data['option_key']); if (isset($chck[0]) and isset($chck[0]['id'])) { $data['id'] = $chck[0]['id']; } else { $table = $this->tables['options']; $copy = $this->app->database_manager->copy_row_by_id($table, $data['id']); $data['id'] = $copy; } } } } } $delete_content_cache = false; if (!isset($data['id']) or intval($data['id']) == 0) { if (isset($data['option_key']) and isset($data['option_group']) and trim($data['option_group']) != '') { $option_group = $data['option_group']; // $this->delete($data['option_key'], $data['option_group']); $existing = $this->get($data['option_key'], $data['option_group'], $return_full = true); if ($existing == false) { // } elseif (isset($existing['id'])) { $data['id'] = $existing['id']; } } } $table = $this->tables['options']; if (isset($data['field_values']) and $data['field_values'] != false) { $data['field_values'] = base64_encode(serialize($data['field_values'])); } if (isset($data['module'])) { $data['module'] = str_ireplace('/admin', '', $data['module']); } if (strval($data['option_key']) != '') { if ($data['option_key'] == 'current_template') { $delete_content_cache = true; } if (isset($data['option_group']) and strval($data['option_group']) == '') { unset($data['option_group']); } if (isset($data['option_value']) and $data['option_value'] != false) { $data['option_value'] = $this->app->url_manager->replace_site_url($data['option_value']); } $data['allow_html'] = true; $data['allow_scripts'] = true; $data['table'] = $this->tables['options']; $save = $this->app->database_manager->save($data); if ($option_group != false) { $cache_group = 'options/' . $option_group; $this->app->cache_manager->delete($cache_group); } else { $cache_group = 'options/' . 'global'; $this->app->cache_manager->delete($cache_group); } if ($save != false) { $cache_group = 'options/' . $save; $this->app->cache_manager->delete($cache_group); } if ($delete_content_cache != false) { $cache_group = 'content/global'; $this->app->cache_manager->delete($cache_group); } if (isset($data['id']) and intval($data['id']) > 0) { $opt = $this->get_by_id($data['id']); if (isset($opt['option_group'])) { $cache_group = 'options/' . $opt['option_group']; $this->app->cache_manager->delete($cache_group); } $cache_group = 'options/' . intval($data['id']); $this->app->cache_manager->delete($cache_group); } $this->app->cache_manager->delete('options'); return $save; } } }
public function extended_save($table_name_or_params, $params = null) { if ($params === null) { $params = $table_name_or_params; } else { if ($params != false) { $params = parse_params($params); } else { $params = array(); } $params['table'] = $table_name_or_params; } if (is_string($params)) { $params = parse_params($params); } if (!isset($params['table'])) { return false; } $ext_params = $params; $saved_id = $this->save($params); if ($saved_id == false) { return false; } if (!empty($ext_params)) { $data_str = 'attribute_'; $data_str_l = strlen($data_str); foreach ($ext_params as $k => $v) { if (is_string($k)) { if (strlen($k) > $data_str_l) { $rest = substr($k, 0, $data_str_l); $left = substr($k, $data_str_l, strlen($k)); if ($rest == $data_str) { if (!isset($ext_params['attributes'])) { $ext_params['attributes'] = array(); } $ext_params['attributes'][$left] = $v; } } } } } if (!is_array($saved_id) and $saved_id != 0) { $ext_params['id'] = $saved_id; event_trigger('mw.database.extended_save', $ext_params); if (isset($ext_params['attributes'])) { $this->extended_save_attributes($ext_params); } if (isset($ext_params['categories'])) { $this->extended_save_categories($ext_params); } if (isset($ext_params['data_fields'])) { $this->extended_save_data_fields($ext_params); } if (isset($ext_params['images'])) { $this->extended_save_images($ext_params); } if (isset($ext_params['custom_fields'])) { $this->extended_save_custom_fields($ext_params); } return $saved_id; } else { return $params; } }
/** * @function get_users * * @param $params array|string; * @params $params['username'] string username for user * @params $params['email'] string email for user * @params $params['password'] string password for user * * * @usage $this->get_all('email=my_email'); * * * @return array of users; */ public function get_all($params) { $params = parse_params($params); $table = $this->tables['users']; $data = $this->app->format->clean_html($params); $orig_data = $data; if (isset($data['ids']) and is_array($data['ids'])) { if (!empty($data['ids'])) { $ids = $data['ids']; } } if (!isset($params['search_in_fields'])) { $data['search_in_fields'] = array('id', 'first_name', 'last_name', 'username', 'email'); } $cache_group = 'users/global'; if (isset($limit) and $limit != false) { $data['limit'] = $limit; } if (isset($count_only) and $count_only != false) { $data['count'] = $count_only; } if (isset($data['username']) and $data['username'] == false) { unset($data['username']); } $data['table'] = $table; $get = $this->app->database_manager->get($data); return $get; }
public function save_item($params) { $params = parse_params($params); $table = $this->tables['categories_items']; $params['table'] = $table; $save = $this->app->database_manager->save($params); if (intval($save) == 0) { return false; } }
function get($params = false) { $params = parse_params($params); $params['table'] = $this->table; if (!isset($params['order_by'])) { $params['order_by'] = 'position ASC'; } $params['limit'] = 1000; return mw()->database_manager->get($params); }
public function send_anonymous_server_data($params = false) { if ($params != false and is_string($params)) { $params = parse_params($params); } if ($params == false) { $params = array(); } $params['function_name'] = 'send_lang_form_to_microweber'; $result = $this->call('send_anonymous_server_data', $params); return $result; }
public function get_products($params = false) { if (is_string($params)) { $params = parse_params($params); } if (!is_array($params)) { $params = array(); } if (!isset($params['content_type'])) { $params['content_type'] = 'product'; } return $this->get($params); }
public function bulk_assign($data) { if (!is_admin()) { return; } if (is_string($data)) { $data = parse_params($data); } if (isset($data['content_ids'])) { $content_ids = $data['content_ids']; if (is_array($content_ids)) { foreach ($content_ids as $content_id) { $to_save = array(); $to_save['id'] = $content_id; $to_save['skip_timestamps'] = true; if (isset($data['parent_id'])) { $to_save['parent'] = $data['parent_id']; } if (isset($data['categories'])) { $to_save['categories'] = $data['categories']; } $this->save_content($to_save); } } } return array('success' => 'Content is moved'); }
public function delete_cart($params) { if (is_string($params)) { $params = parse_params($params); } if (isset($params['session_id'])) { $id = $params['session_id']; \Cart::where('session_id', $id)->delete(); } if (isset($params['order_id'])) { $id = $params['order_id']; \Cart::where('order_id', $id)->delete(); } $this->app->cache_manager->delete('cart'); $this->app->cache_manager->delete('cart_orders'); }