Fix in slugify
This commit is contained in:
commit
1ef52579a3
92 changed files with 14016 additions and 84 deletions
33
libraries/PDO.php
Normal file
33
libraries/PDO.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace PhangoApp\PDO;
|
||||
|
||||
class MySQL {
|
||||
|
||||
static public $host_db='';
|
||||
|
||||
static public $db='';
|
||||
|
||||
static public $login_db='';
|
||||
|
||||
static public $pass_db='';
|
||||
|
||||
//static public $conn=false;
|
||||
|
||||
static public function get_pdo_connection() {
|
||||
|
||||
if(MySQL::$host_db=='' || MySQL::$db=='') {
|
||||
|
||||
echo 'Cannot connect to the mysqldb';
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
|
||||
$conn=new \PDO('mysql:host='.MySQL::$host_db.';dbname='.MySQL::$db, MySQL::$login_db, MySQL::$pass_db);
|
||||
|
||||
return $conn;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,8 @@ class Config {
|
|||
|
||||
static public $modules_allowed=['welcome'];
|
||||
|
||||
static public $base_url='';
|
||||
|
||||
}
|
||||
|
||||
function get_controller($controller, $args=[]) {
|
||||
|
|
@ -32,6 +34,10 @@ function get_controller($controller, $args=[]) {
|
|||
|
||||
}
|
||||
|
||||
//Route is: /module/switch/
|
||||
//Route is: /module/file/switch/
|
||||
//Route is: /module/file/switch/parameter1/parameter2
|
||||
|
||||
function get_route($path_info) {
|
||||
|
||||
if($path_info!='') {
|
||||
|
|
@ -91,7 +97,7 @@ function get_route($path_info) {
|
|||
}
|
||||
else {
|
||||
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/index.php';
|
||||
$controller='modules/'.\PhangoApp\PhaRouter\Config::$home_module.'/controllers/app.php';
|
||||
|
||||
return \PhangoApp\PhaRouter\get_controller($controller, []);
|
||||
|
||||
|
|
@ -140,3 +146,39 @@ function filter_path($path_info) {
|
|||
return $final_path;
|
||||
|
||||
}
|
||||
|
||||
class Url {
|
||||
|
||||
static public function make_url($module, $script='', $file='', $args=[]) {
|
||||
|
||||
$url='/'.$module;
|
||||
|
||||
if($script!='') {
|
||||
|
||||
$url.='/'.$script;
|
||||
|
||||
}
|
||||
|
||||
if($file!='') {
|
||||
|
||||
$url.='/'.$file;
|
||||
|
||||
}
|
||||
|
||||
if(count($args)>0) {
|
||||
|
||||
$url.='/'.implode('/', $args);
|
||||
|
||||
}
|
||||
|
||||
return Config::$base_url.'/index.php'.$url;
|
||||
|
||||
}
|
||||
|
||||
static public function make_media_url($file) {
|
||||
|
||||
return Config::$base_url.'/'.$file;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,68 +35,6 @@ class Utils {
|
|||
static public function slugify($text, $respect_upper=0, $replace_space='-', $replace_dot=0, $replace_barr=0)
|
||||
{
|
||||
|
||||
/*$from='àáâãäåæçèéêëìíîïðòóôõöøùúûýþÿŕñ';
|
||||
$to= 'aaaaaaaceeeeiiiidoooooouuuybyrn';
|
||||
|
||||
//$text = utf8_decode(urldecode($text));
|
||||
|
||||
$text = strtr($text, utf8_encode($from), $to);
|
||||
echo $text;
|
||||
$text=strtolower(trim($text));
|
||||
|
||||
$text=str_replace(' ', $replace_space, $text);
|
||||
|
||||
$text=preg_replace('~-+~', $replace_space, $text);
|
||||
|
||||
$text=preg_replace('~[^-\w]+~', '', $text);
|
||||
|
||||
return $text;*/
|
||||
/*
|
||||
$from='àáâãäåæçèéêëìíîïðòóôõöøùúûýþÿŕñÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÒÓÔÕÖØÙÚÛÝỲŸÞŔÑ¿?!¡()"|#*%,;+&$ºª<>`çÇ{}@~=^:´[]';
|
||||
$to= 'aaaaaaaceeeeiiiidoooooouuuybyrnAAAAAACEEEEIIIIDOOOOOOUUUYYYBRN---------------------------------';
|
||||
|
||||
if($replace_dot==1)
|
||||
{
|
||||
|
||||
$from.='.';
|
||||
$to.='-';
|
||||
|
||||
}
|
||||
|
||||
if($replace_barr==1)
|
||||
{
|
||||
|
||||
$from.="/";
|
||||
$to.="-";
|
||||
|
||||
}
|
||||
|
||||
$text = utf8_decode(urldecode($text));
|
||||
|
||||
$text=trim(str_replace(" ", $replace_space, $text));
|
||||
|
||||
$text = strtr($text, utf8_decode($from), $to);
|
||||
|
||||
//Used for pass base64 via GET that use upper, for example.
|
||||
|
||||
if($respect_upper==0)
|
||||
{
|
||||
|
||||
$text = strtolower($text);
|
||||
|
||||
}
|
||||
|
||||
$text=trim(preg_replace('~'.$replace_space.'+~', $replace_space, $text), '-');
|
||||
|
||||
if($replace_dot==1)
|
||||
{
|
||||
|
||||
$text=preg_replace('~[^-\w]+~', '', $text);
|
||||
|
||||
}
|
||||
|
||||
return utf8_encode($text); */
|
||||
|
||||
$from=iconv('utf-8', 'us-ascii//TRANSLIT', '¿?{}@~=^:´[]#*·');
|
||||
$to= iconv('utf-8', 'us-ascii//TRANSLIT', '---------------');
|
||||
|
||||
|
|
@ -136,8 +74,6 @@ class Utils {
|
|||
}
|
||||
|
||||
return $text; //iconv('us-ascii//TRANSLIT', 'utf-8', $text);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -425,7 +361,7 @@ class Utils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Function used for generate a simple random password. Used RamdomLib from Ircmaxell
|
||||
* Function used for generate a simple random password. Use random_int php function for get the characters of the password
|
||||
*
|
||||
* @param string $length_pass A variable used for set the character's length the password. More length, password more secure
|
||||
*
|
||||
|
|
@ -439,29 +375,37 @@ class Utils {
|
|||
|
||||
$abc=array( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '*', '+', '!', '-', '_', '@', '#', '$');
|
||||
|
||||
$password_final='';
|
||||
$disorder_abc=[];
|
||||
|
||||
$c=count($abc);
|
||||
//Simple disorder using random_int
|
||||
|
||||
while(count($abc)>0) {
|
||||
|
||||
$c_abc=count($abc);
|
||||
|
||||
$num_element_move=random_int(0, $c_abc-1);
|
||||
|
||||
$disorder_abc[]=$abc[$num_element_move];
|
||||
|
||||
unset($abc[$num_element_move]);
|
||||
|
||||
$abc=array_values($abc);
|
||||
|
||||
}
|
||||
|
||||
//Get randomly elements from the randomly generated array.
|
||||
|
||||
$c=count($disorder_abc);
|
||||
|
||||
$password_final='';
|
||||
|
||||
for($x=0;$x<$length_pass;$x++) {
|
||||
|
||||
$num_element_pass=random_int(0, $c-1);
|
||||
|
||||
$password_final.=$abc[$num_element_pass];
|
||||
$password_final.=$disorder_abc[$num_element_pass];
|
||||
|
||||
}
|
||||
|
||||
/*$password_final=bin2hex(random_bytes(round($length_pass/2)));
|
||||
|
||||
$num_element_pass=random_int(0, 5);
|
||||
|
||||
$abc=['*', '+', '!', '-', '_', '@', '#', '$'];
|
||||
|
||||
for($x=0;$x<$num_element_pass;$x++) {
|
||||
|
||||
$num_change_char=random_int(0, len($abc));
|
||||
|
||||
}*/
|
||||
|
||||
//Add strange characters
|
||||
|
||||
|
|
@ -621,7 +565,7 @@ class Utils {
|
|||
|
||||
//}
|
||||
|
||||
return "\n".\PhangoApp\PhaModels\CoreForms::HiddenForm($name_token, '', $_SESSION['csrf_token'])."\n";
|
||||
return "\n<input type=\"hidden\" name=\"".$name_token."\" value=\"".$_SESSION['csrf_token']."\"/>\n";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue