Example #1
0
 public function test1()
 {
     $ini_file = '/tmp/test.ini';
     $x = new ini($ini_file);
     $x->set('Category', 'spex', 17);
     $val = $x->get('Category', 'spex');
     unlink($ini_file);
     $this->assertEquals($val, 17);
 }
Example #2
0
 function start($engine = true)
 {
     self::$site = str_replace('www.', '', $_SERVER['HTTP_HOST']);
     self::$query_string = urldecode($_SERVER['QUERY_STRING']);
     self::$request_uri = str_replace('?' . self::$query_string, '', urldecode($_SERVER['REQUEST_URI']));
     if (!self::$request_uri) {
         self::$request_uri = '/';
     }
     /*
     	Sections
     */
     self::$sections = explode('/', string::clearBoth(self::$request_uri));
     if (!self::$sections) {
         self::$sections[0] = '';
     }
     self::loadEngine();
     // load sites.ini
     if (self::$engine == 'web') {
         // redirects
         $redirect = false;
         $ini = ini::parse(SYS_ROOT . 'conf/global/sites.ini', 'redirects');
         if ($ini) {
             $redirect = arrays::returnValue($ini, self::$site);
             if ($redirect) {
                 headers::site($redirect);
             }
         }
         // mirrors
         $ini = ini::get('mirrors');
         if ($ini) {
             $mirror = arrays::returnValue($ini, self::$site);
             if ($mirror) {
                 self::$site = $mirror;
             }
         }
     }
     self::setConst();
     if ($engine) {
         load::engine(ENGINE);
     }
 }
Example #3
0
 static function trim($ra, $allowedKeys)
 {
     $ret = array();
     if (is_array($ra)) {
         // copy over allowed keys
         foreach ($allowedKeys as $k) {
             $ret[$k] = $ra[$k];
         }
         // track missing keys
         $missing = '';
         $ak = array_flip($allowedKeys);
         foreach ($ra as $k => $i) {
             if (!isset($ak[$k])) {
                 $missing .= (strlen($missing) ? ', ' : '') . "{$k}";
             }
         }
         if (strlen($missing)) {
             $missing = "DB Warning: These fields aren't allowed in one of the tables: {$missing}\n";
             funx::debug($missing);
             email::send(ini::get('email-address'), 'DB Squeak', $missing);
         }
     }
     return $ret;
 }
Example #4
0
 function decho($out, $append = "\n")
 {
     $this->log($out, $append);
     if (!ini::get('silent')) {
         echo $out . $append;
     }
 }
Example #5
0
 static function send($to, $subject, $msg, $attach = '', $attachFilename = '')
 {
     $e = new self();
     $e->setFrom(ini::get('email-address'), ini::get('email-name'));
     $e->setTo($to);
     $e->setSubject($subject);
     $e->setBody($msg);
     if (strlen($attach)) {
         $e->attach($attach, strlen($attachFilename) ? $attachFilename : 'attachment-1');
     }
     return $e->mail();
 }
Example #6
0
 static function getHeader()
 {
     return parent::getHeader(self::$toGlom, self::$fname, ini::get('dir-temp') . self::$fname . '.hash');
 }
Example #7
0
 function sendLastError($txt)
 {
     email::send(ini::get('email-address'), 'Paypal Squeak', $txt . '<br /><br />' . $this->lastErrorTxt);
 }
Example #8
0
 static function cmd($cmd, $passthru = false)
 {
     if (ini::get('verbose') >= 1) {
         echo $cmd . ($passthru ? ' (passthru)' : '') . "\n";
     }
     // passthru (raw output gets echoed)
     if ($passthru === true or $passthru === 'passthru') {
         passthru($cmd, self::$cmdStatus);
     } elseif ($passthru === 'spawn') {
         $ret = proc_open("{$cmd} &", array(), $foo);
         //proc_close($ret);
         return $ret;
     } else {
         exec($cmd, $output, self::$cmdStatus);
         return ra::condense($output, "\n");
     }
 }
Example #9
0
 static function getHeader($fname = 'c.css')
 {
     return parent::getHeader(self::$includes, $fname, ini::get('dir-temp') . 'css.hash');
 }
Example #10
0
 static function findSingle($file, $dirs = '')
 {
     if (!is_file($file) and strlen($file)) {
         // args to array
         if (!is_array($dirs)) {
             $dirs = array($dirs);
         }
         // search dirs
         foreach ($dirs as $dir) {
             if (ini::get('verbose')) {
                 echo "Searching for '{$file}'...\n";
             }
             $files = file::ls("{$dir}/{$file}*");
             if (count($files)) {
                 $file = current($files);
                 break;
             }
         }
         // warning
         if (!is_file($file) and ini::get('verbose')) {
             echo "Cannot find '{$file}'";
             foreach ($dirs as $dir) {
                 echo " or '{$dir}/{$file}*'";
             }
             echo "\n";
         }
     }
     return $file;
 }
Example #11
0
    {
        foreach ($this->lines as &$line) {
            if ($line['type'] != 'entry') {
                continue;
            }
            if ($line['section'] != $section) {
                continue;
            }
            if ($line['key'] != $key) {
                continue;
            }
            $line['value'] = $value;
            $line['data'] = $key . " = " . $value . "\r\n";
            return;
        }
        throw new Exception('Missing Section or Key');
    }
    public function write($file)
    {
        $fp = fopen($file, 'w');
        foreach ($this->lines as $line) {
            fwrite($fp, $line['data']);
        }
        fclose($fp);
    }
}
$ini = new ini();
$ini->read("C:\\php.ini");
$ini->set('PHP', 'engine', 'Off');
echo $ini->get('PHP', 'engine');
$ini->write("C:\\php.ini");
Example #12
0
 static function cleanCaches()
 {
     if ($_GET['cache'] == 'clear') {
         $files = array(ini::get('blog-cache-fname'), ini::get('twitter-cache-fname'));
         foreach ($files as $fname) {
             if (is_file($fname)) {
                 unlink($fname);
             }
         }
     }
 }