2 function format_date($date){
5 if ($date == -1){ return " "; }
8 list($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($date);
9 return ( 1900 +
$year ) . "-" . ++
$mon . "-" . ++
$mday;
10 //return date('Y-m-d',$date);
13 //-------Select box------------------------
16 "Cambodgienne"=>"Cambodgienne",
17 "Cambodgien"=>"Cambodgien",
19 "Canadienne"=>"Canadienne",
20 "Canadien"=>"Canadien",
21 "Chinoise"=>"Chinoise",
23 "Française"=>"Française",
24 "Français"=>"Français",
25 "Laotienne"=>"Laotienne",
28 "Vietnamienne"=>"Vietnamienne",
29 "Vietnamien"=>"Vietnamien",
30 "Malagasy"=>"Malagasy",
36 "Etudiant"=>"Etudiant",
37 "Enseignant"=>"Enseignant",
42 "Agronomie"=>"Agronomie",
44 "Archéologie"=>"Archéologie",
45 "Architecture"=>"Architecture",
46 "Biologie"=>"Biologie",
48 "Commerce"=>"Commerce",
50 "Français"=>"Français",
51 "Génie Civil"=>"Génie Civil",
52 "Génie Electrique"=>"Génie Electrique",
53 "Génie Industriel"=>"Génie Industriel",
54 "Géographie"=>"Géographie",
55 "Géologie"=>"Géologie",
57 "Histoire"=>"Histoire",
58 "Hydraulique"=>"Hydraulique",
59 "Informatique"=>"Informatique",
60 "Ingénieur"=>"Ingénieur",
61 "Littérature"=>"Littérature",
62 "Linguistique"=>"Linguistique",
63 "Mathématique"=>"Mathématique",
64 "Médecine"=>"Médecine",
65 "Odontostomatologie"=>"Odontostomatologie",
66 "Pharmacie"=>"Pharmacie",
67 "Philosophie"=>"Philosophie",
68 "Technicien"=>"Technicien",
69 "Touriste"=>"Touriste");
71 $Etablissement = array(
74 "Ecole Royale d'Administration"=>"Ecole Royale d'Administration",
75 "Faculty of Business"=>"Faculty of Business",
78 "Univ. Royale de Phnom Penh"=>"Univ. Royale de Phnom Penh",
79 "Univ. Royale des Beaux-Arts"=>"Univ. Royale des Beaux-Arts",
80 "Univ. Royale d'Agronomie"=>"Univ. Royale d'Agronomie",
81 "Univ. des Sciences de la Santé"=>"Univ. des Sciences de la Santé",
82 "Univ. de Droit et Siences-Eco"=>"Univ. de Droit et Siences-Eco");
89 //================Array to select box================================================
90 function ArrayToSelectBox($arr,$sel = '',$usekey=1,$nullvalue='') {
91 while (list( $key, $val ) = each($arr)) {
92 if($sel && $usekey && ($key == $sel ||
is_array($sel) && in_array($key,$sel))) {
93 $select_v=" selected='selected'";
94 } else if ($sel && !$usekey && ($val == $sel ||
is_array($sel) && in_array($val,$sel))) {
95 $select_v=" selected='selected'";
100 if($nullvalue != '') {
101 if ($key == $nullvalue) {
107 echo "<option value=\"$key\"$select_v>$val</option>\n";
109 if(($nullvalue != '') && ($key == '')) {
110 echo "<option value=\"$key\"$select_v>$val</option>\n";
112 echo "<option$select_v>$val</option>\n";
118 //---------------------Encrypt Password---------------------------------------------------
120 function EncryptPsWord($password) {
121 mt_srand((double)microtime()*1000000);
122 $salt = mhash_keygen_s2k(MHASH_SHA1
, $password, substr(pack('h*', md5(mt_rand())), 0, 8), 4);
123 $hash = "{BBCSR}".base64_encode(mhash(MHASH_SHA1
, $password.$salt).$salt);
126 //---------------------Decrypt Password---------------------------------------------------
127 function DecryptPsWord($password, $hash) {
128 $hash = base64_decode(substr($hash, 6));
129 $original_hash = substr($hash, 0, 20);
130 $salt = substr($hash, 20);
131 $new_hash = mhash(MHASH_SHA1
, $password . $salt);
132 if (strcmp($original_hash, $new_hash) == 0){
133 // ... do something because your password is valid ...
134 /*echo"Bravo.......!!<br>";
135 echo $original_hash."<br>";
139 //echo 'Unauthorized: Authorization has been refused for the credentials you provided. Please login with a valid username and password.';
141 //... be sure to clear your session data ...
144 //----------------------One more to work with---------------------------------------------
145 //--Veuillez m'aider pour améliorer cette fonction--et envoyer à tclyit@gmail.com
146 //--------Vos critiques sont bienvenues!!----------------------------------------
147 //----------Encrypt----------------------------
149 function encrptPwd($string, $key) {
151 for($i=0; $i<strlen($string); $i++
){
152 $char = substr($string, $i, 1);
153 $keychar = substr($key, ($i %
strlen($key))-1, 1);
154 $char = chr(ord($char)+
ord($keychar));
157 return base64_encode($result);
160 //----------Decrypt----------------------------
161 function decrptPwd($string, $key) {
163 $string = base64_decode($string);
165 for($i=0; $i<strlen($string); $i++
){
166 $char = substr($string, $i, 1);
167 $keychar = substr($key, ($i %
strlen($key))-1, 1);
168 $char = chr(ord($char)-ord($keychar));
173 //--------------Check Mail----------------------
175 function check_email($email){
176 // First, we check that there's one @ symbol, and that the lengths are right
177 if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)){
180 // Split it into sections
181 $email_array = explode("@", $email);
182 $local_array = explode(".", $email_array[0]);
183 for ($i = 0; $i < sizeof($local_array); $i++
){
184 if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])){
188 // Check if domain is IP. If not, it should be valid domain name
189 if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])){
190 $domain_array = explode(".", $email_array[1]);
191 if (sizeof($domain_array) < 2) {
192 return false
; // Not enough parts to domain
194 for ($i = 0; $i < sizeof($domain_array); $i++
){
195 if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])){
203 //----------------------------Change Date Value---------------------------------
204 //===========From DD/MM/YYYY to YYYY/MM/DD==================================
205 function ChangeDateValueInsert($Date){
207 $DateChange=split('[-]',$Date);
208 $Str="$DateChange[2]/$DateChange[1]/$DateChange[0]";
212 //===========From YYYY/MM/DD to DD/MM/YYYY==================================
213 function ChangeDateValueSelect($DateSe){
215 $DateChangeSe=split('[-]',$DateSe);
216 $StrSe="$DateChangeSe[2]/$DateChangeSe[1]/$DateChangeSe[0]";
220 //===========From YYYY/MM/DD to DD/MM/YYYY==================================