Ejemplo n.º 1
0
/**
 * Change an entire array according to the Case
 *
 * @link http://php.net/manual/en/function.array-change-key-case.php#82522, The original owner
 *      
 * @version 1
 * @author Rick de Man <*****@*****.**>
 *        
 * @param array $array
 *        	The array to look in
 * @param string $case
 *        	Options are: 'lcfirst','ucfirst','strToLower','strToUpper' Default: 'strtolower'
 *        	
 * @return array Return the processed Array
 */
function arraychangekey($array, $case = 'strtolower')
{
    $newArray = array();
    // Determine what to do
    switch (strtolower($case)) {
        // Lower-case First character
        case strtolower('lcfirst'):
            if (!function_exists('lcfirst')) {
                $function = create_function('$input', 'return strToLower($input[0]) . substr($input, 1, (strLen($input) - 1));');
            } else {
                $function = 'lcfirst';
            }
            break;
            // Upper-case First character
        // Upper-case First character
        case strtolower('ucfirst'):
            $function = 'ucfirst';
            break;
            // Lower-case all
        // Lower-case all
        case strtolower('strToLower'):
            $function = 'strToLower';
            break;
            // Upper-case all
        // Upper-case all
        case strtolower('strToUpper'):
            $function = 'strToUpper';
            break;
            // Default Action
        // Default Action
        default:
            $function = 'strToLower';
    }
    // Loop through the array
    foreach ($array as $key => $value) {
        // If Array > go level deeper
        if (is_array($value)) {
            $newArray[$function($key)] = ArrayChangeKey($value, $case);
        } elseif (is_string($key)) {
            $newArray[$function($key)] = $value;
        } else {
            $newArray[$key] = $value;
        }
    }
    // Return the Processed Array
    return $newArray;
}
Ejemplo n.º 2
0
Archivo: wms.php Proyecto: RickdeM/wms
 /**
  * Start Loading The WMS - System is Setup
  *
  * @version 1
  * @author Rick de Man <*****@*****.**>
  *        
  */
 protected function WMS_Load()
 {
     // Allow Real Debugging
     $this->Debug = in_array($_SERVER['REMOTE_ADDR'], $this->WMS['Developers']) ? True : False;
     $_SESSION['WMS-Debug'] = $this->Debug;
     // Generate Debug List */
     if ($this->Debug === True && strtolower($_SERVER['QUERY_STRING']) == strtolower('Debug')) {
         Debug_All($this);
     }
     // Generate Debug List
     if ($this->Debug === True && strtolower($_SERVER['QUERY_STRING']) == strtolower('Mkdir')) {
         Debug_Mkdir($this->Root . 'lib');
     }
     $this->HTML_ConstructGet();
     // SQL Connection
     $this->SQL = new MySQL();
     var_dump($this->SQL->IsConnected());
     die;
     if (!$this->SQL->IsConnected()) {
         if (file_exists(WMS_ROOT . 'installation')) {
             header('Location: ' . $this->HTML_Root . 'installation');
             exit;
         }
         die('PHP PDO  is unable to open the connection.');
     }
     // Driver selection
     // TODO: do in the mysql class
     /*
     if( in_array(strtolower($this->_SQL['type']),PDO::getAvailableDrivers()) ){
     }else{
     	// Driver is not enabled / does not exists
     	die('PHP PDO  "'.$this->_SQL['type'].'" is not (yet) enabled or does not exist.');
     }
     */
     if ($this->WMS_Mode != 'AJAX') {
         // SQL Connection Module
         $this->Query_Clear_Locked();
     }
     // Get User Info
     $this->User__Construct();
     // Ajax Determines WMS Mode
     if ($this->WMS_Mode == 'AJAX') {
         $Mode_tmp = $this->WMS_Mode;
         $this->WMS_Mode = $this->WMS_Mode_Ini;
     }
     // Load 'Language' & 'Error' INI Files
     $this->Lang = GetXmlArray(WMS_LIB . 'lang/%1/' . $this->WMS_Mode . '.xml', $this->User['lang'], $this->WMS['LangDefault']);
     $this->Error = GetXmlArray(WMS_LIB . 'lang/%1/' . $this->WMS_Mode . '_error.xml', $this->User['lang'], $this->WMS['LangDefault']);
     // Check for errors
     if ($this->Lang === false) {
         die('Missing language file: ' . $this->WMS_Mode . ':' . $this->User['lang'] . '/' . $this->WMS['LangDefault']);
     }
     if ($this->Error === false) {
         die('Missing Error language file: ' . $this->WMS_Mode . ':' . $this->User['lang'] . '/' . $this->WMS['LangDefault']);
     }
     $_SESSION['Language'] = $this->Lang;
     $_SESSION['WMS-MinifyHtml'] = $this->WMS['MinifyHtml'] !== false;
     // LowerCase
     $this->Lang = ArrayChangeKey($this->Lang);
     $this->Error = ArrayChangeKey($this->Error);
     // Resore WMS mode
     if (isset($Mode_tmp)) {
         $this->WMS_Mode = $Mode_tmp;
     }
 }