Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

handle_rsc_upload()

Description

Handle the POST for an upload of a plugin configuration (.rsc) file

Typically invoked near the beginning of a plugin's setup.php file
something like this:

if (getval('upload','')!='')
{
handle_rsc_upload($plugin_name);
)
elseif (getval('submit','')!='')
{
...
}

Parameters

ColumnTypeDefaultDescription
$plugin_name string - the name of the plugin

Return

string a translated string giving the status of the upload

Location

include/plugin_functions.php lines 402 to 440

Definition

 
function handle_rsc_upload($plugin_name)
    {
    global
$lang;
    
$upload_status=$lang['plugins-goodrsc'];
    if (!
function_exists('json_decode'))
        {
        
$upload_status str_replace('%version','5.2',$lang['error-oldphp']);
        }
    elseif ((
$_FILES['rsc_file']['error'] != 0) || (pathinfo($_FILES['rsc_file']['name'], PATHINFO_EXTENSION)!='rsc') ||
            !
is_uploaded_file($_FILES['rsc_file']['tmp_name']) || ($_FILES['rsc_file']['size'] > 32768))
        {
        
$upload_status $lang['plugins-didnotwork'];
        }
    else
        {
        
$json file_get_contents($_FILES['rsc_file']['tmp_name']);
        if (
substr($json03) == (chr(0xEF) . chr(0xBB) . chr(0xBF))) // Discard UTF-8 BOM if present
            
{
            
$json substr($json3);
            }
        
$tok "\n";
        
$rsc_plugin_name json_decode(strtok($json$tok),true);
        if (
$rsc_plugin_name['ResourceSpacePlugin'] == $plugin_name)
            {
            
$config json_decode(strtok($tok), true);
            foreach(
$config as $key=>$value)
                
$GLOBALS[$key] = $value;
            }
        elseif (
$rsc_plugin_name == '')
            {
            
$upload_status $lang['plugins-badrsc'];
            }
        else
            {
            
$upload_status str_replace('%plugin',$rsc_plugin_name['ResourceSpacePlugin'],$lang['plugins-wrongplugin']);
            }
        }
    return 
$upload_status;
    }

This article was last updated 11th July 2020 22:35 Europe/London time based on the source file dated 2nd July 2020 09:08 Europe/London time.