Location: PHPKode > projects > My Scrapbook > myscrapbook_3_1/functions.php
<? 
//-----------------------------------------------------------------
//MyScrapBook online book program by Eric Gerdes (Crafty Syntax . Com )
//-----------------------------------------------------------------
// Feel free to change this code to better fit your website. I am
// open for any suggestions on how to improve the program and 
// you can submit suggestions and/or bugs to:
// http://craftysyntax.com/myscrapbook/updates/
// if you like using this program and feel it is a good program 
// feel free to send a donation by going to:
// http://craftysyntax.com/myscrapbook/abouts.php
//-----------------------------------------------------------------
function islogedin(){
   global $mydatabase,$myuser,$mypass,$password_admin;
   
   if(($myuser == "admin") && ($password_admin == $mypass)){
     return true;
   }
   if($myuser != ""){
   	$query = "select * from scrapbook_users where recno='$myuser'";
   	$data = $mydatabase->select($query);
       // print "$query";
        $data = $data[0];
        if( ($data[mypassword] != $mypass) || ($data[loggedin] != "Y")){
          return false;	
        } else {
          return true;	
        }        
   } else {   
     return false;
   }
}


// tells if the cookied user has access 
// type = 
// R - read
// A - can click the add button.. 
// m - can add without approval
// F - has all access.
function has_access($type,$section){
   global $myuser,$mypass,$password_admin,$mydatabase;
   
   // if SUPER user
   if(($myuser == "admin") && ($password_admin == $mypass)){
     return true;
   }

   // check global permissions first.
   $query = "SELECT * FROM scrapbook_contents WHERE recno='$section' ";
   $data_e = $mydatabase->select($query);
   $data_e = $data_e[0];

   if( ($type == "R") && ($data_e[permissions] != "none")){
     return true;
   }
      
   if( ($type == "A") && ($data_e[permissions] != "none") && ($data_e[permissions] != "read")){
     return true;
   }
   
   if( ($type == "m") && ($data_e[permissions] != "none") && ($data_e[permissions] != "read") && ($data_e[permissions] != "approval")){
     return true;
   }
   

   $query = "SELECT * FROM scrapbook_access WHERE userid='$myuser' AND contentsid='$section' ";
   $data_e = $mydatabase->select($query);
   
   for($k=0;$k<count($data_e); $k++){
    $data_f = $data_e[$k];  

   if( ($type == "R") && ($data_f[permissions] != "none")){
     return true;
   }    
      
    if( ($type == "A") && ($data_f[myaccess] != "") && ($data_f[myaccess] != "R")){
      return true;
    }    
    if( ($type == "m") && ($data_f[myaccess] != "") && ($data_f[myaccess] != "R") && ($data_f[myaccess] != "A")){
      return true;
    }  
    if( ($type == "F") && ($data_f[myaccess] != "") && ($data_f[myaccess] != "R") && ($data_f[myaccess] != "A") && ($data_f[myaccess] != "m")){
      return true;
    }     
   }

   return false;
}

function uniqueimagename(){
   global $ext;
   $string = md5(uniqid(microtime(),1));
   $string = substr($string,0,12);
   $init1  =substr($string,0,1);
   $fullname = $string . $ext;
   return $string;
}

?>
Return current item: My Scrapbook