예제 #1
0
 function joininigpaths()
 {
     $f = FsObject::get(base::appPath());
     $p1 = $f->joinPath('foo/bar');
     $p2 = $f->joinPath(array('foo', 'bar'));
     $this->assertEquals($p1, $p2);
 }
예제 #2
0
 function __construct()
 {
     $this->cachefile = base::appPath() . '/.l2cache';
     $this->lockfile = base::appPath() . '/.l2lock';
     $this->hlockfile = fopen($this->lockfile, "w");
     flock($this->hlockfile, LOCK_EX);
     if (file_exists($this->cachefile)) {
         Console::debugEx(LOG_BASIC, __CLASS__, "Loading package cache from %s", $this->cachefile);
         $this->loadCache();
     } else {
         Console::debugEx(LOG_BASIC, __CLASS__, "Package cache not found");
         $this->initCache();
     }
 }
예제 #3
0
 function getPolicyRecord($type, $key)
 {
     if ($type == self::SPT_FILEPOLICY) {
         $ap = base::appPath();
         $ap_allowed = array('res');
         $key = realpath($key);
         foreach ($ap_allowed as $apext) {
             $apt = realpath($ap . '/' . $apext);
             if (substr($key, 0, strlen($apt)) == $apt) {
                 return true;
             }
         }
         return false;
     }
     return null;
 }
예제 #4
0
파일: font.php 프로젝트: noccy80/lepton-ng
 /**
  * Constructor, attempts to load the font from the paths defined in the
  * lepton.graphics.fontpaths key or the default locations.
  *
  * @param string $fontname The font name
  * @param int $fontsize The size
  */
 function __construct($fontname, $fontsize)
 {
     $fullname = null;
     $p = config::get('lepton.graphics.fontpaths', array('./', base::appPath() . '/fonts', base::appPath(), '/usr/share/fonts/truetype/', base::basePath()));
     foreach ($p as $fp) {
         $ff = file_find($fp, $fontname);
         if ($ff != null) {
             $fullname = $ff;
             break;
         }
     }
     if ($fullname) {
         $this->font = array('fontname' => $fullname, 'fontsize' => $fontsize, 'angle' => 0);
     } else {
         throw new GraphicsException("Font " . $fontname . " not found", GraphicsException::ERR_BAD_FONT);
     }
 }
예제 #5
0
파일: info.php 프로젝트: noccy80/lepton-ng
 public function php()
 {
     $info = array('php_uname()' => php_uname('a'), 'phpversion()' => phpversion(), 'php_sapi_name()' => php_sapi_name(), 'PHP_OS' => PHP_OS, 'DIRECTORY_SEPARATOR' => DIRECTORY_SEPARATOR, 'PATH_SEPARATOR' => PATH_SEPARATOR, 'PHP_SHLIB_SUFFIX' => PHP_SHLIB_SUFFIX, 'sys_get_temp_dir()' => sys_get_temp_dir(), 'Platform' => LEPTON_PLATFORM_ID);
     $comp = array('COMPAT_GETOPT_LONGOPTS' => PHP_VERSION >= "5.3" ? 'Supported' : 'Emulated (PHP >= 5.3)', 'COMPAT_SOCKET_BACKLOG' => PHP_VERSION >= "5.3.3" ? 'Supported' : 'Missing (PHP >= 5.3.3)', 'COMPAT_HOST_VALIDATION' => PHP_VERSION >= "5.2.13" ? 'Supported' : 'Emulated (PHP >= 5.2.13)', 'COMPAT_NAMESPACES' => PHP_VERSION >= "5.3.0" ? 'Supported' : 'Missing (PHP >= 5.3.0)', 'COMPAT_INPUT_BROKEN' => PHP_VERSION >= "5" && PHP_VERSION < "5.3.1" ? 'php://input possibly broken (PHP >= 5, PHP < 5.3.1)' : 'Functional', 'COMPAT_CALLSTATIC' => PHP_VERSION >= "5.3.0" ? 'Supported' : 'Missing (PHP >= 5.3.0)', 'COMPAT_CRYPT_BLOWFISH' => PHP_VERSION >= "5.3.0" ? 'Supported' : 'Missing (PHP >= 5.3.0)', 'COMPAT_PHP_FNMATCH' => PHP_OS == "Linux" || PHP_OS == "Windows" && PHP_VERSION >= "5.3" ? 'Native' : 'Emulated (WIN + PHP >= 5.3.0)');
     $opts = array('base::basePath()' => base::basePath(), 'base::appPath()' => base::appPath(), 'base::sysPath()' => base::sysPath(), 'TMP_PATH' => TMP_PATH);
     Console::writeLn(__astr("\\b{Lepton Overview:}"));
     foreach ($opts as $key => $val) {
         Console::writeLn("  %-25s : %s", $key, $val);
     }
     Console::writeLn();
     Console::writeLn(__astr("\\b{PHP Overview:}"));
     foreach ($info as $key => $val) {
         Console::writeLn("  %-25s : %s", $key, $val);
     }
     Console::writeLn();
     Console::writeLn(__astr("\\b{Compatibility layer overview:}"));
     foreach ($comp as $key => $val) {
         Console::writeLn("  %-25s : %s", $key, $val);
     }
     Console::writeLn();
 }
예제 #6
0
 public function __construct()
 {
     $this->database = new FsPrefs(base::appPath() . '/.modcache');
 }
예제 #7
0
 /**
  * @brief Update the application base path.
  *
  * Set to null to reset it to the default value.
  *
  * @param String $base The new base path (or null)
  */
 protected function setBase($base = null)
 {
     // config::set(Controller::KEY_CONTROLLER_BASE, $base);
     base::appPath($base);
 }
예제 #8
0
<?php

config::def('lepton.gallery.mediadir', base::appPath() . '/media/');
config::def('lepton.gallery.cachedir', base::appPath() . '/cache/');
// config::def('lepton.gallery.renderer', array('WatermarkImageFilter','mylogo.png'));
using('lepton.graphics.canvas');
using('lepton.utils.pagination');
class GalleryItemsTable extends SqlTableSchema
{
    function define()
    {
        // Only to be used during testing!
        $this->dropOnCreate();
        // Table name
        $this->setName('galleryitems');
        // Table columns
        $this->addColumn('id', 'int', self::COL_AUTO | self::KEY_PRIMARY);
        $this->addColumn('name', 'varchar:160');
        $this->addColumn('uuid', 'char:37', self::COL_FIXED);
        $this->addColumn('src', 'varchar:200');
        // Indexes
        $this->addIndex('uuidkey', array('uuid'), self::KEY_UNIQUE);
        $this->addIndex('srckey', array('src'), self::KEY_UNIQUE);
    }
}
SqlTableSchema::apply(new GalleryItemsTable());
/**
 * @class Gallery
 * @package lepton.media
 * @brief Gallery Management
 *
예제 #9
0
 static function getDebugInformation()
 {
     if (self::isSecure()) {
         $ssl = 'Yes (' . $_SERVER['SSL_TLS_SNI'] . ')';
     } else {
         $ssl = 'No';
     }
     return join("\n", array("Request time: " . date(DATE_RFC822, $_SERVER['REQUEST_TIME']), "Base path: " . base::basePath(), "App path: " . base::appPath(), "Sys path: " . base::sysPath(), "User-agent: " . $_SERVER['HTTP_USER_AGENT'], "Request URI: " . $_SERVER['REQUEST_URI'], "Request method: " . $_SERVER['REQUEST_METHOD'], "Authenticated user: "******"Remote IP: " . $_SERVER['REMOTE_ADDR'] . " (" . gethostbyaddr($_SERVER['REMOTE_ADDR']) . ")", "Hostname: " . $_SERVER['HTTP_HOST'], "Secure: " . $ssl, "Referrer: " . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'null'), sprintf("Running as: %s (uid=%d, gid=%d) with pid %d", get_current_user(), getmyuid(), getmygid(), getmypid()), sprintf("Server: %s", $_SERVER['SERVER_SOFTWARE']) . " (" . php_sapi_name() . ")", sprintf("Memory allocated: %0.3f KB (Total used: %0.3f KB)", memory_get_usage() / 1024 / 1024, memory_get_usage(true) / 1024 / 1024), "Platform: " . LEPTON_PLATFORM_ID, sprintf("Runtime: PHP v%d.%d.%d (%s)", PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, PHP_OS)));
 }
예제 #10
0
파일: base.php 프로젝트: noccy80/lepton-ng
 /**
  *
  */
 static function _mangleModulePath($module)
 {
     // Console::debugEx(LOG_LOG,__CLASS__,"Mangling module %s", $module);
     if (preg_match('/^app\\./', $module)) {
         $path = base::appPath() . '/' . str_replace('.', '/', str_replace('app.', '', $module)) . '.php';
     } else {
         $path = base::sysPath() . '/' . str_replace('.', '/', $module) . '.php';
     }
     // Console::debugEx(LOG_LOG,__CLASS__,"  -> %s", $path);
     return $path;
 }
예제 #11
0
 function compile()
 {
     $this->openDatabase();
     foreach ($this->db as $key => $val) {
         if (string::like('lang:*', $key)) {
             $out = '';
             $keyparts = explode(':', $key);
             $lang = $keyparts[1];
             $out = sprintf("<?php\n// Do not edit! Automatically generated by 'lepton strings'\n\n");
             $out .= sprintf("intl::registerLanguage('%s',array(\n", $lang);
             foreach ($val as $src => $str) {
                 $out .= sprintf("   '%s' => '%s'", str_replace('\'', '\\\'', $src), str_replace('\'', '\\\'', $str));
                 if ($str != end($val)) {
                     $out .= ',';
                 }
                 $out .= "\n";
             }
             $out .= sprintf("));");
             console::writeLn(__astr("\\g{Generated:} %s"), $lang);
             file_put_contents(base::appPath() . 'languages/' . $lang . '.php', $out);
         }
     }
 }
예제 #12
0
 private function geoLocationInsert($fn)
 {
     $this->progress = null;
     $this->activity = "Importing";
     $this->doTaskUpdate();
     $dest = base::appPath() . '/geocache/' . $fn;
     $fz = fopen('zip://' . $dest . '#' . basename($dest, '.zip') . '.txt', 'rb');
     if (!$fz) {
         console::fatal("Could not open file %s (%s)", $dest, $fn);
     }
     $this->doTaskUpdate();
     $batch = array();
     $rowstot = 0;
     while (!feof($fz)) {
         $row = fgetcsv($fz, 16000, "\t", '*');
         $batch[] = $row;
         $rowstot++;
         if (count($batch) >= 50) {
             $this->progress['read'] += count($batch);
             $this->doTaskUpdate();
             $this->geoLocationInsertBatch($batch);
             $batch = array();
         }
     }
     $this->clearTask();
     console::writeLn("%s imported, %d rows.", $fn, $rowstot);
 }
예제 #13
0
 public function initialize($rootuser = null)
 {
     console::writeLn(__astr('\\b{Initializing database}'));
     $db = config::get('lepton.db.default');
     $dbc = config::get('lepton.db.default');
     console::writeLn("  Database:  %s", $dbc['database']);
     console::writeLn("  User:      %s", $dbc['username']);
     console::writeLn("  Host:      %s", $dbc['hostname']);
     switch ($db['driver']) {
         case 'pdo/mysql':
         case 'mysql':
             console::writeLn("  Driver:    MySQL");
             break;
         default:
             console::fatal('This version of the script does not support anything else than MySQL');
             exit(1);
     }
     console::writeLn(__astr("\n\\b{Creating database and user}"));
     console::writeLn("  The script can create the database and the user. Hit enter to skip this step.");
     console::write("  Password for root user: "******"SHOW DATABASES LIKE %s", $dbc['database']);
         if (count($dblist) == 0) {
             console::writeLn("Creating database...");
             try {
                 $conn->exec(sprintf("CREATE DATABASE %s;", $dbc['database']));
             } catch (Exception $e) {
                 console::writeLn("Not successful, does the database already exist?");
             }
         }
         console::writeLn("Creating user...");
         $conn->exec(sprintf("GRANT ALL ON %s.* TO %s@localhost IDENTIFIED BY '%s';", $dbc['database'], $dbc['username'], $dbc['password']));
         $conn->exec("USE " . $dbc['database']);
     } else {
         console::writeLn("No password specified, ignoring database and user creation.");
         $conn = new DatabaseConnection();
     }
     console::writeLn(__astr("\n\\b{Importing tables}"));
     $f = glob(base::basePath() . '/dist/sql/*.sql');
     foreach ($f as $fn) {
         $fc = file_get_contents($fn);
         console::writeLn("  [sys] %s", basename($fn));
         $conn->exec($fc);
     }
     $f = glob(base::appPath() . '/sql/*.sql');
     foreach ($f as $fn) {
         $fc = file_get_contents($fn);
         console::writeLn("  [app] %s", basename($fn));
         $conn->exec($fc);
     }
     console::writeLn("All done.");
 }
예제 #14
0
파일: php.php 프로젝트: noccy80/lepton-ng
 function import($view)
 {
     $path = base::appPath() . '/views/' . $view;
     include $path;
 }