public static function tokenDefault(&$token, &$text) { if ($token['type'] == 'text') { $text .= $token['data']; } else { if ($token['type'] == 'tag' && strtoupper($token['name']) == 'COMPONENT') { $name = $token['data']['name']; $component = SystemComponent::getComponentByName($name); if ($component !== null) { $text .= '<?php $data = ' . var_export($token['data'], true) . '; $flags = ' . var_export($token['flags'], true) . '; ?>'; // Sustituyo esto: //$text .= $component->getPHP(); // Por esto otro: $html = $component->getPHP(); $ctokens = TreeScript::getParse($html); $ctext = ''; foreach ($ctokens as $ctoken) { RenderToken::tokenDefault($ctoken, $ctext); } $text .= $ctext; // FIN ControllerPage::requireComponent($name); } } else { if ($token['type'] == 'tag' && $token['name'] == '') { $text .= ''; } else { //$text .= ''; } } } }
function __construct() { $this->settings = parent::getSetting(); $host = $this->settings['dbhost']; $user = $this->settings['dbusername']; $pass = $this->settings['dbpassword']; $db = $this->settings['dbname']; $this->mysqli = new MySQLi($host, $user, $pass, $db); if ($this->mysqli->connect_errno) { die('Unable to connect to database [' . $this->mysqli->connect_error . ']'); } $this->mysqli->set_charset('utf8'); }
function __construct() { // Load settings from parent class $settings = SystemComponent::getSettings(); // Get the main settings from the array we just loaded $host = $settings['dbhost']; $db = $settings['dbname']; $user = $settings['dbusername']; $pass = $settings['dbpassword']; // Connect to the database $this->link = mysql_connect($host, $user, $pass); mysql_select_db($db); register_shutdown_function(array(&$this, 'close')); }
<?php require_once 'header.php'; if (isset($_POST['login'])) { $ss = new SystemComponent(); $info = $ss->getSetting(); if ($info['adminpass'] == hash('SHA256', trim($_POST['pass']))) { $_SESSION['admin_loged'] = true; header('Location: index.php'); die; } else { header('Location: login.php?error=1'); die; } } else { ?> <form action="" method="post"> <Div class="col-md-6 col-md-push-3"> <?php if (isset($_GET['out'])) { ?> <div class="row"><div class="alert alert-success">Logout was successful</div></div> <?php } else { if (isset($_GET['error'])) { ?> <br><br> <div class="row"><div class="alert alert-danger">Login failed</div></div> <?php } }
/** * 加载操作类 * @param unknown $component_name * @param string $module * @return Ambigous <boolean, multitype:, multitype:> * @date: 2014-11-19 上午11:00:29 * @author: dayunlong<*****@*****.**> */ public static final function loadComponent($component_name, $module = NULL, $type = NULL) { return SystemComponent::loadComponent($component_name, $module, $type); }
<?php $name = $_POST['id_component']; $list = SystemComponent::get($name)->getAjaxNames(); $result = array(); foreach ($list as $l) { $result[$l] = array('id' => $l, 'name' => $l); } sort($result); echo json_encode($result);
private function requireComponent($name) { if (!array_key_exists($name, $this->components_loaded)) { // Busco el componente: $component = SystemComponent::getComponentByName($name); if (null === $component) { // Error $this->components_loaded[$name] = "error"; } else { $this->components_loaded[$name] = true; $this->appendJS($component->getJS(), $name); $this->css = $component->getCSS() . $this->css; } } }
/** * Relocates this component (copy or move) * * This does the following tasks * - Remove all DB entries for this component if moved * - Relocate the component in filesystem * - Fix namespaces of PHP class files * - Alter or copy pages * - Create DB entries for new component * - Activate new component * @todo Test copy of pages (rxqcmv1) * @param string $newName New component name * @param string $newType New component type, one of 'core', 'core_module' and 'module' * @param boolean $customized Copy/move to customizing folder? * @param boolean $copy Copy or move? True means copy, default is move * @return ReflectionComponent New resulting component */ protected function internalRelocate($newName, $newType, $customized, $copy) { // create new ReflectionComponent $newComponent = new self($newName, $newType); if ($newComponent->exists()) { throw new SystemComponentException('The target component is already Exists. Please provide different component name or use uninstall command to remove old component..'); } // move or copy pages before removing DB entries $em = \Env::get('cx')->getDb()->getEntityManager(); $pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); $pages = $pageRepo->findBy(array('module' => $this->componentName)); $migratedNodes = array(); foreach ($pages as $page) { if ($copy) { $node = $page->getNode(); if (!in_array($node->getId(), $migratedNodes)) { // copy the node and persist changes $newNode = $node->copy(); $em->flush(); // update module name of the page foreach ($newNode->getPages() as $newPage) { $newPage->setModule($newName); $em->persist($newPage); } $migratedNodes[] = $node->getId(); } } else { $page->setModule($newName); $em->persist($page); } } $em->flush(); $this->internalCopyData($newComponent); // remove old component from db (component, modules, backend_areas) if (!$copy) { $this->removeFromDb(); } // copy/move in filesystem (name, type and customizing) $newLocation = $newComponent->getDirectory(false, $customized); $this->internalFsRelocate($newLocation, $copy); // fix namespaces $baseDir = ASCMS_DOCUMENT_ROOT; if ($copy) { $baseDir = $newComponent->getDirectory(); } $newComponent->fixNamespaces(SystemComponent::getBaseNamespaceForType($this->componentType) . '\\' . $this->componentName, $baseDir); $newComponent->fixLanguagePlaceholders(strtoupper($this->componentType . '_' . $this->componentName), $baseDir); $newComponent->fixDocBlocks(strtolower($this->componentType . '_' . $this->componentName), $baseDir); // renaming the component in backend navigation does not yet work //$newComponent->setComponentName($baseDir); // add new component to db and activate it (component, modules, backend_areas, pages) $newComponent->activate(); return $newComponent; }
<?php $component_name = $_POST['component_name']; $ajax_name = $_POST['ajax_name']; $ajax_code = $_POST['ajax_code']; SystemComponent::get($component_name)->setAjax($ajax_name, $ajax_code);
<?php $name = $_POST['id_component']; $code = $_POST['html']; SystemComponent::get($name)->setPHP($code); echo SystemComponent::get($name)->getPHP();
<?php $id = $_POST['id_component']; SystemComponent::get($id)->DELETE();
<?php $query = $_POST['query']; $result = array(); foreach (SystemComponent::SELECT() as $c) { $name = $c->getName(); if ('' == $query || false !== stripos($name, $query)) { $result[] = $name; } } sort($result, SORT_NATURAL | SORT_FLAG_CASE); echo json_encode($result);
<?php $name = $_POST['id_component']; $code = $_POST['js']; SystemComponent::getComponentByName($name)->setJS($code);
/** * 站点登陆 */ public function actionLogin() { $username = Yii::app()->request->getParam('email'); $passowrd = Yii::app()->request->getParam('psw'); $PlatUserComponent = SystemComponent::loadComponent('PlatUserComponent', 'plat'); die; if ($username == $username + 0) { $UserInfo = $PlatUserComponent->getPlatUserByUsername($username); } else { $UserInfo = $PlatUserComponent->getPlatUserByPhone($username); } $code = 0; $msg = ''; if ($UserInfo == false) { $msg = '当前用户或者手机号不存在!'; URL::retJson($code, $msg); } $check_psw = Utils::getUserPassword($passowrd); if ($check_psw !== $UserInfo->ts_u_password) { $msg = '密码不对!'; // URL::retJson($code, $msg); } $code = 1; $msg = '登陆成功!'; //生成session HckpSessionComponent::getInstance()->initSession(array('user_id' => $UserInfo->ts_u_id, 'user_username' => $UserInfo->ts_u_username, 'user_phone' => $UserInfo->ts_u_phone, 'user_realname' => $UserInfo->ts_real_name, 'user_type' => $UserInfo->ts_u_type, 'user_headpic' => $UserInfo->ts_u_headpic)); URL::retJson($code, $msg); /* $this->layout=false; //login的登陆处理方法 //如果有跳转的目标地址跳转到目标地址 $user_info=array(); $user_info['user_id']='1'; $user_info['user_username']='******'; $user_info['user_phone']='15026912738'; $user_info['user_realname']='大云龙'; $user_info['user_type']='1'; $user_info['user_headpic']='/data/1.pic'; //session登陆 //HckpSessionComponent::getInstance()->initSession($user_info); //跳转到目标地址 //test //$r=HckpSessionComponent::getInstance()->getVal('user_info'); //var_dump($r); $user=new UserModel(); $loginUser = $user->find( array( 'condition'=>"ts_u_phone = :ts_u_phone and ts_u_password = :ts_u_password", 'params'=>array(":ts_u_phone"=>$_POST['email'],":ts_u_password"=>Utils::getUserPassword($_POST['pwd'])) ) ); if(!isset($loginUser->ts_u_id) || $loginUser->ts_u_id==null){ $info = array( 'status'=>2, 'info'=>'用户名或密码错误' ); }else{ HckpSessionComponent::getInstance()->initSession(array( 'user_id'=>$loginUser->ts_u_id, 'user_username'=>$loginUser->ts_u_username, 'user_phone'=>$loginUser->ts_u_phone, 'user_realname'=>$loginUser->ts_real_name, 'user_type'=>$loginUser->ts_u_type, 'user_headpic'=>$loginUser->ts_u_headpic )); $info = array( 'status'=>1, 'info'=>'登录成功' ); } echo json_encode($info); die(); */ }
public function setPHP($html) { // TODO: Corregir sintaxis... $tokens = TreeScript::getParse($html); $code = ''; foreach ($tokens as $token) { if ($token['type'] == 'text') { $code .= $token['data']; } else { if (strtoupper($token['name']) == 'COMPONENT') { $name = $token['data']['name']; $component = SystemComponent::get($name); if ($component === null) { $token['data']['error'] = 'Component "' . $name . '" does not exists.'; // El componente no existe :S } else { self::validateHTML($token, $component->getValidation()); } } $code .= RenderToken::tokenToString($token); } } $this->php = $code; return file_put_contents(self::$dir_base . '/' . $this->name . '/index.php', $code); }
<?php $param = Router::$parameters; if (!array_key_exists('{component}', $param)) { echo 'show all component list if mode debug on. Else 404'; return; } if (!array_key_exists('{call}', $param)) { echo "See all calls for the component '{$parameters['{component}']}' if mode debug on. Else 404"; return; } $component = SystemComponent::getComponentByName($param['{component}']); if (null === $component) { echo "Component does not exist (debug mode). Else 404"; return; } $ajax = $component->getAjax($param['{call}']); if (null === $ajax) { echo "Ajax does not exist (debug mode). Else 404"; return; } eval('?>' . $ajax); // TODO: fix this !!! if (Config::get('CACHE_AJAX_ENABLED')) { $cached = Router::export() . $ajax; Cache::add(Router::$url, $cached); $filename = 'cache/' . md5(Router::$url); file_put_contents($filename, php_strip_whitespace($filename)); }
<?php $name = $_POST['name']; $component = SystemComponent::INSERT($name); echo $component->getName();
<?php $name = $_POST['id_component']; $component = SystemComponent::getComponentByName($name); $result = new stdClass(); $result->js = $component->getJS(); $result->css = $component->getCSS(); $result->html = $component->getPHP(); echo json_encode($result);
<?php $component_name = $_POST['component_name']; $ajax_name = $_POST['ajax_name']; echo SystemComponent::get($component_name)->getAjax($ajax_name);
<?php $name = $_POST['id_component']; $code = $_POST['css']; SystemComponent::get($name)->setCSS($code);