<?php namespace shop\shipping\gateways\country; api_bind('shop/shipping/gateways/country/shipping_to_country/test', 'shop/shipping/gateways/country/shipping_to_country/test2'); // print('shop/shipping/gateways/country/shipping_to_country/test'. 'shop/shipping/gateways/country/shipping_to_country/test2'); api_expose_admin('shop/shipping/gateways/country/shipping_to_country/save'); api_expose('shop/shipping/gateways/country/shipping_to_country/set'); api_expose('shop/shipping/gateways/country/shipping_to_country/get'); api_expose_admin('shop/shipping/gateways/country/shipping_to_country/delete'); api_expose_admin('shop/shipping/gateways/country/shipping_to_country/reorder'); class shipping_to_country { // singleton instance public $table; public $app; // private constructor function // to prevent external instantiation function __construct($app = false) { $this->table = 'cart_shipping'; if (!is_object($this->app)) { if (is_object($app)) { $this->app = $app; } else { $this->app = mw(); } } } function get_cost() {
//function captcha_url($params=false) //{ // return Microweber\Utils\Captcha::url($params); //} function mw_error($e, $f = false, $l = false) { $f = mw_includes_path() . 'error.php'; $v = new \Microweber\View($f); $v->e = $e; $v->f = $f; $v->l = $l; die($v); } api_expose_admin('mw_composer_save_package'); function mw_composer_save_package($params) { $update_api = mw('update'); return $update_api->composer_save_package($params); } api_expose_admin('mw_composer_run_update'); function mw_composer_run_update($params) { $update_api = mw('update'); return $update_api->composer_run($params); } api_expose_admin('mw_composer_replace_vendor_from_cache'); function mw_composer_replace_vendor_from_cache($params) { $update_api = mw('update'); return $update_api->composer_replace_vendor_from_cache($params); }
function delete_menu_item($id) { return mw()->menu_manager->menu_item_delete($id); } function get_menu_item($id) { return mw()->menu_manager->menu_item_get($id); } api_expose_admin('edit_menu_item'); function edit_menu_item($data_to_save) { return mw()->menu_manager->menu_item_save($data_to_save); } api_expose_admin('reorder_menu_items'); function reorder_menu_items($data) { return mw()->menu_manager->menu_items_reorder($data); } function menu_tree($menu_id = false, $maxdepth = false) { return mw()->menu_manager->menu_tree($menu_id, $maxdepth); } function is_in_menu($menu_id = false, $content_id = false) { return mw()->menu_manager->is_in_menu($menu_id, $content_id); } api_expose_admin('add_content_to_menu'); function add_content_to_menu($content_id, $menu_id = false) { return mw()->content_manager->add_content_to_menu($content_id, $menu_id); }
api_expose_admin('get_order_by_id'); api_expose_admin('checkout_confirm_email_test'); api_expose_admin('delete_client'); api_expose_admin('delete_order'); api_expose_admin('update_order'); api_expose_admin('shop/update_order', function ($data) { return mw()->shop_manager->update_order($data); }); api_expose_admin('shop/save_tax_item', function ($data) { return mw()->tax_manager->save($data); }); api_expose_admin('shop/delete_tax_item', function ($data) { return mw()->tax_manager->delete_by_id($data); }); api_expose_admin('shop/export_orders', function ($data) { return mw()->order_manager->export_orders($data); }); // media api_expose('delete_media_file'); api_expose('upload_progress_check'); api_expose('upload'); api_expose('reorder_media'); api_expose('delete_media'); api_expose('save_media'); api_expose('pixum_img'); api_expose('thumbnail_img'); api_expose('create_media_dir'); api_expose('media/upload'); api_expose('media/delete_media_file'); // queue api_expose('queue_dispatch', function () {
<?php namespace Microweber\Providers; use DB; //event_bind('mw_db_init_default', mw()->shop_manager->db_init()); /** * * Shop module api * * @package modules * @subpackage shop * @since Version 0.1 */ // ------------------------------------------------------------------------ api_expose_admin('shop/update_order'); class ShopManager { public $app; public $tables = array(); public $table_prefix = false; public $no_cache = false; function __construct($app = null) { if (is_object($app)) { $this->app = $app; } else { $this->app = mw(); } $this->set_table_names(); }
api_expose('cart_sum'); api_expose('checkout'); api_expose('checkout_ipn'); api_expose('currency_format'); api_expose('empty_cart'); api_expose('payment_options'); api_expose('remove_cart_item'); api_expose('update_cart'); api_expose('update_cart_item_qty'); api_expose_admin('get_cart'); api_expose_admin('get_orders'); api_expose_admin('get_order_by_id'); api_expose_admin('checkout_confirm_email_test'); api_expose_admin('delete_client'); api_expose_admin('delete_order'); api_expose_admin('update_order'); api_bind_admin('shop/update_order', function ($data) { return mw()->shop_manager->update_order($data); }); // media api_expose('delete_media_file'); api_expose('upload_progress_check'); api_expose('upload'); api_expose('reorder_media'); api_expose('delete_media'); api_expose('save_media'); api_expose('pixum_img'); api_expose('thumbnail_img'); api_expose('create_media_dir'); api_expose('media/upload'); api_expose('media/delete_media_file');
* * @author Microweber * * @link http://microweber.com * * @param bool $id * * * @return array */ function get_user($id = false) { return mw()->user_manager->get($id); } api_expose_admin('users/register_email_send_test', function () { mw()->option_manager->override('users', 'register_email_enabled', true); return mw()->user_manager->register_email_send(); }); api_expose('users/register_email_send', function () { return mw()->user_manager->register_email_send(); }); api_expose('users/verify_email_link', function ($params) { if (isset($params['key'])) { try { $decoded = mw()->format->decrypt($params['key']); if ($decoded) { $decoded = intval($decoded); $adminUser = \User::findOrFail($decoded); $adminUser->is_verified = 1; $adminUser->save(); mw()->cache_manager->delete('users/global'); mw()->cache_manager->delete('users/' . $decoded);
<?php namespace Microweber\Utils; $_mw_email_transport_object = false; api_expose_admin('Microweber/Utils/MailSender/test'); use Config; use View; class MailSender { public $transport = false; public $debug = false; public $email_from = false; public $email_from_name = false; public $cc = false; public $smtp_host = false; public $smtp_port = false; public $smtp_username = false; public $smtp_password = false; public $smtp_auth = false; public $smtp_secure = false; private $here = false; function __construct() { $views = MW_PATH . 'Views' . DS; View::addNamespace('mw_email_send', $views); $email_from = mw()->option_manager->get('email_from_name', 'email'); if ($email_from == false or trim($email_from) == '') { $email_from = getenv("USERNAME"); } $this->email_from_name = $email_from;
api_expose_admin('uninstall_module'); function uninstall_module($params) { return mw()->modules->uninstall($params); } //event_bind('mw_db_init_modules', 're_init_modules_db'); function re_init_modules_db() { //return mw()->modules->update_db(); } api_expose_admin('install_module'); function install_module($params) { return mw()->modules->set_installed($params); } function save_module_to_db($data_to_save) { return mw()->modules->save($data_to_save); } function get_saved_modules_as_template($params) { return mw()->modules->get_saved_modules_as_template($params); } api_expose_admin('delete_module_as_template'); function delete_module_as_template($data) { return mw()->modules->delete_module_as_template($data); } api_bind_admin('module/reorder_modules', function ($data) { return mw()->modules->reorder_modules($data); });
function mw_is_installed() { static $is = null; if ($is === null) { $is = Config::get('microweber.is_installed'); } return (bool) $is; } api_expose_admin('mw_save_framework_config_file', function ($params) { if (empty($params) or !is_admin()) { return; } $save_configs = array(); foreach ($params as $k => $item) { if (is_array($item) and !empty($item)) { foreach ($item as $config_k => $config) { if (is_string($config_k)) { if (is_numeric($config)) { $config = intval($config); } Config::set($k . '.' . $config_k, $config); $save_configs[] = $k; } } } } if (!empty($save_configs)) { Config::save($save_configs); } });
* @param mixed $data_to_cache * your data, anything that can be serialized * @param string $cache_id * id of the cache, you must define it because you will use it later to * retrieve the cached content. * @param string $cache_group * (default is 'global') - this is the subfolder in the cache dir. * @param bool $expiration_in_seconds * * @return bool */ function cache_save($data_to_cache, $cache_id, $cache_group = 'global', $expiration = false) { return mw()->cache_manager->save($data_to_cache, $cache_id, $cache_group, $expiration); } api_expose_admin('clearcache'); /** * Clears all cache data. * * @example * <code> * //delete all cache * clearcache(); * </code> * * @return bool */ function clearcache() { mw()->cache_manager->clear(); mw()->template->clear_cache();
<?php if (!defined("MODULE_DB_COMMENTS")) { define('MODULE_DB_COMMENTS', 'comments'); } /** * mark_comments_as_old */ api_expose_admin('mark_comments_as_old'); function mark_comments_as_old($data) { if (isset($data['content_id'])) { $table = MODULE_DB_COMMENTS; mw_var('FORCE_SAVE', $table); $data['is_new'] = 1; $get_comm = get_comments($data); if (!empty($get_comm)) { foreach ($get_comm as $get_com) { $upd = array(); $upd['is_new'] = 0; $upd['id'] = $get_com['id']; $upd['rel_type'] = 'content'; $upd['rel_id'] = mw()->database_manager->escape_string($data['content_id']); mw()->database_manager->save($table, $upd); } } return $get_comm; } } /** * post_comment
<?php namespace admin\developer_tools\media_cleanup; use Illuminate\Cache\tags; use Illuminate\Support\Facades\Cache; use ZipArchive; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; api_expose_admin('admin/developer_tools/media_cleanup/Worker/create_batch'); class Worker { public $app; public $cache_group = 'media_cleanup_worker'; function __construct($app = null) { if (is_object($app)) { $this->app = $app; } else { $this->app = mw(); } } public function create_batch() { $work = array(); $work['total'] = mw()->media_manager->get_all('count=1'); $work['remaining'] = mw()->media_manager->get_all('count=1'); mw()->cache_manager->save($work, 'create_batch', $this->cache_group); return $work; } public function run()
return mw()->content_manager->copy($data); }); api_bind_admin('current_template_save_custom_css', function ($data) { return mw()->layouts_manager->template_save_css($data); }); // SHOP api_expose_admin('delete_client'); api_expose_admin('update_order'); api_expose('empty_cart'); api_expose('update_cart'); api_expose_admin('delete_order'); api_expose('checkout_ipn'); api_expose('checkout'); api_expose('remove_cart_item'); api_expose('update_cart_item_qty'); api_bind_admin('shop/update_order', function ($data) { return mw()->shop_manager->update_order($data); }); api_expose_admin('checkout_confirm_email_test'); // media api_expose('delete_media_file'); api_expose('upload_progress_check'); api_expose('upload'); api_expose('reorder_media'); api_expose('delete_media'); api_expose('save_media'); api_expose('pixum_img'); api_expose('thumbnail_img'); api_expose('create_media_dir'); api_expose('media/upload'); api_expose('media/delete_media_file');
* * @package utils */ namespace Microweber\Utils; use ZipArchive; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; api_expose_admin('Microweber\\Utils\\Import\\delete'); api_expose_admin('Microweber\\Utils\\Import\\create'); api_expose_admin('Microweber\\Utils\\Import\\download'); api_expose_admin('Microweber\\Utils\\Import\\create_full'); api_expose_admin('Microweber\\Utils\\Import\\move_uploaded_file_to_import'); api_expose_admin('Microweber\\Utils\\Import\\restore'); api_expose_admin('Microweber\\Utils\\Import\\export'); api_expose_admin('Microweber\\Utils\\Import\\batch_process'); class Import { public $import_to_page_id = false; public $imports_folder = false; public $import_file = false; public $app; public $batch_size = 5; public $xml_paths = array('channel' => 'item', 'feed' => 'entry', 'feed' => 'post_item', 'records' => 'record'); /** * The import class is used for making or restoring exported files from other CMS * * @category mics * @package utils */ private $file_q_sep = '; /* MW_QUERY_SEPERATOR */';
<?php namespace Microweber\Providers; api_expose_admin('fields/reorder'); api_expose_admin('fields/delete'); api_expose_admin('fields/make'); api_expose_admin('fields/save'); $_mw_made_default_fields_register = array(); class FieldsManager { public $app; public $tables = array(); public $table = 'custom_fields'; public $table_values = 'custom_fields_values'; private $skip_cache = false; public function __construct($app = null) { if (!is_object($this->app)) { if (is_object($app)) { $this->app = $app; } else { $this->app = mw(); } } $this->tables = $this->app->content_manager->tables; } public function get_by_id($field_id) { if ($field_id != 0) { $params = array();
* Example usage: * get_option('my_key', 'my_group'); * * * */ function get_option($key, $option_group = false, $return_full = false, $orderby = false, $module = false) { return mw()->option_manager->get($key, $option_group, $return_full, $orderby, $module); } /** * * 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'; * save_option($option); * * * */ api_expose_admin('save_option'); function save_option($data) { return mw()->option_manager->save($data); }
* Class used to export and restore the database or the userfiles directory * * You can use it to create export of the site. The export will contain na sql export of the database * and also a zip file with userfiles directory. * * * @package utils */ namespace admin\developer_tools\template_exporter; use ZipArchive; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; api_expose_admin('admin/developer_tools/template_exporter/Worker/create_full'); api_expose_admin('admin/developer_tools/template_exporter/Worker/download'); api_expose_admin('admin/developer_tools/template_exporter/Worker/delete'); if (defined("INI_SYSTEM_CHECK_DISABLED") == false) { define("INI_SYSTEM_CHECK_DISABLED", ini_get('disable_functions')); } class Worker { public $exports_folder = false; public $export_file = false; public $debug = false; public $app; /** * The export class is used for making or restoring a export * * @category mics * @package utils */
{ return mw()->media_manager->pixum($width, $height); } api_expose('thumbnail_img'); function thumbnail_img($params) { return mw()->media_manager->thumbnail_img($params); } if (!function_exists('thumbnail')) { function thumbnail($src, $width = 200, $height = 200) { return mw()->media_manager->thumbnail($src, $width, $height); } } api_expose_admin('get_media'); function get_media($params) { return mw()->media_manager->get($params); } function get_pictures($params) { return mw()->media_manager->get($params); } api_expose_admin('create_media_dir'); function create_media_dir($params) { return mw()->media_manager->create_media_dir($params); } api_bind('media/delete_media_file', function ($data) { return mw()->media_manager->delete_media_file($data); });
<?php if (!defined('MW_WHITE_LABEL_SETTINGS_FILE')) { define('MW_WHITE_LABEL_SETTINGS_FILE', __DIR__ . DIRECTORY_SEPARATOR . 'settings.json'); } api_expose_admin('save_white_label_config'); function save_white_label_config($params) { $file = MW_WHITE_LABEL_SETTINGS_FILE; if (isset($params['powered_by_link']) and trim(strip_tags($params['powered_by_link'])) == '') { unset($params['powered_by_link']); } $params = json_encode($params); return file_put_contents($file, $params); } function get_white_label_config() { $file = MW_WHITE_LABEL_SETTINGS_FILE; if (is_file($file)) { $cont = file_get_contents($file); $params = json_decode($cont, true); return $params; } } event_bind('mw_frontend', 'make_white_label'); event_bind('mw_backend', 'make_white_label'); function make_white_label() { $settings = get_white_label_config(); if (isset($settings['logo_admin']) and trim($settings['logo_admin']) != '') { $logo_admin = $settings['logo_admin'];
api_expose('social_login_process'); function social_login_process() { return mw()->user_manager->social_login_process(); } api_expose('user_reset_password_from_link'); function user_reset_password_from_link($params) { return mw()->user_manager->reset_password_from_link($params); } api_expose('user_send_forgot_password'); function user_send_forgot_password($params) { return mw()->user_manager->send_forgot_password($params); } api_expose_admin('user_make_logged'); function user_make_logged($params) { return mw()->user_manager->make_logged($params); } api_expose('user_login'); function user_login($params) { return mw()->user_manager->login($params); } api_expose('is_logged'); function is_logged() { $is = mw()->user_manager->is_logged(); if (defined("MW_API_CALL")) { mw()->event_manager->trigger('mw.user.is_logged');
public function api($api_function = false, $params = false) { if (isset($_REQUEST['api_key']) and user_id() == 0) { api_login($_REQUEST['api_key']); } if (!defined('MW_API_CALL')) { define('MW_API_CALL', true); } $set_constants = true; $mod_class_api = false; $mod_class_api_called = false; $mod_class_api_class_exist = false; $caller_commander = false; if ($api_function == false) { $api_function_full = $this->app->url_manager->string(); $api_function_full = $this->app->format->replace_once('api_html', '', $api_function_full); $api_function_full = $this->app->format->replace_once('api/api', 'api', $api_function_full); $api_function_full = $this->app->format->replace_once('api', '', $api_function_full); $api_function_full = trim($api_function_full, '/'); //$api_function_full = substr($api_function_full, 4); } else { $api_function_full = $api_function; } if (isset($api_function_full) and $api_function_full != '') { if (ltrim($api_function_full, '/') == 'module') { $set_constants = false; } } if ($set_constants == true) { $this->app->content_manager->define_constants(); } if (defined('TEMPLATE_DIR')) { $load_template_functions = TEMPLATE_DIR . 'functions.php'; if (is_file($load_template_functions)) { include_once $load_template_functions; } } //$api_function_full = str_ireplace('api/', '', $api_function_full); $api_function_full = str_replace('..', '', $api_function_full); $api_function_full = str_replace('\\', '/', $api_function_full); $api_function_full = str_replace('//', '/', $api_function_full); $api_function_full = $this->app->database_manager->escape_string($api_function_full); if (is_string($api_function_full)) { $mod_api_class = explode('/', $api_function_full); } else { $mod_api_class = $api_function_full; } $try_class_func = array_pop($mod_api_class); // $try_class_func2 = array_pop($mod_api_class); $mod_api_class_copy = $mod_api_class; $try_class_func2 = array_pop($mod_api_class_copy); $mod_api_class2 = implode(DS, $mod_api_class_copy); $mod_api_class = implode(DS, $mod_api_class); $mod_api_class_clean = ltrim($mod_api_class, '/'); $mod_api_class_clean = ltrim($mod_api_class_clean, '\\'); $mod_api_class_clean_uc1 = ucfirst($mod_api_class_clean); $mod_api_class1 = normalize_path(modules_path() . $mod_api_class, false) . '.php'; $mod_api_class_native = normalize_path(mw_includes_path() . $mod_api_class, false) . '.php'; $mod_api_class_native_system = normalize_path(dirname(MW_PATH) . DS . $mod_api_class, false) . '.php'; $mod_api_class_native_global_ns = normalize_path(mw_includes_path() . 'classes' . DS . $mod_api_class2, false) . '.php'; $mod_api_class1_uc1 = normalize_path(modules_path() . $mod_api_class_clean_uc1, false) . '.php'; $mod_api_class_native_uc1 = normalize_path(mw_includes_path() . $mod_api_class_clean_uc1, false) . '.php'; $mod_api_class_native_global_ns_uc1 = normalize_path(mw_includes_path() . 'classes' . DS . $mod_api_class_clean_uc1, false) . '.php'; $mod_api_class2 = normalize_path(modules_path() . DS . $mod_api_class_clean . DS . $mod_api_class_clean, false) . '.php'; $mod_api_class2_uc1 = normalize_path(modules_path() . DS . $mod_api_class_clean . DS . $mod_api_class_clean, false) . '.php'; $try_class = '\\' . str_replace('/', '\\', $mod_api_class); if (class_exists($try_class, false)) { $caller_commander = 'class_is_already_here'; $mod_class_api_class_exist = true; } else { if (is_file($mod_api_class1)) { $mod_class_api = true; include_once $mod_api_class1; } elseif (is_file($mod_api_class_native_system)) { $mod_class_api = true; include_once $mod_api_class_native_system; } elseif (is_file($mod_api_class1_uc1)) { $mod_class_api = true; include_once $mod_api_class1_uc1; } elseif (is_file($mod_api_class_native_global_ns_uc1)) { $try_class = str_replace('/', '\\', $mod_api_class2); $mod_class_api = true; include_once $mod_api_class_native_global_ns_uc1; } elseif (is_file($mod_api_class_native_global_ns)) { $try_class = str_replace('/', '\\', $mod_api_class2); $mod_class_api = true; include_once $mod_api_class_native_global_ns; } elseif (is_file($mod_api_class_native_uc1)) { $mod_class_api = true; include_once $mod_api_class_native_uc1; } elseif (is_file($mod_api_class_native)) { $mod_class_api = true; include_once $mod_api_class_native; } elseif (is_file($mod_api_class2)) { $mod_class_api = true; include_once $mod_api_class2; } elseif (is_file($mod_api_class2_uc1)) { $mod_class_api = true; include_once $mod_api_class2_uc1; } } $api_exposed = ''; // user functions $api_exposed .= 'user_login user_logout social_login_process'; // content functions $api_exposed .= 'set_language '; $api_exposed .= api_expose(true); if (is_logged()) { $api_exposed .= api_expose_user(true); } if (is_admin()) { $api_exposed .= api_expose_admin(true); } $api_exposed = explode(' ', $api_exposed); $api_exposed = array_unique($api_exposed); $api_exposed = array_trim($api_exposed); $hooks = api_bind(true); if (is_logged()) { $hooks_admin = api_bind_user(true); if (is_array($hooks_admin)) { $hooks = array_merge($hooks, $hooks_admin); } } if (is_admin()) { $hooks_admin = api_bind_admin(true); if (is_array($hooks_admin)) { $hooks = array_merge($hooks, $hooks_admin); } } if ($api_function == false) { $api_function = $this->app->url_manager->segment(1); } if (!defined('MW_API_RAW')) { if ($mod_class_api != false) { $url_segs = $this->app->url_manager->segment(-1); } } else { if (is_array($api_function)) { $url_segs = $api_function; } else { $url_segs = explode('/', $api_function); } } if (!defined('MW_API_FUNCTION_CALL')) { define('MW_API_FUNCTION_CALL', $api_function); } switch ($caller_commander) { case 'class_is_already_here': if ($params != false) { $data = $params; } elseif (!$_POST and !$_REQUEST) { $data = $this->app->url_manager->params(true); if (empty($data)) { $data = $this->app->url_manager->segment(2); } } else { //$data = $_REQUEST; $data = array_merge($_GET, $_POST); } static $loaded_classes = array(); //$try_class_n = src_ if (isset($loaded_classes[$try_class]) == false) { $res = new $try_class($data); $loaded_classes[$try_class] = $res; } else { $res = $loaded_classes[$try_class]; // } if (method_exists($res, $try_class_func) or method_exists($res, $try_class_func2)) { if (method_exists($res, $try_class_func2)) { $try_class_func = $try_class_func2; } $res = $res->{$try_class_func}($data); if (defined('MW_API_RAW')) { $mod_class_api_called = true; } return $this->_api_responce($res); } break; default: $res = false; if (isset($hooks[$api_function_full])) { $data = array_merge($_GET, $_POST); $call = $hooks[$api_function_full]; if (!empty($call)) { foreach ($call as $call_item) { $res = call_user_func($call_item, $data); } } if ($res != false) { return $this->_api_responce($res); } } if ($mod_class_api == true and $mod_api_class != false) { $mod_api_class = str_replace('..', '', $mod_api_class); $try_class = str_replace('/', '\\', $mod_api_class); $try_class_full = str_replace('/', '\\', $api_function_full); $try_class_full2 = str_replace('\\', '/', $api_function_full); $mod_api_class_test = explode('/', $try_class_full2); $try_class_func_test = array_pop($mod_api_class_test); $mod_api_class_test_full = implode('/', $mod_api_class_test); $mod_api_err = false; if (!defined('MW_API_RAW')) { if (!in_array($try_class_full, $api_exposed) and !in_array($try_class_full2, $api_exposed) and !in_array($mod_api_class_test_full, $api_exposed)) { $mod_api_err = true; foreach ($api_exposed as $api_exposed_value) { if ($mod_api_err == true) { if ($api_exposed_value == $try_class_full) { $mod_api_err = false; } elseif (strtolower('\\' . $api_exposed_value) == strtolower($try_class_full)) { $mod_api_err = false; } elseif ($api_exposed_value == $try_class_full2) { $mod_api_err = false; } else { $convert_slashes = str_replace('\\', '/', $try_class_full); if ($convert_slashes == $api_exposed_value) { $mod_api_err = false; } } } } } else { $mod_api_err = false; } } if ($mod_class_api and $mod_api_err == false) { if (!class_exists($try_class, false)) { $remove = $url_segs; $last_seg = array_pop($remove); $last_prev_seg = array_pop($remove); $last_prev_seg2 = array_pop($remove); if (class_exists($last_prev_seg, false)) { $try_class = $last_prev_seg; } elseif (class_exists($last_prev_seg2, false)) { $try_class = $last_prev_seg2; } } if (!class_exists($try_class, false)) { $try_class_mw = ltrim($try_class, '/'); $try_class_mw = ltrim($try_class_mw, '\\'); $try_class = $try_class_mw; } if (class_exists($try_class, false)) { if ($params != false) { $data = $params; } elseif (!$_POST and !$_REQUEST) { $data = $this->app->url_manager->params(true); if (empty($data)) { $data = $this->app->url_manager->segment(2); } } else { $data = array_merge($_GET, $_POST); } $res = new $try_class($data); if (method_exists($res, $try_class_func) or method_exists($res, $try_class_func2)) { if (method_exists($res, $try_class_func2)) { $try_class_func = $try_class_func2; } $res = $res->{$try_class_func}($data); $mod_class_api_called = true; return $this->_api_responce($res); } } else { mw_error('The api class ' . $try_class . ' does not exist'); } } } break; } if ($api_function) { } else { $api_function = 'index'; } if ($api_function == 'module' and $mod_class_api_called == false) { $this->module(); } else { $err = false; if (!in_array($api_function, $api_exposed)) { $err = true; } if ($err == true) { foreach ($api_exposed as $api_exposed_item) { if ($api_exposed_item == $api_function) { $err = false; } } } if (isset($api_function_full)) { foreach ($api_exposed as $api_exposed_item) { if (is_string($api_exposed_item) and is_string($api_function_full)) { $api_function_full = str_replace('\\', '/', $api_function_full); $api_function_full = ltrim($api_function_full, '/'); if (strtolower($api_exposed_item) == strtolower($api_function_full)) { $err = false; } } } } if ($err == false) { if ($mod_class_api_called == false) { if (!$_POST and !$_REQUEST) { // $data = $this->app->url_manager->segment(2); $data = $this->app->url_manager->params(true); if (empty($data)) { $data = $this->app->url_manager->segment(2); } } else { //$data = $_REQUEST; $data = array_merge($_GET, $_POST); } $api_function_full_2 = explode('/', $api_function_full); unset($api_function_full_2[count($api_function_full_2) - 1]); $api_function_full_2 = implode('/', $api_function_full_2); if (function_exists($api_function)) { $res = $api_function($data); } elseif (class_exists($api_function, false)) { // $segs = $this->app->url_manager->segment(); $mmethod = array_pop($segs); $class = new $api_function($this->app); if (method_exists($class, $mmethod)) { $res = $class->{$mmethod}($data); } } else { $api_function_full_2 = str_replace(array('..', '/'), array('', '\\'), $api_function_full_2); $api_function_full_2 = __NAMESPACE__ . '\\' . $api_function_full_2; if (class_exists($api_function_full_2, false)) { // $segs = $this->app->url_manager->segment(); $mmethod = array_pop($segs); $class = new $api_function_full_2($this->app); if (method_exists($class, $mmethod)) { $res = $class->{$mmethod}($data); } } elseif (isset($api_function_full)) { $api_function_full = str_replace('\\', '/', $api_function_full); $api_function_full1 = explode('/', $api_function_full); $mmethod = array_pop($api_function_full1); $mclass = array_pop($api_function_full1); if (class_exists($mclass, false)) { $class = new $mclass($this->app); if (method_exists($class, $mmethod)) { $res = $class->{$mmethod}($data); } } } } } if (isset($res) and isset($hooks[$api_function]) and is_array($hooks[$api_function]) and !empty($hooks[$api_function])) { foreach ($hooks[$api_function] as $hook_key => $hook_value) { if ($hook_value != false and $hook_value != null) { $hook_value($res); } } } else { //error('The api function ' . $api_function . ' does not exist', __FILE__, __LINE__); } // print $api_function; } else { $api_function = mw()->format->clean_html($api_function); $api_function = mw()->format->clean_xss($api_function); mw_error('The api function ' . $api_function . ' is not defined in the allowed functions list'); } if (isset($res)) { return $this->_api_responce($res); } return; } }
*/ function category_tree($params = false) { return mw()->category_manager->tree($params); } function get_category_items($category_id) { return mw()->category_manager->get_items('parent_id=' . intval($category_id)); } function get_category_items_count($category_id, $rel_type = false) { return mw()->category_manager->get_items_count($category_id, $rel_type); } api_expose_admin('get_category_by_id'); api_expose_admin('get_categories'); api_expose_admin('save_category'); api_bind_admin('category/save', 'save_category'); api_bind_admin('category/delete', 'delete_category'); api_expose_admin('delete_category'); api_expose_admin('reorder_categories'); api_expose_admin('content_categories'); api_expose_admin('get_category_children'); api_expose_admin('category_link'); api_expose_admin('get_page_for_category'); api_expose_admin('category_tree'); api_expose_admin('category/save'); api_expose_admin('category/delete'); api_expose_admin('get_category_items'); api_bind_admin('category/reorder', function ($data) { return mw()->category_manager->reorder($data); });
* Class used to backup and restore the database or the userfiles directory. * * You can use it to create backup of the site. The backup will contain na sql export of the database * and also a zip file with userfiles directory. */ namespace Microweber\Utils; use League\Flysystem\File; use ZipArchive; api_expose_admin('Microweber\\Utils\\Backup\\delete'); api_expose_admin('Microweber\\Utils\\Backup\\create'); api_expose_admin('Microweber\\Utils\\Backup\\download'); api_expose_admin('Microweber\\Utils\\Backup\\create_full'); api_expose_admin('Microweber\\Utils\\Backup\\move_uploaded_file_to_backup'); api_expose_admin('Microweber\\Utils\\Backup\\restore'); api_expose_admin('Microweber\\Utils\\Backup\\cronjob'); if (defined('INI_SYSTEM_CHECK_DISABLED') == false) { define('INI_SYSTEM_CHECK_DISABLED', ini_get('disable_functions')); } class Backup { public $backups_folder = false; public $backup_file = false; public $debug = false; public $app; /** * The backup class is used for making or restoring a backup. * * @category mics */ private $file_q_sep = '; /* MW_QUERY_SEPERATOR */';
* $upd['password'] = $params['passwordhash']; * mw_var('force_save_user', false|true); // if true you want to make new user or foce save ... skips id check and is admin check * mw_var('save_user_no_pass_hash', false|true); //if true skips pass hash function and saves password it as is in the request, please hash the password before that or ensure its hashed * $s = save_user($upd); * * * * * * @return bool|int */ function save_user($params) { return mw()->user_manager->save($params); } api_expose_admin('delete_user'); function delete_user($data) { return mw()->user_manager->delete($data); } api_expose('social_login_process'); function social_login_process() { return mw()->user_manager->social_login_process(); } api_expose('user_reset_password_from_link'); function user_reset_password_from_link($params) { return mw()->user_manager->reset_password_from_link($params); } api_expose('user_send_forgot_password');