public function register($ar = array())
 {
     $tmp['_files'] = $tmp['_cookie'] = array();
     foreach ($ar as $v) {
         /* Cookies first */
         if (isset($_COOKIE[$v]) && $_COOKIE[$v] != '') {
             /* Get values from _COOKIE */
             if (is_string($_COOKIE[$v])) {
                 $tmp[$v] = $tmp['_cookie'][$v] = urldecode($_COOKIE[$v]);
             } else {
                 foreach ($_COOKIE[$v] as $ck => $cv) {
                     if (is_string($cv)) {
                         $tmp[$v][$ck] = $tmp['_cookie'][$v][$ck] = urldecode($cv);
                     }
                 }
             }
         }
         /* _POST and _GET overwrites cookies */
         if (isset($_POST[$v]) && $_POST[$v] != '') {
             /* Get values from _POST */
             if (is_string($_POST[$v]) || !isset($tmp[$v])) {
                 $tmp[$v] = $_POST[$v];
             } else {
                 $tmp[$v] = array_merge_clobber($tmp[$v], $_POST[$v]);
             }
             $tmp['_method'] = 'post';
         } elseif (isset($_GET[$v]) && $_GET[$v] != '') {
             /* Get values from _GET */
             if (is_string($_GET[$v]) || !isset($tmp[$v])) {
                 $tmp[$v] = $_GET[$v];
             } else {
                 $tmp[$v] = array_merge_clobber($tmp[$v], $_GET[$v]);
             }
         } else {
             /* Default value is '' */
             if (!isset($tmp[$v])) {
                 $tmp[$v] = '';
             }
         }
         /* Filter incoming variables */
         if (isset($tmp['_cookie'][$v])) {
             #$tmp['_cookie'][$v] = $this->fix_newline($tmp['_cookie'][$v]);
             #$tmp['_cookie'][$v] = $this->fix_slash($tmp['_cookie'][$v]);
         } else {
             $tmp[$v] = $this->fix_newline($tmp[$v]);
             $tmp[$v] = $this->fix_slash($tmp[$v]);
         }
         /* Get values from _FILES */
         if (isset($_FILES[$v]) && $_FILES[$v] != '') {
             /* Get values from _FILES */
             $tmp['_files'][$v] = $_FILES[$v];
             $tmp['_files'][$v]['name'] = $this->fix_slash($tmp['_files'][$v]['name']);
         }
     }
     if ($this->is_unset) {
         $this->_unset();
     }
     return $tmp;
 }
 public function getVal($k = '')
 {
     if ($k == '') {
         return array_merge_clobber($this->ar_variables, $this->ar_variables_global);
     }
     $k = $this->_parse_var($k);
     return isset($this->ar_variables[$k]) ? $this->ar_variables[$k] : (isset($this->ar_variables_global[$k]) ? $this->ar_variables_global[$k] : false);
 }
Example #3
0
function getZIPHeaderFilepointer(&$fd, &$ThisFileInfo)
{
    $ThisFileInfo['fileformat'] = 'zip';
    $ThisFileInfo['zip']['files'] = array();
    $ThisFileInfo['zip']['compressed_size'] = 0;
    $ThisFileInfo['zip']['uncompressed_size'] = 0;
    $ThisFileInfo['zip']['entries_count'] = 0;
    $EOCDsearchData = '';
    $EOCDsearchCounter = 0;
    while ($EOCDsearchCounter++ < 512) {
        fseek($fd, -128 * $EOCDsearchCounter, SEEK_END);
        $EOCDsearchData = fread($fd, 128) . $EOCDsearchData;
        if (strstr($EOCDsearchData, 'PK' . chr(5) . chr(6))) {
            $EOCDposition = strpos($EOCDsearchData, 'PK' . chr(5) . chr(6));
            fseek($fd, -128 * $EOCDsearchCounter + $EOCDposition, SEEK_END);
            $ThisFileInfo['zip']['end_central_directory'] = ZIPparseEndOfCentralDirectory($fd);
            fseek($fd, $ThisFileInfo['zip']['end_central_directory']['directory_offset'], SEEK_SET);
            $ThisFileInfo['zip']['entries_count'] = 0;
            while ($centraldirectoryentry = ZIPparseCentralDirectory($fd)) {
                $ThisFileInfo['zip']['central_directory'][] = $centraldirectoryentry;
                $ThisFileInfo['zip']['entries_count']++;
                $ThisFileInfo['zip']['compressed_size'] += $centraldirectoryentry['compressed_size'];
                $ThisFileInfo['zip']['uncompressed_size'] += $centraldirectoryentry['uncompressed_size'];
                if ($centraldirectoryentry['uncompressed_size'] > 0) {
                    $ThisFileInfo['zip']['files'] = array_merge_clobber($ThisFileInfo['zip']['files'], CreateDeepArray($centraldirectoryentry['filename'], '/', $centraldirectoryentry['uncompressed_size']));
                }
            }
            if ($ThisFileInfo['zip']['entries_count'] == 0) {
                $ThisFileInfo['error'] .= "\n" . 'No Central Directory entries found (truncated file?)';
                return false;
            }
            if (isset($ThisFileInfo['zip']['end_central_directory']['comment'])) {
                $ThisFileInfo['zip']['comments']['comment'] = $ThisFileInfo['zip']['end_central_directory']['comment'];
                // ZIP tags have highest priority
                if (!empty($ThisFileInfo['zip']['comments'])) {
                    CopyFormatCommentsToRootComments($ThisFileInfo['zip']['comments'], $ThisFileInfo, true, true, true);
                }
                // add tag to array of tags
                $ThisFileInfo['tags'][] = 'zip';
            }
            if (isset($ThisFileInfo['zip']['central_directory'][0]['compression_method'])) {
                $ThisFileInfo['zip']['compression_method'] = $ThisFileInfo['zip']['central_directory'][0]['compression_method'];
            }
            if (isset($ThisFileInfo['zip']['central_directory'][0]['flags']['compression_speed'])) {
                $ThisFileInfo['zip']['compression_speed'] = $ThisFileInfo['zip']['central_directory'][0]['flags']['compression_speed'];
            }
            if (isset($ThisFileInfo['zip']['compression_method']) && $ThisFileInfo['zip']['compression_method'] == 'store' && !isset($ThisFileInfo['zip']['compression_speed'])) {
                $ThisFileInfo['zip']['compression_speed'] = 'store';
            }
            return true;
        }
    }
    if (getZIPentriesFilepointer($fd, $ThisFileInfo)) {
        // central directory couldn't be found and/or parsed
        // scan through actual file data entries, recover as much as possible from probable trucated file
        if ($ThisFileInfo['zip']['compressed_size'] > $ThisFileInfo['filesize'] - 46 - 22) {
            $ThisFileInfo['error'] .= "\n" . 'Warning: Truncated file! - Total compressed file sizes (' . $ThisFileInfo['zip']['compressed_size'] . ' bytes) is greater than filesize minus Central Directory and End Of Central Directory structures (' . ($ThisFileInfo['filesize'] - 46 - 22) . ' bytes)';
        }
        $ThisFileInfo['error'] .= "\n" . 'Cannot find End Of Central Directory - returned list of files in [zip][entries] array may not be complete';
        return true;
    } else {
        unset($ThisFileInfo['zip']);
        $ThisFileInfo['fileformat'] = '';
        $ThisFileInfo['error'] .= "\n" . 'Cannot find End Of Central Directory (truncated file?)';
        return false;
    }
}
 function array_merge_clobber($array1, $array2)
 {
     // written by kc@hireability.com
     // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
     if (!is_array($array1) || !is_array($array2)) {
         return false;
     }
     $newarray = $array1;
     foreach ($array2 as $key => $val) {
         if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
             $newarray[$key] = array_merge_clobber($newarray[$key], $val);
         } else {
             $newarray[$key] = $val;
         }
     }
     return $newarray;
 }
Example #5
0
 function array_merge_clobber($a1, $a2)
 {
     if (!is_array($a1) || !is_array($a2)) {
         return false;
     }
     $arNew = $a1;
     while (list($k, $v) = each($a2)) {
         if (is_array($v) && isset($arNew[$k]) && is_array($arNew[$k])) {
             $arNew[$k] = array_merge_clobber($arNew[$k], $v);
         } else {
             $arNew[$k] = $v;
         }
     }
     return $arNew;
 }
Example #6
0
 /**
  * Loads phrases by tag.
  *
  * @access	public
  * @uses array_merge_clobber() 
  */
 public function import_tag($ar = array(), $lang_uri)
 {
     settype($ar, 'array');
     $this->load_lang_settings($lang_uri);
     /* Correct the current Language URI */
     $lang_uri = $this->ar_ls['lang_uri'];
     /* Prepare filename to file */
     $path = $this->path_locale . '/' . $lang_uri . '-%s.php';
     $a = array();
     for (; list($k, $v) = each($ar);) {
         if (file_exists(sprintf($path, $v))) {
             include_once sprintf($path, $v);
         } else {
             #print '<br />Error loading: '.sprintf( $path, $v );
         }
         $this->a = array_merge_clobber($this->a, $a);
     }
     return true;
 }
 function on_success($ar)
 {
     $ar = $this->check_onoff($ar);
     /* Check for Usergroup ID */
     if (isset($ar['id_group'])) {
         #if ($ar['id_group'] == 1 || $ar['id_group'] == 4)
         if ($ar['id_group'] == 1) {
             $ar['id_group'] = 5;
         }
     }
     /* */
     switch ($this->o->gv['action']) {
         case 'edit':
             $id_user = isset($this->o->gv['id_user']) && $this->o->oSess->is('users') ? $this->o->gv['id_user'] : $this->o->oSess->id_user;
             $q__users = array();
             /* Redirect */
             $href_redirect = $this->o->oHtmlAdm->url_normalize($this->o->V->file_index . '?#area=t.user,a.edit,s.profile');
             /* */
             /* Privacy, available for profile owners only */
             if ($this->o->gv['area']['s'] == 'privacy' && $this->o->V->is_profile_owner) {
                 $q__users['is_visible'] = $ar['is_visible'];
                 /* Redirect to member home */
                 $href_redirect = $this->o->oHtmlAdm->url_normalize($this->o->V->file_index . '?r=' . $_SERVER['REQUEST_TIME']);
             }
             /* Profile */
             if ($this->o->gv['area']['s'] == 'profile' && $this->o->V->is_profile_owner || !$this->o->V->is_profile_owner) {
                 if ($this->o->oSess->is('profile')) {
                     /* When at least one of these fields exists */
                     if (isset($ar['user_sname'])) {
                         $q__users['user_nickname'] = strip_tags($ar['user_nickname']);
                         $q__users['user_sname'] = strip_tags($ar['user_sname']);
                     }
                     /* */
                 }
                 /* Redirect to member home */
                 $href_redirect = $this->o->oHtmlAdm->url_normalize($this->o->V->file_index . '?#area=a.edit,t.user,s.profile,is_saved.1&r=' . $_SERVER['REQUEST_TIME']);
             }
             /* */
             if ($this->o->gv['area']['s'] == 'permissions' && $this->o->V->is_profile_owner || !$this->o->V->is_profile_owner) {
                 /* Redirect to member home */
                 $href_redirect = $this->o->oHtmlAdm->url_normalize($this->o->V->file_index . '?r=' . $_SERVER['REQUEST_TIME']);
             }
             /* Join settings */
             if (isset($ar['user_settings'])) {
                 /* Change interface language */
                 if (isset($ar['user_settings']['il'])) {
                     /* Add cookie */
                     setcookie('arg[il]', $ar['user_settings']['il'], $this->o->V->time_req + $this->o->V->time_sec_y, '/');
                 }
                 $ar_user = $this->o->oSess->user_load_values($id_user);
                 /* Apply other settings */
                 $ar_user['user_settings'] = array_merge_clobber($ar_user['user_settings'], $ar['user_settings']);
                 $q__users['user_settings'] = serialize($ar_user['user_settings']);
             }
             /* Update `users` table */
             if (!empty($q__users)) {
                 $this->o->oDb->update($this->o->V->db_table_users, $q__users, array('id_user' => $id_user));
             }
             break;
     }
     /* Switch content modes */
     switch ($this->o->gv['sef_output']) {
         case 'ajax':
             print 1;
             break;
         default:
             /* */
             $this->o->redirect($this->o->V->server_proto . $this->o->V->server_host . $href_redirect, 0);
             #$this->o->oOutput->append_html( $this->o->soft_redirect(
             #	$this->o->oTkit->_(1031), $href_redirect, CC_COLOR_TRUE
             #));
             break;
     }
 }
Example #8
0
function ParseDirectoryRecord(&$fd, $directorydata, &$ThisFileInfo)
{
    if (isset($ThisFileInfo['iso']['supplementary_volume_descriptor'])) {
        $TextEncoding = 255;
        // Big-Endian Unicode
    } else {
        $TextEncoding = 0;
        // ASCII
    }
    fseek($fd, $directorydata['location_bytes'], SEEK_SET);
    $DirectoryRecordData = fread($fd, 1);
    while (ord($DirectoryRecordData[0]) > 33) {
        $DirectoryRecordData .= fread($fd, ord($DirectoryRecordData[0]) - 1);
        $ThisDirectoryRecord['raw']['length'] = LittleEndian2Int(substr($DirectoryRecordData, 0, 1));
        $ThisDirectoryRecord['raw']['extended_attribute_length'] = LittleEndian2Int(substr($DirectoryRecordData, 1, 1));
        $ThisDirectoryRecord['raw']['offset_logical'] = LittleEndian2Int(substr($DirectoryRecordData, 2, 4));
        $ThisDirectoryRecord['raw']['filesize'] = LittleEndian2Int(substr($DirectoryRecordData, 10, 4));
        $ThisDirectoryRecord['raw']['recording_date_time'] = substr($DirectoryRecordData, 18, 7);
        $ThisDirectoryRecord['raw']['file_flags'] = LittleEndian2Int(substr($DirectoryRecordData, 25, 1));
        $ThisDirectoryRecord['raw']['file_unit_size'] = LittleEndian2Int(substr($DirectoryRecordData, 26, 1));
        $ThisDirectoryRecord['raw']['interleave_gap_size'] = LittleEndian2Int(substr($DirectoryRecordData, 27, 1));
        $ThisDirectoryRecord['raw']['volume_sequence_number'] = LittleEndian2Int(substr($DirectoryRecordData, 28, 2));
        $ThisDirectoryRecord['raw']['file_identifier_length'] = LittleEndian2Int(substr($DirectoryRecordData, 32, 1));
        $ThisDirectoryRecord['raw']['file_identifier'] = substr($DirectoryRecordData, 33, $ThisDirectoryRecord['raw']['file_identifier_length']);
        $ThisDirectoryRecord['file_identifier_ascii'] = RoughTranslateUnicodeToASCII($ThisDirectoryRecord['raw']['file_identifier'], $TextEncoding);
        $ThisDirectoryRecord['filesize'] = $ThisDirectoryRecord['raw']['filesize'];
        $ThisDirectoryRecord['offset_bytes'] = $ThisDirectoryRecord['raw']['offset_logical'] * 2048;
        $ThisDirectoryRecord['file_flags']['hidden'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x1);
        $ThisDirectoryRecord['file_flags']['directory'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x2);
        $ThisDirectoryRecord['file_flags']['associated'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x4);
        $ThisDirectoryRecord['file_flags']['extended'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x8);
        $ThisDirectoryRecord['file_flags']['permissions'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x10);
        $ThisDirectoryRecord['file_flags']['multiple'] = (bool) ($ThisDirectoryRecord['raw']['file_flags'] & 0x80);
        $ThisDirectoryRecord['recording_timestamp'] = ISOtime2UNIXtime($ThisDirectoryRecord['raw']['recording_date_time']);
        if ($ThisDirectoryRecord['file_flags']['directory']) {
            $ThisDirectoryRecord['filename'] = $directorydata['full_path'];
        } else {
            $ThisDirectoryRecord['filename'] = $directorydata['full_path'] . ISOstripFilenameVersion($ThisDirectoryRecord['file_identifier_ascii']);
            $ThisFileInfo['iso']['files'] = array_merge_clobber($ThisFileInfo['iso']['files'], CreateDeepArray($ThisDirectoryRecord['filename'], '/', $ThisDirectoryRecord['filesize']));
        }
        $DirectoryRecord[] = $ThisDirectoryRecord;
        $DirectoryRecordData = fread($fd, 1);
    }
    return $DirectoryRecord;
}
Example #9
0
 public function global_variables($ar = array())
 {
     /* Functions class */
     $this->oFunc =& $this->_init_functions();
     /* HTML-tags (Requires site settings) */
     $this->oHtml =& $this->_init_html_tags();
     $this->oHtmlAdm =& $this->_init_html_tags_admin();
     /* Set Headers class */
     $this->oHdr =& $this->_init_headers();
     /* */
     include_once $this->V->path_includes . '/class.register_globals.php';
     $oGlobals = new site_register_globals();
     $this->gv = $oGlobals->register($ar);
     /* $this->gv['arg']['var'] => $this->gv['var'] */
     if (is_array($this->gv['arg'])) {
         foreach ($this->gv['arg'] as $k => $v) {
             $this->gv[$k] = $this->oHtml->urldecode($v);
             unset($this->gv['arg'][$k]);
         }
     }
     /* Default values */
     $oGlobals->do_default($this->gv['action']);
     $oGlobals->do_default($this->gv['target'], 'notarget');
     $oGlobals->do_default($this->gv['visualtheme'], $this->V->visualtheme);
     $oGlobals->do_default($this->gv['il']);
     $oGlobals->do_default($this->gv['id']);
     $oGlobals->do_default($this->gv['id_item']);
     $oGlobals->do_default($this->gv['area']);
     $oGlobals->do_default($this->gv['uri']);
     $oGlobals->do_default($this->gv['page'], 1);
     $oGlobals->do_default($this->gv['sef_output'], $this->V->sef_output);
     if (strpos($this->V->REQUEST_URI, 'cmsrouter') !== false) {
         $this->V->is_sef = 0;
     }
     /* Decode URL parameters and merge */
     if ($this->V->is_sef) {
         /* Redirect from old URLs */
         if (!in_array($this->gv['sef_output'], array('ajax', 'css', 'js')) && strpos($this->V->REQUEST_URI, $this->V->file_index . '?') !== false) {
             if (isset($this->gv['target']) || isset($this->gv['s'])) {
                 /* */
             } else {
                 #$this->redirect( $this->V->server_url.'/'.$this->V->file_index, 1 );
             }
         }
         $this->gv = array_merge_clobber($this->gv, $this->oHtml->url_undo_sef($this->V->REQUEST_URI));
     }
     /* Parsing arg[area] */
     $this->gv['_area'] = $this->gv['area'];
     $this->gv['area'] = $oGlobals->subparam($this->gv['_area']);
     #	prn_r( $this->gv );
     /* 22 Jan 2010: assign variables from Area */
     $this->gv['action'] = isset($this->gv['area']['a']) ? $this->gv['area']['a'] : $this->gv['action'];
     $this->gv['target'] = isset($this->gv['area']['t']) ? $this->gv['area']['t'] : $this->gv['target'];
     $this->gv['page'] = isset($this->gv['area']['page']) ? $this->gv['area']['page'] : $this->gv['page'];
     $this->gv['id'] = isset($this->gv['area']['id']) ? $this->gv['area']['id'] : $this->gv['id'];
     $this->gv['id_item'] = isset($this->gv['area']['id_item']) ? $this->gv['area']['id_item'] : $this->gv['id_item'];
     #$this->gv['id_user'] = isset( $this->gv['area']['id_user'] ) ? $this->gv['area']['id_user'] : $this->gv['id_user'];
     /* Filter incoming data */
     $oGlobals->do_alphanum($this->gv['target']);
     $oGlobals->do_alphanum($this->gv['action']);
     $oGlobals->do_numeric_one($this->gv['page']);
     /**
      * A special rule:
      *  arg[sef_output]=css&arg[files]=tkit_css,122c => tkit_css.css, 122c.css 
      *  arg[sef_output]=js&arg[files]=lib,func => lib.js, func.js
      */
     if (isset($this->gv['files'])) {
         $ar = explode(',', $this->gv['files']);
         $this->gv['files'] = array();
         foreach ($ar as $v) {
             $this->gv['files'][] = trim($v) . '.' . $this->gv['sef_output'];
         }
     }
 }