/** * Display error message * * @param string $what Dictionary what * @return void */ public function message($what = '') { // load dictionary $this->dict->get_words(); // get page $page = $this->get_page('msg'); $view = new X4View_core(AdmUtils_helper::set_tpl($page->tpl, $this->site->area->theme)); $view->site = $this->site; $view->page = $page; // reset base URL X4Utils_helper::set_base_url(ROOT . LL . X4Route_core::$area . '/' . DC); // get menu $view->menus = $this->site->get_menus($page->id_area); // get message $view->sections = array($this->dict->get_message(_WARNING, strtoupper($what), 'msg')); $view->render(TRUE); }
/** * Register User profile * * @access private * @param array $_post _POST array * @return void */ private function profiling($_post) { $msg = null; // ther'is no permission check because each user can only change his profile // handle _post $post = array('lang' => $_post['lang'], 'username' => $_post['username'], 'description' => strip_tags($_post['description']), 'mail' => $_post['mail'], 'phone' => $_post['phone']); // check for password update if (!empty($_post['password'])) { $post['password'] = X4Utils_helper::hashing($_post['password']); } $user = new User_model(); // check if username or email address are already used by another user $check = (bool) $user->exists($post['username'], $post['mail'], $_SESSION['xuid']); if ($check) { $msg = AdmUtils_helper::set_msg($false, '', $this->dict->get_word('_USER_ALREADY_EXISTS', 'msg')); } else { // update profile $result = $user->update($_SESSION['xuid'], $post); // if user changes his password then send a reminder if ($result[1] && !empty($_post['password'])) { // build subject and message $s = array('DOMAIN', 'USERNAME', 'PASSWORD'); $r = array($this->site->site->domain, $_post['username'], $_post['password']); $subject = str_replace($s, $r, _SUBJECT_PROFILE); $msg = str_replace($s, $r, _MSG_PROFILE); $to = array(array('mail' => $_post['mail'], 'name' => $_post['username'])); // send X4Mailer_helper::mailto(MAIL, false, $subject, $msg, $to); } // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); // set update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => urldecode(BASE_URL . 'profile'), 'title' => null); } } $this->response($msg); }
/** * Save article * * @param string $bid * @return void */ public function update($bid) { // load dictionaries $this->dict->get_words(); // get article id $mod = new Article_model(); $item = $mod->get_by_bid($bid); // check permission AdmUtils_helper::chklevel($_SESSION['xuid'], 'articles', $item->id, 2); // only if there are differences if ($item->content != $_POST['content']) { // tinymce $post = array('bid' => $bid, 'id_area' => $item->id_area, 'lang' => $item->lang, 'code_context' => $item->code_context, 'id_page' => $item->id_page, 'date_in' => time(), 'xkeys' => $item->xkeys, 'name' => $item->name, 'content' => $_POST['content'], 'excerpt' => 0, 'author' => $_SESSION['mail'], 'module' => $item->module, 'param' => $item->param, 'id_editor' => $_SESSION['xuid'], 'xon' => AUTOREFRESH); // insert new article's version $result = $mod->insert($post); if ($result[1]) { // add permission $perm = new Permission_model(); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('articles', $array, $item->id_area); } // set message X4Utils_helper::set_msg($result); echo $_SESSION['msg']; unset($_SESSION['msg']); } else { echo ''; } }
/** * Clear APC cache * * @return void */ public function clear_apc() { // do action if (APC) { apc_clear_cache(); apc_clear_cache('user'); apc_clear_cache('opcode'); } // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg(true); $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'sites/show/1', 'title' => null); $this->response($msg); }
/** * Delete article's version * * @access private * @param integer $id article ID * @param string $bid BID code * @return void */ private function deleting_version($id) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'articles', $id, 4); if (is_null($msg)) { // do action $mod = new Article_model(); $obj = $mod->get_by_id($id, 'articles', 'id_area, lang, bid'); $result = $mod->delete($id); // clear useless permissions if ($result[1]) { $perm = new Permission_model(); $perm->deleting_by_what('articles', $id); } // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'articles/history/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->bid, 'title' => null); } } $this->response($msg); }
/** * Initialize area: create default pages * * @param integer $id_area Area ID * @param string $lang Language code * @return void */ public function init($id_area, $lang) { $msg = null; // check permissions $msg = AdmUtils_helper::chklevel($_SESSION['xuid'], '_page_creation', 0, 4); if (is_null($msg)) { $qs = X4Route_core::get_query_string(); // get object: the area $area = new Area_model(); $a = $area->get_by_id($id_area); $mod = new Page_model($id_area, $lang); // build the post array $post = array(); if ($id_area == 1) { // admin area // uses admin area with language = SESSION['lang'] as base and duplicates all pages $pmod = new Page_model($id_area, $_SESSION['lang']); $pages = $pmod->get_pages(); foreach ($pages as $i) { $post[] = array($i->url, array('lang' => $lang, 'id_area' => $id_area, 'xid' => $i->xid, 'url' => $i->url, 'name' => $i->name, 'title' => $i->title, 'description' => $i->description, 'xfrom' => $i->xfrom, 'tpl' => $i->tpl, 'css' => $i->css, 'id_menu' => $i->id_menu, 'xpos' => $i->xpos, 'deep' => $i->deep, 'ordinal' => $i->ordinal, 'xon' => $i->xon)); } } else { // other areas // home $post[] = array('home', array('lang' => $lang, 'id_area' => $id_area, 'xid' => 'pages', 'url' => 'home', 'name' => 'Home page', 'title' => 'Home page', 'description' => 'Home page', 'xfrom' => 'home', 'tpl' => 'base', 'css' => 'base', 'id_menu' => 0, 'xpos' => 0, 'deep' => 0, 'ordinal' => 'A', 'xon' => 1)); // x3admin $post[] = array('x3admin', array('lang' => $lang, 'id_area' => $id_area, 'xid' => 'pages', 'url' => 'x3admin', 'name' => 'Editor', 'title' => 'Editor', 'description' => 'Editor', 'xfrom' => 'home', 'tpl' => 'base', 'css' => 'base', 'id_menu' => 0, 'xpos' => 1, 'deep' => 1, 'ordinal' => 'A0000001', 'hidden' => 1, 'xlock' => 1, 'xon' => 1)); // msg $post[] = array('comunication', array('lang' => $lang, 'id_area' => $id_area, 'xid' => 'pages', 'url' => 'msg', 'name' => 'Communication', 'title' => 'Communication', 'description' => 'Communication', 'xfrom' => 'home', 'tpl' => 'base', 'css' => 'base', 'id_menu' => 0, 'xpos' => 2, 'deep' => 1, 'ordinal' => 'A0000002', 'hidden' => 1, 'xlock' => 1, 'xon' => 1)); // search $post[] = array('search', array('lang' => $lang, 'id_area' => $id_area, 'xid' => 'pages', 'url' => 'search', 'name' => 'Search result', 'title' => 'Search result', 'description' => 'Search result', 'xfrom' => 'home', 'tpl' => 'base', 'css' => 'base', 'id_menu' => 0, 'xpos' => 3, 'deep' => 1, 'ordinal' => 'A0000003', 'hidden' => 1, 'xlock' => 1, 'xon' => 1)); // if is a private area if ($a->private) { // exit $post[] = array('logout', array('lang' => $lang, 'id_area' => $id_area, 'xid' => 'pages', 'url' => 'logout', 'name' => 'Logout', 'title' => 'Logout', 'description' => 'Logout', 'xfrom' => 'home', 'tpl' => 'base', 'css' => 'base', 'id_menu' => 0, 'xpos' => 4, 'deep' => 1, 'ordinal' => 'A0000004', 'hidden' => 0, 'xlock' => 1, 'xon' => 1)); } } // action $result = $mod->initialize_area($id_area, $lang, $post); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); if ($result[1]) { // create default contexts $mod->initialize_context($id_area, $lang); // refresh permissions $perm = new Permission_model(); $perm->refactory($_SESSION['xuid']); // set update $msg->update[] = array('element' => $qs['div'], 'url' => urldecode($qs['url']), 'title' => null); } } $this->response($msg); }
/** * Register edited file * * @access private * @param array $_post _POST array * @param string $file File path * @return void */ private function editing($_post, $file) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'templates', $_post['id'], 2); if (is_null($msg)) { // get file permission $fileperm = substr(sprintf('%o', fileperms($file)), -3); if ($fileperm != 777) { // set file permission chmod($file, 0777); } // update file content $check = file_put_contents($file, $this->replace(0, stripslashes($_post['code']))); chmod($file, 0755); // set message $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $theme = $mod->get_var($_post['id_theme'], 'themes', 'name'); $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'templates/index/' . $_post['id_theme'] . '/' . $theme, 'title' => null); } } $this->response($msg); }
/** * Perform the importing of words * * @access private * @param array $_post _POST array * @return void */ private function importing($_post) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], '_key_import', 0, 4); if (is_null($msg)) { // get key list($lang, $area, $what) = explode('-', $_post['what']); // handle _post $post = array('lang' => $_post['lang'], 'area' => $_post['area'], 'what' => $what, 'xon' => 1); // set the translator X4Core_core::auto_load('google_translate_library'); $translator = new GoogleTranslate($lang, $post['lang']); // get words to import $dict = new Dictionary_model(); if ($what == 'ALL') { // import all sections in an area $sections = $dict->get_sections($lang, $area); $result = true; foreach ($sections as $s) { // get words in section $words = $dict->get_words_to_import($lang, $area, $s->what, $post['lang'], $post['area']); if (!empty($words)) { $post['what'] = $s->what; // import foreach ($words as $i) { $post['xkey'] = $i->xkey; // try to translate if ($lang != $post['lang']) { $value = $translator->translate($i->xval); } else { $value = $i->xval; } // set the word $post['xval'] = $value; // insert $result = $dict->insert($post); // add permission if ($result[1]) { $amod = new Area_model(); $id_area = $amod->get_area_id($_post['area']); $perm = new Permission_model(); $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('dictionary', $array, $id_area); } } } } // set what for redirect $what = 'global'; } else { // import only one section $words = $dict->get_words_to_import($lang, $area, $what, $post['lang'], $post['area']); $result = true; // import foreach ($words as $i) { $post['xkey'] = $i->xkey; // try to translate if ($lang != $post['lang']) { $value = $translator->translate($i->xval); } else { $value = $i->xval; } // set the word $post['xval'] = $value; // insert $result = $dict->insert($post); // add permission if ($result[1]) { $amod = new Area_model(); $id_area = $amod->get_area_id($_post['area']); $perm = new Permission_model(); $array[] = array('action' => 'insert', 'id_what' => $result[0], 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('dictionary', $array, $id_area); } } } $msg = AdmUtils_helper::set_msg($result); // set what update if ($result[1]) { $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'dictionary/keys/' . $post['lang'] . '/' . $post['area'] . '/' . $what, 'title' => null); } } $this->response($msg); }
/** * Uninstall the plugin * * @access private * @param object $obj Plugin Objject * @return void */ private function uninstalling($obj) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'modules', $obj->id, 4); if (is_null($msg)) { // do action $mod = new X4Plugin_model(); $result = $mod->uninstall($obj->id); // check uninstalling if (is_array($result)) { $this->notice(false, '_plugin_not_uninstalled'); die; } else { // set message $msg = AdmUtils_helper::set_msg(true); // uninstalled if ($result) { // clear useless permissions $perm = new Permission_model(); $perm->deleting_by_what('modules', $obj->id); } $area = $mod->get_by_id($obj->id_area, 'areas', 'name'); $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'modules/index/' . $obj->id_area . '/' . $area->name, 'title' => null); } } $this->response($msg); }
/** * Register Edited image * * @access private * @param integer $id File ID (if 0 then is a new item) * @param array $_post _POST array * @return void */ private function saving($id_file, $_post) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'files', $id_file, 2); if (is_null($msg)) { $ko = _MSG_ERROR; // check if set asnew $asnew = intval(isset($_post['asnew'])); $mod = new File_model(); $file = $mod->get_by_id($id_file); if ($file) { switch ($file->xtype) { case 0: // images $path = APATH . 'files/filemanager/img/'; $rotation = intval($_post['rotate']); $rotation = $rotation ? 360 - $rotation : 0; if ($asnew) { // save a new file // set the new name $final_name = X4Files_helper::get_final_name($path, $file->name); $chk = X4Files_helper::create_cropped($path . $file->name, $path . $final_name, array($_post['width'], $_post['height']), array($_post['xcoord'], $_post['ycoord']), true); if ($chk) { $post = array(); $post[] = array('id_area' => $file->id_area, 'xtype' => $file->xtype, 'category' => $file->category, 'subcategory' => $file->subcategory, 'name' => $final_name, 'alt' => $file->alt, 'xon' => 1); // insert $result = $mod->insert_file($post); // create permissions if ($result[1]) { $id = $result[0]; $perm = new Permission_model(); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $id, 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('files', $array, $file->id_area); if ($rotation) { sleep(1); $res = X4Files_helper::rotate($path . $final_name, $path . $final_name, $rotation); } } } else { $result = array($_post['id'], intval($chk)); } } else { // replace old $chk = X4Files_helper::create_cropped($path . $file->name, $path . $file->name, array($_post['width'], $_post['height']), array($_post['xcoord'], $_post['ycoord']), true); if ($chk && $rotation) { sleep(1); $res = X4Files_helper::rotate($path . $file->name, $path . $file->name, $rotation); } $result = array($_post['id'], intval($chk)); $id = $file->id; } break; case 1: // generic text file $path = APATH . 'files/filemanager/files/'; $txt = $_post['content']; $res = file_put_contents($path . $file->name, $txt); $id = $id_file; $result = array($id, intval($res)); break; case 2: // video file // get the command, if exists $ffmpeg = str_replace(NL, '', $this->command_exist('ffmpeg')); if (!empty($ffmpeg)) { $file_name = $file->name; $mimes = array('video/quicktime' => 'mov', 'video/mp4' => 'mp4', 'video/webm' => 'webm', 'video/ogg' => 'ogv', 'application/ogg' => 'ogv', 'video/x-flv' => 'flv', 'video/avi' => 'avi', 'application/vnd.adobe.flash.movie' => 'swf', 'application/x-shockwave-flash' => 'swf'); if (isset($_post['capture'])) { // we have to extract a frame $vpath = APATH . 'files/filemanager/media/'; $ipath = APATH . 'files/filemanager/img/'; $file_name = str_replace($mimes[$_post['old_format']], 'jpg', $file_name); // set the new name $final_name = X4Files_helper::get_final_name($ipath, $file_name); //ffmpeg -i video_file -an -ss 27.888237 -vframes 1 -s 320x240 -f image2 image_file $chk = shell_exec($ffmpeg . ' -i ' . $vpath . $file->name . ' -an -ss ' . $_post['sec'] . ' -vframes 1 -s ' . $_post['iwidth'] . 'x' . $_post['iheight'] . ' -f image2 ' . $ipath . $final_name . ' 2>&1'); if ($chk && file_exists($ipath . $final_name)) { chmod($ipath . $final_name, 0777); $post = array(); $post[] = array('id_area' => $file->id_area, 'xtype' => 0, 'category' => $file->category, 'subcategory' => $file->subcategory, 'name' => $final_name, 'alt' => $file->alt, 'xon' => 1); // insert $result = $mod->insert_file($post); // create permissions if ($result[1]) { $id = $result[0]; $perm = new Permission_model(); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $id, 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('files', $array, $file->id_area); } } } else { // is a video conversion $path = APATH . 'files/filemanager/media/'; $new_format = $new_size = 0; if ($_post['old_width'] != $_post['width'] || $_post['old_height'] != $_post['height']) { $new_size = 1; } // if new format is a new file if ($_post['old_format'] != $_post['format']) { $new_format = 1; $file_name = str_replace($mimes[$_post['old_format']], $mimes[$_post['format']], $file_name); } if ($asnew || $new_format) { // save a new file // set the new name $final_name = X4Files_helper::get_final_name($path, $file_name); if ($new_size) { $chk = shell_exec($ffmpeg . ' -i ' . $path . $file->name . ' -vf scale=' . $_post['width'] . ':' . $_post['height'] . ' ' . $path . $final_name . ' 2>&1'); } else { // -c:a copy $chk = shell_exec($ffmpeg . ' -i ' . $path . $file->name . ' ' . $path . $final_name . ' 2>&1'); } if ($chk) { chmod($path . $final_name, 0777); $post = array(); $post[] = array('id_area' => $file->id_area, 'xtype' => $file->xtype, 'category' => $file->category, 'subcategory' => $file->subcategory, 'name' => $final_name, 'alt' => $file->alt, 'xon' => 1); // insert $result = $mod->insert_file($post); // create permissions if ($result[1]) { $id = $result[0]; $perm = new Permission_model(); // privs permissions $array[] = array('action' => 'insert', 'id_what' => $id, 'id_user' => $_SESSION['xuid'], 'level' => 4); $res = $perm->pexec('files', $array, $file->id_area); } } } else { // replace old if ($new_size) { $chk = shell_exec($ffmpeg . ' -i ' . $path . $file->name . ' -vf scale=' . $_post['width'] . ':' . $_post['height'] . ' ' . $path . $file->name . ' 2>&1'); } else { $chk = 1; } $result = array($_post['id'], intval($chk)); $id = $result[0]; } } } else { // ffmpeg not available $result = array(0, 0); $ko = _FFMPEG_NOT_FOUND; } break; case 3: // template $path = APATH . 'files/filemanager/template/'; if (extension_loaded('php5-tidy')) { // clean the code $tidy = tidy_parse_string($_post['content']); $tidy->cleanRepair(); $html = $tidy->html(); } else { $html = $_post['content']; } $res = file_put_contents($path . $file->name, $html); $id = $id_file; $result = array($id, intval($res)); break; } // set message $msg = AdmUtils_helper::set_msg($result, _MSG_OK, $ko); // set what update if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'files/editor/' . $id, 'title' => null); } } else { // file not found // set message $msg = AdmUtils_helper::set_msg(array(0, 0)); } } $this->response($msg); }
/** * Delete category * * @access private * @param integer $id Category ID * @param object $obj Category Obj * @return void */ private function deleting($id, $obj) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'categories', $id, 4); if (is_null($msg)) { // do action $mod = new Category_model(); $result = $mod->delete($id); // set message $msg = AdmUtils_helper::set_msg($result); // clear useless permissions if ($result[1]) { $perm = new Permission_model(); $perm->deleting_by_what('categories', $id); // set what update $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'categories/index/' . $obj->id_area . '/' . $obj->lang . '/' . $obj->tag, 'title' => null); } } $this->response($msg); }
/** * Register page's composition * Use _POST data * * @param integer item id (if 0 then is a new item) * @param array _POST array * @return void */ public function compositing() { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $_POST['id_page'], 3); if (is_null($msg)) { // handle _POST $sections = array(); $post = array('id_area' => $_POST['id_area'], 'id_page' => $_POST['id_page'], 'xon' => 1); // handle _POST for each section for ($i = 1; $i <= $_POST['snum']; $i++) { $post['progressive'] = $i; // delete first comma $articles = substr($_POST['sort' . $i], 0, 1) == ',' ? substr($_POST['sort' . $i], 1) : $_POST['sort' . $i]; $post['articles'] = str_replace(',', '|', $articles); $sections[] = $post; } // register composition $mod = new Section_model(); $result = $mod->compose($sections); APC && apc_delete(SITE . 'sections' . $post['id_page']); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); // add permissions on new sections if ($result[1]) { $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'sections/compose/' . $post['id_page'], 'title' => null); if (is_array($result[0]) && !empty($result[0])) { $perm = new Permission_model(); $array = array(); foreach ($result[0] as $i) { $array[] = array('action' => 'insert', 'id_what' => $i, 'id_user' => $_SESSION['xuid'], 'level' => 4); } $result = $perm->pexec('sections', $array, $_POST['id_area']); } } } $this->response($msg); }
/** * Return error message * * @param mixed $fields Form array or boolean * @param string $title Dialog title * @param boolean $session If true save message in a session var * @return void */ public function notice($fields, $title = '_form_not_valid', $session = false) { $dict = new X4Dict_model(X4Route_core::$folder, X4Route_core::$lang); $error = $dict->get_word($title, 'form'); $fields = X4Utils_helper::normalize_form($fields); foreach ($fields as $i) { if (isset($i['error'])) { foreach ($i['error'] as $ii) { // set the available label $label = is_null($i['label']) && isset($i['alabel']) || isset($i['alabel']) ? $i['alabel'] : $i['label']; // for related fields if (isset($i['related'][$i['name']])) { $src = array('XXXRELATEDXXX'); $rpl = array(); $related = $i['related'][$i['name']]; if (isset($fields[$related])) { // if is a related field $rpl[] = is_null($fields[$related]['label']) && isset($fields[$related]['alabel']) || isset($fields[$related]['alabel']) ? $fields[$related]['alabel'] : $fields[$related]['label']; } else { // if is a related value $rpl[] = $related; } if (isset($i['relatedvalue'][$i['name']])) { $src[] = 'XXXVALUEXXX'; $rpl[] = $i['relatedvalue'][$i['name']]; } $error .= '<br /><u>' . $label . '</u> ' . str_replace($src, $rpl, $dict->get_word($ii, 'form')); } else { $error .= '<br /><u>' . $label . '</u> ' . $dict->get_word($ii, 'form'); } } } } if ($session) { $_SESSION['msg'] = $error; } else { // set message $msg = AdmUtils_helper::set_msg(false, $error, $error); $this->response($msg); } }
/** * Refresh menu order * Called via Ajax * * @param integer $id Page ID * @param integer $holder Menu ID * @param string $orders Encoded string, for each menu you have a section, each section contains the list of Page ID in menu * @return void */ public function menu($id, $holder, $orders) { $msg = null; if (!is_null($id) && is_numeric($id)) { // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'pages', $id, 3); if (is_null($msg)) { // refresh order $menu = new Menu_model(); $result = $menu->menu($id, substr($holder, 1), $orders); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); } } $this->response($msg); }
/** * Minimize css files * * @return void */ public function minimize($id_theme, $name) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'themes', $id_theme, 4); if (is_null($msg)) { $qs = X4Route_core::get_query_string(); // do action $res = 1; // get the templates in the theme $mod = new Theme_model(); // CSS section $path = PATH . 'themes/' . $name . '/css/'; $items = $mod->get_css($id_theme); foreach ($items as $i) { if (file_exists($path . $i->css . '.css')) { $txt = file_get_contents($path . $i->css . '.css'); $txt = $mod->compress_css($txt); $chk = file_put_contents($path . $i->css . '.min.css', $txt); if (!$chk) { $res = 0; } } } // JS section X4Core_core::auto_load('jshrink_library'); $path = PATH . 'themes/' . $name . '/js/'; $items = $mod->get_js($id_theme); foreach ($items as $i) { if (file_exists($path . $i->js . '.js')) { $txt = file_get_contents($path . $i->js . '.js'); $txt = Minifier::minify($txt, array('flaggedComments' => false)); $chk = file_put_contents($path . $i->js . '.min.js', $txt); if (!$chk) { $res = 0; } } } $result = array(0, $res); // set message $this->dict->get_words(); $msg = AdmUtils_helper::set_msg($result); // set update if ($result[1]) { $msg->update[] = array('element' => $qs['div'], 'url' => urldecode($qs['url']), 'title' => null); } } $this->response($msg); }
/** * Delete language * * @access private * @param array $_post _POST array * @return void */ private function deleting($_post) { $msg = null; // check permission $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'languages', $_post['id'], 4); if (is_null($msg)) { // action $mod = new Language_model(); $result = $mod->delete_lang($_post['id']); // set message $msg = AdmUtils_helper::set_msg($result); // clear useless permissions if ($result[1]) { $perm = new Permission_model(); $perm->deleting_by_what('languages', $_post['id']); // set what update $msg->update[] = array('element' => 'tdown', 'url' => BASE_URL . 'languages', 'title' => null); } } $this->response($msg); }
/** * Delete area * * @access private * @param integer $id Area ID * @param string $name Area name * @return void */ private function deleting($id, $name) { $msg = null; // check permissions $msg = AdmUtils_helper::chk_priv_level($_SESSION['xuid'], 'areas', $id, 4); if (is_null($msg)) { // action $area = new Area_model(); $result = $area->delete_area($id, $name); // set message $msg = AdmUtils_helper::set_msg($result); // clear useless permissions if ($result[1]) { $perm = new Permission_model(); $perm->deleting_by_what('areas', $id); // set what update $msg->update[] = array('element' => 'topic', 'url' => BASE_URL . 'areas/index/1', 'title' => null); } } $this->response($msg); }