mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-02-26 14:53:45 +01:00
Initial commit
This commit is contained in:
39
Source/src/functions.php
Normal file
39
Source/src/functions.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: joselucross
|
||||
* Date: 6/07/17
|
||||
* Time: 11:56
|
||||
*/
|
||||
function RandomString($length)
|
||||
{
|
||||
//https://phpes.wordpress.com/2007/06/12/generador-de-una-cadena-aleatoria/
|
||||
$source = 'abcdefghijklmnopqrstuvwxyz';
|
||||
$source .= '1234567890';
|
||||
if($length>0){
|
||||
$rstr = "";
|
||||
$source = str_split($source,1);
|
||||
for($i=1; $i<=$length; $i++){
|
||||
mt_srand((double)microtime() * 1000000);
|
||||
$num = mt_rand(1,count($source));
|
||||
$rstr .= $source[$num-1];
|
||||
}
|
||||
|
||||
}
|
||||
return $rstr;
|
||||
}
|
||||
|
||||
function ksonParse($path){
|
||||
$file = fopen($path,"r");
|
||||
$array = [];
|
||||
if($file){
|
||||
while(!feof($file)){
|
||||
$line = fgets($file);
|
||||
$part = explode(":",$line);
|
||||
$array[$part[0]]=$part[1];
|
||||
}
|
||||
return $array;
|
||||
}else{
|
||||
die('<h3>Error, kson file not exist</h3>');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user