コード例 #1
0
ファイル: Adm_usersController.php プロジェクト: Zanej/cms
 static function isUserLogged()
 {
     if (!isset($_COOKIE["authenticate_user"])) {
         return false;
     } else {
         $user = explode("|", $_COOKIE["authenticate_user"]);
         $db = Conf::getDB();
         $res = $db->Query("SELECT id FROM adm_users WHERE md5(username)='" . $user[0] . "' AND password='******' LIMIT 1");
         if (!$res) {
             return false;
         }
         return true;
     }
 }
コード例 #2
0
ファイル: Rewrite.php プロジェクト: Zanej/cms
    $percorso .= $class_name[count($class_name) - 1] . ".php";
    if (strstr($percorso, "Smarty")) {
        //echo $percorso;
    }
    if (file_exists($percorso)) {
        require_once str_replace("//", "/", $percorso);
        /*if($class_name[count($class_name)-1] == "Config"){
              $class::setSmarter();
              $class::readProperties();
              $class::readParameters();
          }*/
    }
});
Config::readParameters();
Config::setSmarter();
Config::readProperties();
$check_equal = $_GET["url"] == ADMIN_DIR || $_GET["url"] == "/" . ADMIN_DIR || $_GET["url"] == ADMIN_DIR . "/" || $_GET["url"] == "/" . ADMIN_DIR . "/";
$check = substr($_GET["url"], 0, strlen(ADMIN_DIR)) == ADMIN_DIR || substr($_GET["url"], 0, strlen(ADMIN_DIR) + 1) == "/" . ADMIN_DIR;
if ($check) {
    $controller = new AdminController();
}
if ($check_equal && COUNT($_POST) > 0) {
    if (AdminController::exists()) {
        $cook = md5($_POST["username"]) . "|" . md5($_POST["password"]);
        setcookie("authenticate_user", $cook, time() + 3600 * 24 * 2, "/");
        $user = $controller->findBy(array("username" => $_POST["username"]));
        if (!isset($_SESSION["admin_user"]) || $_SESSION["admin_user"] != $_COOKIE["authenticate_user"]) {
            $_SESSION["admin_user"] = $_COOKIE["authenticate_user"];
            $setAccess = true;
        } else {
            $setAccess = false;
コード例 #3
0
ファイル: Bundle.php プロジェクト: Zanej/cms
 public function createEntity($name)
 {
     $keys = Config::getDB()->getAllKeys($name);
     $creator = new EntityCreator($name, $keys, "", $this->name);
     $creator->create();
 }
コード例 #4
0
ファイル: EntityCreator.php プロジェクト: Zanej/cms
 /**
  * 
  * @param type $var
  * @return type
  */
 private function getDbVarInfoByDB($var)
 {
     return array("type" => Config::getDB()->getColumnType($var, $this->name), "default" => Config::getDb()->GetDefaultValue($var, $this->name), "key" => isset($this->keys[$var]) ? $this->keys[$var] : null, "extra" => Config::getDb()->GetColumnExtras($var, $this->name), "nullable" => Config::getDb()->IsNullableColumn($var, $this->name));
 }
コード例 #5
0
ファイル: Sezioni.php プロジェクト: Zanej/cms
 public function initFields()
 {
     if ($this->from) {
         $this->campi = $this->ct_controller->findBy(array("id_sezione" => $this->getId(), $this->from => 1));
     } else {
         $this->campi = $this->ct_controller->findBy(array("id_sezione" => $this->getId()));
     }
     $chiave_titolo = false;
     if (!isset($this->table)) {
         /*@var $controller_obj AbstractController*/
         $this->controller = new $this->object();
         $this->chiave = \CMS\Conf\Config::getDB()->getPrimaryKey($this->controller->getTableName());
     } else {
         $this->chiave = \CMS\Conf\Config::getDB()->getPrimaryKey($this->table);
     }
     if ($this->campi == false) {
         if (isset($this->table)) {
             $this->campi = \CMS\Conf\Config::getDB()->GetColumnNames($this->table);
         } else {
             $this->campi = \CMS\Conf\Config::getDB()->GetColumnNames($this->controller->getTableName());
         }
         $chiave_titolo = true;
         foreach ($this->campi as $kk => $vv) {
             $this->campi[$kk] = array("field" => $vv, "hidden" => false, "key" => false);
             if ($kk == $this->chiave) {
                 $this->campi[$kk]["hidden"] = true;
                 $this->campi[$kk]["key"] = true;
                 if ($chiave_titolo) {
                     $this->campi[$kk]["titolo"] = true;
                 }
             }
             $this->campi[$kk] = (object) $this->campi[$kk];
             $this->campi[$kk] = new \CMS\Controller\AbstractStdClass(get_object_vars($this->campi[$kk]));
         }
     }
     foreach ($this->campi as $kk => $vv) {
         $this->getExternalValues($this->campi[$kk]);
     }
 }
コード例 #6
0
ファイル: QueryBuilder.php プロジェクト: Zanej/cms
 /**
  * 
  * @param type $values
  * @param type $table
  */
 private function checkValuesType(&$values, $table)
 {
     /*@var $db MySQL*/
     $db = Config::getDB();
     foreach ($values as $key => $val) {
         $type = $db->GetColumnDataType($key, $table);
         ////echo $type;
         if ($type == "VAR_STRING" || $type == "VAR_BLOB") {
             $values[$key] = addslashes(htmlentities($val));
         }
     }
 }
コード例 #7
0
ファイル: Console.php プロジェクト: Zanej/cms
 /**
  * Creates a bundle
  */
 public static function createBundle($bundlename = "Data", $tables = array())
 {
     $dirname = $_SERVER["DOCUMENT_ROOT"] . "\\" . $bundlename . "Bundle";
     if (!file_exists($dirname)) {
         mkdir($dirname, 0755);
     }
     if (count($tables) > 0) {
         foreach ($tables as $key => $val) {
             if (\CMS\DbWorkers\Table::exists($val)) {
                 \CMS\Conf\Config::createBundle($bundlename, $tables);
             }
         }
     }
 }
コード例 #8
0
ファイル: Table.php プロジェクト: Zanej/cms
 /**
  * Returns all keys of this table
  */
 private function getAllKeys()
 {
     return Config::getDb()->getAllKeys($this->name);
 }
コード例 #9
0
ファイル: AbstractController.php プロジェクト: Zanej/cms
 /**
  * Render a file based on smarty
  * @param type $templatename Template name
  * @param type $params parametri
  */
 public function render($templatename, $params)
 {
     try {
         if (!file_exists($_SERVER["DOCUMENT_ROOT"] . "/Resources/{$templatename}.tpl")) {
             throw new \Exception("Template not found!");
         } else {
             $filename = $_SERVER["DOCUMENT_ROOT"] . "/Resources/{$templatename}.tpl";
         }
         //echo $filename;
         /* @var CMS\Conf\Smarty $smarty*/
         $smarty = Config::getSmarter();
         //print_r($params);
         //exit;
         $smarty->assign("COOKIE", $_COOKIE);
         $smarty->assign("SESSION", $_SESSION);
         $smarty->assign("GET", $_GET);
         $smarty->assign("POST", $_POST);
         foreach ($params as $key => $val) {
             $smarty->assign($key, $val);
         }
         $smarty->display(str_replace("//", "/", $filename));
     } catch (\Exception $e) {
         echo "Caught exception: " . $e->getMessage();
     }
 }