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; } }
function debug_info() { //if (c('debug_mode')) { return include mw_includes_path() . 'debug.php'; // } }
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 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); }
mw.toolbar.ComponentsShow(h); }); $(mwd.querySelectorAll('.edit')).each(function(){ mw.linkTip.init(this); }) }); </script> <?php event_trigger('live_edit_toolbar_end'); include mw_includes_path() . 'toolbar' . DS . "design.php"; } else { ?> <script> previewHTML = function (html, index) { mw.$('.edit').eq(index).html(html); } window.onload = function () { if (window.opener !== null) { window.opener.mw.$('.edit').each(function (i) { var html = $(this).html(); self.previewHTML(html, i); }); } }
print $data['admin_password']; ?> " <?php } ?> /> </div> </div> </div> </div> </div> <?php $default_content_file = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR . 'mw_default_content.zip'; ?> <?php if (is_file($default_content_file)) { ?> <div class="mw-ui-field-holder pull-left"> <label class="mw-ui-check"> <input name="with_default_content" type="checkbox" checked="checked" value="1"> <span></span> <?php _e("Install default content"); ?> <span data-help="<?php _e("If checked, some default content will be added."); ?> "><span class="mw-icon-help-outline mwahi tip"></span></span>
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); }
/** * make_field. * * @desc make_field * * @category forms * * @author Microweber * * @link http://microweber.com * * @param string $field_type * @param string $field_id * @param array $settings */ public function make($field_id = 0, $field_type = 'text', $settings = false) { if (is_array($field_id)) { if (!empty($field_id)) { $data = $field_id; } } else { if ($field_id != 0) { $data = $this->get_by_id($id = $field_id); } } if (isset($data['settings']) or isset($_REQUEST['settings']) and trim($_REQUEST['settings']) == 'y') { $settings = true; } if (isset($data['copy_from'])) { $copy_from = intval($data['copy_from']); if (is_admin() == true) { $table_custom_field = $this->table; $form_data = $this->app->database_manager->get_by_id($table_custom_field, $id = $copy_from); if (is_array($form_data)) { $field_type = $form_data['type']; $data['id'] = 0; if (isset($data['save_on_copy'])) { $cp = $form_data; $cp['id'] = 0; $cp['copy_of_field'] = $copy_from; if (isset($data['rel_type'])) { $cp['rel_type'] = $data['rel_type']; } if (isset($data['rel_id'])) { $cp['rel_id'] = $data['rel_id']; } $this->save($cp); $data = $cp; } else { $data = $form_data; } } } } elseif (isset($data['field_id'])) { $data = $this->get_by_id($id = $data['field_id']); } if (isset($data['type'])) { $field_type = $data['type']; } if (!isset($data['custom_field_required'])) { $data['custom_field_required'] = 'n'; } if (isset($data['type'])) { $field_type = $data['type']; } if (isset($data['field_type'])) { $field_type = $data['field_type']; } if (isset($data['field_values']) and !isset($data['value'])) { $data['values'] = $data['field_values']; } $data['type'] = $field_type; if (isset($data['options']) and is_string($data['options'])) { $data['options'] = $this->_decode_options($data['options']); } $data = $this->app->url_manager->replace_site_url_back($data); $dir = mw_includes_path(); $dir = $dir . DS . 'custom_fields' . DS; $field_type = str_replace('..', '', $field_type); $load_from_theme = false; if (defined('ACTIVE_TEMPLATE_DIR')) { $custom_fields_from_theme = ACTIVE_TEMPLATE_DIR . 'modules' . DS . 'custom_fields' . DS; if (is_dir($custom_fields_from_theme)) { if ($settings == true or isset($data['settings'])) { $file = $custom_fields_from_theme . $field_type . '_settings.php'; } else { $file = $custom_fields_from_theme . $field_type . '.php'; } if (is_file($file)) { $load_from_theme = true; } } } if ($load_from_theme == false) { if ($settings == true or isset($data['settings'])) { $file = $dir . $field_type . '_settings.php'; } else { $file = $dir . $field_type . '.php'; } } if (!is_file($file)) { $field_type = 'text'; if ($settings == true or isset($data['settings'])) { $file = $dir . $field_type . '_settings.php'; } else { $file = $dir . $field_type . '.php'; } } $file = normalize_path($file, false); if (is_file($file)) { $l = new \Microweber\View($file); // $l->assign('settings', $settings); if (isset($data['params'])) { $l->assign('params', $data['params']); } else { $l->assign('params', false); } // $l->settings = $settings; if (isset($data) and !empty($data)) { $l->data = $data; } else { $l->data = array(); } $l->assign('data', $data); $layout = $l->__toString(); return $layout; } }
/** * Shows a section of the help file. * * @internal its used on the help in the admin */ function show_help($section = 'main') { $lang = current_lang(); $lang = str_replace('..', '', $lang); if (trim($lang) == '') { $lang = 'en'; } $lang_file = mw_includes_path() . 'help' . DIRECTORY_SEPARATOR . $lang . '.php'; $lang_file_en = mw_includes_path() . 'help' . DIRECTORY_SEPARATOR . $lang . '.php'; $lang_file = normalize_path($lang_file, false); if (is_file($lang_file)) { include $lang_file; } elseif (is_file($lang_file_en)) { return $lang_file_en; } }
<script type="text/javascript"> mw.require('forms.js', true); mw.require('url.js', true); </script> <?php if (!isset($rand)) { $rand = uniqid(); } ?> <script type="text/javascript"> <?php include mw_includes_path() . 'api/treerenderer.php'; ?> mw.menu_add_new = function(){ var obj = {}; obj.title = $('#new_menu_name').val(); $.post("<?php print api_link('content/menu_create'); ?> ", obj, function(data){ window.location.href = window.location.href; }); }
public function load_apijs($page = false) { $this->app->content_manager->define_constants($page); $l = new \Microweber\View(mw_includes_path() . 'api' . DS . 'api.js'); $l = $l->__toString(); $l = str_replace('{SITE_URL}', $this->app->url_manager->site(), $l); $l = str_replace('{MW_SITE_URL}', $this->app->url_manager->site(), $l); $l = str_replace('%7BSITE_URL%7D', $this->app->url_manager->site(), $l); return $l; }
mw.require("<?php print mw_includes_url(); ?> js/jquery-ui-1.10.0.custom.min.js"); mw.require("tools.js"); mw.require("liveadmin.js"); mw.require("events.js"); mw.require("url.js"); mw.require("wysiwyg.js"); mw.require("css_parser.js"); mw.require ("forms.js"); mw.require("files.js"); mw.require("content.js", true); mw.require("liveedit.js"); mw.require(mw.settings.includes_url + "css/liveedit.css"); mw.require(mw.settings.includes_url + "css/components.css"); mw.require(mw.settings.includes_url + "css/wysiwyg.css"); </script> <style> .mw-sorthandle, .mw_master_handle { display:none !important; } </style> <?php $here = mw_includes_path(); include $here . 'toolbar' . DS . 'wysiwyg.php'; include $here . 'toolbar' . DS . 'wysiwyg_tiny.php';
mw_var('plain_modules', true); if (is_admin() == false) { //exit('Must be admin'); } ?> <div class="mw-admin-editor <?php print $mainclass; ?> " id="the_admin_editor"> <?php //include mw_includes_path() . DS . 'toolbar' . DS ."wysiwyg_admin.php"; ?> <?php include mw_includes_path() . DS . 'toolbar' . DS . "wysiwyg_tiny.php"; ?> <div class="mw-admin-editor-area" id="mw-iframe-editor-area" tabindex="0" >{content}</div> </div> <?php mw_var('plain_modules', false); ?> <span class="mw-plus-top">+</span> <span class="mw-plus-bottom">+</span> <div style="display: none" id="plus-modules-list"> <input type="text" class="mw-ui-searchfield" /> <div class="mw-ui-btn-nav mw-ui-btn-nav-tabs pull-left"> <span class="mw-ui-btn active"><span class="mw-icon-module"></span><?php _e("Modules");
::-webkit-scrollbar-thumb { background: #787878; } .mw-admin-editor .module{ } </style> </head> <body style="padding: 0;margin: 0;"> <?php mw_var('plain_modules', true); if (is_admin() == false) { //exit('Must be admin'); } ?> <div class="mw-admin-editor" id="the_admin_editor"> <?php include mw_includes_path() . DS . 'toolbar' . DS . "wysiwyg_admin.php"; ?> <div id="mw-richtext-content" tabindex="0" autofocus="autofocus">{content}</div> </div> <?php mw_var('plain_modules', false); ?> </body> </html>
} else { $done = true; $f = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR . 'done.php'; include $f; exit; } // var_dump($save_config); } } if (!isset($to_save['IS_INSTALLED'])) { $cfg = MW_CONFIG_FILE; $data = false; if (is_file($cfg)) { include $cfg; if (isset($config)) { $data = $config; } // } if (is_array($data)) { foreach ($data as $key => $value) { if (is_string($value) and !is_array($key)) { $value_clean = str_ireplace($remove, '', $value); $data[$key] = $value_clean; } } } __mw_install_log('Preparing to install'); $f = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR . 'main.php'; include $f; }