The func.inc script This script is essentially an include file that contains helper functions, such as the one that uses regular expressions to check if a given email address is correctly formatted. The file contains at least four functions, which are listed below: <?php function isadmin($id){ //run query to check if this user is admin $sql = "SELECT level FROM users WHERE uid='".$id."'"; $res = mysql_query($sql); if($res){ $row= mysql_fetch_assoc($res); if($row['level'] == 'admin'){ return TRUE; }else{ return FALSE; } } } function isAuthed($uname){ if(isset($uname)){ return TRUE; }else{ return FALSE; } } function genpass() { //This function generates a 7 letter password $chars = "1234567890abcdefGHIJKLMNOPQRSTUVWxyz $thepass = ''; for($i=0;$i<7;$i++) { $thepass .= $chars{rand() % 39}; } return $thepass; } function checkEmail($email){ if(eregi('^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+.[a-z]{2,8}$',$email)){ return TRUE; }else{ return FALSE; } } ?>
blog comments powered by Disqus |
|
|
|
|
|
|
|