Ejemplo n.º 1
0
/**
 * Parse any get params that might be hidden in the URL
 */
function parse_params()
{
    // --[ mod_rewrite code ]--
    if (!isset($_GET[ROSTER_PAGE])) {
        $uri = request_uri();
        $page = substr($uri, strlen(ROSTER_PATH));
        list($page) = explode('.', $page);
        // Build the Roster page var
        $pages = array();
        foreach (explode('/', $page) as $get) {
            if (strpos($get, '=') === false) {
                $pages[] = $get;
            } else {
                parse_str($get, $get);
                if (!get_magic_quotes_gpc()) {
                    $get = escape_array($get);
                }
                $_GET = array_overlay($get, $_GET);
            }
        }
        // Needed in case someone specified www.example.com/roster/index.php.
        // That format is the only one that works in IIS
        if ($pages == array('index')) {
            $pages = array();
        }
        $_GET[ROSTER_PAGE] = implode('-', $pages);
    }
}
Ejemplo n.º 2
0
 /**
  * Adds locale strings to global $wordings array
  *
  * @param string $localefile | Full path to locale file
  * @param string $locale | Locale to add to (IE: enUS)
  */
 function add_locale_file($localefile, $locale)
 {
     if (file_exists($localefile)) {
         include $localefile;
     } else {
         $enUSfile = str_replace($locale . '.php', 'enUS.php', $localefile);
         if (file_exists($enUSfile)) {
             include $enUSfile;
         } else {
             // Do nothing for now. Nothing wrong with an addon not having any of its own localization
             //die_quietly('Could not include locale file [' . $localefile . ']','Locale Inclusion Error',__FILE__,__LINE__);
         }
     }
     if (isset($lang)) {
         if (isset($this->wordings[$locale])) {
             $this->wordings[$locale] = array_overlay($lang, $this->wordings[$locale]);
         } else {
             $this->wordings[$locale] = $lang;
         }
         unset($lang);
     }
 }
Ejemplo n.º 3
0
function array_overlay($a1, $a2)
{
    foreach ($a1 as $k => $v) {
        if (!array_key_exists($k, $a2)) {
            continue;
        }
        if (is_array($v) && is_array($a2[$k])) {
            $a1[$k] = array_overlay($v, $a2[$k]);
        } else {
            $a1[$k] = $a2[$k];
        }
    }
    return $a1;
}
Ejemplo n.º 4
0
if (!file_exists($local_file)) {
    // Get the $directories and fill the array $directories
    if ($subdirectories) {
        GrabAllLocalDirectories('.');
    }
    // Get the $files / versioning info for each $directories and fill the array $files
    foreach ($directories as $directory => $filecount) {
        // Grab all local $files and store the information into the array $files
        GrabLocalVersions($directory);
    }
    file_writer($local_file, json_encode($files), $mode = 'wb');
} else {
    $files = json_decode(file_get_contents($local_file), true);
}
// now we build our full file array
$files = array_overlay($remote, $files);
foreach ($files as $directory => $filedata) {
    $directories[$directory] = count($filedata);
}
/**
 * Grab all directories and subdirectories for directory $dir and shove them into the global array $directories
 *
 * @param string $dir
 */
function GrabAllLocalDirectories($dir)
{
    global $directories;
    if ($handle = @opendir($dir)) {
        while ($filename = readdir($handle)) {
            $directory = $dir . '/' . $filename;
            if (is_dir($directory) && CheckDirectory($filename)) {
Ejemplo n.º 5
0
/**
 * A better array_merge()
 * Merges multi-dimensional arrays
 *
 * @param array $skel
 * @param array $arr
 * @return array
 */
function array_overlay($skel, &$arr)
{
    foreach ($skel as $key => $val) {
        if (!isset($arr[$key])) {
            $arr[$key] = $val;
        } elseif (is_array($val)) {
            $arr[$key] = array_overlay($val, $arr[$key]);
        } else {
            // UnComment if you want to know if you are overwritting a variable
            //trigger_error('Key already set: ' . $key . '->' . $arr[$key] . '<br />&nbsp;&nbsp;New value tried: ' . $skel[$key]);
        }
    }
    return $arr;
}