Beispiel #1
0
 public function edit_field_draft($data)
 {
     only_admin_access();
     $page = false;
     if (isset($_SERVER["HTTP_REFERER"])) {
         $url = $_SERVER["HTTP_REFERER"];
         $url = explode('?', $url);
         $url = $url[0];
         if (trim($url) == '' or trim($url) == $this->app->url_manager->site()) {
             //$page = $this->get_by_url($url);
             $page = $this->homepage();
             // var_dump($page);
         } else {
             $page = $this->get_by_url($url);
         }
     } else {
         $url = $this->app->url_manager->string();
     }
     $this->define_constants($page);
     $table_drafts = $this->tables['content_fields_drafts'];
     $data = parse_params($data);
     if (isset($data['id']) and $data['id'] == 'latest_content_edit') {
         if (isset($page['id'])) {
             $page_data = $this->get_by_id($page['id']);
             $results = array();
             if (isset($page_data['title'])) {
                 $arr = array('rel_type' => 'content', 'field' => 'title', 'value' => $page_data['title']);
                 $results[] = $arr;
                 if (isset($page_data['content_type'])) {
                     $arr = array('rel_type' => $page_data['content_type'], 'field' => 'title', 'value' => $page_data['title']);
                     $results[] = $arr;
                 }
                 if (isset($page_data['subtype'])) {
                     $arr = array('rel_type' => $page_data['subtype'], 'field' => 'title', 'value' => $page_data['title']);
                     $results[] = $arr;
                 }
             }
             if (isset($page_data['content']) and $page_data['content'] != '') {
                 $arr = array('rel_type' => 'content', 'field' => 'content', 'value' => $page_data['content']);
                 $results[] = $arr;
                 if (isset($page_data['content_type'])) {
                     $arr = array('rel_type' => $page_data['content_type'], 'field' => 'content', 'value' => $page_data['content']);
                     $results[] = $arr;
                 }
                 if (isset($page_data['subtype'])) {
                     $arr = array('rel_type' => $page_data['subtype'], 'field' => 'content', 'value' => $page_data['content']);
                     $results[] = $arr;
                 }
             }
             //$results[]
         }
     } else {
         $data['is_draft'] = 1;
         $data['full'] = 1;
         $data['all'] = 1;
         $results = $this->edit_field($data);
     }
     $ret = array();
     if ($results == false) {
         return;
     }
     $i = 0;
     foreach ($results as $item) {
         if (isset($item['value'])) {
             $field_content = htmlspecialchars_decode($item['value']);
             $field_content = $this->_decode_entities($field_content);
             $item['value'] = mw()->parser->process($field_content, $options = false);
         }
         $ret[$i] = $item;
         $i++;
     }
     return $ret;
 }
Beispiel #2
0
<?php

only_admin_access();
?>
<script  type="text/javascript">
$(document).ready(function(){
  mw.options.form('.<?php 
print $config['module_class'];
?>
,.mw_adm_cont_head_change_holder', function(){
      mw.notification.success("<?php 
_e("Advanced settings updated");
?>
.");
    });


	  mw.options.form('.<?php 
print $config['module_class'];
?>
,.mw_adm_robots_txt_change_holder', function(){
      mw.notification.success("<?php 
_e("Advanced settings updated");
?>
.");
    });
});



</script>
Beispiel #3
0
 public function move_uploaded_file_to_backup($params)
 {
     only_admin_access();
     if (!isset($params['src'])) {
         return array('error' => 'You have not provided src to the file.');
     }
     $check = url2dir(trim($params['src']));
     $here = $this->get_bakup_location();
     if (is_file($check)) {
         $fn = basename($check);
         if (copy($check, $here . $fn)) {
             @unlink($check);
             return array('success' => "{$fn} was uploaded!");
         } else {
             return array('error' => 'Error moving uploaded file!');
         }
     } else {
         return array('error' => 'Uploaded file is not found!');
     }
 }
 function install_version($new_version)
 {
     if (defined("MW_API_CALL")) {
         only_admin_access();
     }
     $params = array();
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'ini_set')) {
         ini_set("set_time_limit", 0);
     }
     if (!strstr(INI_SYSTEM_CHECK_DISABLED, 'set_time_limit')) {
         set_time_limit(0);
     }
     $params['mw_version'] = MW_VERSION;
     $params['core_update'] = $new_version;
     $params['mw_update_check_site'] = $this->app->url_manager->site();
     $result = $this->call('get_download_link', $params);
     if (isset($result["core_update"])) {
         $value = trim($result["core_update"]);
         $fname = basename($value);
         $dir_c = mw_cache_path() . 'update/downloads' . DS;
         if (!is_dir($dir_c)) {
             mkdir_recursive($dir_c);
         }
         $dl_file = $dir_c . $fname;
         if (!is_file($dl_file)) {
             $this->_log_msg('Downloading core update');
             $get = $this->app->url_manager->download($value, $post_params = false, $save_to_file = $dl_file);
         }
         if (is_file($dl_file)) {
             $unzip = new \Microweber\Utils\Unzip();
             $target_dir = MW_ROOTPATH;
             $this->_log_msg('Preparing to unzip core update');
             $result = $unzip->extract($dl_file, $target_dir, $preserve_filepath = true);
             $this->_log_msg('Core update unzipped');
             $new_composer = $target_dir . 'composer.json.merge';
             if (is_file($new_composer)) {
                 //     $this->composer_merge($new_composer);
             }
             $this->post_update();
             return $result;
         }
     }
 }
 public function delete_media_file($params)
 {
     only_admin_access();
     $target_path = media_base_path() . 'uploaded' . DS;
     $target_path = normalize_path($target_path, 0);
     $path_restirct = userfiles_path();
     $fn_remove_path = $_REQUEST["path"];
     $resp = array();
     if ($fn_remove_path != false and is_array($fn_remove_path)) {
         foreach ($fn_remove_path as $key => $value) {
             $fn_remove = $this->app->url_manager->to_path($value);
             if (isset($fn_remove) and trim($fn_remove) != '' and trim($fn_remove) != 'false') {
                 $path = urldecode($fn_remove);
                 $path = normalize_path($path, 0);
                 $path = str_replace('..', '', $path);
                 $path = str_replace($path_restirct, '', $path);
                 $target_path = userfiles_path() . DS . $path;
                 $target_path = normalize_path($target_path, false);
                 if (stristr($target_path, media_base_path())) {
                     if (is_dir($target_path)) {
                         mw('Microweber\\Utils\\Files')->rmdir($target_path, false);
                         $resp = array('success' => 'Directory ' . $target_path . ' is deleted');
                     } else {
                         if (is_file($target_path)) {
                             unlink($target_path);
                             $resp = array('success' => 'File ' . basename($target_path) . ' is deleted');
                         } else {
                             $resp = array('error' => 'Not valid file or folder ' . $target_path . ' ');
                         }
                     }
                 } else {
                     $resp = array('error' => 'Not allowed to delete on ' . $target_path . ' ');
                 }
             }
         }
     }
     return $resp;
 }
Beispiel #6
0
function mw_send_anonymous_server_data($params)
{
    only_admin_access();
    $update_api = mw('update');
    if ($params != false) {
        $params = parse_params($params);
    }
    if (method_exists($update_api, 'send_anonymous_server_data')) {
        $iudates = $update_api->send_anonymous_server_data($params);
        return $iudates;
    } else {
        $params['site_url'] = site_url();
        $result = $update_api->call('send_anonymous_server_data', $params);
        return $result;
    }
}
Beispiel #7
0
 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;
     }
 }
Beispiel #8
0
 public function export()
 {
     only_admin_access();
     $cont = get_content("is_active=1&is_deleted=0&limit=250000&orderby=updated_at desc");
     print count($cont);
     exit;
 }