function user_styles_css($params) { if (!is_array($params)) { $template_name = $params; } else { extract($params); } if (!isset($template_name)) { exit; } $template_name = str_replace('..', '', $template_name); if (defined('TEMPLATE_NAME') == false) { define('TEMPLATE_NAME', $template_name); } $custom_fn = TEMPLATES_DIR . $template_name; // d( $custom_fn); if (is_dir($custom_fn)) { $custom_fn = $custom_fn . DS . 'global_styles.php'; $custom_fn = normalize_path($custom_fn, false); if (is_file($custom_fn)) { header("Content-type: text/css", true); include $custom_fn; exit; } //d( $custom_fn); } }
/** * * * Recursive glob() * * @access public * @package Utils * @category Files * * @uses is_array() * @param int|string $pattern * the pattern passed to glob() * @param int $flags * the flags passed to glob() * @param string $path * the path to scan * @return mixed * an array of files in the given path matching the pattern. */ function rglob($pattern = '*', $flags = 0, $path = '') { if (!$path && ($dir = dirname($pattern)) != '.') { if ($dir == '\\' || $dir == '/') { $dir = ''; } return rglob(basename($pattern), $flags, $dir . DS); } $path = normalize_path($path, 1); $paths = glob($path . '*', GLOB_ONLYDIR | GLOB_NOSORT); $files = glob($path . $pattern, $flags); if (is_array($paths)) { foreach ($paths as $p) { $temp = rglob($pattern, false, $p . DS); if (is_array($temp) and is_array($files) and !empty($files)) { $files = array_merge($files, $temp); } else { if (is_array($temp) and !empty($temp)) { $files = $temp; } } } } return $files; }
private function installTemplateContent($template_name) { $default_content_folder = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR; $default_content_file = $default_content_folder . 'mw_default_content.zip'; if ($template_name) { if (function_exists('templates_path')) { $template_dir = templates_path() . DS . $template_name; $template_dir = normalize_path($template_dir, true); if (is_dir($template_dir)) { $template_default_content = $template_dir . 'mw_default_content.zip'; if (is_file($template_default_content) and is_readable($template_default_content)) { $default_content_file = $template_default_content; $default_content_folder = $template_dir; } } } } if (is_file($default_content_file)) { $restore = new \Microweber\Utils\Backup(); $restore->backups_folder = $default_content_folder; $restore->backup_file = 'mw_default_content.zip'; ob_start(); try { $rest = $restore->exec_restore(); } catch (Exception $e) { return false; } ob_get_clean(); return true; } else { return false; } }
public function get_parent(&$cache) { $parent_abs_path = normalize_path(dirname($this->abs_path)); if (starts_with($parent_abs_path, $this->app->get_root_abs_path())) { return Entry::get($this->app, $parent_abs_path, $cache); } return null; }
function userfiles_path() { static $folder; if (!$folder) { $folder = normalize_path(public_path() . DIRECTORY_SEPARATOR . MW_USERFILES_FOLDER_NAME . DIRECTORY_SEPARATOR); } return $folder; }
public function __construct($composer_path = false) { if ($composer_path == false) { $composer_path = normalize_path(base_path() . '/', false); } $this->composer_home = $composer_path; putenv('COMPOSER_HOME=' . $composer_path); }
public function get_abs_path($abs_href = null) { if ($abs_href === null) { return $this->abs_path; } $abs_href = substr($abs_href, strlen($this->root_abs_href)); return normalize_path($this->root_abs_path . "/" . rawurldecode($abs_href)); }
/** * Obtiene un segmento de una ruta a partir de la posición de la * primera ocurrencia de un substring en $needle. * * @param string $path * @param string $needle * @return mixed */ function path_segment($path, $needle) { if ($path) { $path = normalize_path($path); $path = substr($path, strrpos($path, $needle, 0) - 1); } else { $path = null; } return $path; }
function to_path($path) { if (trim($path) == '') { return false; } $path = str_ireplace($this->site_url(), MW_ROOTPATH, $path); $path = str_replace('\\', '/', $path); $path = str_replace('//', '/', $path); return normalize_path($path, false); }
public function createStaticFolderQuery() { $target_path = normalize_path(APPPATH . '../static'); $link_path = normalize_path(APPPATH . 'static/common'); @$this->_symlink($target_path, $link_path); $target_path = normalize_path(PLUGINSPATH . 'static'); $link_path = normalize_path(APPPATH . 'static/plugins'); @$this->_symlink($target_path, $link_path); return $this->success(array('title' => '指向成功', 'content' => 'static目录指向成功'), FALSE); }
/** * @param string $path */ public function setSettingWatermarkFilePath($path) { $path = normalize_path($path); if ($this->isImage($path)) { $imagePath = $this->folderPath($path); $this->fieldSettings['watermark_file_path'] = $imagePath; $this->fieldSettings['watermark'] = true; } else { $this->fieldSettings['watermark'] = false; $this->fieldSettings['watermark_file_path'] = null; } }
public function run() { $removed = 0; $value = mw()->cache_manager->get('create_batch', $this->cache_group); if (isset($value['total']) and $value['total'] > 0) { if (isset($value['remaining']) and $value['remaining'] > 0) { $batch = mw()->media_manager->get_all('limit=30000'); if ($batch) { foreach ($batch as $k => $v) { if (isset($v['id']) and isset($v['filename']) and $v['filename'] != false) { $process = false; if (stristr($v['filename'], '{SITE_URL}')) { $process = true; } else { if (stristr($v['filename'], site_url())) { $process = true; } } if ($process) { $v['filename'] = str_ireplace('{SITE_URL}', '', $v['filename']); $v['filename'] = str_ireplace(site_url(), '', $v['filename']); $is_file = false; $file1 = normalize_path(public_path() . DS . $v['filename'], false); $file2 = normalize_path(base_path() . DS . $v['filename'], false); $file3 = normalize_path(media_base_path() . DS . $v['filename'], false); $file4 = normalize_path(userfiles_path() . DS . $v['filename'], false); if (is_file($file1)) { $is_file = true; } elseif (is_file($file2)) { $is_file = true; } elseif (is_file($file3)) { $is_file = true; } elseif (is_file($file4)) { $is_file = true; } if ($is_file == false) { mw()->media_manager->delete($v['id']); $removed++; } } } } } } } mw()->cache_manager->delete($this->cache_group); $resp = array('success' => "Removed " . $removed . ' items'); return $resp; }
/** @return DirItem */ public static function inst($path, $name = null, $ext = null) { $absPath = normalize_path(file_path($path, $name, $ext)); if (!$absPath || DIR_SEPARATOR == $absPath || PATH_BASE_DIR == $absPath || PATH_BASE_DIR == $absPath . DIR_SEPARATOR) { $absPath = PATH_BASE_DIR; } else { if (!starts_with($absPath, PATH_BASE_DIR)) { $absPath = next_level_dir(PATH_BASE_DIR, $absPath); } } if (array_key_exists($absPath, self::$items)) { return self::$items[$absPath]; } $relPath = cut_string_start($absPath, PATH_BASE_DIR); $relPath = ensure_dir_startswith_dir_separator($relPath); return self::$items[$absPath] = new DirItem($relPath, $absPath); }
public function check($mail) { // list is from here https://gist.github.com/hassanazimi/d6e49469258d7d06f9f4 $file = __DIR__ . DS . 'disposable_email_addresses.txt'; $file = normalize_path($file, false); $mail_domains_ko = file_get_contents($file); $mail_domains_ko = explode("\n", $mail_domains_ko); if (empty($mail_domains_ko)) { return false; } foreach ($mail_domains_ko as $ko_mail) { list(, $mail_domain) = explode('@', $mail); if (strcasecmp($mail_domain, trim($ko_mail)) == 0) { return TRUE; } } return FALSE; }
private function add_hrefs($hrefs) { foreach ($hrefs as $href) { $d = normalize_path(dirname($href), true); $n = basename($href); $code = $this->app->get_http_code($d); if ($code == App::$MAGIC_SEQUENCE && !$this->app->is_ignored($n)) { $real_file = $this->app->get_abs_path($href); // $archived_file = preg_replace("!^" . normalize_path($this->app->get_root_abs_path(), true) . "!", "", $real_file); $archived_file = preg_replace("!^" . normalize_path($this->app->get_abs_path(), true) . "!", "", $real_file); if (is_dir($real_file)) { $this->add_dir($real_file, $archived_file); } else { $this->add_file($real_file, $archived_file); } } } }
/** @return DirItem */ public static function inst($path, $name = null, $ext = null) { $itemPath = normalize_path(file_path($path, $name, $ext)); $corePath = normalize_path(PATH_BASE_DIR); //Обезопасим пути, в которых есть русские буквы try { $itemPath = iconv('UTF-8', 'cp1251', $itemPath); } catch (Exception $e) { //Если произойдёт ошибка - игнорируем } $isAbs = starts_with($itemPath, $corePath); $absPath = $isAbs ? $itemPath : next_level_dir($corePath, $itemPath); if (array_key_exists($absPath, self::$items)) { return self::$items[$absPath]; } $relPath = cut_string_start($absPath, $corePath); $relPath = ensure_starts_with($relPath, DIR_SEPARATOR); return self::$items[$absPath] = new DirItem($relPath, $absPath); }
/** @return DirManager */ public static function inst($notCkeckDirs = null, $dirs = null) { $dirPath = next_level_dir($notCkeckDirs); $corePath = normalize_path(PATH_BASE_DIR); $isAbs = starts_with($dirPath, $corePath); $absPathNotCheck = $isAbs ? $dirPath : next_level_dir($corePath, $dirPath); $absPathNotCheck = ensure_dir_endswith_dir_separator($absPathNotCheck); $absPath = next_level_dir($absPathNotCheck, $dirs); $absPath = ensure_dir_endswith_dir_separator($absPath); //Проверим, нужно ли создать структуру директорий if ($absPathNotCheck != $absPath && !is_dir($absPath)) { @mkdir($absPath, 0777, true); } if (array_key_exists($absPath, self::$insts)) { return self::$insts[$absPath]; } $relPath = cut_string_start($absPath, $corePath); $relPath = ensure_dir_startswith_dir_separator($relPath); return self::$insts[$absPath] = new DirManager($relPath, $absPath); }
function load_all_functions_files_for_modules($options = false) { $is_installed = mw_is_installed(); if (!$is_installed) { return; } $modules = mw()->modules->get('ui=any&installed=1&limit=99999'); $files = array(); if (!empty($modules)) { foreach ($modules as $module) { if (isset($module['module'])) { $is_function = normalize_path(modules_path() . $module['module'] . DS . 'functions.php', false); if (is_file($is_function)) { include_once $is_function; $files[] = $is_function; } } } return $files; } }
/** * Defines all constants that are needed to parse the page layout * * It accepts array or $content that must have $content['id'] set * * @example * <code> * Define constants for some page * $ref_page = $this->get_by_id(1); * $this->define_constants($ref_page); * print PAGE_ID; * print POST_ID; * print CATEGORY_ID; * print MAIN_PAGE_ID; * print DEFAULT_TEMPLATE_DIR; * print DEFAULT_TEMPLATE_URL; * </code> * * @package Content * @subpackage Advanced * @const PAGE_ID Defines the current page id * @const POST_ID Defines the current post id * @const CATEGORY_ID Defines the current category id if any * @const ACTIVE_PAGE_ID Same as PAGE_ID * @const CONTENT_ID current post or page id * @const MAIN_PAGE_ID the parent page id * @const DEFAULT_TEMPLATE_DIR the directory of the site's default template * @const DEFAULT_TEMPLATE_URL the url of the site's default template * * * * @param array|bool $content * @option integer "id" [description] * @option string "content_type" [description] * @return void */ public function define_constants($content = false) { if ($content == false) { if (isset($_SERVER['HTTP_REFERER'])) { $ref_page = $_SERVER['HTTP_REFERER']; if ($ref_page != '') { $ref_page = $this->get_by_url($ref_page); if ($ref_page != false and !empty($ref_page)) { $content = $ref_page; } } } } $page = false; if (is_array($content)) { if (!isset($content['active_site_template']) and isset($content['id']) and $content['id'] != 0) { $content = $this->get_by_id($content['id']); $page = $content; } else { if (isset($content['id']) and $content['id'] == 0) { $page = $content; } else { if (isset($content['active_site_template'])) { $page = $content; } } } if ($page == false) { $page = $content; } } if (is_array($page)) { if (isset($page['content_type']) and ($page['content_type'] == "post" or $page['content_type'] != "page")) { if (isset($page['id']) and $page['id'] != 0) { $content = $page; $current_categorys = $this->app->category_manager->get_for_content($page['id']); if (!empty($current_categorys)) { $current_category = end($current_categorys); if (defined('CATEGORY_ID') == false and isset($current_category['id'])) { define('CATEGORY_ID', $current_category['id']); } } $page = $this->get_by_id($page['parent']); if (defined('POST_ID') == false) { define('POST_ID', $content['id']); } if ($page['content_type'] == "product") { if (defined('PRODUCT_ID') == false) { define('PRODUCT_ID', $content['id']); } } } } else { $content = $page; if (defined('POST_ID') == false) { define('POST_ID', false); } } if (defined('ACTIVE_PAGE_ID') == false) { if (!isset($page['id'])) { $page['id'] = 0; } define('ACTIVE_PAGE_ID', $page['id']); } if (!defined('CATEGORY_ID')) { //define('CATEGORY_ID', $current_category['id']); } if (defined('CATEGORY_ID') == false) { $cat_url = $this->app->url_manager->param('category', $skip_ajax = true); if ($cat_url != false) { define('CATEGORY_ID', intval($cat_url)); } } if (!defined('CATEGORY_ID')) { define('CATEGORY_ID', false); } if (defined('CONTENT_ID') == false and isset($content['id'])) { define('CONTENT_ID', $content['id']); } if (defined('PAGE_ID') == false and isset($content['id'])) { define('PAGE_ID', $page['id']); } if (isset($page['parent'])) { $parent_page_check_if_inherited = $this->get_by_id($page['parent']); if (isset($parent_page_check_if_inherited["layout_file"]) and $parent_page_check_if_inherited["layout_file"] == 'inherit') { $inherit_from_id = $this->get_inherited_parent($parent_page_check_if_inherited["id"]); if (defined('MAIN_PAGE_ID') == false) { define('MAIN_PAGE_ID', $inherit_from_id); } } //$root_parent = $this->get_inherited_parent($page['parent']); // $this->get_inherited_parent($page['id']); // if ($par_page != false) { // $par_page = $this->get_by_id($page['parent']); // } if (defined('ROOT_PAGE_ID') == false) { $root_page = $this->get_parents($page['id']); if (!empty($root_page) and isset($root_page[0])) { $root_page[0] = end($root_page); } else { $root_page[0] = $page['parent']; } define('ROOT_PAGE_ID', $root_page[0]); } if (defined('MAIN_PAGE_ID') == false) { if ($page['parent'] == 0) { define('MAIN_PAGE_ID', $page['id']); } else { define('MAIN_PAGE_ID', $page['parent']); } } if (defined('PARENT_PAGE_ID') == false) { define('PARENT_PAGE_ID', $page['parent']); } } } if (defined('ACTIVE_PAGE_ID') == false) { define('ACTIVE_PAGE_ID', false); } if (defined('CATEGORY_ID') == false) { define('CATEGORY_ID', false); } if (defined('CONTENT_ID') == false) { define('CONTENT_ID', false); } if (defined('POST_ID') == false) { define('POST_ID', false); } if (defined('PAGE_ID') == false) { define('PAGE_ID', false); } if (defined('MAIN_PAGE_ID') == false) { define('MAIN_PAGE_ID', false); } if (isset($page) and isset($page['active_site_template']) and $page['active_site_template'] != '' and strtolower($page['active_site_template']) != 'inherit' and strtolower($page['active_site_template']) != 'default') { $the_active_site_template = $page['active_site_template']; } else { if (isset($page) and isset($page['active_site_template']) and $page['active_site_template'] != '' and strtolower($page['active_site_template']) != 'default') { $the_active_site_template = $page['active_site_template']; } else { if (isset($content) and isset($content['active_site_template']) and $content['active_site_template'] != '' and strtolower($content['active_site_template']) != 'default') { $the_active_site_template = $content['active_site_template']; } else { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); // } } } if (isset($content['parent']) and $content['parent'] != 0 and isset($content['layout_file']) and $content['layout_file'] == 'inherit') { $inh = $this->get_inherited_parent($content['id']); if ($inh != false) { $inh_parent = $this->get_by_id($inh); if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] != '' and strtolower($inh_parent['active_site_template']) != 'default') { $the_active_site_template = $inh_parent['active_site_template']; } else { if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] != '' and strtolower($inh_parent['active_site_template']) == 'default') { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); } else { if (isset($inh_parent['active_site_template']) and $inh_parent['active_site_template'] == '') { $the_active_site_template = $this->app->option_manager->get('current_template', 'template'); } } } } } if (isset($the_active_site_template) and $the_active_site_template != 'default' and $the_active_site_template == 'mw_default') { $the_active_site_template = 'default'; } if ($the_active_site_template == false) { $the_active_site_template = 'default'; } if (defined('THIS_TEMPLATE_DIR') == false and $the_active_site_template != false) { define('THIS_TEMPLATE_DIR', templates_path() . $the_active_site_template . DS); } if (defined('THIS_TEMPLATE_FOLDER_NAME') == false and $the_active_site_template != false) { define('THIS_TEMPLATE_FOLDER_NAME', $the_active_site_template); } $the_active_site_template_dir = normalize_path(templates_path() . $the_active_site_template . DS); if (defined('DEFAULT_TEMPLATE_DIR') == false) { define('DEFAULT_TEMPLATE_DIR', templates_path() . 'default' . DS); } if (defined('DEFAULT_TEMPLATE_URL') == false) { define('DEFAULT_TEMPLATE_URL', templates_url() . '/default/'); } if (trim($the_active_site_template) != 'default') { if (!strstr($the_active_site_template, DEFAULT_TEMPLATE_DIR)) { $use_default_layouts = $the_active_site_template_dir . 'use_default_layouts.php'; if (is_file($use_default_layouts)) { if (isset($page['layout_file'])) { $template_view = DEFAULT_TEMPLATE_DIR . $page['layout_file']; } else { $template_view = DEFAULT_TEMPLATE_DIR; } if (isset($page)) { if (!isset($page['layout_file']) or (isset($page['layout_file']) and $page['layout_file'] == 'inherit' or $page['layout_file'] == '')) { $par_page = $this->get_inherited_parent($page['id']); if ($par_page != false) { $par_page = $this->get_by_id($par_page); } if (isset($par_page['layout_file'])) { $the_active_site_template = $par_page['active_site_template']; $page['layout_file'] = $par_page['layout_file']; $page['active_site_template'] = $par_page['active_site_template']; $template_view = templates_path() . $page['active_site_template'] . DS . $page['layout_file']; } } } if (is_file($template_view) == true) { if (defined('THIS_TEMPLATE_DIR') == false) { define('THIS_TEMPLATE_DIR', templates_path() . $the_active_site_template . DS); } if (defined('THIS_TEMPLATE_URL') == false) { $the_template_url = templates_url() . '/' . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('THIS_TEMPLATE_URL') == false) { define("THIS_TEMPLATE_URL", $the_template_url); } if (defined('TEMPLATE_URL') == false) { define("TEMPLATE_URL", $the_template_url); } } $the_active_site_template = 'default'; $the_active_site_template_dir = DEFAULT_TEMPLATE_DIR; } } } } if (defined('ACTIVE_TEMPLATE_DIR') == false) { define('ACTIVE_TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('THIS_TEMPLATE_DIR') == false) { define('THIS_TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('THIS_TEMPLATE_URL') == false) { $the_template_url = templates_url() . '/' . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('THIS_TEMPLATE_URL') == false) { define("THIS_TEMPLATE_URL", $the_template_url); } } if (defined('TEMPLATE_NAME') == false) { define('TEMPLATE_NAME', $the_active_site_template); } if (defined('TEMPLATE_DIR') == false) { define('TEMPLATE_DIR', $the_active_site_template_dir); } if (defined('ACTIVE_SITE_TEMPLATE') == false) { define('ACTIVE_SITE_TEMPLATE', $the_active_site_template); } if (defined('TEMPLATES_DIR') == false) { define('TEMPLATES_DIR', templates_path()); } $the_template_url = templates_url() . $the_active_site_template; $the_template_url = $the_template_url . '/'; if (defined('TEMPLATE_URL') == false) { define("TEMPLATE_URL", $the_template_url); } if (defined('LAYOUTS_DIR') == false) { $layouts_dir = TEMPLATE_DIR . 'layouts/'; define("LAYOUTS_DIR", $layouts_dir); } else { $layouts_dir = LAYOUTS_DIR; } if (defined('LAYOUTS_URL') == false) { $layouts_url = reduce_double_slashes($this->app->url_manager->link_to_file($layouts_dir) . '/'); define("LAYOUTS_URL", $layouts_url); } return true; }
public function create_full() { if (!defined('INI_SYSTEM_CHECK_DISABLED')) { define('INI_SYSTEM_CHECK_DISABLED', ini_get('disable_functions')); } if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) { ini_set('memory_limit', '512M'); } if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) { set_time_limit(600); } $backup_actions = array(); $backup_actions[] = 'make_db_backup'; $userfiles_folder = userfiles_path(); $media_folder = media_base_path(); $all_images = $this->app->media_manager->get_all('limit=10000'); if (!empty($all_images)) { foreach ($all_images as $image) { if (isset($image['filename']) and $image['filename'] != false) { $fn = url2dir($image['filename']); if (is_file($fn)) { $backup_actions[] = $fn; } } } } $host = parse_url(site_url()); $host_dir = false; if (isset($host['host'])) { $host_dir = $host['host']; $host_dir = str_ireplace('www.', '', $host_dir); $host_dir = str_ireplace('.', '-', $host_dir); } $userfiles_folder_uploaded = $media_folder . DS . $host_dir . DS . 'uploaded' . DS; $userfiles_folder_uploaded = $media_folder . DS . $host_dir . DS; $userfiles_folder_uploaded = \normalize_path($userfiles_folder_uploaded); $folders = \rglob($userfiles_folder_uploaded . '*', GLOB_NOSORT); if (!is_array($folders)) { $folders = array(); } $cust_css_dir = $userfiles_folder . 'css' . DS; if (is_dir($cust_css_dir)) { $more_folders = \rglob($cust_css_dir . '*', GLOB_NOSORT); if (!empty($more_folders)) { $folders = array_merge($folders, $more_folders); } } if (!empty($folders)) { $text_files = array(); foreach ($folders as $fold) { if (!stristr($fold, 'backup')) { if (stristr($fold, '.php') or stristr($fold, '.js') or stristr($fold, '.css')) { $text_files[] = $fold; } else { $backup_actions[] = $fold; } } } if (!empty($text_files)) { $backup_actions = array_merge($text_files, $backup_actions); } } $cache_id = 'backup_queue'; $cache_id_loc = 'backup_progress'; $cache_state_id = 'backup_zip_state'; $this->app->cache_manager->save($backup_actions, $cache_id, 'backup'); $this->app->cache_manager->save(false, $cache_id_loc, 'backup'); $this->app->cache_manager->save(false, $cache_state_id, 'backup'); if (!defined('MW_NO_SESSION')) { define('MW_NO_SESSION', 1); } return; }
public function detect() { $this->connect_event_socket(); if (!$this->event_socket) { throw new Exception('Failed to use event socket'); } $FS_Version = $this->event_socket_request('api version'); preg_match("/FreeSWITCH Version (\\d+)\\.(\\d+)\\.(\\d+(?:\\.\\d+)?).*\\(.*?(\\d+\\w+)\\s*\\)/", $FS_Version, $matches); $this->_major = $matches[1]; $this->_minor = $matches[2]; $this->_build = $matches[3]; $this->_bits = $matches[4]; $FS_Vars = $this->event_socket_request('api global_getvar'); foreach (explode("\n", $FS_Vars) as $FS_Var) { preg_match("/(\\w+_dir)=(.*)/", $FS_Var, $matches); if (count($matches) > 0 and property_exists($this, "_" . $matches[1])) { $field = "_" . $matches[1]; $this->{$field} = normalize_path($matches[2]); } } $this->_voicemail_vdir = normalize_path($this->_storage_dir . DIRECTORY_SEPARATOR . "voicemail"); $this->_phrases_vdir = normalize_path($this->_conf_dir . DIRECTORY_SEPARATOR . "lang"); $this->_extensions_vdir = normalize_path($this->_conf_dir . DIRECTORY_SEPARATOR . "directory"); $this->_sip_profiles_vdir = normalize_path($this->_conf_dir . DIRECTORY_SEPARATOR . "sip_profiles"); $this->_dialplan_vdir = normalize_path($this->_conf_dir . DIRECTORY_SEPARATOR . "dialplan"); $this->_backup_vdir = normalize_path(sys_get_temp_dir()); }
public function editor_tools() { if (!defined('IN_ADMIN') and is_admin()) { define('IN_ADMIN', true); } if (!defined('IN_EDITOR_TOOLS')) { define('IN_EDITOR_TOOLS', true); } if (mw_is_installed() == true) { //event_trigger('mw_db_init'); // event_trigger('mw_cron'); } $tool = $this->app->url_manager->segment(1); if ($tool) { } else { $tool = 'index'; } $page = false; if (isset($_REQUEST['content_id'])) { if (intval($_REQUEST['content_id']) == 0) { $this->create_new_page = true; $custom_content_data_req = $_REQUEST; $custom_content_data = array(); if (isset($custom_content_data_req['content_type'])) { // $custom_content_data['content_type'] = $custom_content_data_req['content_type']; } if (isset($custom_content_data_req['content_type'])) { $custom_content_data['content_type'] = $custom_content_data_req['content_type']; } if (isset($custom_content_data_req['subtype'])) { $custom_content_data['subtype'] = $custom_content_data_req['subtype']; } if (isset($custom_content_data_req['parent_page']) and is_numeric($custom_content_data_req['parent_page'])) { $custom_content_data['parent'] = intval($custom_content_data_req['parent_page']); } if (isset($custom_content_data_req['preview_layout'])) { // $custom_content_data['preview_layout'] =($custom_content_data_req['preview_layout']); } if (!empty($custom_content_data)) { $custom_content_data['id'] = 0; $this->content_data = $custom_content_data; } $this->return_data = 1; $page = $this->frontend(); } else { $page = $this->app->content_manager->get_by_id($_REQUEST['content_id']); } } elseif (isset($_SERVER['HTTP_REFERER'])) { $url = $_SERVER['HTTP_REFERER']; $url = explode('?', $url); $url = $url[0]; if (trim($url) == '' or trim($url) == $this->app->url_manager->site()) { //$page = $this->app->content_manager->get_by_url($url); $page = $this->app->content_manager->homepage(); } else { $page = $this->app->content_manager->get_by_url($url); } } else { $url = $this->app->url_manager->string(); } if (!isset($page['active_site_template'])) { $page['active_site_template'] = 'default'; } if (isset($_GET['preview_template'])) { $page['active_site_template'] = $_GET['preview_template']; } if (isset($_GET['content_type'])) { $page['content_type'] = $_GET['content_type']; } if (isset($_GET['preview_layout']) and $_GET['preview_layout'] != 'inherit') { $page['layout_file'] = $_GET['preview_layout']; } $this->app->content_manager->define_constants($page); $page['render_file'] = $this->app->template->get_layout($page); if (defined('TEMPLATE_DIR')) { $load_template_functions = TEMPLATE_DIR . 'functions.php'; if (is_file($load_template_functions)) { include_once $load_template_functions; } } $params = $_REQUEST; $tool = str_replace('..', '', $tool); $p_index = mw_includes_path() . 'toolbar/editor_tools/index.php'; $p_index = normalize_path($p_index, false); $standalone_edit = true; $p = mw_includes_path() . 'toolbar/editor_tools/' . $tool . '/index.php'; $standalone_edit = false; if ($tool == 'plupload') { $standalone_edit = true; } if ($tool == 'plupload') { $standalone_edit = true; } if ($tool == 'imageeditor') { $standalone_edit = true; } if ($tool == 'rte_image_editor') { $standalone_edit = true; } if ($tool == 'editor_toolbar') { $standalone_edit = true; } if ($tool == 'wysiwyg') { $standalone_edit = false; $ed_file_from_template = TEMPLATE_DIR . 'editor.php'; if (is_file($ed_file_from_template)) { $p_index = $ed_file_from_template; } if (isset($page['content_type']) and $page['content_type'] != 'post' and $page['content_type'] != 'page' and $page['content_type'] != 'product') { if (isset($page['subtype']) and ($page['subtype'] != 'post' and $page['subtype'] != 'product')) { $standalone_edit = true; } } elseif (isset($page['content_type']) and $page['content_type'] == 'post') { if (isset($page['subtype']) and ($page['subtype'] != 'post' and $page['subtype'] != 'product')) { $standalone_edit = true; } } if ($standalone_edit) { if (!isset($page['content'])) { $page['content'] = '<div class="element"></div>'; } $page['content'] = '<div class="edit" field="content" rel="content" contenteditable="true">' . $page['content'] . '</div>'; $page['render_file'] = false; } // // $page['content'] = '<div class="edit" field="content" rel="content" contenteditable="true">' . $page['content'] . '</div>'; } $default_css = ''; $apijs_settings_loaded = ''; $apijs_loaded = ''; $p = normalize_path($p, false); $l = new \Microweber\View($p_index); $l->params = $params; $layout = $l->__toString(); $apijs_loaded = false; if ($layout != false) { //$apijs_loaded = $this->app->template->get_apijs_url() . '?id=' . CONTENT_ID; $apijs_loaded = $this->app->template->get_apijs_url(); // $apijs_settings_loaded = $this->app->template->get_apijs_settings_url() . '?id=' . CONTENT_ID . '&category_id=' . CATEGORY_ID; $apijs_settings_loaded = $this->app->template->get_apijs_settings_url(); // $is_admin = $this->app->user_manager->is_admin(); $default_css = '<link rel="stylesheet" href="' . mw_includes_url() . 'default.css" type="text/css" />'; $headers = event_trigger('site_header', TEMPLATE_NAME); $template_headers_append = ''; $one = 1; if (is_array($headers)) { foreach ($headers as $modify) { if ($modify != false and is_string($modify) and $modify != '') { $template_headers_append = $template_headers_append . $modify; } } if ($template_headers_append != false and $template_headers_append != '') { $layout = str_ireplace('</head>', $template_headers_append . '</head>', $l, $one); } } if (function_exists('template_headers_src')) { $template_headers_src = template_headers_src(); if ($template_headers_src != false and $template_headers_src != '') { $layout = str_ireplace('</head>', $template_headers_src . '</head>', $l, $one); } } if (isset($page['active_site_template'])) { if ($page['active_site_template'] == '') { $page['active_site_template'] = 'default'; } if ($page['active_site_template'] == 'default') { $active_site_template = $this->app->option_manager->get('current_template', 'template'); } else { $active_site_template = $page['active_site_template']; if ($active_site_template == 'mw_default') { $active_site_template = 'default'; } } $live_edit_css_folder = userfiles_path() . 'css' . DS . $active_site_template . DS; $custom_live_edit = $live_edit_css_folder . DS . 'live_edit.css'; if (is_file($custom_live_edit)) { $live_edit_url_folder = userfiles_url() . 'css/' . $active_site_template . '/'; $custom_live_editmtime = filemtime($custom_live_edit); $liv_ed_css = '<link rel="stylesheet" href="' . $live_edit_url_folder . 'live_edit.css?version=' . $custom_live_editmtime . '" id="mw-template-settings" type="text/css" />'; $layout = str_ireplace('</head>', $liv_ed_css . '</head>', $l); } } } if (isset($_REQUEST['plain'])) { if (is_file($p)) { $p = new \Microweber\View($p); $p->params = $params; $layout = $p->__toString(); echo $layout; return; } } elseif (is_file($p)) { $p = new \Microweber\View($p); $p->params = $params; $layout_tool = $p->__toString(); $layout = str_replace('{content}', $layout_tool, $layout); } else { $layout = str_replace('{content}', 'Not found!', $layout); } $category = false; if (defined('CATEGORY_ID')) { $category = $this->app->category_manager->get_by_id(CATEGORY_ID); } // $page['render_file'] = $render_file; if (!$standalone_edit) { if (isset($page['render_file'])) { event_trigger('mw.front', $page); $l = new \Microweber\View($page['render_file']); $l->page_id = PAGE_ID; $l->content_id = CONTENT_ID; $l->post_id = POST_ID; $l->category_id = CATEGORY_ID; $l->content = $page; $l->category = $category; $l->params = $params; $l->page = $page; $l->application = $this->app; $l = $l->__toString(); // // // $render_params = array(); // $render_params['render_file'] = $p; // $render_params['page_id'] = PAGE_ID; // $render_params['content_id'] = CONTENT_ID; // $render_params['post_id'] = POST_ID; // $render_params['category_id'] = CATEGORY_ID; // $render_params['page'] = $page; // $render_params['params'] = $params; // $render_params['application'] = $this->app; // $l = $this->app->template->render($render_params); if (is_object($l)) { return $l; } $l = $this->app->parser->process($l, $options = false); // if(isset($page['content']) and $page['content'] != false){ // // if($page['content'] == ''){ // unset($page['content']); // } // } else { // $page['content'] = $l; // } $editable = $this->app->parser->isolate_content_field($l, true); if ($editable != false) { $page['content'] = $editable; } else { if ($tool == 'wysiwyg') { $err = 'no editable content region found'; if (isset($page['layout_file'])) { $file = $page['layout_file']; $file = str_replace('__', '/', $page['layout_file']); $err = $err . ' in file ' . $file; } if (isset($page['active_site_template'])) { $err = $err . ' (' . $page['active_site_template'] . ' template)'; } return $err; } } } } if (!stristr($layout, $apijs_loaded)) { $rep = 0; $default_css = $default_css . "\r\n" . '<script src="' . $apijs_settings_loaded . '"></script>' . "\r\n"; $default_css = $default_css . "\r\n" . '<script src="' . $apijs_loaded . '"></script>' . "\r\n"; $layout = str_ireplace('<head>', '<head>' . $default_css, $layout, $rep); } if (isset($page['content'])) { if ($standalone_edit) { if (!isset($render_file)) { if (stristr($page['content'], 'field="content"') or stristr($page['content'], 'field=\'content\'')) { $page['content'] = '<div class="edit" field="content" rel="content" contenteditable="true">' . $page['content'] . '</div>'; } } } $layout = str_replace('{content}', $page['content'], $layout); } $layout = mw()->template->process_meta($layout); $layout = $this->app->parser->process($layout, $options = false); $layout = execute_document_ready($layout); $layout = str_replace('{head}', '', $layout); $layout = str_replace('{content}', '', $layout); echo $layout; return; }
public function load($module_name, $attrs = array()) { $is_element = false; $custom_view = false; if (isset($attrs['view'])) { $custom_view = $attrs['view']; $custom_view = trim($custom_view); $custom_view = str_replace('\\', '/', $custom_view); $attrs['view'] = $custom_view = str_replace('..', '', $custom_view); } if ($custom_view != false and strtolower($custom_view) == 'admin') { if ($this->app->user_manager->is_admin() == false) { mw_error('Not logged in as admin'); } } $module_name = trim($module_name); $module_name = str_replace('\\', '/', $module_name); $module_name = str_replace('..', '', $module_name); // prevent hack of the directory $module_name = reduce_double_slashes($module_name); $module_namei = $module_name; if (strstr($module_name, 'admin')) { $module_namei = str_ireplace('\\admin', '', $module_namei); $module_namei = str_ireplace('/admin', '', $module_namei); } //$module_namei = str_ireplace($search, $replace, $subject)e $uninstall_lock = $this->app->modules->get('one=1&ui=any&module=' . $module_namei); if (isset($uninstall_lock["installed"]) and $uninstall_lock["installed"] != '' and intval($uninstall_lock["installed"]) != 1) { return ''; } if (!defined('ACTIVE_TEMPLATE_DIR')) { $this->app->content_manager->define_constants(); } $module_in_template_dir = ACTIVE_TEMPLATE_DIR . 'modules/' . $module_name . ''; $module_in_template_dir = normalize_path($module_in_template_dir, 1); $module_in_template_file = ACTIVE_TEMPLATE_DIR . 'modules/' . $module_name . '.php'; $module_in_template_file = normalize_path($module_in_template_file, false); $try_file1 = false; $mod_d = $module_in_template_dir; $mod_d1 = normalize_path($mod_d, 1); $try_file1zz = $mod_d1 . 'index.php'; $in_dir = false; if ($custom_view == true) { $try_file1zz = $mod_d1 . trim($custom_view) . '.php'; } else { $try_file1zz = $mod_d1 . 'index.php'; } if (is_dir($module_in_template_dir) and is_file($try_file1zz)) { $try_file1 = $try_file1zz; $in_dir = true; } elseif (is_file($module_in_template_file)) { $try_file1 = $module_in_template_file; $in_dir = false; } else { $module_in_default_dir = modules_path() . $module_name . ''; $module_in_default_dir = normalize_path($module_in_default_dir, 1); // d($module_in_default_dir); $module_in_default_file = modules_path() . $module_name . '.php'; $module_in_default_file_custom_view = modules_path() . $module_name . '_' . $custom_view . '.php'; $element_in_default_file = elements_path() . $module_name . '.php'; $element_in_default_file = normalize_path($element_in_default_file, false); // $module_in_default_file = normalize_path($module_in_default_file, false); if (is_file($module_in_default_file)) { $in_dir = false; if ($custom_view == true and is_file($module_in_default_file_custom_view)) { $try_file1 = $module_in_default_file_custom_view; } else { $try_file1 = $module_in_default_file; } } else { if (is_dir($module_in_default_dir)) { $in_dir = true; $mod_d1 = normalize_path($module_in_default_dir, 1); if ($custom_view == true) { $try_file1 = $mod_d1 . trim($custom_view) . '.php'; } else { $try_file1 = $mod_d1 . 'index.php'; } } elseif (is_file($element_in_default_file)) { $in_dir = false; $is_element = true; $try_file1 = $element_in_default_file; } } } // if (isset($try_file1) != false and $try_file1 != false and is_file($try_file1)) { if (isset($attrs) and is_array($attrs) and !empty($attrs)) { $attrs2 = array(); foreach ($attrs as $attrs_k => $attrs_v) { $attrs_k2 = substr($attrs_k, 0, 5); if (strtolower($attrs_k2) == 'data-') { $attrs_k21 = substr($attrs_k, 5); $attrs2[$attrs_k21] = $attrs_v; } elseif (!isset($attrs['data-' . $attrs_k])) { $attrs2['data-' . $attrs_k] = $attrs_v; } $attrs2[$attrs_k] = $attrs_v; } $attrs = $attrs2; } $config['path_to_module'] = $config['mp'] = $config['path'] = normalize_path(dirname($try_file1) . '/', true); $config['the_module'] = $module_name; $config['module'] = $module_name; $module_name_dir = dirname($module_name); $config['module_name'] = $module_name_dir; $config['module_name_url_safe'] = $this->module_name_encode($module_name); $find_base_url = $this->app->url_manager->current(1); if ($pos = strpos($find_base_url, ':' . $module_name) or $pos = strpos($find_base_url, ':' . $config['module_name_url_safe'])) { $find_base_url = substr($find_base_url, 0, $pos) . ':' . $config['module_name_url_safe']; } $config['url'] = $find_base_url; $config['url_main'] = $config['url_base'] = strtok($find_base_url, '?'); if ($in_dir != false) { $mod_api = str_replace('/admin', '', $module_name); } else { $mod_api = str_replace('/admin', '', $module_name_dir); } $config['module_api'] = $this->app->url_manager->site('api/' . $mod_api); $config['module_view'] = $this->app->url_manager->site('module/' . $module_name); $config['ns'] = str_replace('/', '\\', $module_name); $config['module_class'] = $this->module_css_class($module_name); $config['url_to_module'] = $this->app->url_manager->link_to_file($config['path_to_module']); if (isset($attrs['id'])) { $attrs['id'] = str_replace('__MODULE_CLASS_NAME__', $config['module_class'], $attrs['id']); $template = false; } //$config['url_to_module'] = rtrim($config['url_to_module'], '///'); $lic = $this->app->modules->license($module_name); // $lic = 'valid'; if ($lic != false) { $config['license'] = $lic; } if (isset($attrs['module-id']) and $attrs['module-id'] != false) { $attrs['id'] = $attrs['module-id']; } if (!isset($attrs['id'])) { global $mw_mod_counter; $mw_mod_counter++; // $seg_clean = $this->app->url_manager->segment(0); $seg_clean = $this->app->url_manager->segment(0, url_current()); if (defined('IS_HOME')) { $seg_clean = ''; } $seg_clean = str_replace('%20', '-', $seg_clean); $seg_clean = str_replace(' ', '-', $seg_clean); $seg_clean = str_replace('.', '', $seg_clean); $attrs1 = crc32(serialize($attrs) . $seg_clean . $mw_mod_counter); $attrs1 = str_replace('%20', '-', $attrs1); $attrs1 = str_replace(' ', '-', $attrs1); $attrs['id'] = $config['module_class'] . '-' . $attrs1; } if (isset($attrs['id']) and strstr($attrs['id'], '__MODULE_CLASS_NAME__')) { $attrs['id'] = str_replace('__MODULE_CLASS_NAME__', $config['module_class'], $attrs['id']); //$attrs['id'] = ('__MODULE_CLASS__' . '-' . $attrs1); } $l1 = new \Microweber\View($try_file1); $l1->config = $config; $l1->app = $this->app; if (!isset($attrs['module'])) { $attrs['module'] = $module_name; } if (!isset($attrs['parent-module'])) { $attrs['parent-module'] = $module_name; } if (!isset($attrs['parent-module-id'])) { $attrs['parent-module-id'] = $attrs['id']; } // $mw_restore_get = mw_var('mw_restore_get'); // if ($mw_restore_get != false and is_array($mw_restore_get)) { // $l1->_GET = $mw_restore_get; // $_GET = $mw_restore_get; // } if (defined('MW_MODULE_ONDROP')) { if (!isset($attrs['ondrop'])) { $attrs['ondrop'] = true; } } $l1->params = $attrs; if ($config) { $this->current_module = $config; } if ($attrs) { $this->current_module_params = $attrs; } if (isset($attrs['view']) && trim($attrs['view']) == 'empty') { $module_file = EMPTY_MOD_STR; } elseif (isset($attrs['view']) && trim($attrs['view']) == 'admin') { $module_file = $l1->__toString(); } else { if (isset($attrs['display']) && trim($attrs['display']) == 'custom') { $module_file = $l1->__get_vars(); return $module_file; } else { if (isset($attrs['format']) && trim($attrs['format']) == 'json') { $module_file = $l1->__get_vars(); header("Content-type: application/json"); exit(json_encode($module_file)); } else { $module_file = $l1->__toString(); } } } // $l1 = null; unset($l1); if ($lic != false and isset($lic["error"]) and $lic["error"] == 'no_license_found') { $lic_l1_try_file1 = MW_ADMIN_VIEWS_DIR . 'activate_license.php'; $lic_l1 = new \Microweber\View($lic_l1_try_file1); $lic_l1->config = $config; $lic_l1->params = $attrs; $lic_l1e_file = $lic_l1->__toString(); unset($lic_l1); $module_file = $lic_l1e_file . $module_file; } // $mw_loaded_mod_memory[$function_cache_id] = $module_file; return $module_file; } else { //define($cache_content, FALSE); // $mw_loaded_mod_memory[$function_cache_id] = false; return false; } }
function composer_run() { $composer_cache = mw_cache_path() . 'composer' . DS; $vendor_cache = normalize_path($composer_cache . 'vendor', true); $composer_path = normalize_path(base_path() . '/', false); $composer_json = normalize_path(base_path() . DS . 'composer.json', false); $composer_json_cache = normalize_path($composer_cache . DS . 'composer.json', false); if (!is_dir($vendor_cache)) { mkdir_recursive($vendor_cache); } if (is_file($composer_json)) { copy($composer_json, $composer_json_cache); } putenv("COMPOSER_VENDOR_DIR=" . $vendor_cache); putenv("COMPOSER_NO_INTERACTION=1"); $this->_log_msg('Composer update...'); $runner = new \Microweber\Utils\ComposerUpdate($composer_cache); $config = array('prepend-autoloader' => false, 'no-install' => true, 'no-scripts' => true, 'no-plugins' => true, 'no-progress' => true, 'preferred-install' => 'dist', 'no-dev' => true, 'no-custom-installers' => true, 'no-autoloader' => true); $out = $runner->run($config); if ($out == 2) { return array('error' => 'Error resolving Composer dependencies'); } elseif ($out == 1) { return array('error' => 'Composer has an unknown error'); } elseif ($out === 0) { return array('move_vendor' => 1, 'working' => 1, 'message' => 'Composer has completed'); } else { return array('success' => 1, 'message' => $out); } }
public function render($params = array()) { $roit1 = rand(1, 6); $font = dirname(__FILE__) . DS . 'catcha_fonts' . DS . 'font' . $roit1 . '.ttf'; $font = normalize_path($font, 0); if (function_exists('imagettftext')) { $text1 = mt_rand(100, 4500); } else { $text1 = mt_rand(100, 999); } $text2 = mt_rand(2, 9); $roit = mt_rand(1, 5); $text = "{$text1}"; $answ = $text1; $x = 100; $y = 20; $image = @imagecreate($x, 20) or die('Unable to render a CAPTCHA picture!'); $tcol1z = rand(1, 150); $ttcol1z1 = rand(0, 150); $tcol1z11 = rand(0, 150); $bgcolor = imagecolorallocate($image, 255, 255, 255); $gray = imagecolorallocate($image, 240, 240, 240); // $black = imagecolorallocate($image, $tcol1z, $ttcol1z1, $tcol1z11); $black = imagecolorallocate($image, 0, 0, 0); $captcha_sid = 'captcha'; if (isset($params['id'])) { $captcha_sid = 'captcha_' . $params['id']; } elseif (isset($_GET['id'])) { $captcha_sid = 'captcha_' . $_GET['id']; } $old = mw()->user_manager->session_get('captcha'); if ($old != false) { $old_array = mw()->user_manager->session_get('captcha_recent'); if (!is_array($old_array)) { $old_array = array(); } array_unshift($old_array, $old); array_slice($old_array, 20); mw()->user_manager->session_set('captcha_recent', $old_array); } $sess = mw()->user_manager->session_set($captcha_sid, $answ); $col1z = rand(200, 242); $col1z1 = rand(150, 242); $col1z11 = rand(150, 242); $color1 = imagecolorallocate($image, $col1z, $col1z1, $tcol1z11); $color2 = imagecolorallocate($image, $tcol1z - 1, $ttcol1z1 - 1, $tcol1z11 - 2); // imagefill($image, 0, 0, $color1); for ($i = 0; $i < $x; ++$i) { for ($j = 0; $j < $y; ++$j) { if (mt_rand(0, 20) < 10) { //$coords = array(mt_rand(0, 10), mt_rand(0, 10), mt_rand(0, 10), mt_rand(0, 10), 5, 6); $y21 = mt_rand(5, 20); $this->captcha_vector($image, $x - mt_rand(0, 10), mt_rand(0, 10), mt_rand(0, 180), 200, $bgcolor); // imagesetpixel($image, $i, $j, $color2); } } } $x1 = mt_rand(0, 5); $y1 = mt_rand(20, 22); $tsize = rand(13, 15); $pad = 2; // extra char spacing for text if (function_exists('imagettftext')) { imagettftext($image, $tsize, $roit, $x1, $y1, $black, $font, $text); } else { if (function_exists('imagestring')) { $font = mw_includes_path() . DS . 'admin' . DS . 'catcha_fonts' . DS . 'font' . $roit1 . '.gdf'; $font = normalize_path($font, 0); $font = imageloadfont($font); imagestring($image, $font, 0, 0, $text, $black); } else { } } $s = 180; $e = 360; if (function_exists('imagefilter')) { $filter_img = rand(1, 6); switch ($filter_img) { case 1: $gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0)); imageconvolution($image, $gaussian, 16, 0); break; // break; // break; case 3: imagefilter($image, IMG_FILTER_PIXELATE, 1); break; default: break; } } $y21 = mt_rand(5, 20); $this->captcha_vector($image, $x, $y21 / 2, 180, 200, $bgcolor); $y21 = mt_rand(5, 20); $this->captcha_vector($image, $x, $y21 / 2, $col1z11, 200, $bgcolor); $y21 = mt_rand(5, 20); $this->captcha_vector($image, $x / 3, $y21 / 3, $col1z11, 200, $bgcolor); if (function_exists('imagestring')) { $this->captcha_vector($image, $x / 3, $y21 / 3, $col1z11, 200, $gray); imagestring($image, 0, $y21, 2, $text, $gray); } // $emboss = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1)); // $embize = mt_rand(1, 4); header('Content-type: image/png'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); imagepng($image); imagecolordeallocate($image, $bgcolor); imagecolordeallocate($image, $black); imagedestroy($image); }
function index() { exit('webdav is not yet finished'); ob_clean(); $this->load->helper('url'); $publicDir = USERFILES . 'media/content'; $tmpDir = CACHEDIR . 'webdav'; $tmpDir = normalize_path($tmpDir); if (is_dir($tmpDir) == false) { mkdir($tmpDir); } $publicDir = normalize_path($publicDir); if (is_dir($publicDir) == false) { mkdir($publicDir); } // If you want to run the SabreDAV server in a custom location (using mod_rewrite for instance) // You can override the baseUri here. require_once BASEPATH . 'libraries/webshare/lib/Sabre.autoload.php'; $u = 'admin'; $p = '1234'; //$auth = new Sabre_HTTP_DigestAuth (); //$auth->init (); $is_valid = false; //$username_test = $auth->getUsername (); //$pass_test = $auth->validatePassword (); //$auth2 = new Sabre_HTTP_BasicAuth (); //$passresult = $auth2->getUserPass (); //p($passresult); /*if (! $username_test) { $is_valid = false; } else { $data = array (); $data ['username'] = $username_test; //$data ['password'] = $pass_test; $data ['is_active'] = 'y'; $data ['is_admin'] = 'y'; $data = CI::model ( 'users' )->getUsers ( $data ); $data = $data [0]; // if (! empty ( $data )) { //p($data); $pass_test = $auth->validatePassword ( $data ['password'] ); //p($pass_test); if ($pass_test == true) { $is_valid = true; } else { $is_valid = false; } } else { $is_valid = false; } //p($data); } if ($is_valid == false) { //$auth->requireLogin (); //echo "Authentication required\n"; //die (); }*/ // Create the root node $root = new Sabre_DAV_FS_Directory($publicDir); //..p($_SERVER); // The rootnode needs in turn to be passed to the server class $server = new Sabre_DAV_Server($root); //$baseUri = '/cms/webdav/'; $temp1 = site_url('webdav'); $temp1 = parse_url($temp1); //p($temp1); $baseUri = $temp1['path']; if (isset($baseUri)) { $server->setBaseUri($baseUri); } // Support for LOCK and UNLOCK $lockBackend = new Sabre_DAV_Locks_Backend_FS($tmpDir); $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend); $server->addPlugin($lockPlugin); $server->addPlugin(new Sabre_DAV_Mount_Plugin()); // Support for html frontend $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); // Temporary file filter $tempFF = new Sabre_DAV_TemporaryFileFilterPlugin($tmpDir); $server->addPlugin($tempFF); // And off we go! $server->exec(); dav; }
public function countries_list($full = false) { static $data = array(); if (empty($data)) { $countries_file = normalize_path(MW_PATH . 'Utils/lib/country.csv', false); if (is_file($countries_file)) { $data = array_map('str_getcsv', file($countries_file)); if (isset($data[0])) { unset($data[0]); } } } if ($full == false and !empty($data)) { $res = array(); foreach ($data as $item) { $res[] = $item[1]; } return $res; } return $data; }
public function checkout_ipn($data) { if (isset($data['payment_verify_token'])) { $payment_verify_token = $data['payment_verify_token']; } if (!isset($data['payment_gw'])) { return array('error' => 'You must provide a payment gateway parameter!'); } $data['payment_gw'] = str_replace('..', '', $data['payment_gw']); $hostname = $this->get_domain_from_str($_SERVER['REMOTE_ADDR']); $payment_verify_token = $this->app->database_manager->escape_string($payment_verify_token); $table = $this->tables['cart_orders']; $query = array(); $query['payment_verify_token'] = $payment_verify_token; if (isset($data['order_id'])) { $query['id'] = intval($data['order_id']); } else { $query['transaction_id'] = '[null]'; } $query['limit'] = 1; $query['table'] = $table; $query['no_cache'] = true; $ord_data = $this->app->database_manager->get($query); if (!isset($ord_data[0]) or !is_array($ord_data[0])) { return array('error' => 'Order is completed or expired.'); } else { $ord_data = $ord_data[0]; $ord = $ord_data['id']; } $cart_table = $this->tables['cart']; $table_orders = $this->tables['cart_orders']; $data['payment_gw'] = str_replace('..', '', $data['payment_gw']); $gw_process = modules_path() . $data['payment_gw'] . '_checkout_ipn.php'; if (!is_file($gw_process)) { $gw_process = normalize_path(modules_path() . $data['payment_gw'] . DS . 'checkout_ipn.php', false); } $update_order = array(); if (is_file($gw_process)) { include $gw_process; } else { return array('error' => 'The payment gateway is not found!'); } if (!empty($update_order) and isset($update_order['order_completed']) and trim($update_order['order_completed']) == 1) { $update_order['id'] = $ord; $update_order['payment_gw'] = $data['payment_gw']; $ord = $this->app->database_manager->save($table_orders, $update_order); $this->confirm_email_send($ord); if (isset($update_order['is_paid']) and $update_order['is_paid'] == 1) { $this->update_quantities($ord); } if ($ord > 0) { $this->app->cache_manager->delete('cart/global'); $this->app->cache_manager->delete('cart_orders/global'); //return true; } } if (isset($data['return_to'])) { $return_to = urldecode($data['return_to']); $append = '?'; if (strstr($return_to, '?')) { $append = '&'; } $return_to = $return_to . $append . 'mw_payment_success=1'; return $this->app->url_manager->redirect($return_to); } return; }
function extended_save_images($params) { if ($this->extended_save_has_permission()) { event_trigger('mw.database.extended_save_images', $params); $data_to_save = $params; if (isset($data_to_save['images'])) { $data_fields = $data_to_save['images']; if (is_array($data_fields) and !empty($data_fields)) { foreach ($data_fields as $k => $v) { if (isset($v['filename'])) { $save_cat_item = array(); $save_cat_item['rel_type'] = $data_to_save['table']; $save_cat_item['rel_id'] = $data_to_save['id']; if (isset($data_to_save['download_remote_images']) and $data_to_save['download_remote_images'] != false) { $is_url = false; if (filter_var($v['filename'], FILTER_VALIDATE_URL)) { if (!stristr($v['filename'], site_url())) { $image_src = $v['filename']; $to_download = false; $image_src = strtok($image_src, '?'); $ext = get_file_extension($image_src); switch (strtolower($ext)) { case 'jpg': case 'jpeg': case 'png': case 'gif': case 'svg': $to_download = $image_src; break; default: break; } if ($to_download != false) { $output_fn = 'ext_save' . crc32($to_download) . '.' . $ext; $relative = 'downloaded' . DS . $save_cat_item['rel_type'] . DS . $save_cat_item['rel_id'] . DS; $output = media_base_path() . $relative; $output_relative = media_base_url() . str_replace(DS, '/', $relative); $output = normalize_path($output, true); if (!is_dir($output)) { mkdir_recursive($output); } $output_file = $output . $output_fn; if (!is_file($output_file)) { $download = new \Microweber\Utils\Http(); $download->set_url($image_src); $download->download($output_file); } $v['filename'] = $output_relative . $output_fn; $v['filename'] = str_replace(site_url(), '{SITE_URL}', $v['filename']); } } } } $save_cat_item["filename"] = $v['filename']; $check = $this->app->media_manager->get($save_cat_item); if ($check == false) { if (isset($v['position'])) { $save_cat_item["position"] = $v['position']; } $save = $this->app->media_manager->save($save_cat_item); } } } } } } }
public function checkout($data) { return $this->app->checkout_manager->checkout($data); $exec_return = false; $sid = mw()->user_manager->session_id(); $sess_order_id = mw()->user_manager->session_get('order_id'); $cart = array(); $cart_table = $this->tables['cart']; $table_orders = $this->tables['cart_orders']; $cart['session_id'] = $sid; $cart['order_completed'] = 0; $cart['limit'] = 1; $mw_process_payment = true; $mw_process_payment_success = false; $mw_process_payment_failed = false; if (isset($_REQUEST['mw_payment_success'])) { $mw_process_payment = false; $mw_process_payment_success = true; $exec_return = true; } elseif (isset($_REQUEST['mw_payment_failure'])) { $mw_process_payment_failed = true; $exec_return = true; } $cart_table_real = $this->app->database_manager->real_table_name($cart_table); $order_table_real = $this->app->database_manager->real_table_name($table_orders); if ($exec_return == true) { if (isset($_REQUEST['return_to'])) { $return_to = urldecode($_REQUEST['return_to']); $append = '?'; if (strstr($return_to, '?')) { $append = '&'; } if ($mw_process_payment_success == true) { $return_to = $return_to . $append . 'mw_payment_success=1'; } elseif ($mw_process_payment_failed == true) { $return_to = $return_to . $append . 'mw_payment_failure=1'; } return $this->app->url_manager->redirect($return_to); } } $additional_fields = false; if (isset($data['for']) and isset($data['for_id'])) { $additional_fields = $this->app->fields_manager->get($data['for'], $data['for_id'], 1); } $seach_address_keys = array('country', 'city', 'address', 'state', 'zip'); $addr_found_from_search_in_post = false; if (isset($data) and is_array($data)) { foreach ($data as $k => $v) { if (is_array($v)) { foreach ($seach_address_keys as $item) { $case1 = ucfirst($item); if (!isset($data[$item]) and (isset($v[$item]) or isset($v[$case1]))) { $data[$item] = $v[$item]; if ($addr_found_from_search_in_post == false) { unset($data[$k]); } $addr_found_from_search_in_post = 1; } } } } } $save_custom_fields_for_order = array(); if (is_array($additional_fields) and !empty($additional_fields)) { foreach ($additional_fields as $cf) { if (isset($data) and is_array($data)) { foreach ($data as $k => $item) { $key1 = str_replace('_', ' ', $cf['name']); $key2 = str_replace('_', ' ', $k); if ($key1 == $key2) { $save_custom_fields_for_order[$key1] = $this->app->format->clean_html($item); } } } } } $checkout_errors = array(); $check_cart = $this->get_cart($cart); if (!is_array($check_cart)) { $checkout_errors['cart_empty'] = 'Your cart is empty'; } else { if (!isset($data['payment_gw']) and $mw_process_payment == true) { $data['payment_gw'] = 'none'; } else { if ($mw_process_payment == true) { $gw_check = $this->payment_options('payment_gw_' . $data['payment_gw']); if (is_array($gw_check[0])) { $gateway = $gw_check[0]; } else { $checkout_errors['payment_gw'] = 'No such payment gateway is activated'; } } } $shipping_country = false; $shipping_cost_max = false; $shipping_cost = false; $shipping_cost_above = false; if (mw()->user_manager->session_get('shipping_country')) { $shipping_country = mw()->user_manager->session_get('shipping_country'); } if (mw()->user_manager->session_get('shipping_cost_max')) { $shipping_cost_max = mw()->user_manager->session_get('shipping_cost_max'); } if (mw()->user_manager->session_get('shipping_cost')) { $shipping_cost = mw()->user_manager->session_get('shipping_cost'); } if (mw()->user_manager->session_get('shipping_cost_above')) { $shipping_cost_above = mw()->user_manager->session_get('shipping_cost_above'); } //post any of those on the form $flds_from_data = array('first_name', 'last_name', 'email', 'country', 'city', 'state', 'zip', 'address', 'address2', 'payment_email', 'payment_name', 'payment_country', 'payment_address', 'payment_city', 'payment_state', 'payment_zip', 'phone', 'promo_code', 'payment_gw'); if (!isset($data['email']) or $data['email'] == '') { $checkout_errors['email'] = 'Email is required'; } if (!isset($data['first_name']) or $data['first_name'] == '') { $checkout_errors['first_name'] = 'First name is required'; } if (!isset($data['last_name']) or $data['last_name'] == '') { $checkout_errors['last_name'] = 'Last name is required'; } if (isset($data['payment_gw']) and $data['payment_gw'] != '') { $data['payment_gw'] = str_replace('..', '', $data['payment_gw']); } $custom_order_id = $this->app->option_manager->get('custom_order_id', 'shop'); $posted_fields = array(); $place_order = array(); $place_order['id'] = false; $return_url_after = ''; if ($this->app->url_manager->is_ajax()) { $place_order['url'] = $this->app->url_manager->current(true); $return_url_after = '&return_to=' . urlencode($_SERVER['HTTP_REFERER']); } elseif (isset($_SERVER['HTTP_REFERER'])) { $place_order['url'] = $_SERVER['HTTP_REFERER']; $return_url_after = '&return_to=' . urlencode($_SERVER['HTTP_REFERER']); } else { $place_order['url'] = $this->app->url_manager->current(); } $place_order['session_id'] = $sid; $place_order['order_completed'] = 0; $items_count = 0; foreach ($flds_from_data as $value) { if (isset($data[$value]) and $data[$value] != false) { $place_order[$value] = $data[$value]; $posted_fields[$value] = $data[$value]; } } $amount = $this->cart_total(); $tax = $this->app->cart_manager->get_tax(); if (!empty($checkout_errors)) { return array('error' => $checkout_errors); } $place_order['amount'] = $amount; $place_order['allow_html'] = true; $place_order['currency'] = $this->app->option_manager->get('currency', 'payments'); if (isset($data['shipping_gw'])) { $place_order['shipping_service'] = $data['shipping_gw']; } $place_order['shipping'] = $shipping_cost; if ($tax != 0) { $place_order['taxes_amount'] = $tax; } $items_count = $this->cart_sum(false); $place_order['items_count'] = $items_count; $cart_checksum = md5($sid . serialize($check_cart) . uniqid()); $place_order['payment_verify_token'] = $cart_checksum; define('FORCE_SAVE', $table_orders); if (isset($save_custom_fields_for_order) and !empty($save_custom_fields_for_order)) { $place_order['custom_fields_data'] = $this->app->format->array_to_base64($save_custom_fields_for_order); } if (!isset($place_order['shipping']) or $place_order['shipping'] == false) { $place_order['shipping'] = 0; } $temp_order = $this->app->database_manager->save($table_orders, $place_order); if ($temp_order != false) { $place_order['id'] = $temp_order; } else { $place_order['id'] = 0; } if ($custom_order_id != false) { foreach ($place_order as $key => $value) { $custom_order_id = str_ireplace('{' . $key . '}', $value, $custom_order_id); } $custom_order_id = str_ireplace('{YYYYMMDD}', date('Ymd'), $custom_order_id); $custom_order_id = str_ireplace('{date}', date('Y-m-d'), $custom_order_id); } if ($custom_order_id != false) { $place_order['item_name'] = 'Order id:' . ' ' . $custom_order_id; $place_order['order_id'] = $custom_order_id; } else { $place_order['item_name'] = 'Order id:' . ' ' . $place_order['id']; } if ($mw_process_payment == true) { $shop_dir = module_dir('shop'); $shop_dir = $shop_dir . DS . 'payments' . DS . 'gateways' . DS; if ($data['payment_gw'] != 'none') { $gw_process = modules_path() . $data['payment_gw'] . '_process.php'; if (!is_file($gw_process)) { $gw_process = normalize_path(modules_path() . $data['payment_gw'] . DS . 'process.php', false); } $mw_return_url = $this->app->url_manager->api_link('checkout') . '?mw_payment_success=1&order_id=' . $place_order['id'] . '&payment_gw=' . $data['payment_gw'] . '&payment_verify_token=' . $place_order['payment_verify_token'] . '&order_id=' . $place_order['id'] . $return_url_after; $mw_cancel_url = $this->app->url_manager->api_link('checkout') . '?mw_payment_failure=1&order_id=' . $place_order['id'] . '&payment_gw=' . $data['payment_gw'] . '&payment_verify_token=' . $place_order['payment_verify_token'] . '&order_id=' . $place_order['id'] . $return_url_after; $mw_ipn_url = $this->app->url_manager->api_link('checkout_ipn') . '?payment_gw=' . $data['payment_gw'] . '&order_id=' . $place_order['id'] . '&payment_verify_token=' . $place_order['payment_verify_token'] . $return_url_after; // $place_order['success_url'] = $mw_return_url; // $place_order['cancel_url'] = $mw_cancel_url; // $place_order['notify_url'] = $mw_ipn_url; if (is_file($gw_process)) { require_once $gw_process; } else { $checkout_errors['payment_gw'] = 'Payment gateway\'s process file not found.'; } } else { $place_order['order_completed'] = 1; $place_order['is_paid'] = 0; $place_order['success'] = 'Your order has been placed successfully!'; } $place_order['order_status'] = 'pending'; if (!empty($checkout_errors)) { return array('error' => $checkout_errors); } $ord = $this->place_order($place_order); $place_order['id'] = $ord; } if (isset($place_order) and !empty($place_order)) { if (!isset($place_order['success'])) { $place_order['success'] = 'Your order has been placed successfully!'; } $return = $place_order; if (isset($place_order['redirect'])) { $return['redirect'] = $place_order['redirect']; } return $return; } } if (!empty($checkout_errors)) { return array('error' => $checkout_errors); } }