Collections functions
General functions
Render functions
Theme permission functions
Resource functions

generate_resource_access_key()

Parameters

ColumnTypeDefaultDescription
$resource
$userref
$access
$expires
$email
$group ""
$sharepwd ""

Location

include/resource_functions.php lines 5852 to 5877

Definition

 
function generate_resource_access_key($resource,$userref,$access,$expires,$email,$group="",$sharepwd="")
        {
        if(
checkperm("noex"))
            {
            
// Shouldn't ever happen, but catch in case not already checked
            
return false;
            }

        global 
$userref,$usergroup$scramble_key;
        if (
$group=="" || !checkperm("x")) {$group=$usergroup;} # Default to sharing with the permission of the current usergroup if not specified OR no access to alternative group selection.
        
$k=substr(md5(time()),0,10);
        
ps_query("insert into external_access_keys(resource,access_key,user,access,expires,email,date,usergroup,password_hash) values (?, ?, ?, ?, ?, ?,now(), ?, ?);",
            [
            
'i'$resource,
            
's'$k,
            
'i'$userref,
            
'i'$access,
            
's', (($expires=="")? null $expires),
            
's'$email,
            
'i'$group,
            
's', (($sharepwd != "" && $sharepwd != "(unchanged)") ? "'" hash('sha256'$k $sharepwd $scramble_key) : null)
            ]
        );
        
hook("generate_resource_access_key","",array($resource,$k,$userref,$email,$access,$expires,$group));
        return 
$k;
        }

This article was last updated 5th October 2022 03:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.