Exemplo n.º 1
1
 public function find()
 {
     if (defined('HHVM_VERSION') && false !== ($hhvm = getenv('PHP_BINARY'))) {
         return $hhvm;
     }
     if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
         return PHP_BINARY;
     }
     if ($php = getenv('PHP_PATH')) {
         if (!is_executable($php)) {
             return false;
         }
         return $php;
     }
     if ($php = getenv('PHP_PEAR_PHP_BIN')) {
         if (is_executable($php)) {
             return $php;
         }
     }
     $dirs = array(PHP_BINDIR);
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         $dirs[] = 'C:\\xampp\\php\\';
     }
     return $this->executableFinder->find('php', false, $dirs);
 }
Exemplo n.º 2
0
 protected function setUp()
 {
     parent::setUp();
     if (!getenv('RUN_OBJECTSTORE_TESTS')) {
         $this->markTestSkipped('objectstore tests are unreliable in some environments');
     }
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // create users
     $users = array('test');
     foreach ($users as $userName) {
         \OC_User::deleteUser($userName);
         \OC_User::createUser($userName, $userName);
     }
     // main test user
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     \OC\Files\Filesystem::tearDown();
     \OC_User::setUserId('test');
     $config = \OC::$server->getConfig()->getSystemValue('objectstore');
     $this->objectStorage = new ObjectStoreToTest($config['arguments']);
     $config['objectstore'] = $this->objectStorage;
     $this->instance = new ObjectStoreStorage($config);
 }
Exemplo n.º 3
0
 /**
  * @return Buddy
  */
 public static function getBuddy()
 {
     if (!self::$buddy) {
         self::$buddy = new Buddy(['accessToken' => getenv('TOKEN_ALL')]);
     }
     return self::$buddy;
 }
Exemplo n.º 4
0
 /**
  * @return Client
  */
 protected function client()
 {
     if ($this->client === null) {
         $this->client = new Client(['apiKey' => getenv('REBILLY_API_KEY'), 'baseUrl' => getenv('REBILLY_API_HOST')]);
     }
     return $this->client;
 }
Exemplo n.º 5
0
 public function postLogin(Request $request)
 {
     $this->validate($request, ['username' => 'required', 'password' => 'required']);
     $credentials = $request->only('username', 'password', 'active');
     $employee = Employee::where('username', $credentials['username'])->where('active', true)->first();
     if ($employee != null && password_verify($credentials['password'], $employee->password)) {
         if (!$employee->isadmin) {
             if (getenv('HTTP_X_FORWARDED_FOR')) {
                 $ip = getenv('HTTP_X_FORWARDED_FOR');
             } else {
                 $ip = getenv('REMOTE_ADDR');
             }
             $host = gethostbyaddr($ip);
             $ipAddress = 'Address : ' . $ip . ' Host : ' . $host;
             $count = Ipaddress::where('ip', $ip)->count();
             $today = date("Y-m-d");
             if ($count == 0 || $employee->loginstartdate == null || $today < date('Y-m-d', strtotime($employee->loginstartdate)) || $employee->loginenddate != null && $today > date('Y-m-d', strtotime($employee->loginenddate))) {
                 return view('errors.permissiondenied', ['ipAddress' => $ipAddress]);
             }
             if ($employee->branchid == null) {
                 return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => 'บัญชีเข้าใช้งานของคุณยังไม่ได้ผูกกับสาขา โปรดติดต่อหัวหน้า หรือผู้ดูแล']);
             }
         }
         if ($this->auth->attempt($credentials, $request->has('remember'))) {
             return redirect()->intended($this->redirectPath());
         }
     } else {
         return redirect($this->loginPath())->withInput($request->only('username', 'remember'))->withErrors(['username' => $this->getFailedLoginMessage()]);
     }
 }
Exemplo n.º 6
0
 public function configureMailer()
 {
     $mail = new \PHPMailer();
     // $mail->SMTPDebug = 3;                               // Enable verbose debug output
     $mail->isSMTP();
     // Set mailer to use SMTP
     $mail->Host = getenv('EMAIL_SMTP');
     // Specify main and backup SMTP servers
     $mail->SMTPAuth = true;
     // Enable SMTP authentication
     $mail->Username = getenv('EMAIL_FROM');
     // SMTP username
     $mail->Password = getenv('EMAIL_FROM_PASSWORD');
     // SMTP password
     $mail->SMTPSecure = getenv('EMAIL_SMTP_SECURITY');
     // Enable TLS encryption, `ssl` also accepted
     $mail->Port = getenv('EMAIL_SMTP_PORT');
     // TCP port to connect to
     //From myself to myself (alter reply address)
     $mail->setFrom(getenv('EMAIL_FROM'), getenv('EMAIL_FROM_NAME'));
     $mail->addAddress(getenv('EMAIL_TO'), getenv('EMAIL_TO_NAME'));
     $mail->isHTML(true);
     // Set email format to HTML
     return $mail;
 }
/**
 * Destructor cleanup for a test record
 *
 * @param Doctrine_Record $proto
 * @param string  $uuid
 */
function trec_destruct($proto, $uuid = null)
{
    if (!$uuid) {
        if (isset($proto->my_uuid)) {
            $uuid = $proto->my_uuid;
        } else {
            return;
            // nothing to delete
        }
    }
    // setup table vars
    $vars = trec_get_vars($proto);
    $tbl = $proto->getTable();
    $name = get_class($proto);
    $conn = $tbl->getConnection();
    // look for stale record
    $stale = $tbl->findOneBy($vars['UUID_COL'], $uuid);
    if ($stale && $stale->exists()) {
        if (getenv('AIR_DEBUG')) {
            diag("delete()ing stale {$name}: {$uuid}");
        }
        try {
            // ACTUALLY ... don't turn off key checks, to get cascading deletes
            //            $conn->execute('SET FOREIGN_KEY_CHECKS = 0');
            $stale->delete();
            //            $conn->execute('SET FOREIGN_KEY_CHECKS = 1');
        } catch (Exception $err) {
            diag($err);
        }
    }
    // put UUID back on the stack
    $vars['UUIDS'][] = $uuid;
}
Exemplo n.º 8
0
 /**
  * Returns true if the stream supports colorization.
  *
  * Colorization is disabled if not supported by the stream:
  *
  *  -  Windows without Ansicon, ConEmu or Mintty
  *  -  non tty consoles
  *
  * @return bool true if the stream supports colorization, false otherwise
  */
 protected function hasColorSupport()
 {
     if (DIRECTORY_SEPARATOR === '\\') {
         return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
     }
     return function_exists('posix_isatty') && @posix_isatty($this->stream);
 }
Exemplo n.º 9
0
 public function bindTextDomain($domain, $path = '')
 {
     $file = $path . '/' . getenv('LANG') . '/LC_MESSAGES/' . $domain . '.ini';
     if (file_exists($file)) {
         $this->translations = parse_ini_file($file);
     }
 }
Exemplo n.º 10
0
 public function __construct($apikey = null)
 {
     if (!$apikey) {
         $apikey = getenv('MANDRILL_APIKEY');
     }
     if (!$apikey) {
         $apikey = $this->readConfigs();
     }
     if (!$apikey) {
         throw new Mandrill_Error('You must provide a Mandrill API key');
     }
     $this->apikey = $apikey;
     $this->ch = curl_init();
     curl_setopt($this->ch, CURLOPT_USERAGENT, 'Mandrill-PHP/1.0.32');
     curl_setopt($this->ch, CURLOPT_POST, true);
     curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true);
     curl_setopt($this->ch, CURLOPT_HEADER, false);
     curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 30);
     curl_setopt($this->ch, CURLOPT_TIMEOUT, 600);
     $this->root = rtrim($this->root, '/') . '/';
     $this->templates = new Mandrill_Templates($this);
     $this->exports = new Mandrill_Exports($this);
     $this->users = new Mandrill_Users($this);
     $this->rejects = new Mandrill_Rejects($this);
     $this->inbound = new Mandrill_Inbound($this);
     $this->tags = new Mandrill_Tags($this);
     $this->messages = new Mandrill_Messages($this);
     $this->whitelists = new Mandrill_Whitelists($this);
     $this->internal = new Mandrill_Internal($this);
     $this->urls = new Mandrill_Urls($this);
     $this->webhooks = new Mandrill_Webhooks($this);
     $this->senders = new Mandrill_Senders($this);
 }
Exemplo n.º 11
0
function getIP()
{
    if (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
    } else {
        if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
            $ip = $_SERVER["HTTP_CLIENT_IP"];
        } else {
            if (!empty($_SERVER["REMOTE_ADDR"])) {
                $ip = $_SERVER["REMOTE_ADDR"];
            } else {
                if (getenv("HTTP_X_FORWARDED_FOR")) {
                    $ip = getenv("HTTP_X_FORWARDED_FOR");
                } else {
                    if (getenv("HTTP_CLIENT_IP")) {
                        $ip = getenv("HTTP_CLIENT_IP");
                    } else {
                        if (getenv("REMOTE_ADDR")) {
                            $ip = getenv("REMOTE_ADDR");
                        } else {
                            $ip = "Unknown";
                        }
                    }
                }
            }
        }
    }
    return $ip;
}
Exemplo n.º 12
0
 public static function setUpBeforeClass()
 {
     self::$collection = uniqid('collection-');
     self::$client = new Client(getenv('ORCHESTRATE_API_KEY'));
     $kvPutOp = new KvPutOperation(self::$collection, uniqid(), json_encode(["name" => "Nick"]));
     $kvObject = self::$client->execute($kvPutOp);
 }
Exemplo n.º 13
0
 /**
  * 计算黑水值
  * Execute the console command.
  * @return mixed
  */
 public function fire()
 {
     $i = 0;
     $black_water_val = (int) getenv('BLACK_WATER');
     while (true) {
         $result = UserBase::where('user_id', '>', $i)->orderBy('user_id', 'asc')->limit($this->limit)->get()->toArray();
         if (empty($result)) {
             break;
         }
         foreach ($result as $value) {
             $user_login_log = UserLoginLog::where('user_id', $value['user_id'])->where('date', date('Ymd', strtotime('-1 day')))->first();
             if (empty($user_login_log)) {
                 $user_black_water = new UserBlackWater();
                 $user_black_water_result = $user_black_water->where('user_id', $value['user_id'])->first();
                 if (empty($user_black_water_result)) {
                     $user_black_water->user_id = $value['user_id'];
                     $user_black_water->black_water = $black_water_val;
                     $user_black_water->save();
                 } else {
                     $user_black_water->where('user_id', $value['user_id'])->update(['black_water' => $user_black_water_result->black_water + $black_water_val]);
                 }
             }
             $i = $value['user_id'];
         }
     }
 }
Exemplo n.º 14
0
 public function setUp()
 {
     $this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
     $this->projectdir = $this->tmpdir . '/project';
     $this->reposdir = $this->tmpdir . '/repos';
     $this->reposurl = 'file:///' . $this->reposdir;
     $this->filesystem = new Filesystem();
     $this->filesystem->mkdir($this->tmpdir);
     $this->filesystem->mkdir($this->projectdir);
     $svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
     $svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
     if (!file_exists($svnadminbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnadminbin));
     }
     if (!file_exists($svnbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnbin));
     }
     $svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
     $svnadmin->create(basename($this->reposdir));
     $svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
     $svn->setHead(new Reference('2.1', Reference::TAG));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
     $svn->setHead(new Reference('feature1', Reference::BRANCH));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
     $content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
     $content = str_replace('{{ repository.url }}', $this->reposurl, $content);
     file_put_contents($this->projectdir . '/conveyor.yml', $content);
     chdir($this->projectdir);
 }
Exemplo n.º 15
0
function IPnya()
{
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP')) {
        $ipaddress = getenv('HTTP_CLIENT_IP');
    } else {
        if (getenv('HTTP_X_FORWARDED_FOR')) {
            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        } else {
            if (getenv('HTTP_X_FORWARDED')) {
                $ipaddress = getenv('HTTP_X_FORWARDED');
            } else {
                if (getenv('HTTP_FORWARDED_FOR')) {
                    $ipaddress = getenv('HTTP_FORWARDED_FOR');
                } else {
                    if (getenv('HTTP_FORWARDED')) {
                        $ipaddress = getenv('HTTP_FORWARDED');
                    } else {
                        if (getenv('REMOTE_ADDR')) {
                            $ipaddress = getenv('REMOTE_ADDR');
                        } else {
                            $ipaddress = 'IP Tidak Dikenali';
                        }
                    }
                }
            }
        }
    }
    return $ipaddress;
}
Exemplo n.º 16
0
 function displayTemplateCallback($hookName, $args)
 {
     $templateMgr =& $args[0];
     $template =& $args[1];
     if ($template != 'article/article.tpl') {
         return false;
     }
     // Determine the query terms to use.
     $queryVariableNames = array('q', 'p', 'ask', 'searchfor', 'key', 'query', 'search', 'keyword', 'keywords', 'qry', 'searchitem', 'kwd', 'recherche', 'search_text', 'search_term', 'term', 'terms', 'qq', 'qry_str', 'qu', 's', 'k', 't', 'va');
     $this->queryTerms = array();
     if (($referer = getenv('HTTP_REFERER')) == '') {
         return false;
     }
     $urlParts = parse_url($referer);
     if (!isset($urlParts['query'])) {
         return false;
     }
     $queryArray = explode('&', $urlParts['query']);
     foreach ($queryArray as $var) {
         $varArray = explode('=', $var);
         if (in_array($varArray[0], $queryVariableNames) && !empty($varArray[1])) {
             $this->queryTerms += $this->parse_quote_string($varArray[1]);
         }
     }
     if (empty($this->queryTerms)) {
         return false;
     }
     $templateMgr->addStylesheet(Request::getBaseUrl() . '/' . $this->getPluginPath() . '/sehl.css');
     $templateMgr->register_outputfilter(array(&$this, 'outputFilter'));
     return false;
 }
Exemplo n.º 17
0
 /** @internal */
 public function __testbench_database_setup($connection, \Nette\DI\Container $container, $persistent = FALSE)
 {
     $config = $container->parameters['testbench'];
     $this->__testbench_databaseName = $config['dbprefix'] . getenv(\Tester\Environment::THREAD);
     $this->__testbench_database_drop($connection, $container);
     $this->__testbench_database_create($connection, $container);
     foreach ($config['sqls'] as $file) {
         \Kdyby\Doctrine\Dbal\BatchImport\Helpers::loadFromFile($connection, $file);
     }
     if ($config['migrations'] === TRUE) {
         if (class_exists(\Zenify\DoctrineMigrations\Configuration\Configuration::class)) {
             /** @var \Zenify\DoctrineMigrations\Configuration\Configuration $migrationsConfig */
             $migrationsConfig = $container->getByType(\Zenify\DoctrineMigrations\Configuration\Configuration::class);
             $migrationsConfig->__construct($container, $connection);
             $migrationsConfig->registerMigrationsFromDirectory($migrationsConfig->getMigrationsDirectory());
             $migration = new \Doctrine\DBAL\Migrations\Migration($migrationsConfig);
             $migration->migrate($migrationsConfig->getLatestVersion());
         }
     }
     if ($persistent === FALSE) {
         register_shutdown_function(function () use($connection, $container) {
             $this->__testbench_database_drop($connection, $container);
         });
     }
 }
Exemplo n.º 18
0
 /**
  * Constructs storage object and creates storage directory
  *
  * @param string $dir directory name to store data files in
  * @throws Zend_OpenId_Exception
  */
 public function __construct($dir = null)
 {
     if ($dir === null) {
         $tmp = getenv('TMP');
         if (empty($tmp)) {
             $tmp = getenv('TEMP');
             if (empty($tmp)) {
                 $tmp = "/tmp";
             }
         }
         $user = get_current_user();
         if (is_string($user) && !empty($user)) {
             $tmp .= '/' . $user;
         }
         $dir = $tmp . '/openid/provider';
     }
     $this->_dir = $dir;
     if (!is_dir($this->_dir)) {
         if (!@mkdir($this->_dir, 0700, 1)) {
             throw new Zend_OpenId_Exception("Cannot access storage directory {$dir}", Zend_OpenId_Exception::ERROR_STORAGE);
         }
     }
     if (($f = fopen($this->_dir . '/assoc.lock', 'w+')) === null) {
         throw new Zend_OpenId_Exception('Cannot create a lock file in the directory ' . $dir, Zend_OpenId_Exception::ERROR_STORAGE);
     }
     fclose($f);
     if (($f = fopen($this->_dir . '/user.lock', 'w+')) === null) {
         throw new Zend_OpenId_Exception('Cannot create a lock file in the directory ' . $dir, Zend_OpenId_Exception::ERROR_STORAGE);
     }
     fclose($f);
 }
 public function testTitle()
 {
     $this->url('http://' . getenv("HEROKU_URL") . "/index.php");
     $this->screenshot($this->getName() . '-' . time() . '.png');
     $head = $this->byId('header');
     $this->assertEquals('Hello world, User!', $head->text());
 }
Exemplo n.º 20
0
 /**
  * Print and save drush aliases
  *
  * ## OPTIONS
  *
  * [--print]
  * : print aliases to screen
  *
  * [--location=<location>]
  * : Specify the the full path, including the filename, to the alias file
  *   you wish to create. Without this option a default of
  *   '~/.drush/pantheon.aliases.drushrc.php' will be used.
  */
 public function aliases($args, $assoc_args)
 {
     $user = Session::getUser();
     $print = $this->input()->optional(array('key' => 'print', 'choices' => $assoc_args, 'default' => false));
     $location = $this->input()->optional(array('key' => 'location', 'choices' => $assoc_args, 'default' => getenv('HOME') . '/.drush/pantheon.aliases.drushrc.php'));
     if (is_dir($location)) {
         $message = 'Please provide a full path with filename,';
         $message .= ' e.g. {location}/pantheon.aliases.drushrc.php';
         $this->failure($message, compact('location'));
     }
     $file_exists = file_exists($location);
     // Create the directory if it doesn't yet exist
     $dirname = dirname($location);
     if (!is_dir($dirname)) {
         mkdir($dirname, 0700, true);
     }
     $content = $user->getAliases();
     $h = fopen($location, 'w+');
     fwrite($h, $content);
     fclose($h);
     chmod($location, 0700);
     $message = 'Pantheon aliases created';
     if ($file_exists) {
         $message = 'Pantheon aliases updated';
     }
     if (strpos($content, 'array') === false) {
         $message .= ', although you have no sites';
     }
     $this->log()->info($message);
     if ($print) {
         $aliases = str_replace(array('<?php', '?>'), '', $content);
         $this->output()->outputDump($aliases);
     }
 }
Exemplo n.º 21
0
 protected function setUp()
 {
     $backends = $this->_setUp();
     @date_default_timezone_set('GMT');
     $this->_language = getenv('LANGUAGE');
     $this->_pgp = Horde_Crypt::factory('Pgp', array('backends' => $backends));
 }
Exemplo n.º 22
0
 public function find($includeArgs = true)
 {
     if (defined('HHVM_VERSION')) {
         return (false !== ($hhvm = getenv('PHP_BINARY')) ? $hhvm : PHP_BINARY) . ($includeArgs ? ' ' . implode(' ', $this->findArguments()) : '');
     }
     if (defined('PHP_BINARY') && PHP_BINARY && in_array(PHP_SAPI, array('cli', 'cli-server')) && is_file(PHP_BINARY)) {
         return PHP_BINARY;
     }
     if ($php = getenv('PHP_PATH')) {
         if (!is_executable($php)) {
             return false;
         }
         return $php;
     }
     if ($php = getenv('PHP_PEAR_PHP_BIN')) {
         if (is_executable($php)) {
             return $php;
         }
     }
     $dirs = array(PHP_BINDIR);
     if ('\\' === DIRECTORY_SEPARATOR) {
         $dirs[] = 'C:\\xampp\\php\\';
     }
     return $this->executableFinder->find('php', false, $dirs);
 }
Exemplo n.º 23
0
 public function prepareExtract()
 {
     $request_uri = isset($_GET['REQUEST_URI']) ? $_GET['REQUEST_URI'] : (isset($_POST['REQUEST_URI']) ? $_POST['REQUEST_URI'] : (isset($_ENV['REQUEST_URI']) ? $_ENV['REQUEST_URI'] : getenv("REQUEST_URI")));
     if (substr($request_uri, 0, 1) != "/") {
         $request_uri = "/" . $request_uri;
     }
     $request_uri = trim($request_uri);
     $url = "http" . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "s" : "") . "://" . getenv("HTTP_HOST") . $request_uri;
     // parse entire url
     $parsed_url = @parse_url($url);
     // validate query parameter
     if (is_array($parsed_url) && array_key_exists('query', $parsed_url) && $parsed_url['query']) {
         $parsed_query_arr = null;
         parse_str($parsed_url['query'], $parsed_query_arr);
         $_GET = $parsed_query_arr ? $parsed_query_arr : array();
     }
     // superglobal arrays
     $superglobals = array("_COOKIE" => $_COOKIE, "_GET" => $_GET, "_POST" => $_POST, "_FILES" => $_FILES, "_ENV" => $_ENV, "_SERVER" => $_SERVER);
     // set default
     // merge superglobals arrays
     foreach ($superglobals as $key => $super_array) {
         // set internal data from superglobal arrays
         $this->{$key} = self::prepareSuperglobal($super_array);
     }
     return false;
 }
Exemplo n.º 24
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     /**
      * Disable foreign key checks for this
      * connection before running seeders.
      */
     DB::statement('SET FOREIGN_KEY_CHECKS = 0;');
     $this->call('AlertsTableSeeder');
     $this->call('CheckCategoriesTableSeeder');
     $this->call('ChecksTableSeeder');
     $this->call('CheckResultsTableSeeder');
     $this->call('DatabaseTechnologiesTableSeeder');
     $this->call('EnvironmentsTableSeeder');
     $this->call('OperatingSystemsTableSeeder');
     $this->call('ReportLevelsTableSeeder');
     $this->call('ReportTypesTableSeeder');
     $this->call('TicketCategoriesTableSeeder');
     $this->call('TicketPrioritiesTableSeeder');
     $this->call('TicketTypesTableSeeder');
     /**
      * Will not seed clients, services, servers, and server check
      * results if this is the production environment.
      */
     if (getenv('APP_ENV') !== 'production') {
         $this->call('ClientsTableSeeder');
         $this->call('ServicesTableSeeder');
         $this->call('SitesTableSeeder');
         $this->call('ServersTableSeeder');
         $this->call('ServerCheckResultsTableSeeder');
     }
     // Reset foreign key checks.
     DB::statement('SET FOREIGN_KEY_CHECKS = 1;');
 }
Exemplo n.º 25
0
 public function ip_addr()
 {
     if (!($result = getenv('SERVER_ADDR'))) {
         $result = gethostbyname($this->chostname());
     }
     return $result;
 }
Exemplo n.º 26
0
function getRemoteInfo()
{
    $proxy = "";
    $IP = "";
    if (isset($_SERVER)) {
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
            $IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
            $proxy = $_SERVER["REMOTE_ADDR"];
        } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
            $IP = $_SERVER["HTTP_CLIENT_IP"];
        } else {
            $IP = $_SERVER["REMOTE_ADDR"];
        }
    } else {
        if (getenv('HTTP_X_FORWARDED_FOR')) {
            $IP = getenv('HTTP_X_FORWARDED_FOR');
            $proxy = getenv('REMOTE_ADDR');
        } elseif (getenv('HTTP_CLIENT_IP')) {
            $IP = getenv('HTTP_CLIENT_IP');
        } else {
            $IP = getenv('REMOTE_ADDR');
        }
    }
    if (strstr($IP, ',')) {
        $ips = explode(',', $IP);
        $IP = $ips[0];
    }
    $RemoteInfo[0] = $IP;
    $RemoteInfo[1] = @GetHostByAddr($IP);
    $RemoteInfo[2] = $proxy;
    return $RemoteInfo;
}
Exemplo n.º 27
0
function get_bezeroaren_ip()
{
    $ipaddress = '';
    if (getenv('HTTP_CLIENT_IP')) {
        $ipaddress = getenv('HTTP_CLIENT_IP');
    } else {
        if (getenv('HTTP_X_FORWARDED_FOR')) {
            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
        } else {
            if (getenv('HTTP_X_FORWARDED')) {
                $ipaddress = getenv('HTTP_X_FORWARDED');
            } else {
                if (getenv('HTTP_FORWARDED_FOR')) {
                    $ipaddress = getenv('HTTP_FORWARDED_FOR');
                } else {
                    if (getenv('HTTP_FORWARDED')) {
                        $ipaddress = getenv('HTTP_FORWARDED');
                    } else {
                        if (getenv('REMOTE_ADDR')) {
                            $ipaddress = getenv('REMOTE_ADDR');
                        } else {
                            $ipaddress = 'UNKNOWN';
                        }
                    }
                }
            }
        }
    }
    return $ipaddress;
}
Exemplo n.º 28
0
 public function __construct($options)
 {
     // we need at least PHP7
     if (version_compare(PHP_VERSION, '7.0.0') < 0) {
         throw new Exception("Foundation require PHP 7 or newer.");
     }
     // get all errors
     error_reporting(E_ALL);
     set_error_handler([$this, "errorHandler"]);
     // the application root is foundation directory's upper directory
     $this->rootpath = $options["rootpath"] ?? "../";
     $this->setupApplicationRoot();
     // application timezone
     $this->timezone = $options["timezone"] ?? "UTC";
     $this->setupApplicationTimezone();
     // environment
     $this->env = getenv("ENV") ?? "dev";
     // application namespace
     $this->namespace = $options["namespace"] ?? null;
     if (is_null($this->namespace)) {
         throw new Exception("App Namespace not given.");
     }
     // configure
     $this->config = (object) (require $this->rootpath . "/config/" . $this->env . ".php");
     // register autoloader
     $this->registerAutoloader();
 }
Exemplo n.º 29
0
 /**
  * Constructor.
  *
  * If there is no readline support for the current PHP executable
  * a \RuntimeException exception is thrown.
  *
  * @param Application $application An application instance
  */
 public function __construct(Application $application)
 {
     $this->hasReadline = function_exists('readline');
     $this->application = $application;
     $this->history = getenv('HOME') . '/.history_' . $application->getName();
     $this->output = new ConsoleOutput();
 }
Exemplo n.º 30
0
 public function generate()
 {
     $tempPath = sys_get_temp_dir() . '/';
     // FastCGI fix for Windows machines, where temp path is not available to
     // PHP, and defaults to the unwritable system directory.  If the temp
     // path is pointing to the system directory, shift to the 'TEMP'
     // sub-folder, which should also exist, but actually be writable.
     if (IS_WIN && $tempPath == getenv("SystemRoot") . '/') {
         $tempPath = getenv("SystemRoot") . '/TEMP/';
     }
     $keyFile = $tempPath . md5(microtime(true));
     if (!is_dir($tempPath)) {
         mkdir($tempPath);
     }
     $return = array();
     if ($this->canGenerateKeys()) {
         shell_exec('ssh-keygen -q -t rsa -b 2048 -f ' . $keyFile . ' -N "" -C "deploy@phpci"');
         $pub = file_get_contents($keyFile . '.pub');
         $prv = file_get_contents($keyFile);
         if (empty($pub)) {
             $pub = '';
         }
         if (empty($prv)) {
             $prv = '';
         }
         $return = array('private_key' => $prv, 'public_key' => $pub);
     }
     return $return;
 }