Ejemplo n.º 1
0
 function getSyncClass($master, $syncserver, $class)
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$login) {
         return;
     }
     if (isLocalhost($master)) {
         $master = 'localhost';
     }
     if ($login->isSuperadmin() && $master === 'localhost') {
         return null;
     }
     if (isLocalhost($syncserver)) {
         $syncserver = 'localhost';
     }
     //Dynamically load the syncserver info....
     if (!isset($this->driver) || !isset($this->driver[$master])) {
         $this->loaddriverappInfo($master);
     }
     if (!isset($this->driver[$master][$syncserver])) {
         $this->loaddriverappInfo($master);
     }
     $class_var = strtolower("pg_" . $class);
     //debugBacktrace();
     $pgm = $this->driver[$master][$syncserver]->driver_b;
     if (isset($pgm->{$class_var})) {
         $str = $pgm->{$class_var};
         if (csb($str, "__v_")) {
             $class_var = "pg_" . strtolower(strfrom($str, "__v_"));
         }
         return $pgm->{$class_var};
     }
     return null;
 }
Ejemplo n.º 2
0
 static function initThisObject($parent, $class, $name = null)
 {
     global $gbl, $sgbl, $login, $ghtml;
     $driverapp = $gbl->getSyncClass(null, null, 'fake');
     if (isLocalhost($parent->__masterserver)) {
         $master = 'localhost';
     } else {
         $master = $parent->__masterserver;
     }
     $sync = $gbl->driver[$master][$parent->syncserver];
     return $sync;
 }
Ejemplo n.º 3
0
 /**
  * Insert $lang to use in a View & include tracking code.
  */
 private function processSmartyView($v)
 {
     global $app_i, $lang;
     $viewDir = currentViewDir();
     $v->assign('lang', $lang[$viewDir]);
     if (!isLocalhost() && file_exists(BASEVIEW . '/' . $viewDir . '/tracking_code.html')) {
         $v->assign('inc_tracking_code', 'file:' . BASEVIEW . '/' . $viewDir . '/tracking_code.html');
         // abs path so Extensions find it too.
     } else {
         $v->assign('inc_tracking_code', 'file:' . BASEVIEW . '/blank.html');
     }
 }
Ejemplo n.º 4
0
<?php

// Uncomment to enable debug logging locally.
//ini_set('error_log', '/tmp/php_errors.log');
// Some global settings.
date_default_timezone_set('UTC');
// Provides access to app specific values such as your app id and app secret.
// Defined in 'AppInfo.php'
require_once dirname(__FILE__) . '/../AppInfo.php';
// This provides access to helper functions defined in 'utils.php'
require_once dirname(__FILE__) . '/../utils.php';
// Enforce https on production
if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && !isLocalhost()) {
    header('Location: https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit;
}
// Load the Facebook PHP SDK
require_once 'facebook/src/facebook.php';
// Load our own libraries.
require 'pat-fb/PATFacebookUser.class.php';
require 'pat-fb/PATIncident.class.php';
require 'pat-fb/template_functions.inc.php';
$FB = new Facebook(array('appId' => AppInfo::appID(), 'secret' => AppInfo::appSecret(), 'trustForwarded' => true));
$user_id = $FB->getUser();
if ($user_id) {
    try {
        // Fetch the viewer's basic information
        $me = new PATFacebookUser($FB);
        $me->loadFriends('id,name,gender,picture.type(square),bio,installed');
        $my_prefs = $me->getPreferences();
        date_default_timezone_set($my_prefs['user_timezone_name']);
Ejemplo n.º 5
0
function send_to_some_stream_server($type, $size, $raddress, $var, $fd)
{
    global $gbl, $sgbl, $login, $ghtml;
    $exitchar = $sgbl->__var_exit_char;
    $remotechar = $sgbl->__var_remote_char;
    $con = $sgbl->__var_connection_type;
    if ($raddress === "localhost") {
        $con = "tcp";
        $port = $sgbl->__var_local_port;
    } else {
        $con = "ssl";
        $port = $sgbl->__var_remote_port;
    }
    print_time('server');
    print_time('serverstart');
    $rraddress = $raddress;
    if (isLocalhost($raddress)) {
        $rraddress = "127.0.0.1";
    }
    $socket = stream_socket_client("{$con}://{$rraddress}:{$port}");
    //$socket =  fsockopen("$con://$raddress", $port);
    print_time('serverstart', "Fsockopen");
    if ($socket <= 0) {
        if ($raddress === 'localhost' && !WindowsOs() && !$sgbl->isDebug()) {
            //20140131 OA: dont reenable this, Ive just removed.
            //lxshell_background("/usr/sbin/lxrestart", $sgbl->__var_program_name);
            throw new lxException('no_socket_connect_to_server', '', $raddress);
            throw new lxException('restarting_backend', '', $raddress);
        } else {
            throw new lxException('no_socket_connect_to_server', '', $raddress);
        }
    }
    stream_set_timeout($socket, 30000000000);
    //stream_context_set_option($socket, 'ssl', 'allow_self_signed', true);
    //stream_context_set_option($socket, 'ssl', 'verify_peer', false);
    $in = $var;
    fwrite($socket, $in);
    $in = "\n";
    fwrite($socket, $in);
    $in = $exitchar;
    fwrite($socket, $in);
    $in = "\n";
    fwrite($socket, $in);
    $totalout = null;
    $totalsize = 0;
    while (true) {
        $out = fgets($socket, 8092);
        if (!$out) {
            if (!$totalout) {
                dprint("Got Nothing\n");
            }
            break;
        }
        if ($type === 'fileprint' || $type === 'file') {
            // The stream comes with a first and last character appended to it.
            if ($totalsize === 0 && $out[0] === 'f') {
                log_log("servfile", "Got failure from the servfile {$out}");
                break;
            }
            if ($totalsize === 0) {
                $out = substr($out, 1);
            }
            $totalsize += strlen($out);
            if ($totalsize >= $size + 1) {
                $out = substr($out, 0, strlen($out) - 1);
            }
            print_or_write($fd, $out);
            if ($totalsize >= $size + 1) {
                break;
            }
        } else {
            //$out = trim($out);
            $totalout .= $out;
            if (csa($totalout, $exitchar)) {
                break;
            }
        }
    }
    fclose($socket);
    if ($type === 'file' || $type === 'fileprint') {
        return $totalsize;
    }
    if (!$totalout) {
        return null;
    }
    dprint("Got this much:" . strlen($totalout));
    //dprint($totalout);
    $totalout = trim($totalout);
    $size = round(strlen($totalout) / 1024, 4);
    //dprint($totalout);
    //$ee = unserialize(base64_decode($totalout));
    return $totalout;
}
Ejemplo n.º 6
0
function getOneIPForLocalhost($v)
{
    if (isLocalhost($v)) {
        return 'localhost';
    }
    if (is_secondary_master()) {
        $list = os_get_allips();
        $ip = getFirstFromList($list);
        return $ip;
    }
    return getFQDNforServer('localhost');
}
Ejemplo n.º 7
0
 *
 * @author      Mirko Pagliai <*****@*****.**>
 * @copyright   Copyright (c) 2016, Mirko Pagliai for Nova Atlantis Ltd
 * @license     http://www.gnu.org/licenses/agpl.txt AGPL License
 * @link        http://git.novatlantis.it Nova Atlantis Ltd
 */
/**
 * (here `Cake\Core\Plugin` is used, as the plugins are not yet all loaded)
 */
use Cake\Core\Plugin;
use Cake\Routing\DispatcherFactory;
/**
 * Requires the base of bootstrap
 */
require_once __DIR__ . DS . 'bootstrap_base.php';
/**
 * Loads DebugKit on localhost, if required
 */
if (isLocalhost() && config('main.debug_on_localhost') && !config('debug') && !Plugin::loaded('DebugKit')) {
    Plugin::load('DebugKit', ['bootstrap' => true]);
}
/**
 * Loads other plugins
 */
Plugin::load('Thumber', ['bootstrap' => true, 'routes' => true]);
Plugin::load('Tokens', ['bootstrap' => true]);
Plugin::load('MysqlBackup', ['bootstrap' => true]);
Plugin::load('WyriHaximus/MinifyHtml', ['bootstrap' => true]);
Plugin::load('Gourmet/CommonMark');
//CakePHP will automatically set the locale based on the current user
DispatcherFactory::add('LocaleSelector');
Ejemplo n.º 8
0
 public function district_get()
 {
     $url = HOST . "/classes/District?include=city&";
     $json = $this->jsonWithGETUrl($url);
     $error = checkResponseError($json);
     if (!empty($error)) {
         return $error;
     }
     $results = resultsWithJson($json);
     foreach ($results as $result) {
         $array[] = array_slice_keys($result, array('title', 'objectId'));
     }
     if (!isLocalhost()) {
         $this->output->cache(CacheTime);
     }
     return $this->outputArray($array);
 }
Ejemplo n.º 9
0
 function restoreMeUpThere($oldserver, $backupfilepass)
 {
     $this->setUpdateSubaction('top_level_network_restore');
     $this->createExtraVariables();
     if (isLocalhost($oldserver) && !isLocalhost($this->getDataServer())) {
         $oldserver = getOneIPForLocalhost($this->getDataServer());
     }
     $this->__var_machine = $oldserver;
     $this->__var_backupfilepass = $backupfilepass;
     $res = rl_exec_set(null, $this->getDataServer(), $this);
 }
Ejemplo n.º 10
0
 /**
  * 
  * 返回总店的所有分店信息
  * param: parentId
  */
 public function shopbranches_get()
 {
     $url = HOST . "/classes/Shop?";
     $parentId = $this->get('parentId');
     if (empty($parentId)) {
         outputError(-1, '没有总店信息');
     }
     $where = array('parent' => avosPointer('Shop', $parentId));
     $url .= 'where=' . json_encode($where);
     $json = $this->kq->get($url);
     $error = checkResponseError($json);
     if (!empty($error)) {
         return $error;
     }
     $results = resultsWithJson($json);
     foreach ($results as $result) {
         $array[] = array_slice_keys($result, array('title', 'objectId', 'phone', 'address', 'openTime', 'location'));
     }
     if (!isLocalhost()) {
         $this->output->cache(CacheTime);
     }
     return $this->output_results($array);
 }
Ejemplo n.º 11
0
 * Adds `is('banned')` detector.
 *
 * It checks if the user's IP address is banned.
 *
 * Example:
 * <code>
 * $this->request->isBanned();
 * </code>
 */
Request::addDetector('banned', function ($request) {
    $banned = config('Banned');
    //The IP address is allowed if:
    //  - the list of banned IP is empty;
    //  - is localhost;
    //  - the IP address has already been verified.
    if (!$banned || isLocalhost() || $request->session()->read('allowed_ip')) {
        return false;
    }
    //Replaces asteriskes
    $banned = preg_replace('/\\\\\\*/', '[0-9]{1,3}', array_map('preg_quote', (array) $banned));
    if (preg_match(sprintf('/^(%s)$/', implode('|', $banned)), $request->clientIp())) {
        return true;
    }
    //In any other case, saves the result in the session
    $request->session()->write('allowed_ip', true);
    return false;
});
/**
 * Adds `is('offline')` detector.
 *
 * It checks if the site is offline.
Ejemplo n.º 12
0
}
if (!folderIsWriteable(PHOTOS)) {
    throw new InternalErrorException(sprintf('File or directory %s not writeable', PHOTOS));
}
/**
 * Loads the MeCms configuration
 */
Configure::load('MeCms.me_cms');
//Merges with the configuration from application, if exists
if (is_readable(CONFIG . 'me_cms.php')) {
    Configure::load('me_cms');
}
/**
 * Forces debug on localhost, if required
 */
if (isLocalhost() && config('main.debug_on_localhost') && !config('debug')) {
    Configure::write('debug', true);
}
/**
 * Loads theme plugin
 */
$theme = config('default.theme');
if ($theme && !Plugin::loaded($theme)) {
    Plugin::load($theme);
}
/**
 * Loads the cache configuration
 */
Configure::load('MeCms.cache');
//Merges with the configuration from application, if exists
if (is_readable(CONFIG . 'cache.php')) {
Ejemplo n.º 13
0
    ?>
&do=model-list">Model List</a>
                <a class="btn btn-secondary" href="<?php 
    echo $url;
    ?>
&do=entity-list">Entity List</a>
                <a class="btn btn-secondary" href="<?php 
    echo $url;
    ?>
&do=file-upload-test">File Upload Test</a>
                <a class="btn btn-secondary" href="/?module=overframe&action=point_event">포인트 이벤트</a>
            <?php 
}
?>
            <?php 
if (isLocalhost() || banner()->hasAccess()) {
    ?>
                <a class="btn btn-secondary" href="<?php 
    echo $url;
    ?>
&do=philgo-banner">배너</a>
            <?php 
}
?>

    </nav>

    <div class="of-content jumbotron">
        <?php 
switch (http_input('do')) {
    case 'test':
Ejemplo n.º 14
0
 /**
  * Create a script block for Google Analytics
  * @param string $id Analytics ID
  * @uses MeTools\View\Helper\HtmlHelper::scriptBlock()
  * @return mixed|null Html code or null if is localhost
  */
 public function analytics($id)
 {
     if (isLocalhost()) {
         return;
     }
     return $this->Html->scriptBlock(sprintf('!function(e,a,t,n,c,o,s){e.GoogleAnalyticsObject=c,e[c]=e[c]||function(){(e[c].q=e[c].q||[]).push(arguments)},e[c].l=1*new Date,o=a.createElement(t),s=a.getElementsByTagName(t)[0],o.async=1,o.src=n,s.parentNode.insertBefore(o,s)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create","%s","auto"),ga("send","pageview");', $id), ['block' => 'script_bottom']);
 }