<?php /* type: layout content_type: static name: Home position: 11 description: Home layout */ mw_var('photon_layout', 'photon-default'); include THIS_TEMPLATE_DIR . "header.php"; ?> <style type="text/css"> #main-content-holder{ max-width: none; } </style> <div data-mw="main"> <module data-type="posts" data-limit="0" id="home-posts" data-description-length="100" data-show="thumbnail" data-hide-paging="true" data-template="justified" /> </div> <?php include THIS_TEMPLATE_DIR . "footer.php";
public function send_forgot_password($params) { if (!isset($params['captcha'])) { return array('error' => 'Please enter the captcha answer!'); } else { $validate_captcha = $this->app->captcha->validate($params['captcha']); if ($validate_captcha == false) { return array('error' => 'Invalid captcha answer!', 'captcha_error' => true); } } if (isset($params['email'])) { //return array('error' => 'Enter username or email!'); } else { if (!isset($params['username']) or trim($params['username']) == '') { return array('error' => 'Enter username or email!'); } } $data_res = false; $data = false; if (isset($params) and !empty($params)) { $user = isset($params['username']) ? $params['username'] : false; $email = isset($params['email']) ? $params['email'] : false; $data = array(); if (trim($user != '')) { $data1 = array(); $data1['username'] = $user; $data = array(); if (trim($user != '')) { $data = $this->get_all($data1); if ($data == false) { $data1 = array(); $data1['email'] = $user; $data = $this->get_all($data1); } } } elseif (trim($email != '')) { $data1 = array(); $data1['email'] = $email; $data = array(); if (trim($email != '')) { $data = $this->get_all($data1); } } if (isset($data[0])) { $data_res = $data[0]; } if (!is_array($data_res)) { return array('error' => 'Enter right username or email!'); } else { $to = $data_res['email']; if (isset($to) and filter_var($to, FILTER_VALIDATE_EMAIL)) { $subject = "Password reset!"; $content = "Hello, {$data_res['username']} <br> "; $content .= "You have requested a password reset link from IP address: " . MW_USER_IP . "<br><br> "; $security = array(); $security['ip'] = MW_USER_IP; // $security['hash'] = $this->app->format->array_to_base64($data_res); $function_cache_id = md5(rand()) . uniqid() . rand() . str_random(40); if (isset($data_res['id'])) { $data_to_save = array(); $data_to_save['id'] = $data_res['id']; $data_to_save['password_reset_hash'] = $function_cache_id; $table = $this->tables['users']; mw_var('FORCE_SAVE', $table); $save = $this->app->database_manager->save($table, $data_to_save); } $base_link = $this->app->url_manager->current(1); $cur_template = template_dir(); $cur_template_file = normalize_path($cur_template . 'login.php', false); $cur_template_file2 = normalize_path($cur_template . 'forgot_password.php', false); if (is_file($cur_template_file)) { $base_link = site_url('login'); } elseif (is_file($cur_template_file2)) { $base_link = site_url('forgot_password'); } $pass_reset_link = $base_link . '?reset_password_link=' . $function_cache_id; $notif = array(); $notif['module'] = "users"; $notif['rel_type'] = 'users'; $notif['rel_id'] = $data_to_save['id']; $notif['title'] = "Password reset link sent"; $content_notif = "User with id: {$data_to_save['id']} and email: {$to} has requested a password reset link"; $notif['description'] = $content_notif; $this->app->log_manager->save($notif); $content .= "Click here to reset your password <a href='{$pass_reset_link}'>" . $pass_reset_link . "</a><br><br> "; $sender = new \Microweber\Utils\MailSender(); $sender->send($to, $subject, $content); return array('success' => 'Your password reset link has been sent to ' . $to); } else { return array('error' => 'Error: the user doesn\'t have a valid email address!'); } } } }
public function module() { if (!defined('MW_API_CALL')) { // define('MW_API_CALL', true); } if (!defined('MW_NO_SESSION')) { $is_ajax = $this->app->url_manager->is_ajax(); if (!mw()->user_manager->session_id() and $is_ajax == false) { if (!defined('MW_SESS_STARTED')) { define('MW_SESS_STARTED', true); // //session_start(); } } $editmode_sess = $this->app->user_manager->session_get('editmode'); if ($editmode_sess == true and !defined('IN_EDIT')) { define('IN_EDIT', true); } } $page = false; $custom_display = false; if (isset($_REQUEST['data-display']) and $_REQUEST['data-display'] == 'custom') { $custom_display = true; } if (isset($_REQUEST['data-module-name'])) { $_REQUEST['module'] = $_REQUEST['data-module-name']; $_REQUEST['data-type'] = $_REQUEST['data-module-name']; if (!isset($_REQUEST['id'])) { $_REQUEST['id'] = $this->app->url_manager->slug($_REQUEST['data-module-name'] . '-' . date('YmdHis')); } } if (isset($_REQUEST['data-type'])) { $_REQUEST['module'] = $_REQUEST['data-type']; } if (isset($_REQUEST['display']) and $_REQUEST['display'] == 'custom') { $custom_display = true; } if (isset($_REQUEST['view']) and $_REQUEST['view'] == 'admin') { $custom_display = false; } if ($custom_display == true) { $custom_display_id = false; if (isset($_REQUEST['id'])) { $custom_display_id = $_REQUEST['id']; } if (isset($_REQUEST['data-id'])) { $custom_display_id = $_REQUEST['data-id']; } } if (isset($_REQUEST['from_url'])) { $from_url = $_REQUEST['from_url']; } elseif (isset($_SERVER['HTTP_REFERER'])) { $from_url = $_SERVER['HTTP_REFERER']; } if (isset($from_url) and $from_url != false) { if (stristr($from_url, 'editor_tools/wysiwyg')) { if (!defined('IN_EDITOR_TOOLS')) { define('IN_EDITOR_TOOLS', true); } } $url = $from_url; $from_url2 = str_replace('#', '/', $from_url); $content_id = $this->app->url_manager->param('content_id', false, $from_url2); if ($content_id == false) { $content_id = $this->app->url_manager->param('editpage', false, $from_url2); } if ($content_id == false) { $content_id = $this->app->url_manager->param('editpost', false, $from_url2); } if ($content_id == false) { $is_current = $this->app->url_manager->param('is-current', false, $from_url2); if ($is_current) { $content_id = $this->app->url_manager->param('content-id', false, $from_url2); } else { $content_id = $this->app->url_manager->param('mw-adm-content-id', false, $from_url2); } } if ($content_id == false) { $action_test = $this->app->url_manager->param('action', false, $from_url2); if ($action_test != false) { $action_test = str_ireplace('editpage:', '', $action_test); $action_test = str_ireplace('editpost:', '', $action_test); $action_test = str_ireplace('edit:', '', $action_test); $action_test = str_ireplace('showposts:', '', $action_test); $action_test = intval($action_test); if ($action_test != 0) { $content_id = $action_test; $this->app->content_manager->define_constants(array('id' => $content_id)); } } } if (strpos($url, '#')) { $url = substr($url, 0, strpos($url, '#')); } //$url = $_SERVER["HTTP_REFERER"]; $url = explode('?', $url); $url = $url[0]; if ($content_id != false) { $page = array(); $page['id'] = $content_id; if ($content_id) { $page = $this->app->content_manager->get_by_id($content_id); $url = $page['url']; } } else { if (trim($url) == '' or trim($url) == $this->app->url_manager->site()) { //var_dump($from_url); //$page = $this->app->content_manager->get_by_url($url); $page = $this->app->content_manager->homepage(); if (!defined('IS_HOME')) { define('IS_HOME', true); } if (isset($from_url2)) { $mw_quick_edit = $this->app->url_manager->param('mw_quick_edit', false, $from_url2); if ($mw_quick_edit) { $page = false; } } } else { if (!stristr($url, admin_url())) { $page = $this->app->content_manager->get_by_url($url); } else { $page = false; if (!defined('PAGE_ID')) { define('PAGE_ID', false); } if (!defined('POST_ID')) { define('POST_ID', false); } if (!defined('CONTENT_ID')) { define('CONTENT_ID', false); } } } } } else { $url = $this->app->url_manager->string(); } if (!defined('IS_HOME')) { if (isset($page['is_home']) and $page['is_home'] == 'y') { define('IS_HOME', true); } } if ($page == false) { if (!isset($content_id)) { return; } $this->app->content_manager->define_constants(array('id' => $content_id)); } else { $this->app->content_manager->define_constants($page); } if (defined('TEMPLATE_DIR')) { $load_template_functions = TEMPLATE_DIR . 'functions.php'; if (is_file($load_template_functions)) { include_once $load_template_functions; } } if ($custom_display == true) { $u2 = $this->app->url_manager->site(); $u1 = str_replace($u2, '', $url); $this->render_this_url = $u1; $this->isolate_by_html_id = $custom_display_id; $this->frontend(); return; } $url_last = false; if (!isset($_REQUEST['module'])) { $url = $this->app->url_manager->string(0); if ($url == __FUNCTION__) { $url = $this->app->url_manager->string(0); } /* $is_ajax = $this->app->url_manager->is_ajax(); if ($is_ajax == true) { $url = $this->app->url_manager->string(true); }*/ $url = $this->app->format->replace_once('module/', '', $url); $url = $this->app->format->replace_once('module_api/', '', $url); $url = $this->app->format->replace_once('m/', '', $url); if (is_module($url)) { $_REQUEST['module'] = $url; $mod_from_url = $url; } else { $url1 = $url_temp = explode('/', $url); $url_last = array_pop($url_temp); $try_intil_found = false; $temp1 = array(); foreach ($url_temp as $item) { $temp1[] = implode('/', $url_temp); $url_laset = array_pop($url_temp); } $i = 0; foreach ($temp1 as $item) { if ($try_intil_found == false) { if (is_module($item)) { $url_tempx = explode('/', $url); $_REQUEST['module'] = $item; $url_prev = $url_last; $url_last = array_pop($url_tempx); $url_prev = array_pop($url_tempx); // d($url_prev); $mod_from_url = $item; $try_intil_found = true; } } ++$i; } } } $module_info = $this->app->url_manager->param('module_info', true); if ($module_info) { if ($_REQUEST['module']) { $_REQUEST['module'] = str_replace('..', '', $_REQUEST['module']); $try_config_file = modules_path() . '' . $_REQUEST['module'] . '_config.php'; $try_config_file = normalize_path($try_config_file, false); if (is_file($try_config_file)) { include $try_config_file; if (!isset($config) or !is_array($config)) { return false; } if (!isset($config['icon']) or $config['icon'] == false) { $config['icon'] = modules_path() . '' . $_REQUEST['module'] . '.png'; $config['icon'] = $this->app->url_manager->link_to_file($config['icon']); } echo json_encode($config); return; } } } $admin = $this->app->url_manager->param('admin', true); $mod_to_edit = $this->app->url_manager->param('module_to_edit', true); $embed = $this->app->url_manager->param('embed', true); $mod_iframe = false; if ($mod_to_edit != false) { $mod_to_edit = str_ireplace('_mw_slash_replace_', '/', $mod_to_edit); $mod_iframe = true; } //$data = $_REQUEST; if ($_POST) { $data = $_POST; } else { $url = $this->app->url_manager->segment(); if (!empty($url)) { foreach ($url as $k => $v) { $kv = explode(':', $v); if (isset($kv[0]) and isset($kv[1])) { $data[$kv[0]] = $kv[1]; } } } } $tags = false; $mod_n = false; if (isset($data['type']) != false) { if (trim($data['type']) != '') { $mod_n = $data['data-type'] = $data['type']; } } if (isset($data['data-module-name'])) { $mod_n = $data['data-type'] = $data['data-module-name']; unset($data['data-module-name']); } if (isset($data['data-type']) != false) { $mod_n = $data['data-type']; } if (isset($data['data-module']) != false) { if (trim($data['data-module']) != '') { $mod_n = $data['module'] = $data['data-module']; } } if (isset($data['module'])) { $mod_n = $data['data-type'] = $data['module']; unset($data['module']); } if (isset($data['type'])) { $mod_n = $data['data-type'] = $data['type']; unset($data['type']); } if (isset($data['data-type']) != false) { $data['data-type'] = rtrim($data['data-type'], '/'); $data['data-type'] = rtrim($data['data-type'], '\\'); $data['data-type'] = str_replace('__', '/', $data['data-type']); } if (!isset($data)) { $data = $_REQUEST; } if (!isset($data['module']) and isset($mod_from_url) and $mod_from_url != false) { $data['module'] = $mod_from_url; } if (!isset($data['id']) and isset($_REQUEST['id']) == true) { $data['id'] = $_REQUEST['id']; } if (isset($data['ondrop'])) { if (!defined('MW_MODULE_ONDROP')) { define('MW_MODULE_ONDROP', true); } unset($data['ondrop']); } if ($mod_n == 'layout') { if (isset($data['template'])) { $t = str_replace('..', '', $data['template']); $possible_layout = templates_path() . $t; $possible_layout = normalize_path($possible_layout, false); if (is_file($possible_layout)) { $l = new \Microweber\View($possible_layout); $layout = $l->__toString(); $layout = $this->app->parser->process($layout, $options = false); echo $layout; return; } } } $has_id = false; if (isset($data) and is_array($data)) { foreach ($data as $k => $v) { if ($k != 'ondrop') { if ($k == 'id') { $has_id = true; } if (is_array($v)) { $v1 = $this->app->format->array_to_base64($v); $tags .= "{$k}=\"{$v1}\" "; } else { $v = $this->app->format->clean_html($v); //$v = $this->app->database_manager->escape_string($v); $tags .= "{$k}=\"{$v}\" "; } } } } if ($has_id == false) { // $mod_n = $this->app->url_manager->slug($mod_n) . '-' . date("YmdHis"); // $tags .= "id=\"$mod_n\" "; } $tags = "<module {$tags} />"; $opts = array(); if ($_REQUEST) { $opts = $_REQUEST; } if (isset($_REQUEST['live_edit'])) { event_trigger('mw.live_edit'); } $opts['admin'] = $admin; if ($admin == 'admin') { event_trigger('mw_backend'); event_trigger('mw.admin'); } else { event_trigger('mw_frontend'); event_trigger('mw.front'); } if (isset($_SERVER['HTTP_REFERER']) and $_SERVER['HTTP_REFERER'] != false) { $get_arr_from_ref = $_SERVER['HTTP_REFERER']; if (strstr($get_arr_from_ref, $this->app->url_manager->site())) { $get_arr_from_ref_arr = parse_url($get_arr_from_ref); if (isset($get_arr_from_ref_arr['query']) and $get_arr_from_ref_arr['query'] != '') { $restore_get = parse_str($get_arr_from_ref_arr['query'], $get_array); if (is_array($get_array)) { mw_var('mw_restore_get', $get_array); } // } } } $res = $this->app->parser->process($tags, $opts); $res = preg_replace('~<(?:!DOCTYPE|/?(?:html|head|body))[^>]*>\\s*~i', '', $res); if ($embed != false) { $p_index = mw_includes_path() . 'api/index.php'; $p_index = normalize_path($p_index, false); $l = new \Microweber\View($p_index); $layout = $l->__toString(); $res = str_replace('{content}', $res, $layout); } $aj = $this->app->url_manager->is_ajax(); if (isset($_REQUEST['live_edit']) and $aj == false) { $p_index = mw_includes_path() . DS . 'toolbar' . DS . 'editor_tools' . DS . 'module_settings' . DS . 'index.php'; $p_index = normalize_path($p_index, false); $l = new \Microweber\View($p_index); $l->params = $data; $layout = $l->__toString(); $res = str_replace('{content}', $res, $layout); $res = $this->app->parser->process($res, $options = false); } $res = execute_document_ready($res); if (!defined('MW_NO_OUTPUT')) { $res = $this->app->url_manager->replace_site_url_back($res); echo $res; } if ($url_last != __FUNCTION__) { if (function_exists($url_last)) { // $this->api($url_last); } elseif (isset($url_prev) and function_exists($url_prev)) { $this->api($url_last); } elseif (class_exists($url_last, false)) { $this->api($url_last); } elseif (isset($url_prev) and class_exists($url_prev, false)) { $this->api($url_prev); } } return; }
function stats_insert_cookie_based() { $function_cache_id = false; $uip = $_SERVER['REMOTE_ADDR']; $function_cache_id = $function_cache_id . $uip . MW_USER_IP; $cookie_name = 'mw-stats' . crc32($function_cache_id); $cookie_name_time = 'mw-time' . crc32($function_cache_id); $vc1 = 1; $few_mins_ago_visit_date = date("Y-m-d H:i:s"); if (isset($_COOKIE[$cookie_name])) { $vc1 = intval($_COOKIE[$cookie_name]) + 1; // mw()->session->get($cookie_name) = $vc1; setcookie($cookie_name, $vc1, time() + 99); // return true; } elseif (!isset($_COOKIE[$cookie_name])) { setcookie($cookie_name, $vc1, time() + 99); //mw()->session->get($cookie_name) = $vc1; // return true; } if (!isset($_COOKIE[$cookie_name_time])) { setcookie($cookie_name_time, $few_mins_ago_visit_date, time() + 90); $data = array(); $data['visit_date'] = date("Y-m-d", strtotime("now")); $data['visit_time'] = date("H:i:s", strtotime("now")); $table = MODULE_DB_USERS_ONLINE; $check = db_get("no_cache=1&table={$table}&user_ip={$uip}&one=1&limit=1&visit_date=" . $data['visit_date']); if ($check != false and is_array($check) and !empty($check) and isset($check['id'])) { $data['id'] = $check['id']; $vc = 0; if (isset($check['view_count'])) { $vc = $check['view_count']; } $vc1 = 0; if (isset($_COOKIE[$cookie_name])) { $vc1 = intval($_COOKIE[$cookie_name]); } $vc = $vc + $vc1; $data['view_count'] = $vc; } if (isset($_SERVER['HTTP_REFERER'])) { $lp = $_SERVER['HTTP_REFERER']; } else { $lp = $_SERVER['PHP_SELF']; } $data['last_page'] = $lp; $data['skip_cache'] = 1; if (mw()->user_manager->session_id() and !(mw()->user_manager->session_all() == false)) { $data['session_id'] = mw()->user_manager->session_id(); } mw_var('FORCE_SAVE', $table); mw_var('apc_no_clear', 1); $save = mw()->database_manager->save($table, $data); setcookie($cookie_name, 0, time() + 99); } return true; }
<?php /* type: layout content_type: dynamic name: Online Shop is_shop: y description: shop layout position: 4 */ mw_var('photon_layout', 'photon-inner'); include THIS_TEMPLATE_DIR . "header.php"; ?> <style> body.photon-inner #main-content-holder{ background-color: transparent; } </style> <section id="content"> <div class="container"> <div class="mw-ui-row" id="shop-products-conteiner"> <div class="mw-ui-col"> <div class="mw-ui-col-container"> <module type="shop/products" template="" limit="6" description-length="160" hide-paging="n" /> </div> </div> </div> </div> </section> <?php include THIS_TEMPLATE_DIR . "footer.php";
public function post($params) { $adm = $this->app->user_manager->is_admin(); if (defined("MW_API_CALL")) { // $validate_token = $this->app->user_manager->csrf_validate($params); // if (!$adm) { // if ($validate_token == false) { // return array('error' => 'Invalid token!'); // } // } } $before_process = $this->app->event_manager->trigger('mw.forms_manager.before_post', $params); if (is_array($before_process) and !empty($before_process)) { foreach ($before_process as $before_process_item) { if ($before_process_item === false) { return; } } } $table = MW_DB_TABLE_FORMS_DATA; mw_var('FORCE_SAVE', $table); if (isset($params['id'])) { if ($adm == false) { return array('error' => 'Error: Only admin can edit forms!'); } } $for = 'module'; if (isset($params['for'])) { $for = $params['for']; } if (isset($params['for_id'])) { $for_id = $params['for_id']; } else { if (isset($params['data-id'])) { $for_id = $params['data-id']; } else { if (isset($params['id'])) { $for_id = $params['id']; } } } if (isset($params['rel_id'])) { $for_id = $params['rel_id']; } if (!isset($for_id)) { return array('error' => 'Please provide for_id parameter with module id'); } $dis_cap = $this->app->option_manager->get('disable_captcha', $for_id) == 'y'; if ($dis_cap == false) { if (!isset($params['captcha'])) { return array('error' => 'Please enter the captcha answer!'); } else { if ($for_id != false) { $validate_captcha = mw()->captcha->validate($params['captcha'], $for_id); } else { $validate_captcha = mw()->captcha->validate($params['captcha']); } if (!$validate_captcha) { if ($adm == false) { return array('error' => 'Invalid captcha answer!', 'captcha_error' => true); } } } } // if ($for=='module'){ $list_id = $this->app->option_manager->get('list_id', $for_id); // } $email_to = $this->app->option_manager->get('email_to', $for_id); $email_bcc = $this->app->option_manager->get('email_bcc', $for_id); $email_autorespond = $this->app->option_manager->get('email_autorespond', $for_id); $email_autorespond_subject = $this->app->option_manager->get('email_autorespond_subject', $for_id); if (!isset($list_id) or $list_id == false) { $list_id = 0; } $to_save = array(); $fields_data = array(); $get_fields = array(); $get_fields['rel_type'] = $for; $get_fields['rel_id'] = $for_id; $get_fields['return_full'] = true; $more = $this->app->fields_manager->get($get_fields); $cf_to_save = array(); if (!empty($more)) { foreach ($more as $item) { if (isset($item['name'])) { $cfn = $item['name']; $cfn2 = str_replace(' ', '_', $cfn); if (isset($params[$cfn2]) and $params[$cfn2] != false) { $fields_data[$cfn2] = $params[$cfn2]; $item['value'] = $params[$cfn2]; $cf_to_save[$cfn] = $item; } elseif (isset($params[$cfn]) and $params[$cfn] != false) { $fields_data[$cfn] = $params[$cfn]; $item['value'] = $params[$cfn2]; $cf_to_save[$cfn] = $item; } } } } else { $cf_to_save = $params; } $to_save['list_id'] = $list_id; $to_save['rel_id'] = $for_id; $to_save['rel_type'] = $for; $to_save['user_ip'] = MW_USER_IP; if (isset($params['module_name'])) { $to_save['module_name'] = $params['module_name']; } if (!empty($fields_data)) { $to_save['form_values'] = json_encode($fields_data); } else { $to_save['form_values'] = json_encode($params); } $save = $this->app->database_manager->save($table, $to_save); $event_params = $params; $event_params['saved_form_entry_id'] = $save; $this->app->event_manager->trigger('mw.forms_manager.after_post', $event_params); if (isset($params['module_name'])) { $pp_arr = $params; $pp_arr['ip'] = MW_USER_IP; unset($pp_arr['module_name']); if (isset($pp_arr['rel_type'])) { unset($pp_arr['rel_type']); } if (isset($pp_arr['rel_id'])) { unset($pp_arr['rel_id']); } if (isset($pp_arr['list_id'])) { unset($pp_arr['list_id']); } if (isset($pp_arr['for'])) { unset($pp_arr['for']); } if (isset($pp_arr['for_id'])) { unset($pp_arr['for_id']); } $notif = array(); $notif['module'] = $params['module_name']; $notif['rel_type'] = 'forms_lists'; $notif['rel_id'] = $list_id; $notif['title'] = "New form entry"; $notif['description'] = "You have new form entry"; $notif['content'] = "You have new form entry from " . $this->app->url_manager->current(1) . '<br />' . $this->app->format->array_to_ul($pp_arr); $this->app->notifications_manager->save($notif); if ($email_to == false) { $email_to = $this->app->option_manager->get('email_from', 'email'); } $admin_user_mails = array(); if ($email_to == false) { $admins = $this->app->user_manager->get_all('is_admin=1'); if (is_array($admins) and !empty($admins)) { foreach ($admins as $admin) { if (isset($admin['email']) and filter_var($admin['email'], FILTER_VALIDATE_EMAIL)) { $admin_user_mails[] = $admin['email']; $email_to = $admin['email']; } } } } if ($email_to != false) { $mail_sj = "Thank you!"; $mail_autoresp = "Thank you for your request!"; if ($email_autorespond_subject != false) { $mail_sj = $email_autorespond_subject; } if ($email_autorespond != false) { $mail_autoresp = $email_autorespond; } $mail_autoresp = $mail_autoresp . $this->app->format->array_to_ul($pp_arr); $user_mails = array(); if (isset($admin_user_mails) and !empty($admin_user_mails)) { $user_mails = $admin_user_mails; } $user_mails[] = $email_to; if (isset($email_bcc) and filter_var($email_bcc, FILTER_VALIDATE_EMAIL)) { $user_mails[] = $email_bcc; } $email_from = false; if (isset($cf_to_save) and !empty($cf_to_save)) { foreach ($cf_to_save as $value) { if (is_array($value) and isset($value['value'])) { $to = $value['value']; } else { $to = $value; } if (isset($to) and filter_var($to, FILTER_VALIDATE_EMAIL)) { $user_mails[] = $to; $email_from = $to; } } } else { } if (!empty($user_mails)) { array_unique($user_mails); foreach ($user_mails as $value) { $sender = new \Microweber\Utils\MailSender(); $sender->send($value, $mail_sj, $mail_autoresp); } } } } return $save; }
public function save($params) { $force = false; if (defined('MW_FORCE_USER_SAVE')) { $force = MW_FORCE_USER_SAVE; } elseif ($this->force_save) { $force = $this->force_save; } elseif (mw_var('force_save_user')) { $force = mw_var('force_save_user'); } if (!$force) { if (defined('MW_API_CALL') and mw_is_installed() == true) { if (isset($params['is_admin']) and $this->is_admin() == false and !is_null(User::first())) { unset($params['is_admin']); } } } if ($force == false) { if (isset($params['id']) and $params['id'] != 0) { $adm = $this->is_admin(); if ($adm == false) { $is_logged = user_id(); if ($is_logged == false or $is_logged == 0) { return array('error' => 'You must be logged to save user'); } elseif (intval($is_logged) == intval($params['id']) and intval($params['id']) != 0) { // the user is editing their own profile } else { return array('error' => 'You must be logged to as admin save this user'); } } } else { if (defined('MW_API_CALL') and mw_is_installed() == true) { $adm = $this->is_admin(); if ($adm == false) { $params['id'] = $this->id(); $is_logged = user_id(); if (intval($params['id']) != 0 and $is_logged != $params['id']) { return array('error' => 'You must be logged save your settings'); } } else { if (!isset($params['id'])) { $params['id'] = $this->id(); } } } } } $data_to_save = $params; if (isset($data_to_save['id']) and $data_to_save['id'] != 0 and isset($data_to_save['email']) and $data_to_save['email'] != false) { $old_user_data = $this->get_by_id($data_to_save['id']); if (isset($old_user_data['email']) and $old_user_data['email'] != false) { if ($data_to_save['email'] != $old_user_data['email']) { if (isset($old_user_data['password_reset_hash']) and $old_user_data['password_reset_hash'] != false) { $hash_cache_id = md5(serialize($old_user_data)) . uniqid() . rand(); $data_to_save['password_reset_hash'] = $hash_cache_id; } } } } if (isset($data_to_save['email']) and isset($data_to_save['id'])) { $email = trim($data_to_save['email']); if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $check_existing = array(); $check_existing['email'] = $email; $check_existing['single'] = 1; $check_existing = $this->get_all($check_existing); if (isset($check_existing['id']) and $check_existing['id'] != $data_to_save['id']) { return array('error' => 'User with this email already exists! Try different email address!'); } } } if (isset($params['id']) and intval($params['id']) != 0) { $user = User::find($params['id']); } else { $user = new User(); } $id_to_return = false; $data_to_save = $this->app->format->clean_xss($data_to_save); if ($user->validateAndFill($data_to_save)) { $save = $user->save(); if (isset($user->id)) { $data_to_save['id'] = $params['id'] = $user->id; } if (isset($data_to_save['username']) and $data_to_save['username'] != false and isset($data_to_save['id']) and $data_to_save['id'] != false) { $check_existing = array(); $check_existing['username'] = $data_to_save['username']; $check_existing['single'] = 1; $check_existing = $this->get_all($check_existing); if (isset($check_existing['id']) and $check_existing['id'] != $data_to_save['id']) { return array('error' => 'User with this username already exists! Try different username!'); } } if (isset($params['attributes']) or isset($params['data_fields'])) { $params['extended_save'] = true; } if (isset($params['extended_save'])) { if (isset($data_to_save['password'])) { unset($data_to_save['password']); } if (isset($data_to_save['id'])) { $data_to_save['table'] = 'users'; $this->app->database_manager->extended_save($data_to_save); } } if (isset($params['id']) and intval($params['id']) != 0) { $id_to_return = intval($params['id']); } else { $id_to_return = DB::getPdo()->lastInsertId(); } $params['id'] = $id_to_return; $this->app->event_manager->trigger('mw.user.save', $params); } else { return array('error' => 'Error saving the user!'); } $this->app->cache_manager->delete('users' . DIRECTORY_SEPARATOR . 'global'); $this->app->cache_manager->delete('users' . DIRECTORY_SEPARATOR . '0'); $this->app->cache_manager->delete('users' . DIRECTORY_SEPARATOR . $id_to_return); return $id_to_return; }
<?php $is_new = mw_var('new_page'); $data = array(); $data['id'] = 0; $data['content_type'] = 'page'; $data['title'] = 'Title'; $data['url'] = ''; $data['thumbnail'] = ''; $data['is_active'] = 1; $data['is_home'] = 0; $data['is_shop'] = 0; $data['subtype'] = 'static'; $data['description'] = ''; $data['active_site_template'] = ''; $data['subtype_value'] = ''; $data['parent'] = 0; $data['layout_name'] = ''; $data['layout_file'] = ''; if ($is_new != false) { foreach ($is_new as $k => $v) { $data[$k] = $v; } }
<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"); ?> </span> <span class="mw-ui-btn"><span class="mw-icon-template"></span><?php _e("Layouts"); ?> </span>
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->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); $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'] = 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->css_class($module_name); $config['url_to_module'] = $this->app->url_manager->link_to_file($config['path_to_module']); $get_module_template_settings_from_options = mw_var('get_module_template_settings_from_options'); if (isset($attrs['id'])) { $attrs['id'] = str_replace('__MODULE_CLASS_NAME__', $config['module_class'], $attrs['id']); $template = false; } $lic = $this->license($module_name); // $lic = 'valid'; if ($lic != false) { $config['license'] = $lic; } if (!isset($attrs['id']) and 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); 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 (!empty($config)) { foreach ($config as $key1 => $value1) { mw_var($key1, $value1); } } 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; } }
<meta name="keywords" content="{content_meta_keywords}"> <meta name="description" content="{content_meta_description}"> <!-- Site Open Graph Meta Data --> <meta property="og:title" content="{content_meta_title}"> <meta property="og:type" content="{og_type}"> <meta property="og:url" content="{content_url}"> <meta property="og:image" content="{content_image}"> <meta property="og:description" content="{og_description}"> <meta property="og:site_name" content="{og_site_name}"> <?php include 'header_scripts.php'; ?> </head> <body class="<?php print mw_var('photon_layout'); ?> "> <div id="site-main"> <module type="shop/cart" template="small" id="header-cart"> <div id="sidenav" class="active"> <div id="side-nav-content"> <div class="edit" rel="global" field="header"> <module type="logo" id="logo" /> <module type="menu" name="header_menu" id="main-navigation" template="photon" /> <hr> <module type="social_links" id="nav-social-links"> </div> <div id="copyright" class="edit" field="copyright" rel="global"> <a href="<?php
function post_comment($data) { $adm = is_admin(); $table = MODULE_DB_COMMENTS; mw_var('FORCE_SAVE', $table); if (isset($data['id'])) { if ($adm == false) { error('Error: Only admin can edit comments!'); } } if (defined("MW_API_CALL")) { if (!$adm) { $validate_token = mw()->user_manager->csrf_validate($data); if ($validate_token == false) { return array('error' => 'Invalid token!'); } } } if (isset($data['action']) and isset($data['id'])) { if ($adm == false) { error('Error: Only admin can edit comments!'); } else { $action = strtolower($data['action']); switch ($action) { case 'publish': $data['is_moderated'] = 1; break; case 'unpublish': $data['is_moderated'] = 0; break; case 'spam': $data['is_moderated'] = 0; break; case 'delete': $del = mw()->database_manager->delete_by_id($table, $id = intval($data['id']), $field_name = 'id'); return array('success' => 'Deleted comment with id:' . $id); return $del; break; default: break; } } } else { if (isset($data['rel'])) { $data['rel_type'] = $data['rel']; } if (!isset($data['rel_type'])) { return array('error' => 'Error: invalid data'); } if (!isset($data['rel_id'])) { return array('error' => 'Error: invalid data'); } else { if (trim($data['rel_id']) == '') { return array('error' => 'Error: invalid data'); } } if (!isset($data['captcha'])) { return array('error' => 'Please enter the captcha answer!'); } else { $cap = mw()->user_manager->session_get('captcha'); if (isset($data['module_id'])) { $captcha_sid = 'captcha_' . $data['module_id']; $cap_sid = mw()->user_manager->session_get($captcha_sid); if ($cap_sid != false) { $cap = $cap_sid; } } if ($cap == false) { return array('error' => 'You must load a captcha first!'); } if (intval($data['captcha']) != $cap) { if ($adm == false) { return array('error' => 'Invalid captcha answer!'); } } } } if (!isset($data['id']) and isset($data['comment_body'])) { if (!isset($data['comment_email']) and user_id() == 0) { return array('error' => 'You must type your email or be logged in order to comment.'); } $ref = mw()->url_manager->current(1); if ($ref != false and $ref != '') { $data['from_url'] = htmlentities(strip_tags(mw()->url_manager->current(1))); } } if ($adm == true and !isset($data['id']) and !isset($data['is_moderated'])) { $data['is_moderated'] = '1'; } else { $require_moderation = get_option('require_moderation', 'comments'); if ($require_moderation != 'y') { $data['is_moderated'] = '0'; } } if (!isset($data['id'])) { $data['is_new'] = '1'; } $data['allow_html'] = true; $data = mw()->format->clean_xss($data); $saved_data = mw()->database_manager->save($table, $data); if (!isset($data['id']) and isset($data['comment_body'])) { $notif = array(); $notif['module'] = "comments"; $notif['rel_type'] = $data['rel_type']; $notif['rel_id'] = $data['rel_id']; $notif['title'] = "You have new comment"; $notif['description'] = "New comment is posted on " . mw()->url_manager->current(1); $notif['content'] = mw()->format->limit(strip_tags($data['comment_body']), 800); $notf_id = mw()->notifications_manager->save($notif); $data['moderate'] = admin_url('view:modules/load_module:comments/mw_notif:' . $notf_id); $email_on_new_comment = get_option('email_on_new_comment', 'comments') == 'y'; $to = get_option('email_on_new_comment_value', 'comments'); if ($email_on_new_comment == true) { $subject = "You have new comment"; $message = "Hi, <br/> You have new comment posted on " . mw()->url_manager->current(1) . ' <br /> '; $message .= "IP:" . MW_USER_IP . ' <br /> '; $message .= mw()->format->array_to_ul($data); $sender = new \Microweber\Utils\MailSender(); $sender->send($to, $subject, $message); } } return $saved_data; }
// $restore->debug = 1; ob_start(); $rest = $restore->exec_restore(); ob_get_clean(); __mw_install_log('Default content is installed'); } } } if (isset($to_save['default_template']) and $to_save['default_template'] != false and $to_save['default_template'] != '{default_template}') { $templ = $to_save['default_template']; $templ = str_replace('..', '', $templ); $option = array(); $option['option_value'] = trim($templ); $option['option_key'] = 'current_template'; $option['option_group'] = 'template'; mw_var('FORCE_SAVE', get_table_prefix() . 'options'); $option = mw('option')->save($option); mw()->cache_manager->delete('options'); } __mw_install_log('Clearing cache after install'); mw()->cache_manager->clear(); // mw()->content_manager->create_default_content('install'); if ($auto_install != false) { $done = true; $f = mw_includes_path() . 'install' . DIRECTORY_SEPARATOR . 'main.php'; include $f; exit; } else { print 'done'; } __mw_install_log('done');
static function mark_as_old($data) { only_admin_access(); 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; } }
<? $dashboard_user = user_id_from_url(); ?> <div id="sidebar"> <microweber module="users/new" dashboard_user="******" limit="12"></microweber> <microweber module="users/new" dashboard_user="******" limit="3"></microweber> <p align="right"><a class="mw_blue_link" href="<?php print site_url('dashboard/action:find-friends'); ?> ">Find New Friends</a> | <a href="<?php print site_url('dashboard/action:my-friends'); ?> " class="mw_blue_link">See your friends</a></p> <br /> <br /> <? include(TEMPLATE_DIR.'banner_side.php') ; ?> <br /> <br /> <? $var_params= array();
public function save_content_admin($data, $delete_the_cache = true) { if (is_string($data)) { $data = parse_params($data); } $adm = $this->app->user_manager->is_admin(); $checks = mw_var('FORCE_SAVE_CONTENT'); $orig_data = $data; $stop = false; $data = $this->app->format->strip_unsafe($data); if ($adm == false) { $stop = true; $author_id = user_id(); if (isset($data['created_at'])) { unset($data['created_at']); } if (isset($data['updated_at'])) { unset($data['updated_at']); } if (isset($data['id']) and $data['id'] != 0 and $author_id != 0) { $page_data_to_check_author = $this->get_by_id($data['id']); if (!isset($page_data_to_check_author['created_by']) or $page_data_to_check_author['created_by'] != $author_id) { $stop = true; return array('error' => "You don't have permission to edit this content"); } elseif (isset($page_data_to_check_author['created_by']) and $page_data_to_check_author['created_by'] == $author_id) { $stop = false; } } elseif ($author_id == false) { return array('error' => 'You must be logged to save content'); } if (isset($data['id']) and $data['id'] != 0) { if (!is_admin()) { $check = get_content_by_id($data['id']); if ($check['created_by'] != user_id()) { return array('error' => 'Wrong content'); } } } if (isset($data['is_home'])) { if (!is_admin()) { unset($data['is_home']); } } if ($stop == true) { if (defined('MW_API_FUNCTION_CALL') and MW_API_FUNCTION_CALL == __FUNCTION__) { if (!isset($data['captcha'])) { if (isset($data['error_msg'])) { return array('error' => $data['error_msg']); } else { return array('error' => 'Please enter a captcha answer!'); } } else { $cap = $this->app->user_manager->session_get('captcha'); if ($cap == false) { return array('error' => 'You must load a captcha first!'); } if ($data['captcha'] != $cap) { return array('error' => 'Invalid captcha answer!'); } } } } if (isset($data['categories'])) { $data['category'] = $data['categories']; } //if (defined('MW_API_FUNCTION_CALL') and MW_API_FUNCTION_CALL == __FUNCTION__) { if (isset($data['category'])) { $cats_check = array(); if (is_array($data['category'])) { foreach ($data['category'] as $cat) { $cats_check[] = intval($cat); } } else { $cats_check[] = intval($data['category']); } $check_if_user_can_publish = $this->app->category_manager->get('ids=' . implode(',', $cats_check)); if (!empty($check_if_user_can_publish)) { $user_cats = array(); foreach ($check_if_user_can_publish as $item) { if (isset($item['users_can_create_content']) and $item['users_can_create_content'] == 1) { $user_cats[] = $item['id']; $cont_cat = $this->get('limit=1&content_type=page&subtype_value=' . $item['id']); } } if (!empty($user_cats)) { $stop = false; $data['categories'] = $user_cats; } } } } // } if ($stop == true) { return array('error' => 'You don\'t have permissions to save content here!'); } return $this->save_content($data, $delete_the_cache); }
<?php /* type: layout content_type: dynamic name: Portfolio position: 3 description: Portfolio */ mw_var('photon_layout', 'photon-overflow'); include THIS_TEMPLATE_DIR . "header.php"; ?> <script> $(document).ready(function(){ $("#sidenav").removeClass('active'); }); </script> <module data-type="posts" data-limit="0" id="portfolio-posts" data-description-length="100" data-show="thumbnail" data-hide-paging="true" data-template="justified" /> <?php include THIS_TEMPLATE_DIR . "footer.php";
static/img/what_track.jpg" alt="" /> <p style="padding-bottom: 10px;">On Skidekids, the parents are in charge, they have special features that allows them to instantly view all the friends and activities of their child.</p> <p>By the easy dashboard switch you can track your kid’s activity in real time. Check all the tols inside</p> </div> </div> <div id="whatis_members"> <microweber module="users/new" dashboard_user="******" limit="15" list_class="user_friends_list_wide"> <div class="c" style="padding-bottom: 10px;"> </div> <a href="<? print site_url('users/user_action:register') ?>" class="mw_btn_x right"><span>Register Now</span></a> <? /* <strong class="right" style="color: #0671AF;margin-top: 10px;"><big>2,958</big> Members </strong> */ ?> </div> </div> </div> <br /><br /><br />
<?php only_admin_access(); $mw_help_path = mw_var('mw_help_path'); $mw_help_file = mw_var('mw_help_file'); $path = $mw_help_path; $file = $mw_help_file; if ($path != false) { $kw = false; if (isset($params['kw'])) { $kw = $params['kw']; } // $dirs = mw('Microweber\Utils\Files')->dir_tree($path,$kw); // $dirs = str_replace($base_path, '', $dirs); if (isset($params['ul_class'])) { // $dirs = str_replace("ul class='directory_tree'","ul class='directory_tree ".$params['ul_class']."'", $dirs); } // print $dirs; } $path = str_replace('..', '', $path); $file = str_replace('..', '', $file); if ($path != false and trim($path != '') and $file != false) { $try_file = $path . $file; if (is_file($try_file)) { include $try_file; } //d($try_file); } else { if ($path != false and trim($path != '') and $file == false) { $try_file = $path . DS . 'index.php'; if (is_file($try_file)) {
public function update_cart($data) { if (isset($data['content_id'])) { $data['for'] = 'content'; $for_id = $data['for_id'] = $data['content_id']; } $override = $this->app->event_manager->trigger('mw.shop.update_cart', $data); if (is_array($override)) { foreach ($override as $resp) { if (is_array($resp) and !empty($resp)) { $data = array_merge($data, $resp); } } } if (!isset($data['for'])) { $data['for'] = 'content'; } $update_qty = 0; $update_qty_new = 0; if (isset($data['qty'])) { $update_qty_new = $update_qty = intval($data['qty']); unset($data['qty']); } if (!isset($data['for']) or !isset($data['for_id'])) { if (!isset($data['id'])) { // if (!isset($data['title']) and !isset($data['price'])) { // $this->app->error('Invalid data'); // // } } else { $cart = array(); $cart['id'] = intval($data['id']); $cart['limit'] = 1; $data_existing = $this->get_cart($cart); if (is_array($data_existing) and is_array($data_existing[0])) { $data = array_merge($data, $data_existing[0]); } } } if (!isset($data['for']) and isset($data['rel_type'])) { $data['for'] = $data['rel_type']; } if (!isset($data['for_id']) and isset($data['rel_id'])) { $data['for_id'] = $data['rel_id']; } if (!isset($data['for']) and !isset($data['for_id'])) { $this->app->error('Invalid for and for_id params'); } $data['for'] = $this->app->database_manager->assoc_table_name($data['for']); $for = $data['for']; $for_id = intval($data['for_id']); if ($for_id == 0) { $this->app->error('Invalid data'); } $cont_data = false; if ($update_qty > 0) { $data['qty'] = $update_qty; } if ($data['for'] == 'content') { $cont = $this->app->content_manager->get_by_id($for_id); $cont_data = $this->app->content_manager->data($for_id); if ($cont == false) { $this->app->error('Invalid product?'); } else { if (is_array($cont) and isset($cont['title'])) { $data['title'] = $cont['title']; } } } if (isset($data['title']) and is_string($data['title'])) { $data['title'] = strip_tags($data['title']); } $found_price = false; $add = array(); if (isset($data['custom_fields_data']) and is_array($data['custom_fields_data'])) { $add = $data['custom_fields_data']; } $prices = array(); $skip_keys = array(); $content_custom_fields = array(); $content_custom_fields = $this->app->fields_manager->get($for, $for_id, 1); if ($content_custom_fields == false) { $content_custom_fields = $data; if (isset($data['price'])) { $found_price = $data['price']; } } elseif (is_array($content_custom_fields)) { foreach ($content_custom_fields as $cf) { if (isset($cf['type']) and $cf['type'] == 'price') { $prices[$cf['name']] = $cf['value']; } } } foreach ($data as $k => $item) { if ($k != 'for' and $k != 'for_id' and $k != 'title') { $found = false; foreach ($content_custom_fields as $cf) { if (isset($cf['type']) and isset($cf['name']) and $cf['type'] != 'price') { $key1 = str_replace('_', ' ', $cf['name']); $key2 = str_replace('_', ' ', $k); if (isset($cf['name']) and ($cf['name'] == $k or $key1 == $key2)) { $k = str_replace('_', ' ', $k); $found = true; if (is_array($cf['values'])) { if (in_array($item, $cf['values'])) { $found = true; } } if ($found == false and $cf['value'] != $item) { unset($item); } } } elseif (isset($cf['type']) and $cf['type'] == 'price') { if ($cf['value'] != '') { $prices[$cf['name']] = $cf['value']; } } elseif (isset($cf['type']) and $cf['type'] == 'price') { if ($cf['value'] != '') { $prices[$cf['name']] = $cf['value']; } } } if ($found == false) { $skip_keys[] = $k; } if (is_array($prices)) { foreach ($prices as $price_key => $price) { if (isset($data['price'])) { if ($price == $data['price']) { $found = true; $found_price = $price; } } else { if ($price == $item) { $found = true; if ($found_price == false) { $found_price = $item; } } } } if ($found_price == false) { $found_price = array_pop($prices); } else { if (count($prices) > 1) { foreach ($prices as $pk => $pv) { if ($pv == $found_price) { $add[$pk] = $this->currency_format($pv); } } } } } if (isset($item)) { if ($found == true) { if ($k != 'price' and !in_array($k, $skip_keys)) { $add[$k] = $this->app->format->clean_html($item); } } } } // } } if ($found_price == false and is_array($prices)) { $found_price = array_pop($prices); } if ($found_price == false) { $found_price = 0; } if (is_array($prices)) { ksort($add); asort($add); $table = $this->tables['cart']; $cart = array(); $cart['rel_type'] = $data['for']; $cart['rel_id'] = intval($data['for_id']); $cart['title'] = $data['title']; $cart['price'] = floatval($found_price); $cart_return = $cart; $cart_return['custom_fields_data'] = $add; $cart['custom_fields_data'] = $this->app->format->array_to_base64($add); $cart['order_completed'] = 0; $cart['session_id'] = mw()->user_manager->session_id(); $cart['limit'] = 1; $check_cart = $this->get_cart($cart); if ($check_cart != false and is_array($check_cart) and isset($check_cart[0])) { $cart['id'] = $check_cart[0]['id']; if ($update_qty > 0) { $cart['qty'] = $check_cart[0]['qty'] + $update_qty; } elseif ($update_qty_new > 0) { $cart['qty'] = $update_qty_new; } else { $cart['qty'] = $check_cart[0]['qty'] + 1; } } else { if ($update_qty > 0) { $cart['qty'] = $update_qty; } else { $cart['qty'] = 1; } } if (isset($cont_data['qty']) and trim($cont_data['qty']) != 'nolimit') { if (intval($cont_data['qty']) < intval($cart['qty'])) { $cart['qty'] = $cont_data['qty']; } } if (isset($data['other_info']) and is_string($data['other_info'])) { $cart['other_info'] = strip_tags($data['other_info']); } if (isset($data['item_image']) and is_string($data['item_image'])) { $cart['item_image'] = mw()->format->clean_xss(strip_tags($data['item_image'])); } mw_var('FORCE_SAVE', $table); $cart_saved_id = $this->app->database_manager->save($table, $cart); $this->app->cache_manager->delete('cart'); $this->app->cache_manager->delete('cart_orders/global'); if (isset($cart['rel_type']) and isset($cart['rel_id']) and $cart['rel_type'] == 'content') { $cart_return['image'] = $this->app->media_manager->get_picture($cart['rel_id']); $cart_return['product_link'] = $this->app->content_manager->link($cart['rel_id']); } return array('success' => 'Item added to cart', 'product' => $cart_return); // return ($cart_saved_id); } else { return array('error' => 'Invalid cart items'); } }
public function _create_mw_default_options() { $function_cache_id = 'default_opts'; $cache_content = $this->app->cache_manager->get($function_cache_id, $cache_group = 'db'); if ($cache_content == '--true--') { return true; } $table = $this->tables['options']; mw_var('FORCE_SAVE', $table); $datas = array(); $data = array(); $data['name'] = 'Website name'; $data['help'] = 'This is very important for search engines. Your website will be categorized by many criteria and its name is one of them.'; $data['option_group'] = 'website'; $data['option_key'] = 'website_title'; $data['option_value'] = 'Microweber'; $data['field_type'] = 'text'; $data['position'] = '1'; $data['is_system'] = '1'; $datas[] = $data; $data = array(); $data['option_group'] = 'website'; $data['option_key'] = 'website_description'; $data['option_value'] = 'My website description'; $data['name'] = 'Website description'; $data['help'] = 'Create Free Online Shop, Free Website and Free Blog with Microweber (MW)'; $data['field_type'] = 'textarea'; $data['is_system'] = '1'; $data['position'] = '2'; $datas[] = $data; $data = array(); $data['option_group'] = 'website'; $data['option_key'] = 'website_keywords'; $data['option_value'] = 'free website, free shop, free blog, make web, mw, microweber'; $data['name'] = 'Website keywords'; $data['help'] = 'Write keywords for your site.'; $data['field_type'] = 'textarea'; $data['is_system'] = '1'; $data['position'] = '3'; $datas[] = $data; $data = array(); $data['name'] = 'Website template'; $data['help'] = 'This is your current template. You can easy change it anytime.'; $data['option_group'] = 'template'; $data['option_key'] = 'current_template'; $data['option_value'] = 'default'; $data['field_type'] = 'website_template'; $data['position'] = '5'; $data['is_system'] = '1'; $datas[] = $data; $data = array(); $data['name'] = 'Items per page'; $data['help'] = 'Select how many items you want to have per page? example 10,25,50...'; $data['option_group'] = 'website'; $data['option_key'] = 'items_per_page'; $data['option_value'] = '30'; $data['field_type'] = 'dropdown'; $data['field_values'] = array('10' => '10', '30' => '30', '50' => '50', '100' => '100', '200' => '200'); $data['position'] = '6'; $data['is_system'] = '1'; $datas[] = $data; $data = array(); $data['option_group'] = 'users'; $data['option_key'] = 'enable_user_registration'; $data['name'] = 'Enable user registration'; $data['help'] = 'You can enable or disable the registration for new users'; $data['option_value'] = 'y'; $data['position'] = '10'; $data['is_system'] = '1'; $data['field_type'] = 'dropdown'; $data['field_values'] = array('y' => 'yes', 'n' => 'no'); $datas[] = $data; $changes = false; foreach ($datas as $value) { $ch = $this->set_default($value); if ($ch == true) { $changes = true; } } if ($changes == true) { $this->app->cache_manager->delete('options/global'); } $this->app->cache_manager->save('--true--', $function_cache_id, $cache_group = 'db'); return true; }
private function _replace_editable_fields($layout, $no_cache = false) { if ($layout != '') { global $mw_replaced_edit_fields_vals; global $mw_parser_nest_counter_level; global $mw_replaced_edit_fields_vals_inner; $mw_parser_nest_counter_level++; $replaced_code_tags = array(); if ($this->_mw_parser_passed_replaces == null) { $this->_mw_parser_passed_replaces = array(); } $mw_found_elems = ''; $mw_found_elems_arr = array(); $mw_elements_array = array('orig', $layout); $cached = false; if (!isset($parser_mem_crc)) { $parser_mem_crc = 'parser_' . crc32($layout) . content_id(); $parser_modules_crc = 'parser_modules' . crc32($layout) . content_id(); } if (isset($this->_mw_parser_passed_replaces[$parser_mem_crc])) { return $this->_mw_parser_passed_replaces[$parser_mem_crc]; } if (isset($mw_replaced_edit_fields_vals[$parser_mem_crc])) { // return false; return $mw_replaced_edit_fields_vals[$parser_mem_crc]; } $script_pattern = "/<pre[^>]*>(.*)<\\/pre>/Uis"; preg_match_all($script_pattern, $layout, $mw_script_matches); if (!empty($mw_script_matches)) { foreach ($mw_script_matches[0] as $key => $value) { if ($value != '') { $v1 = crc32($value); $v1 = '<!-- mw_replace_back_this_pre_' . $v1 . ' -->'; $layout = str_replace($value, $v1, $layout); if (!isset($replaced_code_tags[$v1])) { $replaced_code_tags[$v1] = $value; } } } } $script_pattern = "/<code[^>]*>(.*)<\\/code>/Uis"; preg_match_all($script_pattern, $layout, $mw_script_matches); if (!empty($mw_script_matches)) { foreach ($mw_script_matches[0] as $key => $value) { if ($value != '') { $v1 = crc32($value); $v1 = '<!-- mw_replace_back_this_pre_code_' . $v1 . ' -->'; $layout = str_replace($value, $v1, $layout); if (!isset($replaced_code_tags[$v1])) { $replaced_code_tags[$v1] = $value; } } } } $ch = mw_var($parser_mem_crc); if ($cached != false) { $mw_elements_array = $cached; } else { if ($ch != false) { $layout = $ch; } else { require_once __DIR__ . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'phpQuery.php'; $pq = \phpQuery::newDocument($layout); $els = $pq['.edit']; $is_editable = true; foreach ($els as $elem) { // iteration returns PLAIN dom nodes, NOT phpQuery objects $tagName = $elem->tagName; $name = pq($elem)->attr('field'); if (strval($name) == '') { $name = pq($elem)->attr('data-field'); } $rel = pq($elem)->attr('rel'); if ($rel == false) { $rel = pq($elem)->attr('data-rel'); if ($rel == false) { $rel = 'page'; } } $option_group = pq($elem)->attr('data-option_group'); if ($option_group == false) { $option_group = 'editable_region'; } $data_id = pq($elem)->attr('data-id'); if ($data_id == false) { $data_id = pq($elem)->attr('rel-id'); } if ($data_id == false) { $data_id = pq($elem)->attr('rel_id'); } if ($data_id == false) { $data_id = pq($elem)->attr('data-rel-id'); } $option_mod = pq($elem)->attr('data-module'); if ($option_mod == false) { $option_mod = pq($elem)->attr('data-type'); } if ($option_mod == false) { $option_mod = pq($elem)->attr('type'); } $name = trim($name); $get_global = false; $field = $name; $use_id_as_field = $name; if ($rel == 'global') { $get_global = true; } else { $get_global = false; } $try_inherited = false; // if ($rel == 'content') { if (!isset($data_id) or $data_id == false) { $data_id = content_id(); } $get_global = false; $data_id = intval($data_id); $data = $this->app->content_manager->get_by_id($data_id); } else { if ($rel == 'page') { if (!isset($data_id) or $data_id == false) { $data_id = PAGE_ID; } if (!isset($data_id) or $data_id == false) { $data_id = content_id(); } $data = $this->app->content_manager->get_by_id($data_id); $get_global = false; } else { if ($rel == 'post') { $get_global = false; if (!isset($data_id) or $data_id == false) { $data_id = POST_ID; } if (!isset($data_id) or $data_id == false) { $data_id = PAGE_ID; } $data = $this->app->content_manager->get_by_id($data_id); } else { if ($rel == 'inherit') { $get_global = false; if (!isset($data_id) or $data_id == false) { $data_id = PAGE_ID; } $data_inh_check = $this->app->content_manager->get_by_id($data_id); if (isset($data_inh_check['id']) and isset($data_inh_check['layout_file']) and trim($data_inh_check['layout_file']) != '' and $data_inh_check['layout_file'] != 'inherit') { $inh = $data_inh_check['id']; } else { $inh = $this->app->content_manager->get_inherited_parent($data_id); } if ($inh != false and intval($inh) != 0) { $try_inherited = true; $data_id = $inh; $rel = 'content'; $data = $this->app->content_manager->get_by_id($data_id); } else { $rel = 'content'; $data = $this->app->content_manager->get_page($data_id); } } else { if ($rel == 'global') { $get_global = 1; $cont_field = false; } else { if (isset($attr['post'])) { $get_global = false; $data = $this->app->content_manager->get_by_id($attr['post']); if ($data == false) { $data = $this->app->content_manager->get_page($attr['post']); } } else { if (isset($attr['category'])) { $get_global = false; $data = $this->app->category_manager->get_by_id($attr['category']); } else { if (isset($attr['global'])) { $get_global = true; } } } } } } } } $cf = false; $field_content = false; $orig_rel = $rel; $this->_current_parser_rel = $rel; if (!empty($this->filter)) { foreach ($this->filter as $filter) { if (isset($data)) { $new_data = call_user_func($filter, $data, $elem); if (is_array($new_data) and !empty($new_data)) { $data = array_merge($data, $new_data); } } } } if (isset($data[$field])) { if (isset($data[$field])) { $field_content = $data[$field]; } } else { if ($rel == 'page') { $rel = 'content'; } if ($rel == 'post') { $rel = 'content'; } $cont_field = false; if (isset($data_id) and $data_id != 0 and trim($data_id) != '' and trim($field) != '') { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}&rel_id={$data_id}"); if ($cont_field == false and $try_inherited == true) { $inh = $this->app->content_manager->get_inherited_parent($data_id); if ($inh != false and intval($inh) != 0 and $inh != $data_id) { $data_id = $inh; $cont_field2 = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}&rel_id={$inh}"); if ($cont_field2 != false) { $rel = 'content'; $data = $this->app->content_manager->get_by_id($inh); $cont_field = $cont_field2; } } } } else { if (isset($data_id) and trim($data_id) != '' and $field_content == false and isset($rel) and isset($field) and trim($field) != '') { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}&rel_id={$data_id}"); if ($cont_field != false) { $field_content = $cont_field; } } else { $field_content = $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}"); } } if ($cont_field != false) { $field_content = $cont_field; } $mw_replaced_edit_fields_vals[$parser_mem_crc] = $field_content; } if ($rel == 'global') { $field_content = false; $get_global = 1; } // $filter $this->_current_parser_rel = $rel; $no_edit = false; if ($field_content == false) { if ($get_global == true) { if (isset($data_id)) { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}&rel_id={$data_id}"); } if (isset($cont_field) and !empty($cont_field)) { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}"); } if ($cont_field == false) { if ($option_mod != false) { $field_content = $this->app->content_manager->edit_field("rel_type={$option_group}&field={$field}"); } else { $field_content = $this->app->content_manager->edit_field("rel_type={$option_group}&field={$field}"); } } else { $field_content = $cont_field; } } else { if ($use_id_as_field != false) { if (isset($data[$use_id_as_field])) { $field_content = $data[$use_id_as_field]; } } if ($field_content == false) { if (isset($data_id) and $data_id != false) { $cont_field = $this->app->content_manager->edit_field("rel_type={$orig_rel}&field={$field}&rel_id={$data_id}"); } else { $cont_field = $this->app->content_manager->edit_field("rel_type={$orig_rel}&field={$field}&rel_id=" . PAGE_ID); } } if (isset($data[$field])) { $field_content = $data[$field]; } else { if (isset($cont_field) and $cont_field != false) { $field_content = $cont_field; } } } if ($field == 'content' and template_var('content') != false) { $field_content = template_var('content'); template_var('content', false); $no_edit = template_var('no_edit'); } if (isset($data_id) and trim($data_id) != '' and $field_content == false and isset($rel) and isset($field) and trim($field) != '') { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}&rel_id={$data_id}"); if ($cont_field != false) { $field_content = $cont_field; } } else { if ($field_content == false and isset($rel) and isset($field) and trim($field) != '') { $cont_field = $this->app->content_manager->edit_field("rel_type={$rel}&field={$field}"); if ($cont_field != false) { $field_content = $cont_field; } } } } if ($field_content != false and $field_content != '' and is_string($field_content)) { $parser_mem_crc2 = 'parser_field_content_' . $field . $rel . $data_id . crc32($field_content); $ch2 = mw_var($parser_mem_crc); if ($ch2 == false) { $this->_mw_parser_passed_hashes[] = $parser_mem_crc2; if (!isset($mw_replaced_edit_fields_vals[$parser_mem_crc2]) and $field_content != false and $field_content != '') { $mw_replaced_edit_fields_vals[$parser_mem_crc2] = $ch2; $parser_mem_crc3 = 'mw_replace_back_this_editable_' . $parser_mem_crc2 . ''; $mw_found_elems = ',' . $parser_mem_crc2; $mw_found_elems_arr[$parser_mem_crc2] = $field_content; // $rep = pq($elem)->html(); $rep = pq($elem)->html(); if ($no_edit != false or isset($data) and isset($data['no_edit']) and $data['no_edit'] != false) { $is_editable = false; if ($is_editable === false) { pq($elem)->removeClass('edit'); } else { } $is_editable = 1; } $mw_replaced_edit_fields_vals_inner[$parser_mem_crc3] = array('s' => $rep, 'r' => $field_content); } } mw_var($parser_mem_crc2, 1); } } $layout = $pq->htmlOuter(); $pq->__destruct(); $pq = null; unset($pq); if (!empty($mw_replaced_edit_fields_vals_inner)) { $reps_arr = array(); $reps_arr2 = array(); foreach ($mw_replaced_edit_fields_vals_inner as $k => $v) { $repc = 1; if (isset($v['s'])) { $reps_arr[] = $v['s']; $reps_arr2[] = $v['r']; $layout = $this->_str_replace_first($v['s'], $v['r'], $layout, $repc); unset($mw_replaced_edit_fields_vals_inner[$k]); } } // $layout = str_replace($reps_arr, $reps_arr2, $layout,$repc); } mw_var($parser_mem_crc, $layout); if ($mw_found_elems != '') { $mw_elements_array['new'] = $layout; $mw_elements_array['to_replace'] = $mw_found_elems; $mw_elements_array['elems'] = $mw_found_elems_arr; } else { $mw_elements_array['new'] = $layout; } } } } if (isset($mw_elements_array) and !empty($mw_elements_array)) { if (isset($mw_elements_array['elems']) and isset($mw_elements_array['to_replace']) and isset($mw_elements_array['new'])) { $modified_layout = $mw_elements_array['new']; $reps = $mw_elements_array['elems']; $c = 1; foreach ($reps as $elk => $value) { $elk_crc = crc32($elk); $global_holder_hash = 'replaced' . $elk_crc; if (!isset($mw_replaced_edit_fields_vals[$global_holder_hash])) { $this->_mw_parser_passed_replaces[] = $elk_crc; $mw_replaced_edit_fields_vals[$global_holder_hash] = $modified_layout; if ($value != '') { $val_rep = $value; $val_rep = $this->_replace_editable_fields($val_rep, true); $rep = 'mw_replace_back_this_editable_' . $elk . ''; $ct = 1; // $modified_layout = str_replace($rep, $val_rep, $modified_layout,$ct); $modified_layout = $this->_str_replace_first($rep, $val_rep, $modified_layout); } } else { $rep = 'mw_replace_back_this_editable_' . $elk . ''; $modified_layout = $this->_str_replace_first($rep, $value, $modified_layout); // $modified_layout = str_replace($rep, $value, $modified_layout); } } $layout = $modified_layout; $mw_replaced_edit_fields_vals[$parser_mem_crc] = $layout; } if (!empty($replaced_code_tags)) { foreach ($replaced_code_tags as $key => $value) { if ($value != '') { $layout = str_replace($key, $value, $layout); } unset($replaced_code_tags[$key]); } } if ($no_cache == false) { // $this->app->cache_manager->save($layout, $parser_mem_crc, 'content_fields/global/parser'); } } $this->_mw_parser_passed_replaces[$parser_mem_crc] = $layout; $mw_replaced_edit_fields_vals[$parser_mem_crc] = $layout; return $layout; }
public function get_link($options = false) { $args = func_get_args(); $function_cache_id = ''; foreach ($args as $k => $v) { $function_cache_id = $function_cache_id . serialize($k) . serialize($v); } $cache_id = __FUNCTION__ . crc32($function_cache_id); //get cache from memory $mem = mw_var($cache_id); if ($mem != false) { return $mem; } $options = parse_params($options); $fn = false; if (isset($options[0])) { $fn = $options[0]; } elseif (is_array($options)) { $val = current($options); $fn = key($options); } $page_url_segment_1 = $this->app->url_manager->segment(0); $td = templates_path() . $page_url_segment_1; $td_base = $td; $page_url_segment_2 = $this->app->url_manager->segment(1); $directly_to_file = false; $page_url_segment_3 = $this->app->url_manager->segment(); if (!is_dir($td_base)) { array_shift($page_url_segment_3); //$page_url_segment_1 = $the_active_site_template = $this->app->option_manager->get('current_template'); //$td_base = templates_path() . $the_active_site_template.DS; } else { } if (empty($page_url_segment_3)) { $page_url_segment_str = ''; } else { $page_url_segment_str = $page_url_segment_3[0]; } //$page_url_segment_str = implode('/', $page_url_segment_3); $fn = $this->app->url_manager->site($page_url_segment_str . '/' . $fn); //d($page_url_segment_3); //set cache in memory mw_var($cache_id, $fn); return $fn; }
public function save($params) { $params = parse_params($params); $table_orig = $this->table; $table = $this->app->database_manager->real_table_name($this->table); mw_var('FORCE_SAVE', $table); if (!isset($params['rel_type']) or !isset($params['rel_id'])) { return 'Error: invalid data you must send rel and rel_id as params for $this->save function'; } $old = date("Y-m-d H:i:s", strtotime('-30 days')); $cleanup = "DELETE FROM {$table} WHERE created_at < '{$old}'"; $this->app->database_manager->q($cleanup); if (isset($params['replace'])) { if (isset($params['module']) and isset($params['rel_type']) and isset($params['rel_id'])) { unset($params['replace']); $rel1 = $this->app->database_manager->escape_string($params['rel_type']); $module1 = $this->app->database_manager->escape_string($params['module']); $rel_id1 = $this->app->database_manager->escape_string($params['rel_id']); $cleanup = "DELETE FROM {$table} WHERE rel_type='{$rel1}' AND module='{$module1}' AND rel_id='{$rel_id1}'"; $this->app->database_manager->q($cleanup); } } if (!isset($params['is_read'])) { $params['is_read'] = 0; } $this->app->cache_manager->delete('notifications' . DIRECTORY_SEPARATOR . 'global'); $data = $this->app->database_manager->save($table_orig, $params); return $data; }
<?php /* type: layout name: Default layout description: default site layout */ //include "header.php" ?> <microweber module="header" page='<? mw_var($page) ?>'></microweber> {content} <microweber module="footer"></microweber> <?php // include "footer.php"
function create_default_content($what) { if (defined("MW_NO_DEFAULT_CONTENT")) { return true; } switch ($what) { case 'shop': $is_shop = $this->get('content_type=page&is_shop=0'); //$is_shop = false; $new_shop = false; if ($is_shop == false) { $add_page = array(); $add_page['id'] = 0; $add_page['parent'] = 0; $add_page['is_active'] = 1; $add_page['title'] = "Online shop"; $add_page['url'] = "shop"; $add_page['content_type'] = "page"; $add_page['subtype'] = 'dynamic'; $add_page['is_shop'] = '1'; $add_page['active_site_template'] = 'default'; $find_layout = $this->app->layouts_manager->scan(); if (is_array($find_layout)) { foreach ($find_layout as $item) { if (isset($item['layout_file']) and isset($item['is_shop'])) { $add_page['layout_file'] = $item['layout_file']; if (isset($item['name'])) { $add_page['title'] = $item['name']; } } } } $new_shop = $this->app->database_manager->save('content', $add_page); $this->app->cache_manager->delete('content'); $this->app->cache_manager->delete('categories'); $this->app->cache_manager->delete('custom_fields'); // } else { if (isset($is_shop[0])) { $new_shop = $is_shop[0]['id']; } } $posts = $this->get('content_type=post&parent=' . $new_shop); if ($posts == false and $new_shop != false) { $add_page = array(); $add_page['id'] = 0; $add_page['parent'] = $new_shop; $add_page['title'] = "My product"; $add_page['url'] = "my-product"; $add_page['content_type'] = "post"; $add_page['subtype'] = "product"; $add_page['is_active'] = 1; //$new_shop = $this->save_content($add_page); //$this->app->cache_manager->delete('content'); //$this->app->cache_manager->clear(); } break; case 'blog': $is_shop = $this->get('is_deleted=0&content_type=page&subtype=dynamic&is_shop=1&limit=1'); //$is_shop = false; $new_shop = false; if ($is_shop == false) { $add_page = array(); $add_page['id'] = 0; $add_page['parent'] = 0; $add_page['is_active'] = 1; $add_page['title'] = "Blog"; $add_page['url'] = "blog"; $add_page['content_type'] = "page"; $add_page['subtype'] = 'dynamic'; $add_page['is_shop'] = 0; $add_page['active_site_template'] = 'default'; $find_layout = $this->app->layouts_manager->scan(); if (is_array($find_layout)) { foreach ($find_layout as $item) { if (!isset($item['is_shop']) and isset($item['layout_file']) and isset($item['content_type']) and trim(strtolower($item['content_type'])) == 'dynamic') { $add_page['layout_file'] = $item['layout_file']; if (isset($item['name'])) { $add_page['title'] = $item['name']; } } } foreach ($find_layout as $item) { if (isset($item['name']) and stristr($item['name'], 'blog') and !isset($item['is_shop']) and isset($item['layout_file']) and isset($item['content_type']) and trim(strtolower($item['content_type'])) == 'dynamic') { $add_page['layout_file'] = $item['layout_file']; if (isset($item['name'])) { $add_page['title'] = $item['name']; } } } } $new_shop = $this->app->database_manager->save('content', $add_page); $this->app->cache_manager->delete('content'); $this->app->cache_manager->delete('categories'); $this->app->cache_manager->delete('content_fields'); // } else { if (isset($is_shop[0])) { $new_shop = $is_shop[0]['id']; } } break; case 'default': case 'install': $any = $this->get('count=1&content_type=page&limit=1'); if (intval($any) == 0) { $table = $this->tables['content']; mw_var('FORCE_SAVE_CONTENT', $table); mw_var('FORCE_SAVE', $table); $add_page = array(); $add_page['id'] = 0; $add_page['parent'] = 0; $add_page['title'] = "Home"; $add_page['url'] = "home"; $add_page['content_type'] = "page"; $add_page['subtype'] = 'static'; $add_page['is_shop'] = 0; //$add_page['debug'] = 1; $add_page['is_active'] = 1; $add_page['is_home'] = 1; $add_page['active_site_template'] = 'default'; $new_shop = $this->save_content($add_page); } break; default: break; } }
public function save($data, $delete_the_cache = true) { if (is_string($data)) { $data = parse_params($data); } $mw_global_content_memory = array(); $adm = $this->app->user_manager->is_admin(); $table = $this->tables['content']; $table_data = $this->tables['content_data']; $checks = mw_var('FORCE_SAVE_CONTENT'); $orig_data = $data; $stop = false; if ($stop == true) { return array('error' => 'You are not logged in as admin to save content!'); } $cats_modified = false; if (!empty($data)) { if (!isset($data['id'])) { $data['id'] = 0; } if ($data['id'] == 0 and !isset($data['is_active'])) { $data['is_active'] = 1; } $this->app->event_manager->trigger('content.before.save', $data); if (intval($data['id']) == 0) { if (isset($data['subtype']) and $data['subtype'] == 'post' and !isset($data['content_type'])) { $data['subtype'] = 'post'; $data['content_type'] = 'post'; } if (!isset($data['subtype'])) { $data['subtype'] = 'post'; } if (!isset($data['content_type'])) { $data['content_type'] = 'post'; } } } if (isset($data['content_url']) and !isset($data['url'])) { $data['url'] = $data['content_url']; } if (!isset($data['parent']) and isset($data['content_parent'])) { $data['parent'] = $data['content_parent']; } if (isset($data['parent'])) { $data['parent'] = intval($data['parent']); } if (isset($data['is_active'])) { if ($data['is_active'] === 'y') { $data['is_active'] = 1; } elseif ($data['is_active'] === 'n') { $data['is_active'] = 0; } } $data_to_save = $data; if (!isset($data['title']) and isset($data['content_title'])) { $data['title'] = $data['content_title']; } if (isset($data['title'])) { $data['title'] = strip_tags($data['title']); $data['title'] = htmlspecialchars($data['title'], ENT_QUOTES, 'UTF-8'); $data_to_save['title'] = $data['title']; } if (!isset($data['url']) and intval($data['id']) != 0) { $q = $this->get_by_id($data_to_save['id']); $thetitle = $q['title']; $q = $q['url']; $theurl = $q; } else { if (isset($data['url'])) { $theurl = $data['url']; } else { $theurl = $data['title']; } $thetitle = $data['title']; } if (isset($data['id']) and intval($data['id']) == 0) { if (!isset($data['is_deleted']) or $data['is_deleted'] == '') { $data_to_save['is_deleted'] = 0; } else { $data_to_save['is_deleted'] = $data['is_deleted']; } if (!isset($data['title']) or $data['title'] == '') { $data['title'] = 'New page'; if (isset($data['content_type']) and $data['content_type'] != 'page') { $data['title'] = 'New ' . $data['content_type']; if (isset($data['subtype']) and $data['subtype'] != 'page' and $data['subtype'] != 'post' and $data['subtype'] != 'static' and $data['subtype'] != 'dynamic') { $data['title'] = 'New ' . $data['subtype']; } } $data_to_save['title'] = $data['title']; } } if (isset($data['url']) == false or $data['url'] == '') { if (isset($data['title']) != false and intval($data['id']) == 0) { $data['url'] = $this->app->url_manager->slug($data['title']); if ($data['url'] == '') { $data['url'] = date('Y-M-d-His'); } } } $url_changed = false; if (isset($data['url']) != false and is_string($data['url'])) { $search_weird_chars = array('%E2%80%99', '%E2%80%99', '%E2%80%98', '%E2%80%9C', '%E2%80%9D'); $str = $data['url']; $good[] = 9; #tab $good[] = 10; #nl $good[] = 13; #cr for ($a = 32; $a < 127; ++$a) { $good[] = $a; } $newstr = ''; $len = strlen($str); for ($b = 0; $b < $len + 1; ++$b) { if (isset($str[$b]) and in_array(ord($str[$b]), $good)) { $newstr .= $str[$b]; } } $newstr = str_replace('--', '-', $newstr); $newstr = str_replace('--', '-', $newstr); if ($newstr == '-' or $newstr == '--') { $newstr = 'post-' . date('YmdHis'); } $data['url'] = $newstr; $url_changed = true; $data_to_save['url'] = $data['url']; } if (isset($data['category']) or isset($data['categories'])) { $cats_modified = true; } $table_cats = $this->tables['categories']; if (isset($data_to_save['title']) and $data_to_save['title'] != '' and (!isset($data['url']) or trim($data['url']) == '')) { $data['url'] = $this->app->url_manager->slug($data_to_save['title']); } if (isset($data['url']) and $data['url'] != false) { if (trim($data['url']) == '') { $data['url'] = $this->app->url_manager->slug($data['title']); } $data['url'] = $this->app->database_manager->escape_string($data['url']); $date123 = date('YmdHis'); $get = array(); $get['url'] = $data['url']; $get['single'] = true; $q = $this->get($get); if (!empty($q)) { if ($data['id'] != $q['id']) { $orig_slug = $data['url']; $slug = $data['url']; $count = 1; while ($this->get_by_url($slug, true)) { $slug = $orig_slug . '-' . $count++; } $data['url'] = $slug; $data_to_save['url'] = $data['url']; } } if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['url'] = $data_to_save['url'] . '-' . $date123; } if (isset($data_to_save['title']) and strval($data_to_save['title']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['title'] = 'post-' . $date123; } if (isset($data_to_save['url']) and strval($data_to_save['url']) == '' and isset($data_to_save['quick_save']) == false) { $data_to_save['url'] = strtolower(reduce_double_slashes($data['url'])); } } if (isset($data_to_save['url']) and is_string($data_to_save['url'])) { if ($data_to_save['url'] == '') { $data_to_save['url'] = date('Y-M-d-His'); } $data_to_save['url'] = str_replace(site_url(), '', $data_to_save['url']); } if (isset($data['created_at'])) { $data_to_save['created_at'] = $data['created_at']; } if (isset($data['updated_at'])) { $data_to_save['updated_at'] = $data['updated_at']; } $data_to_save_options = array(); if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'y') { $data_to_save['is_home'] = 1; } elseif (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 'n') { $data_to_save['is_home'] = 0; } if (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'y') { $data_to_save['is_shop'] = 1; } elseif (isset($data_to_save['is_shop']) and $data_to_save['is_shop'] === 'n') { $data_to_save['is_shop'] = 0; } if (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'y') { $data_to_save['require_login'] = 1; } elseif (isset($data_to_save['require_login']) and $data_to_save['require_login'] === 'n') { $data_to_save['require_login'] = 0; } if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) { $data_to_save['is_home'] = strval($data_to_save['is_home']); if ($adm == true) { $q = Content::where('is_home', 1)->update(array('is_home' => 0)); } else { $data_to_save['is_home'] = 0; } // } if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') { if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'static') { $data_to_save['subtype'] = 'post'; } elseif (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') { $data_to_save['subtype'] = 'post'; } } if (isset($data_to_save['subtype']) and strval($data_to_save['subtype']) == 'dynamic') { $check_ex = false; if (isset($data_to_save['subtype_value']) and trim($data_to_save['subtype_value']) != '' and intval($data_to_save['subtype_value']) > 0) { $check_ex = $this->app->category_manager->get_by_id(intval($data_to_save['subtype_value'])); } if ($check_ex == false) { if (isset($data_to_save['id']) and intval(trim($data_to_save['id'])) > 0) { $test2 = $this->app->category_manager->get('data_type=category&rel_type=content&rel_id=' . intval($data_to_save['id'])); if (isset($test2[0])) { $check_ex = $test2[0]; $data_to_save['subtype_value'] = $test2[0]['id']; } } unset($data_to_save['subtype_value']); } } $par_page = false; if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'post') { if (isset($data_to_save['parent']) and intval($data_to_save['parent']) > 0) { $par_page = $this->get_by_id($data_to_save['parent']); } if (is_array($par_page)) { $change_to_dynamic = true; if (isset($data_to_save['is_home']) and $data_to_save['is_home'] == 1) { $change_to_dynamic = false; } if ($change_to_dynamic == true and $par_page['subtype'] == 'static') { $par_page_new = array(); $par_page_new['id'] = $par_page['id']; $par_page_new['subtype'] = 'dynamic'; $par_page_new = $this->app->database_manager->save($table, $par_page_new); $cats_modified = true; } if (!isset($data_to_save['categories'])) { $data_to_save['categories'] = ''; } if (is_string($data_to_save['categories']) and isset($par_page['subtype_value']) and intval($par_page['subtype_value']) != 0) { $data_to_save['categories'] = $data_to_save['categories'] . ', ' . intval($par_page['subtype_value']); } } $c1 = false; if (isset($data_to_save['category']) and !isset($data_to_save['categories'])) { $data_to_save['categories'] = $data_to_save['category']; } if (isset($data_to_save['categories']) and $par_page == false) { if (is_string($data_to_save['categories'])) { $c1 = explode(',', $data_to_save['categories']); if (is_array($c1)) { foreach ($c1 as $item) { $item = intval($item); if ($item > 0) { $cont_cat = $this->get('limit=1&content_type=page&subtype_value=' . $item); if (isset($cont_cat[0]) and is_array($cont_cat[0])) { $cont_cat = $cont_cat[0]; if (isset($cont_cat['subtype_value']) and intval($cont_cat['subtype_value']) > 0) { $data_to_save['parent'] = $cont_cat['id']; break; } } } } } } } } $allow_remote_images_download = false; if ($adm == true and isset($data['download_remote_images']) and $data['download_remote_images'] != false) { $allow_remote_images_download = true; } if (isset($data_to_save['content'])) { if (trim($data_to_save['content']) == '' or $data_to_save['content'] == false) { $data_to_save['content'] = null; } else { if ($allow_remote_images_download) { $data_to_save['content'] = $this->app->content_manager_helpers->download_remote_images_from_text($data_to_save['content']); } $data_to_save['content'] = $this->app->parser->make_tags($data_to_save['content']); } } if (!isset($data_to_save['updated_at'])) { $data_to_save['updated_at'] = date('Y-m-d H:i:s'); } if (isset($data_to_save['id']) and intval($data_to_save['id']) == 0 or !isset($data_to_save['id'])) { if (!isset($data_to_save['position']) or intval($data_to_save['position']) == 0) { $pos_params = array(); $pos_params['table'] = 'content'; if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') { $pos_params['content_type'] = $data_to_save['content_type']; $pos_params['min'] = 'position'; } else { $pos_params['max'] = 'position'; } $get_max_pos = $this->app->database_manager->get($pos_params); if (is_null($get_max_pos)) { $data_to_save['position'] = 1; } elseif (is_int($get_max_pos) or is_string($get_max_pos)) { if (isset($data_to_save['content_type']) and strval($data_to_save['content_type']) == 'page') { $data_to_save['position'] = intval($get_max_pos) - 1; } else { $data_to_save['position'] = intval($get_max_pos) + 1; } } } $data_to_save['posted_at'] = $data_to_save['updated_at']; } $cats_modified = true; if (isset($data_to_save['url']) and $data_to_save['url'] == $this->app->url_manager->site()) { unset($data_to_save['url']); } $data_to_save['allow_html'] = true; $this->no_cache = true; //clean some fields if (isset($data_to_save['custom_field_type']) and isset($data_to_save['value'])) { unset($data_to_save['custom_field_type']); unset($data_to_save['value']); } if (isset($data_to_save['custom_field_help_text'])) { unset($data_to_save['custom_field_help_text']); unset($data_to_save['custom_field_help_text']); } if (isset($data_to_save['custom_field_is_active'])) { unset($data_to_save['custom_field_is_active']); } if (isset($data_to_save['name'])) { unset($data_to_save['name']); } if (isset($data_to_save['values'])) { unset($data_to_save['values']); } if (isset($data_to_save['value'])) { unset($data_to_save['value']); } if (isset($data_to_save['title'])) { $url_changed = true; } $data_to_save['table'] = $table; $data_fields = array(); if (!empty($orig_data)) { $data_str = 'data_'; $data_str_l = strlen($data_str); foreach ($orig_data as $k => $v) { if (is_string($k)) { if (strlen($k) > $data_str_l) { $rest = substr($k, 0, $data_str_l); $left = substr($k, $data_str_l, strlen($k)); if ($rest == $data_str) { if (!isset($data_to_save['data_fields'])) { $data_to_save['data_fields'] = array(); } $data_to_save['data_fields'][$left] = $v; } } } } } if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) { if (isset($data_to_save['id']) and $data_to_save['id'] != 0) { if ($data_to_save['parent'] == $data_to_save['id']) { $data_to_save['parent'] = 0; } } } $data_to_save = $this->map_params_to_schema($data_to_save); //dd($data_to_save); $save = $this->app->database_manager->extended_save($table, $data_to_save); /* SQLITE FIX */ if ($adm == true) { if (isset($data_to_save['is_home'])) { $q = Content::where('id', $save)->update(array('is_home' => intval($data_to_save['is_home']))); } if (isset($data_to_save['is_shop'])) { $q = Content::where('id', $save)->update(array('is_shop' => intval($data_to_save['is_shop']))); } if (isset($data_to_save['require_login'])) { $q = Content::where('id', $save)->update(array('require_login' => intval($data_to_save['require_login']))); } } /* END SQLITE FIX */ $id = $save; if (isset($data_to_save['parent']) and $data_to_save['parent'] != 0) { $upd_posted = array(); $upd_posted['posted_at'] = $data_to_save['updated_at']; $upd_posted['id'] = $data_to_save['parent']; $save_posted = $this->app->database_manager->save($table, $upd_posted); } $after_save = $data_to_save; $after_save['id'] = $id; $this->app->event_manager->trigger('content.after.save', $after_save); $this->app->cache_manager->delete('content/' . $save); $this->app->cache_manager->delete('content_fields/global'); if ($url_changed != false) { $this->app->cache_manager->delete('menus'); $this->app->cache_manager->delete('categories'); } if (!isset($data_to_save['images']) and isset($data_to_save['pictures'])) { $data_to_save['images'] = $data_to_save['pictures']; } if (isset($data_to_save['images']) and is_string($data_to_save['images'])) { $data_to_save['images'] = explode(',', $data_to_save['images']); } if (isset($data_to_save['images']) and is_array($data_to_save['images']) and !empty($data_to_save['images'])) { $images_to_save = $data_to_save['images']; foreach ($images_to_save as $image_to_save) { if (is_string($image_to_save)) { $image_to_save = trim($image_to_save); if ($image_to_save != '') { $save_media = array(); $save_media['content_id'] = $id; $save_media['filename'] = $image_to_save; $check = $this->app->media_manager->get($save_media); $save_media['media_type'] = 'picture'; if ($allow_remote_images_download) { $save_media['allow_remote_download'] = true; } if ($check == false) { $this->app->media_manager->save($save_media); } } } elseif (is_array($image_to_save) and !empty($image_to_save)) { $save_media = $image_to_save; $save_media['content_id'] = $id; if ($allow_remote_images_download) { $save_media['allow_remote_download'] = true; } $this->app->media_manager->save($save_media); } } } $custom_field_table = $this->tables['custom_fields']; $custom_field_table = $this->app->database_manager->real_table_name($custom_field_table); $sid = $this->app->user_manager->session_id(); $media_table = $this->tables['media']; $media_table = $this->app->database_manager->real_table_name($media_table); if ($sid != false and $sid != '' and $id != false) { DB::transaction(function () use($sid, $id) { DB::table($this->tables['custom_fields'])->whereSessionId($sid)->where(function ($query) { $query->whereRelId(0)->orWhere('rel_id', null)->orWhere('rel_id', '0'); })->whereRelType('content')->update(['rel_type' => 'content', 'rel_id' => $id]); DB::table($this->tables['media'])->whereSessionId($sid)->where(function ($query) { $query->whereRelId(0)->orWhere('rel_id', null)->orWhere('rel_id', '0'); })->whereRelType('content')->update(['rel_type' => 'content', 'rel_id' => $id]); }); } $this->app->cache_manager->delete('custom_fields'); $this->app->cache_manager->delete('custom_fields_values'); $this->app->cache_manager->delete('media/global'); if (isset($data_to_save['parent']) and intval($data_to_save['parent']) != 0) { $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['parent'])); } if (isset($data_to_save['id']) and intval($data_to_save['id']) != 0) { $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . intval($data_to_save['id'])); } $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . 'global'); $this->app->cache_manager->delete('content' . DIRECTORY_SEPARATOR . '0'); $this->app->cache_manager->delete('content_fields/global'); $this->app->cache_manager->delete('content'); $this->app->cache_manager->delete('categories/global'); $this->app->cache_manager->delete('categories_items/global'); if ($cats_modified != false) { if (isset($c1) and is_array($c1)) { foreach ($c1 as $item) { $item = intval($item); if ($item > 0) { $this->app->cache_manager->delete('categories/' . $item); } } } } // event_trigger('mw_save_content', $save); return $id; }