public function getExtensionById($id) { global $mainframe; $obj_row = YiiTables::getInstance(TBL_EXTENSIONS); $obj_row->load($id); $path = Yii::app()->basePath . '/extensions/modules/' . $obj_row->folder; $module_xml_file = $path . "/" . $obj_row->folder . ".xml"; if (!file_exists($module_xml_file)) { YiiMessage::raseWarning("Error! file xml module is not existing!."); $mainframe->redirect(Yii::app()->createUrl("/modules")); } $params = sysLoadXmlParam($module_xml_file, $obj_row->params); $obj_row->params = $params; return $obj_row; }
static function render($node, $value = null, $prefix_name = "params", $_w1 = 5, $_w2 = 7) { $node['type'] = isset($node['type']) ? $node['type'] : "text"; $node['default'] = isset($node['default']) ? $node['default'] : null; $node['label'] = isset($node['label']) ? $node['label'] : "label field"; $node['value'] = isset($node['value']) ? $node['value'] : ""; $node['name'] = isset($node['name']) ? $node['name'] : $node['type']; $node['description'] = isset($node['description']) ? $node['description'] : ""; $node['attr'] = isset($node['attr']) ? $node['attr'] : ""; $className = ucfirst($node['type']) . "Element"; if (!in_array(strtolower($node['type']), array("menutype", "list", 'radio', 'text', "textarea", "catid"))) { return ""; } if (!class_exists($className)) { YiiMessage::raseWarning("Element " . $node['type'] . " is not existing "); exit; } $element = new $className($node, $value); return $element->build($prefix_name, array($_w1, $_w2)); }
public function getItem($cid) { global $mainframe; $obj_module = YiiModule::getInstance(); $obj_row = $obj_module->loadItem($cid); $path = Yii::app()->basePath . '/extensions/modules/' . $obj_row->module; $module_xml_file = $path . "/" . $obj_row->module . ".xml"; if (!file_exists($module_xml_file)) { YiiMessage::raseWarning("Error! file xml module is not existing!."); $mainframe->redirect(Yii::app()->createUrl("/modules")); } $params = sysLoadXmlParam($module_xml_file, $obj_row->params); $obj_row->params = $params; return $obj_row; }
public function accessRules() { global $db, $user, $mainframe; $YiiApp = Yii::app(); $app = Request::getVar('app', 'cpanel'); $view = Request::getVar('view', 'cpanel'); $layout = Request::getVar('layout', 'cpanel'); if (is_object($user) and $user->isLogin()) { if (!$user->isAdmin()) { YiiMessage::raseWarning("Your account not have permission to visit backend page"); Yii::app()->session['userbackend'] = null; $this->redirect(Router::buildLink("users", array("view" => 'user', 'layout' => 'logout'))); // $this->redirect(array('users/logout')); return; } if ($app == "users" and $view == "user" and $layout == "login") { $this->redirect(Router::buildLink("cpanel")); // $this->redirect(array('/cpanel')); return; } return array(); $return = array(array('allow', 'actions' => array("templates"), 'users' => array('*'))); return $return; } else { if ($app == "users" and $view == "user" and $layout == "login") { return array(array('allow', 'actions' => array("login"), 'users' => array('*')), array('allow', 'users' => array('@')), array('deny', 'users' => array('*'))); } else { $this->redirect(Router::buildLink("users", array("view" => 'user', 'layout' => 'login'))); // return array(); } } }
public function actionUploadext() { global $mainframe, $user; if (!$user->isSuperAdmin()) { YiiMessage::raseNotice("Your account not have permission to install extension"); $this->redirect(Router::buildLink("cpanel")); } $pack_install = $_FILES['install_package']; if ($pack_install == null or $pack_install['error'] != 0) { YiiMessage::raseWarning("Unable to find install package"); $this->redirect(Router::buildLink("installer")); } // $YiiFile = new YiiFile; $path_file_pach_install = PATH_TMP . $pack_install['name']; YiiFile::upload($pack_install['tmp_name'], $path_file_pach_install); $file_info = pathinfo($path_file_pach_install); if (strtolower($file_info['extension']) != "zip") { YiiMessage::raseWarning("Invalid extension install package"); YiiFile::delete($path_file_pach_install); $this->redirect(Router::buildLink("installer")); } $filename = $file_info['filename']; $zip = new ZipArchive(); $res = $zip->open($path_file_pach_install); $path_extact = PATH_TMP . $filename; if ($res === TRUE) { $zip->extractTo($path_extact); $zip->close(); } else { YiiMessage::raseWarning("Invalid extract file install package"); YiiFile::delete($path_file_pach_install); $this->redirect(Router::buildLink("installer")); } $files_xml = YiiFolder::files($path_extact, "\\.xml", 1, true); if (count($files_xml) == 0) { YiiFile::delete($path_file_pach_install); YiiFolder::delete($path_extact); YiiMessage::raseWarning("Invalid extension install package"); $this->redirect(Router::buildLink("installer")); } $xml = null; foreach ($files_xml as $file_xml) { $xml = simplexml_load_file($file_xml); if (!$xml) { unset($xml); continue; } if ($xml->getName() != 'extension') { unset($xml); continue; } $type = (string) $xml->attributes()->type; if (!in_array($type, array("app", "module"))) { unset($xml); continue; } } $type = (string) $xml->attributes()->type; $row_ext = YiiTables::getInstance(TBL_EXTENSIONS); $arr_info = array(); $arr_info['title'] = (string) $xml->title; $arr_info['name'] = (string) $xml->name; $arr_info['alias'] = $this->convertalias($arr_info['title']); $arr_info['author'] = (string) $xml->author; $arr_info['version'] = (string) $xml->version; $arr_info['creationDate'] = (string) $xml->creationDate; $arr_info['description'] = (string) $xml->description; $arr_info['type'] = (string) $xml->attributes()->type; $arr_info['folder'] = trim(preg_replace('/[^\\w\\d]+/is', '', $row_ext->title)); $arr_info['client'] = (string) $xml->attributes()->client; if ($arr_info['client'] == "") { $arr_info['client'] = 1; } $row_ext->loadRow("*", "title = '" . $arr_info['title'] . "' OR alias = '" . $arr_info['alias'] . "'"); $ext_new = false; if ($row_ext->id == 0) { $row_ext->cdate = date("Y-m-d H:i:s"); $ext_new = true; } $row_ext->mdate = date("Y-m-d H:i:s"); $row_ext->bind($arr_info); $path_ext = PATH_MODULES . $row_ext->folder; if ($row_ext->type == "app" and $row_ext->client == 1) { $path_ext = PATH_APPS_FRONT . $row_ext->folder; } else { if ($row_ext->type == "app" and $row_ext->client == 0) { $path_ext = PATH_APPS_BACKEND . $row_ext->folder; } } if (!YiiFolder::create($path_ext, 0775)) { YiiMessage::raseWarning("FILESYSTEM ERROR Could not create directory"); YiiFile::delete($path_file_pach_install); YiiFolder::delete($path_extact); $this->redirect(Router::buildLink("installer")); } $bool = YiiFolder::copy($path_extact, $path_ext, '', 1); if ($row_ext->type == "module" and $ext_new == true) { $row_module = YiiTables::getInstance(TBL_MODULES); $row_module->title = $row_ext->title; $row_module->alias = $row_ext->alias; $row_module->cdate = date("Y-m-d H:i:s"); $row_module->mdate = date("Y-m-d H:i:s"); $row_module->module = $row_ext->folder; $row_module->status = 0; $row_module->store(); } YiiFile::delete($path_file_pach_install); YiiFolder::delete($path_extact); $this->redirect(Router::buildLink("installer"), "Succesfully install package"); }
function actionCancel() { $menuID = Request::getInt('menu', ""); if ($menuID <= 0) { YiiMessage::raseWarning("Invalid menu id"); $this->redirect(Router::buildLink('menus', array("view" => "menutype"))); } else { $this->redirect(Router::buildLink('menus', array("view" => "menuitem", 'menu' => $menuID))); } }
function reloaUserLogin($isBackEnd = 1) { global $user; if ($isBackEnd) { $query = "SELECT u.*,g.lft,g.name groupname, g.backend " . "FROM " . TBL_USERS_GROUP . " g right join " . TBL_USERS . " u ON g.id = u.groupID " . " WHERE u.id = {$this->id} AND u.status = 1 "; $conmmand = Yii::app()->db->createCommand($query); $result = $conmmand->queryRow(); if (!$result) { YiiMessage::raseWarning("Your account not have permission to visit backend"); $this->redirect(Router::buildLink("users", array("view" => "user"))); } else { $query = "UPDATE " . TBL_USERS . " SET lastvisit = now() WHERE id = " . $this->id; $command = Yii::app()->db->createCommand($query); $command->execute(); foreach ($result as $field_name => $field_value) { if (strpos($field_name, "_") === 0) { continue; } $this->{$field_name} = $field_value; } $user = Yii::app()->session['userbackend'] = $this; } } else { $query = "SELECT * " . "FROM " . TBL_USERS . " WHERE u.id = {$this->id} AND status = 1 AND verify = 1 "; $conmmand = Yii::app()->db->createCommand($query); $result = $conmmand->queryRow(); if (!$result) { } else { $result['suppliers'] = ""; foreach ($result as $field_name => $field_value) { if (strpos($field_name, "_") === 0) { continue; } $this->{$field_name} = $field_value; } $user = Yii::app()->session['userfront'] = $this; } } }
public function actionLogin() { $LoginForm = Request::getVar("LoginForm"); if (Request::getVar("LoginForm") and $LoginForm['username'] == "" || $LoginForm['password'] == "") { YiiMessage::raseWarning("Type your username and password"); $this->redirect(Router::buildLink("users", array("view" => "user", 'layout' => 'login'))); return; } $model = new UserForm(); // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; $session_id = session_id(); // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { $this->afterLogin($session_id, session_id()); $this->redirect(Router::buildLink("cpanel")); // $this->redirect("/backend/"); } else { YiiMessage::raseWarning("Invalid your usename or password"); } } $this->layout = "//login"; $this->pageTitle = "Page login"; $this->render('login'); }