Ejemplo n.º 1
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
Ejemplo n.º 2
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     // this value is used by the Panel
     $this->indexDetected = true;
     if (r::cli()) {
         return $this->index = '/';
     } else {
         return $this->index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
Ejemplo n.º 3
0
 public function index()
 {
     if (isset($this->index)) {
         return $this->index;
     }
     if (r::cli()) {
         $index = '/';
     } else {
         $index = url::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
     // fix index URL for the Panel
     if (function_exists('panel')) {
         $index = dirname($index);
     }
     return $this->index = $index;
 }
Ejemplo n.º 4
0
/**
 * Dumps any array or object in a human readable way
 *
 * @param mixed $variable Whatever you like to inspect
 * @param boolean $echo
 * @return string
 */
function dump($variable, $echo = true)
{
    if (r::cli()) {
        $output = print_r($variable, true) . PHP_EOL;
    } else {
        $output = '<pre>' . print_r($variable, true) . '</pre>';
    }
    if ($echo == true) {
        echo $output;
    }
    return $output;
}
Ejemplo n.º 5
0
 /**
  * Returns the URL for document root no 
  * matter what the path is. 
  * 
  * @return string
  */
 public static function index()
 {
     if (r::cli()) {
         return '/';
     } else {
         return static::base() . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
     }
 }
Ejemplo n.º 6
0
 /**
  * Generates a fingerprint from the user agent string
  * 
  * @return string
  */
 public static function fingerprint()
 {
     if (!r::cli()) {
         return sha1($_SERVER['HTTP_USER_AGENT'] . (ip2long($_SERVER['REMOTE_ADDR']) & ip2long('255.255.0.0')));
     } else {
         return '';
     }
 }
Ejemplo n.º 7
0
 /**
  * Generates a fingerprint from the user agent string
  * 
  * @return string
  */
 public static function fingerprint()
 {
     if (!r::cli()) {
         return sha1(Visitor::ua() . (ip2long($_SERVER['REMOTE_ADDR']) & ip2long('255.255.0.0')));
     } else {
         return '';
     }
 }
Ejemplo n.º 8
0
 /**
  * Returns the proper base url for the installation
  *
  * @return string
  */
 protected static function url()
 {
     // auto-detect the url
     if (empty(c::$data['url'])) {
         if (r::cli()) {
             return c::$data['url'] = '/';
         } else {
             return c::$data['url'] = url::scheme() . '://' . server::get('HTTP_HOST') . preg_replace('!\\/index\\.php$!i', '', server::get('SCRIPT_NAME'));
         }
     } else {
         return c::$data['url'];
     }
 }
Ejemplo n.º 9
0
 public function testCli()
 {
     $this->assertTrue(r::cli());
 }