Exemple #1
0
 public function setNewServer($host, $user, $password, $database, $faild = self::EXCEPTION_FAILD_MODE)
 {
     //$this->server=null;
     //
     if ($host == "" and $user == "" and $database == "") {
         throw new DatabaseArgumentsException();
     } else {
         Database::$server = mysqli_connect($host, $user, $password, $database);
         //
         if (!Database::$server) {
             if ($faild == 2) {
                 throw new DatabaseConnectionException();
             } else {
                 if ($faild == 1) {
                     \Errors::r_db();
                 }
             }
         }
         //
         mysqli_query(Database::$server, "SET NAMES " . Config::get("database.charset"));
         //
         Database::$serverData = ['host' => $host, "username" => $user, "password" => $password, "database" => $database];
         //
         //
         return Database::$server;
     }
 }
Exemple #2
0
 public static function getMenuByGroup($group)
 {
     if (!is_array($group)) {
         $files = glob("../app/modules/*", GLOB_ONLYDIR);
         $T = array();
         foreach ($files as $key => $filename) {
             $F = (include $filename . "/config.php");
             if (count($F['menu']) > 0) {
                 if ($F['container'] == $group) {
                     if ($F['etat'] == "active") {
                         $T[$key] = $F['menu'];
                     }
                 }
             }
         }
         return array_values($T);
     } else {
         if (Config::get('database.prefixing')) {
             $data = Database::read("select * from  " . Config::get('database.prefixe') . $group['table'] . " where id='" . $group['id'] . "'", 1);
             $data = $data[0];
             $menu = unserialize(base64_decode($data["content"]));
         } else {
             $data = Database::read("select * from  " . $group['table'] . " where id='" . $group['id'] . "'", 1);
             $data = $data[0];
             $menu = unserialize(base64_decode($data["content"]));
         }
         if (count($menu) > 0) {
             return $menu;
         } else {
             return "Error";
         }
     }
 }
Exemple #3
0
 public static function where($where)
 {
     $self = self::instance();
     $rows = new ModelArray();
     //
     $sql = "select * from " . $self->DBtable . " where {$where} ";
     $data = Database::read($sql, 1);
     //
     foreach ($data as $key => $value) {
         $row = self::instance();
         //
         foreach ($value as $key2 => $value2) {
             $row->{$key2} = $value2;
         }
         //
         $rows->add($row);
     }
     //
     return $rows;
 }
Exemple #4
0
 /**
  *
  * @return Response
  */
 public static function Actions()
 {
     $action = $_POST['action'];
     switch ($action) {
         case "new_migration":
             $time2 = date("Y/m/d H:i:s", time());
             $time = time();
             $name = $_POST['migname'];
             $object = $_POST['object'];
             $module = $_POST['module'];
             if (isset($name) && isset($object) && isset($module) && !empty($name) && !empty($object) && !empty($module)) {
                 if (is_dir("../app/modules/{$module}/Schemas")) {
                     $myfile = fopen("../app/modules/{$module}/Schemas/" . $time . "_" . $name . ".php", "w");
                     $txt = "<?php\n\n";
                     $txt .= "/* Schema info\n* @date : " . $time2 . "(" . $time . ")\n* @name : " . $name . "\n* @object : " . $object . "\n*/\n\n\n";
                     $txt .= "\t/**\n\t * Run the schemas.\n\t*/\n";
                     $txt .= "\tfunction up()\n\t{\n\t\treturn true;\n\n";
                     $txt .= "\t\t/* Ex.\treturn Schema::create('tbl_test',function(" . '$tab' . ")\n\t\t\t{\n\t\t\t\t" . '$tab->string("column");' . "\n\t\t\t});\n\t\t\t*/";
                     $txt .= "\n\t}\n\n";
                     $txt .= "\t/**\n\t * Reverse the schemas.\n\t*/\n";
                     $txt .= "\tfunction down()\n\t{\n\t\treturn true;\n\n";
                     $txt .= "\t\t// Ex.\t return Schema::drop('tbl_test');\n\n";
                     $txt .= "\t}\n\n";
                     $txt .= "?>\n";
                     fwrite($myfile, $txt);
                     fclose($myfile);
                     if (!Schema::existe(Config::get('database.migration'))) {
                         Schema::create(Config::get('database.migration'), function ($tab) {
                             $tab->inc("pk_schema");
                             $tab->string("name_schema");
                             $tab->timestamp("date_schema");
                             $tab->string("status_schema");
                             $tab->string("type_schema");
                         });
                     }
                     Database::exec("insert into " . Config::get('database.prefixe') . Config::get('database.migration') . "(name_schema,date_schema,status_schema,type_schema) values('" . $name . "','" . $time . "','init','" . $object . "')");
                     Migration::updateRegister($time . "_" . $name, "init", "", $module);
                     $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "le schema à été ajoutée avec success");
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 } else {
                     $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Merci d'importer ou de créer votre module {$module} tout d'abord ");
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 }
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Vous avez oublié de remplire un champ :(");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "exec_migration":
             $dropshema = isset($_POST['dropshema']) ? 1 : 0;
             $module = $_POST['module'];
             if ($dropshema) {
                 $r = glob("../app/modules/{$module}/Schemas/*.php");
                 $pieces = array();
                 $pieces1 = array();
                 $pieces2 = array();
                 $full_names = array();
                 $time = "";
                 $name = "";
                 $f = array();
                 foreach ($r as $key) {
                     $pieces = explode("../app/modules/{$module}/Schemas/", $key);
                     $pieces1 = explode("_", $pieces[1]);
                     $time = $pieces1[0];
                     $p = explode(".", $pieces1[1]);
                     $name = $p[0];
                     $f[] = $pieces1[0];
                     $pieces2[] = $pieces[1];
                     $full_names = $pieces1[0] . "_" . $name;
                 }
                 // echo "<pre>",print_r($f),"</pre>";
                 $mx = max($f);
                 $ind = 0;
                 $i = 0;
                 foreach ($pieces2 as $value) {
                     if (strpos($value, $mx) !== false) {
                         $ind = $i;
                     }
                     $i++;
                 }
                 $link = $r[$ind];
                 try {
                     include_once $link;
                     if (down()) {
                         if (Schema::existe(Config::get('database.migration'))) {
                             Database::exec("update " . Config::get('database.prefixe') . Config::get('database.migration') . " set status_schema='rolledback' where name_schema='" . $name . "' and date_schema='" . $time . "'");
                         }
                         $full_names = $time . "_" . $name;
                         Migration::updateRegister($full_names, "rollback", "", $module);
                         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Schéma annulé");
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     } else {
                         $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Schema n'est pas annulé" . Database::execErr());
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     }
                 } catch (Exception $e) {
                     $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => $e->getMessage());
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 }
             } else {
                 $r = glob("../app/modules/{$module}/Schemas/*.php");
                 $pieces = array();
                 $pieces1 = array();
                 $pieces2 = array();
                 $time = "";
                 $name = "";
                 $f = array();
                 foreach ($r as $key) {
                     $pieces = explode("../app/modules/{$module}/Schemas/", $key);
                     $pieces1 = explode("_", $pieces[1]);
                     $time = $pieces1[0];
                     $p = explode(".", $pieces1[1]);
                     $name = $p[0];
                     $f[] = $pieces1[0];
                     $pieces2[] = $pieces[1];
                     $full_name = $pieces1[0] . "_" . $name;
                 }
                 $mx = max($f);
                 $ind = 0;
                 $i = 0;
                 foreach ($pieces2 as $value) {
                     if (strpos($value, $mx) !== false) {
                         $ind = $i;
                     }
                     $i++;
                 }
                 $link = $r[$ind];
                 try {
                     include_once $link;
                     if (up()) {
                         $full_name = $time . "_" . $name;
                         if (Schema::existe(Config::get('database.migration'))) {
                             Database::exec("update " . Config::get('database.prefixe') . Config::get('database.migration') . " set status_schema='executed' where name_schema='" . $name . "' and date_schema='" . $time . "'");
                         }
                         Migration::updateRegister($full_name, "exec", "", $module);
                         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Schéma executé");
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     } else {
                         $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Schema n'est pas executé" . Database::execErr());
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     }
                 } catch (Exception $e) {
                     $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => $e->getMessage());
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 }
             }
             break;
         case "new_models":
             $class = $_POST['new_models_class_name'];
             $file = $_POST['new_models_file_name'];
             $table = $_POST['new_models_table_name'];
             $module = $_POST['module'];
             if (!file_exists("../app/modules/{$module}/Models/{$file}.php")) {
                 $myfile = fopen("../app/modules/{$module}/Models/{$file}.php", "w");
                 $txt = "<?php\n\n";
                 $txt .= "class {$class} extends Model\n\t{\n\t\t//Name of the table in database\n\t\tprotected static " . '$table' . "='{$table}';\n\t\tprotected static " . '$foreignKeys=array();' . "\n\n\t}";
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Le model à bien été creé :D ");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Le fichier deja existe");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "new_view":
             $dossier = $_POST['dossier'];
             $module = $_POST['module'];
             $file = $_POST['new_view_file_name'];
             if ($dossier === "Back-end") {
                 $pathview = str_replace('{themeName}', Config::get('themes.name'), Config::get('themes.basepath'));
             } else {
                 $pathview = str_replace('{themeName}', Config::get('themes.nameFrontEnd'), Config::get('themes.basepathFrontEnd'));
             }
             $structure = $pathview . "{$module}/";
             if (!is_dir($structure)) {
                 if (mkdir($structure, 0777, true)) {
                     if (strpos($file, ".")) {
                         $ext = explode(".", $file);
                         $extention = $ext[1] ? $ext[1] : "php";
                         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => self::CreatView($file, $structure, $extention));
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     } else {
                         $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => self::CreatView($file, $structure, "php"));
                         header("Content-type: application/json; charset=utf-8");
                         echo json_encode($arr);
                     }
                 } else {
                     $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Probléme de création de répértoire");
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 }
             } else {
                 if (strpos($file, ".")) {
                     $ext = explode(".", $file);
                     $extention = $ext[1] ? $ext[1] : "php";
                     $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => self::CreatView($file, $structure, $extention));
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 } else {
                     $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => self::CreatView($file, $structure, "php"));
                     header("Content-type: application/json; charset=utf-8");
                     echo json_encode($arr);
                 }
             }
             break;
         case "new_controller":
             $class = $_POST['new_controller_class_name'];
             $file = $_POST['new_controller_file_name'];
             $module = $_POST['module'];
             if (!file_exists("../app/modules/{$module}/Controllers/{$file}.php")) {
                 $myfile = fopen("../app/modules/{$module}/Controllers/{$file}.php", "w");
                 $txt = "<?php\n\n";
                 $txt .= "/**\n* class de controller {$class}\n*/\n\nclass {$class} extends Controller\n{\n\t";
                 //view
                 $txt .= "\n\t\n\tpublic static " . '$id = null' . ";\n\tpublic static " . '$object = null' . ";\n\n";
                 //index
                 $txt .= "\n\t/**\n\t * Display a listing of the resource.\n\t *\n\t * \n\t * @return Response\n\t */";
                 $txt .= "\n\tpublic static function index()\n\t{\n\t\t//\n\t}";
                 //show
                 $txt .= "\n\n\n\t/**\n\t * Get the resource by id\n\t *\n\t * @param id(mixed) id of the object \n\t * @return Response\n\t */";
                 $txt .= "\n\tpublic static function show(" . '$id' . ")\n\t{\n\t\t//\n\t}";
                 //add
                 $txt .= "\n\n\n\t/**\n\t * Show the form for creating a new resource.\n\t *\n\t  * @return Response\n\t */";
                 $txt .= "\n\tpublic static function add()\n\t{\n\t\t//\n\t}";
                 //insert
                 $txt .= "\n\n\n\t/**\n\t * Insert newly created resource in storage.\n\t *\n\t  * @return Response\n\t */";
                 $txt .= "\n\tpublic static function insert()\n\t{\n\t\t//\n\t}";
                 //edit
                 $txt .= "\n\n\n\t/**\n\t * Show the form for editing the specified resource.\n\t *\n\t * @param id(mixed) id of the object \n\t * @return Response\n\t */";
                 $txt .= "\n\tpublic static function edit(" . '$id' . ")\n\t{\n\t\t//\n\t}";
                 //update
                 $txt .= "\n\n\n\t/**\n\t * Update the specified resource in storage.\n\t *\n\t * @param id(mixed) id of the object \n\t * @return Response\n\t */";
                 $txt .= "\n\tpublic static function update(" . '$id=null' . ")\n\t{\n\t\t//\n\t}";
                 //delete
                 $txt .= "\n\n\n\t/**\n\t * Delete the specified resource in storage.\n\t *\n\t * @param id(mixed) id of the object \n\t * @return Response\n\t */";
                 $txt .= "\n\tpublic static function delete(" . '$id' . ")\n\t{\n\t\t//\n\t}";
                 $txt .= "\n}";
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 //Création des routes
                 $RouterFile = "../app/modules/{$module}/Resources/config/Routes.php";
                 //index
                 $RouterContent = "\n\n/**\n* {$file} \n*/\n\n";
                 $RouterContent .= "Route::get('{$file}',\tfunction(){\n\t{$file}::index();\n});";
                 file_put_contents($RouterFile, $RouterContent, FILE_APPEND | LOCK_EX);
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "La class controller à été creé avec success :D");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Le fichier deja existe");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "new_seed":
             $nom = $_POST['seedname_name'] . "Seeder";
             if (!file_exists("../app/seeds/{$nom}.php")) {
                 $myfile = fopen("../app/seeds/{$nom}.php", "w");
                 $txt = "<?php\n\n";
                 $txt .= "use Fiesta\\Core\\Database\\Seeder;\n\n";
                 $txt .= "/**\n* class de seeder {$nom}\n*/\n\nclass {$nom} extends Seeder\n{\n";
                 //datatable name
                 $txt .= "\t/*\n\t* Name of DataTable\n\t*/\n\tpublic " . '$table="tbl_user";' . "\n\n";
                 //run
                 $txt .= "\t/*\n\t* Run the Database Seeder\n\t*/\n\tpublic function run()\n\t{\n\t\t" . '$dataTable = array();' . "\n\t\t//\n\t\t" . '$dataTable[] = array(/* Data Fields */);' . "\n\t\t//\n\t\t" . 'Schema::table($this->table)->insert($dataTable);' . "\n\t}\n}";
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 //
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "le seeder est créé");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Le fichier deja existe");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "exec_seed":
             if (Seeder::ini()) {
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Les Seeders ont bien executé");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Erreur d'execution des sedders :(");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "new_lang_dir":
             $name = $_POST['lang_dir_name'];
             if (mkdir("../app/Local/" . $name)) {
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "le dossier a été creé avec success");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Erreur de création du dossier de langue merci de vérifier les droit d'acces :(");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "new_lang_file":
             $dir = $_POST['lang_dir_name_2'];
             $file = $_POST['lang_file_name'];
             $date = date("Y/m/d");
             $auteur = $_SESSION["ArFramework_pnl_fst_profil"]['display_name'];
             if (!file_exists("../app/Local/{$dir}/{$file}.xml")) {
                 $myfile = fopen("../app/Local/{$dir}/{$file}.xml", "w");
                 $txt = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                 $txt .= "<!DOCTYPE language_translation SYSTEM \"../language_translation.dtd\">\n";
                 $txt .= "<language_translation target_language=\"{$dir}\">\n";
                 $txt .= "\t<meta>\n\t\t<creation author=\"{$auteur}\" date=\"{$date}\" comment=\"\"/>\n\t</meta>\n";
                 $txt .= "\t<translations>\n\t\t<translation key=\"default\" arguments=\"1\">hello</translation>\n\t</translations>\n";
                 $txt .= "</language_translation>";
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "le fichier de langue a été creé avec success");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Le fichier deja existe");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
         case "new_link":
             $time = time();
             $name = $_POST['link_name'];
             if (empty($name)) {
                 $name = $time;
             }
             //
             if (!file_exists("../app/links/" . $name . ".php")) {
                 $myfile = fopen("../app/links/" . $name . ".php", "w");
                 $txt = "<?php\n\n";
                 $txt .= "/*\n\tlinks of " . $name . "\n*/\n\n";
                 $txt .= "return array(\n\t'link_name_1' => 'link_value_1',\n\t'link_name_2' => 'link_value_2'\n);";
                 $txt .= "\n\n?>";
                 fwrite($myfile, $txt);
                 fclose($myfile);
                 //
                 $arr = array('statut' => 'success', 'icon' => 'entypo-check alert-success', 'Message' => "Le fichier link a été creé");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             } else {
                 $arr = array('statut' => 'error', 'icon' => 'entypo-cancel-circled alert-danger', 'Message' => "Le fichier deja existe");
                 header("Content-type: application/json; charset=utf-8");
                 echo json_encode($arr);
             }
             break;
     }
 }
Exemple #5
0
 public function getAll()
 {
     return Database::read('select * from ' . $this->DatabaseTableName());
 }
Exemple #6
0
 public static function run($p = null, $root = null, $routes = true, $session = true, $whoops = true)
 {
     ob_start();
     //
     self::$page = $p;
     self::$root = $root;
     //
     require self::$root . '../core/Access/ErrorHandler.php';
     // Config
     require self::$root . '../core/Config/Config.php';
     require self::$root . '../core/Config/Exceptions/ConfigException.php';
     // Set the error log
     ini_set("log_errors", 1);
     ini_set("error_log", self::$root . '../app/storage/logs/Fiesta.log');
     // Set Whoops error handler
     if ($whoops) {
         ErrorHandler::ini(self::$root);
     }
     //session
     require self::$root . '../core/Storage/Session.php';
     if ($session) {
         Session::start(self::$root . '../app/storage/session');
     }
     //Maintenance
     require self::$root . '../core/Maintenance/Maintenance.php';
     //Objects
     require self::$root . '../core/Objects/Vars.php';
     require self::$root . '../core/Objects/String/String.php';
     require self::$root . '../core/Objects/String/Exceptions/StringOutIndexException.php';
     // Access
     require self::$root . '../core/Access/Path.php';
     //Alias
     require self::$root . '../core/Config/Alias.php';
     //
     //require self::$root.'../core/MVC/Templete.php';
     require self::$root . '../core/Objects/Exception.php';
     require self::$root . '../core/Resources/Faker.php';
     require self::$root . '../core/Storage/Cookie.php';
     // Routes
     require self::$root . '../core/Router/Routes.php';
     require self::$root . '../core/Router/Route.php';
     require self::$root . '../core/Router/Exceptions/RouteNotFoundException.php';
     // Caches
     require self::$root . '../core/Caches/Caches.php';
     require self::$root . '../core/Caches/Cache.php';
     require self::$root . '../core/Caches/FileCache.php';
     require self::$root . '../core/Caches/DatabaseCache.php';
     require self::$root . '../core/Caches/Exceptions/DriverNotFoundException.php';
     require self::$root . '../core/Storage/Storage.php';
     require self::$root . '../core/Security/Auth.php';
     require self::$root . '../core/Objects/Table.php';
     // Database
     require self::$root . '../core/Database/Schema.php';
     require self::$root . '../core/Database/Migration.php';
     require self::$root . '../core/Database/Seeder.php';
     require self::$root . '../core/Database/Database.php';
     require self::$root . '../core/Database/Drivers/MySql.php';
     require self::$root . '../core/Database/Exceptions/DatabaseArgumentsException.php';
     require self::$root . '../core/Database/Exceptions/DatabaseConnectionException.php';
     require self::$root . '../core/Access/Url.php';
     require self::$root . '../core/Objects/DateTime.php';
     require self::$root . '../core/Objects/Sys.php';
     require self::$root . '../core/Http/Links.php';
     require self::$root . '../core/Http/Menu.php';
     require self::$root . '../core/Objects/Base.php';
     require self::$root . '../core/Resources/Libs.php';
     require self::$root . '../core/Hypertext/Res.php';
     require self::$root . '../core/Hypertext/Input.php';
     require self::$root . '../core/Security/License.php';
     //Languages
     require self::$root . '../core/Lang/XMLUtilities.php';
     require self::$root . '../core/Lang/Lang.php';
     // MVC - model
     require self::$root . '../core/MVC/Model/Model.php';
     require self::$root . '../core/MVC/Model/ModelArray.php';
     require self::$root . '../core/MVC/Model/Exceptions/ForeingKeyMethodException.php';
     require self::$root . '../core/MVC/Model/Exceptions/ColumnNotEmptyException.php';
     require self::$root . '../core/MVC/Model/Exceptions/ManyPrimaryKeysException.php';
     require self::$root . '../core/MVC/Model/Exceptions/PrimaryKeyNotFoundException.php';
     // MVC - View
     require self::$root . '../core/MVC/View/View.php';
     require self::$root . '../core/MVC/View/Libs/Template.php';
     require self::$root . '../core/MVC/View/Libs/Views.php';
     require self::$root . '../core/MVC/View/Exceptions/ViewNotFoundException.php';
     require self::$root . '../core/Hypertext/ShortCode.php';
     require self::$root . '../core/Hypertext/HTML.php';
     require self::$root . '../core/Security/Encrypt.php';
     require self::$root . '../core/Security/Security.php';
     require self::$root . '../core/MVC/Controller.php';
     require self::$root . '../core/Http/Error.php';
     require self::$root . '../core/Http/Root.php';
     require self::$root . '../core/Mailing/Mail.php';
     require self::$root . '../core/Objects/DataCollection.php';
     require self::$root . '../core/Maintenance/Debug.php';
     // Filesystem
     require self::$root . '../core/Filesystem/Exceptions/FileNotFoundException.php';
     require self::$root . '../core/Filesystem/Exceptions/DirectoryNotFoundException.php';
     require self::$root . '../core/Filesystem/Filesystem.php';
     // Database files
     require self::$root . '../core/Database/DBTable.php';
     //
     Alias::ini(self::$root);
     Sys::ini();
     Url::ini();
     Path::ini();
     Template::ini(self::$root);
     Faker::ini();
     Links::ini($root);
     Menu::ini($root);
     Errors::ini($root);
     License::ini(self::$page);
     //langues
     Lang::setReplaceBlankTranslationBy(Lang::REPLACE_BY_BLANK);
     Lang::setReplaceNonExistingTranslationBy(Lang::REPLACE_BY_KEY_TRANSLATE_ME);
     Lang::initLanguage();
     Database::ini();
     Auth::ini();
     //
     if ($root != null) {
         $getConfig = file_exists(self::$root . "../app/modules/" . self::getCurrentModule() . "/config.php") ? include self::$root . "../app/modules/" . self::getCurrentModule() . "/config.php" : "";
         if (is_array($getConfig)) {
             if (isset($getConfig['etat']) && $getConfig['etat'] == "active") {
                 Lang::addDictionary(self::getCurrentModule(), "index");
                 //functions
                 if (file_exists(self::$root . "../app/modules/" . self::getCurrentModule() . "/function.php")) {
                     include_once self::$root . "../app/modules/" . self::getCurrentModule() . "/function.php";
                 }
                 // include models
                 self::includeFiles(self::$root . "../app/modules/" . self::getCurrentModule() . "/Models/*.php");
                 //include the controllers files
                 self::includeFiles(self::$root . "../app/modules/" . self::getCurrentModule() . "/Controllers/*.php");
                 //include the link files
                 self::includeFiles(self::$root . "../app/paths/*.php");
                 //include the seeders files
                 self::includeFiles(self::$root . "../app/seeds/*.php");
                 //include filters
                 include_once self::$root . "../app/http/Filters.php";
                 //include for routes
                 if ($routes) {
                     include_once self::$root . "../app/http/Routes.php";
                     include_once self::$root . "../app/modules/" . self::getCurrentModule() . "/Resources/config/Routes.php";
                     Routes::run();
                 }
             } else {
                 Errors::r_403();
             }
         } else {
             Errors::r_404();
         }
     } else {
         $getConfig = file_exists("../app/modules/" . self::getCurrentModule() . "/config.php") ? include "../app/modules/" . self::getCurrentModule() . "/config.php" : "";
         if (is_array($getConfig)) {
             if (isset($getConfig['etat']) && $getConfig['etat'] == "active") {
                 Lang::addDictionary(self::getCurrentModule(), "index");
                 //functions
                 if (file_exists("../app/modules/" . self::getCurrentModule() . "/function.php")) {
                     include_once "../app/modules/" . self::getCurrentModule() . "/function.php";
                 }
                 // include models
                 self::includeFiles("../app/modules/" . self::getCurrentModule() . "/Models/*.php");
                 //include the controllers files
                 self::includeFiles("../app/modules/" . self::getCurrentModule() . "/Controllers/*.php");
                 //include the seeders files
                 self::includeFiles("../app/seeds/*.php");
                 //include filters
                 include_once "../app/http/Filters.php";
                 //include for routes
                 if ($routes) {
                     include_once "../app/http/Routes.php";
                     include_once "../app/modules/" . self::getCurrentModule() . "/Resources/config/Routes.php";
                     Routes::run();
                 }
             } else {
                 Errors::r_403();
             }
         } else {
             Errors::r_404();
         }
     }
 }
Exemple #7
0
 public static function remove($nom, $colmuns)
 {
     $name = self::tableName($nom);
     //
     self::$main_sql = "alter table " . $name . " ";
     //
     if (is_array($colmuns)) {
         // foreach ($colmuns as $value) {
         for ($i = 0; $i < count($colmuns); $i++) {
             if ($i == count($colmuns) - 1) {
                 self::$main_sql .= " drop " . $colmuns[$i];
             } else {
                 self::$main_sql .= " drop " . $colmuns[$i] . ",";
             }
         }
     } else {
         self::$main_sql .= " drop " . $colmuns;
     }
     //
     return Database::exec(self::$main_sql);
 }
Exemple #8
0
 public static function check()
 {
     if (Session::existe('auths')) {
         return true;
     } else {
         if (Cookie::existe(Config::get('auth.rememeber_cookie'))) {
             $y = Database::countS('select * from ' . Config::get('auth.table') . ' where rememberToken="' . Cookie::get(Config::get('auth.rememeber_cookie')) . '"');
             if ($y == 1) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }
Exemple #9
0
 public function paginate($RowsPerPage)
 {
     // count data
     $sql = "select count(*) as nbRows from " . $this->name;
     $var = Database::read($sql);
     $this->RowsPerPage = $RowsPerPage;
     $this->nbRows = $var[0]['nbRows'];
     $this->nbPages = ceil($this->nbRows / $RowsPerPage);
     //if isset get
     $this->CurrentPage = 1;
     if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) {
         if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $this->nbPages) {
             $this->CurrentPage = Res::get(Config::get('view.pagination_param'));
         }
     }
     //get Data
     $r = array();
     $sql = "select * from " . $this->name . " Limit " . ($this->CurrentPage - 1) * $this->RowsPerPage . ",{$this->RowsPerPage}";
     $this->data = Database::read($sql);
     //
     return $this;
 }