Ejemplo n.º 1
0
 /**
  * Returns the primary key
  */
 public static function getKeyName()
 {
     $class_name = get_called_class();
     $real_name = str_replace("controller", "", strtolower(substr($class_name, strrpos($class_name, "\\") + 1)));
     //echo Config::getDB()->getPrimaryKey($real_name);
     return Config::getDB()->getPrimaryKey($real_name);
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
Archivo: Table.php Proyecto: Zanej/cms
 /**
  * 
  * @param type $name
  * @param type $values
  */
 public static function create($name, $values)
 {
     $query = "CREATE TABLE {$name} (";
     $query .= "id INTEGER AUTO_INCREMENT PRIMARY KEY ,";
     foreach ($values as $key => $val) {
         $query .= "`" . $key . "` " . $val . ",";
         /*$add = explode("|",$val);
           $query.=" ".$add[0]."(".$add[1].")".$add[2].",";*/
     }
     $query = substr($query, 0, strlen($query) - 1);
     $query .= ")";
     if (strstr(strtolower($query), "references ")) {
         $query .= " ENGINE='InnoDB'";
         Config::getDB()->Query("SET FOREIGN_KEY_CHECKS=1");
     }
     if (Config::getDb()->Query($query)) {
         //echo json_encode(array("success"=>true));
         return true;
     } else {
         //echo $query;
         return false;
     }
 }
Ejemplo n.º 4
0
 /**
  * 
  * @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));
 }
Ejemplo n.º 5
0
Archivo: Bundle.php Proyecto: Zanej/cms
 public function createEntity($name)
 {
     $keys = Config::getDB()->getAllKeys($name);
     $creator = new EntityCreator($name, $keys, "", $this->name);
     $creator->create();
 }
Ejemplo n.º 6
0
 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]);
     }
 }
Ejemplo n.º 7
0
 /**
  * 
  * @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));
         }
     }
 }