Ejemplo n.º 1
0
 public function __construct($r = null, $t = null, $c = null)
 {
     $this->uri = $_SERVER['REQUEST_URI'];
     $this->path = parse_url($this->uri, PHP_URL_PATH);
     // set up basic delegation concepts (via params or htaccess)
     $this->container = presto_lib::_get('c', $c);
     $this->route = presto_lib::_get('r', $r);
     $this->type = presto_lib::_c(presto_lib::_get('t', $t), 'json');
     $params = $this->params();
     if (!array_key_exists('r', $_GET) || !array_key_exists('t', $_GET) || !array_key_exists('c', $_GET)) {
         presto_lib::_trace("Rewrite delegation setup for {$this->uri} is missing.", json_encode($_GET));
     }
     unset($_GET['t']);
     unset($_GET['r']);
     unset($_GET['c']);
     // pop routing parameters
     // setup request parameters
     $this->method = strtolower($_SERVER['REQUEST_METHOD']);
     $this->action = presto_lib::_c($this->method, 'get');
     // default to GET
     $this->host = $_SERVER['HTTP_HOST'];
     $this->referer = _server('HTTP_REFERER', '');
     $this->refererPath = parse_url($this->referer, PHP_URL_PATH);
     $this->service = strstr($this->host, '.', -1);
     $this->tld = pathinfo($this->host, PATHINFO_EXTENSION);
     $this->scheme = _server_has('HTTPS', 'on') || _server_has('HTTP_X_FORWARDED_PROTO', 'https') || _server_has('HTTP_X_FORWARDED_SSL', 'on') ? 'https' : 'http';
     $this->options = $_GET;
     $_GET = array();
     // discourage use of $_GET
 }
Ejemplo n.º 2
0
function printHeader($filename, $type)
{
    $mime = getImageType($filename);
    if ($type == "view") {
        header("Content-type: {$mime}");
        header("Content-Transfer-Encoding: binary\n");
        header("Expires: 0");
        //header('Content-length: '.sizeOf($imgcode));
    } elseif ($type == "download") {
        if (strpos(_server('HTTP_USER_AGENT'), "MSIE") !== FALSE) {
            header("Content-type: {$mime}");
            header("Content-Disposition: attachment; filename={$filename}");
            header("Expires: 0");
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header("Content-Transfer-Encoding: binary");
            header('Pragma: public');
            //header("Content-Length: ".strlen($data));
        } else {
            header("Content-type: {$mime}");
            header("Content-Disposition: attachment; filename={$filename}");
            header("Content-Transfer-Encoding: binary");
            header("Expires: 0");
            header('Pragma: no-cache');
            //header("Content-Length: ".strlen($data));
        }
    }
}
Ejemplo n.º 3
0
 function transferFileHTTPToLocal($src, $dest = "", $autoExtension = false)
 {
     if (strlen($dest) <= 0) {
         $dest = ROOT . CACHE_FOLDER;
     }
     if (strpos($src, "http://") != 0 && strpos($src, "https://") != 0) {
         return false;
     }
     $fpath = $dest;
     if ($autoExtension) {
         $arr = explode("/", $src);
         $ext = $arr[sizeOf($arr) - 1];
         $fpath = $dest . $ext;
     }
     if (!function_exists('curl_init')) {
         //Use File_get_contents
         $fh1 = fopen($src, "rb");
         if ($fh1) {
             $fh = fopen($fpath, "w");
             if ($fh) {
                 while (!feof($fh1)) {
                     $contents = fread($fh1, 8192);
                     fwrite($fh, $contents);
                 }
                 return $fpath;
             } else {
                 return false;
             }
         }
         return false;
     } else {
         //Use CURL
         $site = SiteLocation . _server("SCRIPT_NAME");
         $site = str_replace("http://", "h1", $site);
         $site = str_replace("https://", "h2", $site);
         $site = str_replace("//", "/", $site);
         $site = str_replace("h1", "http://", $site);
         $site = str_replace("h2", "https://", $site);
         $ch = curl_init();
         // Set URL to download
         curl_setopt($ch, CURLOPT_URL, $src);
         // Set a referer
         curl_setopt($ch, CURLOPT_REFERER, $site);
         // User agent
         curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
         // Include header in result? (0 = yes, 1 = no)
         curl_setopt($ch, CURLOPT_HEADER, 0);
         // Should cURL return or print out the data? (true = return, false = print)
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         // Timeout in seconds
         curl_setopt($ch, CURLOPT_TIMEOUT, 100);
         // Download the given URL, and return output
         $data = curl_exec($ch);
         // Close the cURL resource, and free system resources
         curl_close($ch);
         file_put_contents($fpath, $data);
         return $fpath;
     }
     return false;
 }
Ejemplo n.º 4
0
 function forceDownloadData($data = '', $extension = "*", $filename = "download")
 {
     include ROOT . 'config/mimes.php';
     $mime = getMimeTypeFor($extension);
     if ($extension == "*") {
         $extension = "";
     }
     if (!(substr($filename, strlen($filename) - strlen($extension)) == $extension)) {
         $filename .= "." . $extension;
     }
     if (strpos(_server('HTTP_USER_AGENT'), "MSIE") !== FALSE) {
         header('Content-Type: "' . $mime . '"');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header("Content-Transfer-Encoding: binary");
         header('Pragma: public');
         header("Content-Length: " . strlen($data));
     } else {
         header('Content-Type: "' . $mime . '"');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header("Content-Transfer-Encoding: binary");
         header('Expires: 0');
         header('Pragma: no-cache');
         header("Content-Length: " . strlen($data));
     }
     exit($data);
 }
Ejemplo n.º 5
0
function doFilter()
{
    $file = _server("SCRIPT_NAME");
    $uri = _server("REQUEST_URI");
    $ip = _server("REMOTE_ADDR");
    $method = _server("REQUEST_METHOD");
    $agent = _server("HTTP_USER_AGENT");
    $post = json_encode($_POST);
    $dt = date("H:i:s");
    $msg = "{$dt} {$method} {$uri} {$ip}";
    if (strlen($post) > 2) {
        $msg .= " {$post}";
    }
    $msg .= "\r\n";
    $path = getRoot() . "/myfolder/log/filter_" . date("Ymd") . ".log";
    $handle = fopen($path, "a");
    fwrite($handle, $msg);
    fclose($handle);
    $path = getRoot() . "/myfolder/log/register_" . date("Ymd") . ".log";
    if ($file == "/registerAuth.php" && file_exists($path)) {
        $handle = fopen($path, "r");
        $count = 0;
        while ($line = fgets($handle)) {
            if (strlen($line) > 2) {
                $count++;
            }
        }
        fclose($handle);
        if ($count > 10) {
            header("content-type:text/json;charset=utf-8");
            echo '{"result":false,"msg":"用户注册量异常,注册功能暂不可用"}';
            exit;
        }
    }
}
 public function authorize()
 {
     if (!User::is_login()) {
         $this->flash->add('message_error', '로그 인이 필요합니다.');
         $this->redirect_to('/user/login_form?return_url=' . _server('REQUEST_URI'));
     }
 }
Ejemplo n.º 7
0
function __log($user)
{
    $path = getRoot() . "/myfolder/log/register_" . date("Ymd") . ".log";
    $handle = fopen($path, "a");
    $msg = date("H:i:s") . " " . _server("REMOTE_ADDR") . " {$user}\r\n";
    fwrite($handle, $msg);
    fclose($handle);
}
Ejemplo n.º 8
0
 public function back()
 {
     $http_referer = _server('HTTP_REFERER');
     if (!empty($http_referer)) {
         $this->redirect_to($http_referer);
     }
     echo '<script type="text/javascript">history.back();</script>';
     $this->skip();
 }
Ejemplo n.º 9
0
 function getBasePath()
 {
     if (_server('PATH_INFO')) {
         $file = _server('PATH_INFO');
         return getRelativePath($file);
     } else {
         return "";
     }
 }
Ejemplo n.º 10
0
 function _log($logMsg, $logkey = "activity", $logLevel = null, $logData = array())
 {
     if ($logLevel == null) {
         $logLevel = LogiksLogger::LOG_WARNING;
     }
     if (_server('REQUEST_TIME_FLOAT')) {
         $logData['time'] = microtime(true) - _server('REQUEST_TIME_FLOAT');
     } elseif (_server('REQUEST_PAGE_START')) {
         $logData['time'] = microtime(true) - _server('REQUEST_PAGE_START');
     } elseif (_server('REQUEST_SERVICE_START')) {
         $logData['time'] = microtime(true) - _server('REQUEST_SERVICE_START');
     }
     LogiksLogger::log($logkey, $logLevel, $logMsg, $logData);
 }
Ejemplo n.º 11
0
 function __closeDevMode()
 {
     if (defined("DEV_MODE_IP") && strlen(DEV_MODE_IP) > 0) {
         $addr = explode(",", DEV_MODE_IP);
         if (count($addr) > 0) {
             if (is_array($addr)) {
                 if (!in_array(_server("REMOTE_ADDR"), $addr)) {
                     ob_end_clean();
                 } else {
                     ob_end_flush();
                 }
             } else {
                 if (_server("REMOTE_ADDR") != $addr) {
                     ob_end_clean();
                 } else {
                     ob_end_flush();
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 function checkBrowser()
 {
     if (!_server('HTTP_USER_AGENT')) {
         return array("browser" => "", "version" => "", "platform" => "", "userAgent" => "");
     }
     $browsers = "mozilla msie gecko firefox ";
     $browsers .= "konqueror safari netscape navigator ";
     $browsers .= "opera mosaic lynx amaya omniweb chrome";
     $browsers = explode(" ", $browsers);
     $userAgent = strtolower(_server('HTTP_USER_AGENT'));
     $l = count($browsers);
     for ($i = 0; $i < $l; $i++) {
         $browser = $browsers[$i];
         $n = stristr($userAgent, $browser);
         if (strlen($n) > 0) {
             $version = "";
             $navigator = $browser;
             $j = strpos($userAgent, $navigator) + $n + strlen($navigator) + 1;
             for (; $j <= strlen($userAgent); $j++) {
                 $s = substr($userAgent, $j, 1);
                 if (is_numeric($version . $s)) {
                     $version .= $s;
                 } else {
                     break;
                 }
             }
         }
     }
     if (strpos($userAgent, 'linux')) {
         $platform = 'linux';
     } elseif (strpos($userAgent, 'macintosh') || strpos($userAgent, 'mac platform x')) {
         $platform = 'mac';
     } elseif (strpos($userAgent, 'windows') || strpos($userAgent, 'win32')) {
         $platform = 'windows';
     }
     return array("browser" => $navigator, "version" => $version, "platform" => $platform, "userAgent" => $userAgent);
 }
Ejemplo n.º 13
0
			alert('로그 인이 필요합니다.');
			$('#comment_textarea').val('');
			location.href="/user/login_form?return_url=<?php 
    echo _server('REQUEST_URI');
    ?>
";
		<?php 
}
?>
	});
	$('#submit_comment').click(function() {
		<?php 
if (User::is_login()) {
    ?>
			$('#blog_comment_form').submit();
		<?php 
} else {
    ?>
			alert('로그 인이 필요합니다.');
			location.href="/user/login_form?return_url=<?php 
    echo _server('REQUEST_URI');
    ?>
";
		<?php 
}
?>
	});
});
</script>

Ejemplo n.º 14
0
<?php

if (!defined('ROOT')) {
    exit('No direct script access allowed');
}
if (MASTER_DEBUG_MODE && !defined("SERVICE_ROOT") && !defined("TEST_ROOT") && isset($_GET['debug']) && $_GET['debug'] == "true") {
    if (_server("REQUEST_TIME_FLOAT")) {
        //Use server's inbuilt time
        echo "<div style='position:fixed;right:0px;bottom:0px;padding:5px;background:maroon;color:white;z-index:99999999999999999;'>DT:" . (microtime(true) - _server("REQUEST_TIME_FLOAT")) . " secs</div>";
    } else {
        echo "<div style='position:fixed;right:0px;bottom:0px;padding:5px;background:maroon;color:white;z-index:99999999999999999;'>DT:" . (microtime(true) - _server('REQUEST_PAGE_START')) . " secs</div>";
    }
}
Ejemplo n.º 15
0
 function getSysHash()
 {
     return md5(session_id() . _server('REMOTE_ADDR'));
 }
Ejemplo n.º 16
0
 public function __construct()
 {
     if (!_server('HTTP_USER_AGENT')) {
         _envData("SERVER", 'HTTP_USER_AGENT', "Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19");
     }
     $this->userAgent = _server('HTTP_USER_AGENT');
     //$this->userAgent = "(iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML  like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5,CGI/1.1,HTTP/1.0,GET,219.91.184.34";
     if (_server('HTTP_ACCEPT')) {
         $this->accept = _server('HTTP_ACCEPT');
     } else {
         $this->accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
     }
     if (_server('HTTP_X_WAP_PROFILE') || _server('HTTP_PROFILE')) {
         $this->isMobile = true;
     } elseif (strpos($this->accept, 'text/vnd.wap.wml') > 0 || strpos($this->accept, 'application/vnd.wap.xhtml+xml') > 0) {
         $this->isMobile = true;
     } else {
         foreach ($this->devices as $device => $regexp) {
             if ($this->isDevice($device)) {
                 $this->isMobile = true;
             }
         }
     }
     if ($this->isBlackberrytablet()) {
         $this->isTablet = true;
         $this->isMobile = false;
     } elseif ($this->isAndroidtablet()) {
         $this->isTablet = true;
         $this->isMobile = false;
     } elseif ($this->isIpad()) {
         $this->isTablet = true;
         $this->isMobile = false;
     }
 }
Ejemplo n.º 17
0
//header('P3P: CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
//header('P3P: CP="ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC"');
session_start();
// init flash
$flash = Context::get('flash');
$flash->load();
// routing
Log::debug(_server('REQUEST_METHOD') . ' ' . _server('PATH_INFO'));
// make contents
ob_start();
try {
    /**
     * @see Controller.forward_to()
     */
    // parse path
    $path = parse_url_path(_server('PATH_INFO'));
    if (empty($path[1])) {
        $path[1] = Config::get('default_controller');
    }
    if (empty($path[2])) {
        $path[2] = Config::get('default_action');
    }
    $controller_path = $path[1];
    $action_path = $path[2];
    if (file_exists(Config::get('help_dir') . '/' . $controller_path . '.php')) {
        require_once Config::get('help_dir') . '/' . $controller_path . '.php';
    }
    $controller_name = under_to_camel($controller_path . '_controller');
    $controller = new $controller_name();
    // set action name
    $controller->controller_name = $controller_name;
Ejemplo n.º 18
0
    ini_set('display_errors', 1);
    error_reporting(1);
    define("MASTER_DEBUG_MODE", true);
} else {
    ini_set('display_errors', 0);
    error_reporting(0);
}
include_once ROOT . "config/classpath.php";
include_once ROOT . "api/bootlogiks.php";
logiksRequestPreboot();
include_once SERVICE_ROOT . "ServiceAuthEngine.inc";
include_once SERVICE_ROOT . "api.php";
include_once ROOT . "api/configurator.php";
loadConfigs([ROOT . "config/basic.cfg", ROOT . "config/php.cfg", ROOT . "config/system.cfg", ROOT . "config/developer.cfg", ROOT . "config/services.cfg", ROOT . "config/errorlog.cfg", ROOT . "config/security.cfg", ROOT . "config/others.cfg", ROOT . "config/xtras.cfg", ROOT . "config/folders.cfg"]);
LogiksConfig::fixPHPINIConfigs();
define('SiteLocation', 'http' . (_server('HTTPS') ? 's' : '') . '://' . "{_server('HTTP_HOST')}/" . InstallFolder);
require_once ROOT . "api/libs/errorLogs/boot.php";
logiksServiceBoot();
header("X-Powered-By: Logiks [http://openlogiks.org]", false);
header("SESSION-KEY:" . session_id(), false);
header("Access-Control-Allow-Origin:*");
//Origin
//Access-Control-Allow-Methods:OPTIONS,GET,POST,PUT,DELETE
//Access-Control-Allow-Headers:Content-Type, Authorization, X-Requested-With
//header("Access-Control-Allow-Headers", "access-control-allow-origin, accept, access-control-allow-methods, access-control-allow-headers, x-random-shit");
//header("X-Powered-By: ".Framework_Title." [".Framework_Site."]",false);
//print_r($GLOBALS['LOGIKS']["_SERVER"]);exit();
include_once ROOT . "api/libs/logiksCache/boot.php";
include_once ROOT . "api/libs/loaders/boot.php";
include_once ROOT . "api/system.php";
include_once ROOT . "api/security.php";
Ejemplo n.º 19
0
 function getRequestPath()
 {
     return dirname('http://' . _server('HTTP_HOST') . _server('PHP_SELF')) . '/';
 }
Ejemplo n.º 20
0
}
?>
	if(action!=null && action.length>0) {
		sxx+="&action="+action;
	}
	if(format!=null && format.length>0) {
		sxx+="&format="+format;
	}
	if(q!=null && q.length>0) {
		sxx+=q;
	}
	return sxx;	
}
function _link(href) {
	if(href==null) href="<?php 
echo SiteLocation . _server('REQUEST_PATH');
?>
";
	if(href.indexOf("http")>=0) {
	} else if(href.indexOf("ftp")>=0) {
	} else if(href.indexOf("/")===0) {
		href="<?php 
echo SiteLocation;
?>
"+href.substr(1);
	} else {
		href="<?php 
echo SiteLocation;
?>
"+href;
	}
Ejemplo n.º 21
0
 function logiksServiceBoot()
 {
     if (LogiksSingleton::funcCheckout("logiksServiceBoot")) {
         $dm = new DomainMap();
         $dm->detect();
         if (!defined("SITENAME")) {
             trigger_error("SITE NOT DEFINED", E_USER_ERROR);
         }
         if (!isset($_REQUEST['scmd'])) {
             $rURI = explode("?", _server('REQUEST_URI'));
             $rURI = explode(".", $rURI[0]);
             if (isset($rURI[1])) {
                 $_REQUEST['format'] = $rURI[1];
             }
             $scmdArr = explode("services/", $rURI[0]);
             if (count($scmdArr) > 1) {
                 array_shift($scmdArr);
             }
             $scmdArr = explode("/", $scmdArr[0]);
             $_REQUEST['scmd'] = $scmdArr[0];
             if (isset($scmdArr[1])) {
                 $_REQUEST['action'] = $scmdArr[1];
             }
             if (count($scmdArr) > 2) {
                 array_shift($scmdArr);
                 $_REQUEST['actionslug'] = implode("-", $scmdArr);
                 $_REQUEST['slug'] = $scmdArr;
             }
         }
         if (!isset($_REQUEST['action'])) {
             //TODO : GET, POST, PUT, DELETE, PURGE, VIEW
             //		PATCH, COPY, HEAD, OPTIONS, LINK, UNLINK, LOCK, UNLOCK, PROPFIND,
             $_REQUEST['action'] = "";
         }
         if (!isset($_REQUEST['actionslug'])) {
             $_REQUEST['slugpath'] = $_REQUEST['action'];
         }
         if (!isset($_REQUEST['slug'])) {
             $_REQUEST['slug'] = array();
         }
         $_REQUEST['site'] = SITENAME;
         //Handling Encoded/Encrypted QUERY_STRINGS
         if (isset($_REQUEST['encoded'])) {
             $query = $_REQUEST['encoded'];
             $queryo = decryptURL($query);
             $query = explode("&", $queryo);
             foreach ($query as $q) {
                 $q = explode("=", $q);
                 if (count($q) == 0) {
                 } elseif (count($q) == 1) {
                     $_REQUEST[$q[0]] = "";
                 } else {
                     $qs = $q[0];
                     unset($q[0]);
                     $qv = implode("=", $q);
                     $_REQUEST[$qs] = $qv;
                 }
             }
             _envData("SERVER", 'QUERY_STRING', "&{$queryo}");
         }
         $cmdFormat = explode(",", SUPPORTED_OUTPUT_FORMATS);
         if (!isset($_REQUEST['format'])) {
             $_REQUEST['format'] = getConfig("DEFAULT_OUTPUT_FORMAT");
         } else {
             $_REQUEST['format'] = strtolower($_REQUEST['format']);
             if (!in_array($_REQUEST['format'], $cmdFormat)) {
                 trigger_logikserror(902, E_USER_ERROR);
             } else {
                 $_GET['format'] = $_REQUEST['format'];
             }
         }
     }
 }
Ejemplo n.º 22
0
function gotoSuccessLink()
{
    $onsuccess = "";
    if (ALLOW_LOGIN_RELINKING || ALLOW_LOGIN_RELINKING) {
        if (isset($_REQUEST['onsuccess'])) {
            $onsuccess = $_REQUEST['onsuccess'];
        }
    }
    $domain = $_SESSION['SESS_ACTIVE_SITE'];
    //ACTIVE
    if (ALLOW_MAUTH) {
        if (isset($_POST['mauth']) && $_POST['mauth'] == "authkey") {
            echo $_SESSION['MAUTH_KEY'];
        } elseif (isset($_POST['mauth']) && $_POST['mauth'] == "jsonkey") {
            $arr = array("user" => $_SESSION['SESS_USER_ID'], "mobile" => $_SESSION['SESS_USER_CELL'], "email" => $_SESSION['SESS_USER_EMAIL'], "country" => $_SESSION['SESS_USER_COUNTRY'], "authkey" => $_SESSION['MAUTH_KEY'], "date" => date("Y-m-d"), "time" => date("H:i:s"), "site" => $domain, "client" => _server('REMOTE_ADDR'), "token" => $_SESSION['SESS_TOKEN'], "username" => $_SESSION['SESS_USER_NAME'], "avatar" => $_SESSION['SESS_USER_AVATAR']);
            header("Content-Type:text/json");
            echo json_encode($arr);
        } else {
            echo "<h5>Securing Access Authentication ... </h5>";
            if (strlen($onsuccess) == 0 || $onsuccess == "*") {
                header("location: " . SiteLocation . "?site={$domain}");
            } else {
                if (substr($onsuccess, 0, 7) == "http://" || substr($onsuccess, 0, 8) == "https://" || substr($onsuccess, 0, 2) == "//" || substr($onsuccess, 0, 2) == "./" || substr($onsuccess, 0, 1) == "/") {
                    header("location: {$onsuccess}");
                }
            }
        }
    } else {
        //echo "<h5>Securing Access Authentication ... </h5>";
        if (strlen($onsuccess) == 0 || $onsuccess == "*") {
            header("location: " . _link(getConfig("PAGE_HOME")));
        } else {
            if (substr($onsuccess, 0, 7) == "http://" || substr($onsuccess, 0, 8) == "https://" || substr($onsuccess, 0, 2) == "//" || substr($onsuccess, 0, 2) == "./" || substr($onsuccess, 0, 1) == "/") {
                header("location: {$onsuccess}");
            }
        }
    }
    exit;
}
Ejemplo n.º 23
0
 public function test_service()
 {
     $actual = _service('test', 'action1', 'json', array('id' => 30), 'default');
     $expected = SiteLocation . 'services/test?site=default&syshash=' . md5(session_id() . _server('REMOTE_ADDR')) . '&action=action1&format=json&id=30';
     $this->assertEquals($actual, $expected);
 }
Ejemplo n.º 24
0
function gotoSuccessLink()
{
    $onsuccess = "";
    if (ALLOW_LOGIN_RELINKING == "true" || ALLOW_LOGIN_RELINKING) {
        if (isset($_REQUEST['onsuccess'])) {
            $onsuccess = $_REQUEST['onsuccess'];
        }
    }
    $domain = $_SESSION['SESS_ACTIVE_SITE'];
    //ACTIVE
    if (ALLOW_MAUTH == "true") {
        if (isset($_POST['mauth']) && $_POST['mauth'] == "authkey") {
            echo $_SESSION['MAUTH_KEY'];
        } elseif (isset($_POST['mauth']) && $_POST['mauth'] == "jsonkey") {
            $arr = array("user" => $_SESSION['SESS_USER_ID'], "authkey" => $_SESSION['MAUTH_KEY'], "date" => date("Y-m-d"), "time" => date("H:i:s"), "site" => $domain, "client" => _server('REMOTE_ADDR'), "token" => $_SESSION['SESS_TOKEN']);
            header("Content-Type:text/json");
            echo json_encode($arr);
        } else {
            echo "<h5>Securing Access Authentication ... </h5>";
            if (strlen($onsuccess) == 0 || $onsuccess == "*") {
                header("location: " . SiteLocation . $domain);
            } else {
                if (substr($onsuccess, 0, 7) == "http://" || substr($onsuccess, 0, 8) == "https://" || substr($onsuccess, 0, 2) == "//" || substr($onsuccess, 0, 2) == "./" || substr($onsuccess, 0, 1) == "/") {
                    header("location: {$onsuccess}");
                }
            }
        }
    } else {
        echo "<h5>Securing Access Authentication ... </h5>";
        if (strlen($onsuccess) == 0 || $onsuccess == "*") {
            header("location: " . SiteLocation . $domain);
        } else {
            if (substr($onsuccess, 0, 7) == "http://" || substr($onsuccess, 0, 8) == "https://" || substr($onsuccess, 0, 2) == "//" || substr($onsuccess, 0, 2) == "./" || substr($onsuccess, 0, 1) == "/") {
                header("location: {$onsuccess}");
            }
        }
    }
    exit;
}
Ejemplo n.º 25
0
function get_request_url()
{
    return get_request_host() . '://' . _server('PATH_INFO');
}
Ejemplo n.º 26
0
<?php

if (!isset(_server("HTTP_REFERER")) || strlen(_server("HTTP_REFERER")) <= 0) {
    ?>
	
<script language='javascript'>
$(function() {
	if(location.hash.slice(1).length>0) {
		hs=location.hash.slice(1);
		hso=hs.split("=");
		
		if(hso[0]=="overlay") {
			loadOverlay("#"+hso[1]);
		}
	}
});
function loadOverlay(g) {
	if($(g).length>0) {
		ele=$(g).prop('tagName');
		if(ele=="DIV") {
			jqPopupDiv(g, null, true,$(window).width()-50,$(window).height()-50,"fade");
		} else if(ele=="A") {
			r=$(g).attr("href");
			t=$(g).html();
			jqPopupURL(r,t, null, true,$(window).width()-50,$(window).height()-50,"fade");
		}
	}
}
</script>
<?php 
}
Ejemplo n.º 27
0
 function generateMAuthKey()
 {
     if (!isset($_REQUEST['deviceuuid'])) {
         $_REQUEST['deviceuuid'] = "LOGIKS007";
     }
     $str = $_REQUEST['site'] . _server('HTTP_USER_AGENT') . SiteID . $_REQUEST['deviceuuid'];
     if (isset($_SESSION['SESS_USER_ID'])) {
         $str .= $_SESSION['SESS_USER_ID'];
     }
     $key = md5(base64_encode($str));
     unset($_REQUEST['deviceuuid']);
     return $key;
 }
Ejemplo n.º 28
0
 @session_start();
 $startTime = microtime(true);
 $_SESSION['REQUEST_PAGE_START'] = $startTime;
 include_once 'syscheck.php';
 include_once 'commons.php';
 _envData("SESSION", 'REQUEST_PAGE_START', $startTime);
 $dirPath = str_replace(_server("DOCUMENT_ROOT"), '', dirname(_server("SCRIPT_FILENAME")) . "/");
 $dirPath = substr($dirPath, 1);
 if (!defined("InstallFolder")) {
     define('InstallFolder', $dirPath);
 }
 if (!defined("WEBROOT")) {
     define('WEBROOT', 'http' . (_server('HTTPS') ? 's' : '') . '://' . str_replace("//", "/", _server('HTTP_HOST') . dirname(_server('SCRIPT_NAME')) . "/"));
 }
 if (!defined("SiteLocation")) {
     define('SiteLocation', 'http' . (_server('HTTPS') ? 's' : '') . '://' . str_replace("//", "/", _server('HTTP_HOST') . "/" . InstallFolder . "/"));
 }
 include_once ROOT . "config/classpath.php";
 require_once 'bootlogiks.php';
 logiksRequestPreboot();
 require_once 'configurator.php';
 loadConfigs([ROOT . "config/basic.cfg", ROOT . "config/php.cfg", ROOT . "config/system.cfg", ROOT . "config/developer.cfg", ROOT . "config/debug.cfg", ROOT . "config/errorlog.cfg", ROOT . "config/security.cfg", ROOT . "config/folders.cfg", ROOT . "config/others.cfg", ROOT . "config/xtras.cfg", ROOT . "config/framework.cfg", ROOT . "config/masters/appPage.cfg"]);
 if (PRINT_PHP_HEADERS) {
     header("X-Powered-By: " . Framework_Title . " [" . Framework_Site . "]", false);
 }
 require_once ROOT . "api/libs/errorLogs/boot.php";
 LogiksConfig::fixPHPINIConfigs();
 logiksSystemBoot();
 include_once ROOT . "api/libs/logiksCache/boot.php";
 include_once ROOT . "api/libs/loaders/boot.php";
 include_once ROOT . "api/system.php";
Ejemplo n.º 29
0
 function printSQLResult($result, $dataType = "json", $params = array(), $msg = "", $autoLing = true, $maxTextLength = 0)
 {
     if ($result == null || is_bool($result)) {
         $responce->MSG = $msg;
         header("Content-type: application/json");
         echo json_encode($responce);
         return;
     }
     if ($dataType == "json") {
         if (isset($params["page"])) {
             $responce->page = intval($params["page"]);
         }
         if (isset($params["total"])) {
             $responce->total = intval($params["total"]);
         }
         if (isset($params["records"])) {
             $responce->records = intval($params["records"]);
         }
         //if(isset($params["limit"])) $responce->limit =intval($params["limit"]);
         $i = 0;
         //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH mysql_fetch_array
         while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) {
             //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
             $responce->rows[$i]['id'] = $row[0];
             $responce->rows[$i]['cell'] = array();
             $c = 0;
             foreach ($row as $a => $b) {
                 //if(is_numeric($a)) continue; if :: MYSQL_BOTH
                 $type = mysql_field_type($result, $c);
                 if (strlen($b) > 0) {
                     if ($type == "date") {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "time") {
                         $dt = str_replace("m", "i", getConfig("TIME_FORMAT"));
                         $b = _time($b);
                         $bT = _time("00:00:00", "H:i:s", $dt);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "datetime") {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $dt = str_replace("m", "i", getConfig("TIME_FORMAT"));
                         $ss = explode(" ", $b);
                         $s0 = _date($ss[0], "Y/m/d", $df);
                         if (isset($ss[1])) {
                             $s1 = _time($ss[1]);
                         } else {
                             $s1 = "";
                         }
                         $b = "{$s0} {$s1}";
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         $bT .= " " . _time("00:00:00", "H:i:s", $dt);
                         if ($b == $bT) {
                             $b = "";
                         }
                     } elseif ($type == "blob") {
                         if ($maxTextLength > 0 && strlen($b) > $maxTextLength) {
                             $b = substr($b, 0, 200) . "...";
                         } else {
                             $b = stripslashes($b);
                         }
                         $b = htmlentities($b);
                         //str_replace('"',"\\'",$b));
                     } else {
                         if ($autoLing) {
                             $b = _ling($b, true);
                         }
                     }
                 }
                 array_push($responce->rows[$i]['cell'], $b);
                 $c++;
             }
             $i++;
         }
         $responce->MSG = $msg;
         header("Content-type: application/json");
         echo json_encode($responce);
     } elseif ($dataType == "xml") {
         if (stristr(_server("HTTP_ACCEPT"), "application/xhtml+xml")) {
             header("Content-type: application/xhtml+xml;charset=utf-8");
         } else {
             header("Content-type: text/xml;charset=utf-8");
         }
         $et = ">";
         $s = "<?xml version='1.0' encoding='utf-8'?{$et}\n";
         $s .= "<rows>";
         $s .= "<page>" . $page . "</page>";
         $s .= "<total>" . $total_pages . "</total>";
         $s .= "<records>" . $count . "</records>";
         //while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
         while ($row = _db()->fetchData($result)) {
             $s .= "<row id='" . $row[id] . "'>";
             $i = 0;
             foreach ($row as $a => $b) {
                 $type = mysql_field_type($result, $i);
                 $length = mysql_field_len($result, $i);
                 if ($type == "date") {
                     if (strlen($b) > 0) {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     }
                     if (strlen($b) > 0) {
                         $s .= "<cell><![CDATA[" . $b . "]]></cell>";
                     }
                 } elseif ($type == "string" && $length > 5) {
                     if ($autoLing) {
                         $b = _ling($b);
                     }
                     if (strlen($b) > 0) {
                         $s .= "<cell><![CDATA[" . $b . "]]></cell>";
                     } else {
                         $s .= "<cell></cell>";
                     }
                 } else {
                     if ($autoLing) {
                         $b = _ling($b);
                     }
                     $s .= "<cell>" . $b . "</cell>";
                 }
                 $i++;
             }
             $s .= "</row>";
         }
         $s .= "</rows>";
         echo $s;
     } elseif ($dataType == "html") {
         if (isset($params["withheader"])) {
             $withheader = $params["withheader"];
         } else {
             $withheader = "false";
         }
         if (isset($params["multiselect"])) {
             $multiselect = $params["multiselect"];
         } else {
             $multiselect = "false";
         }
         if ($withheader == "true" || $withheader == 1) {
             $withheader = true;
         } else {
             $withheader = false;
         }
         if ($multiselect == "true" || $multiselect == 1) {
             $multiselect = true;
         } else {
             $multiselect = false;
         }
         $header = "";
         $body = "";
         if ($withheader) {
             $header .= "<thead>";
             $header .= "<tr class='tblheader'>";
             if ($multiselect) {
                 $header .= "<td width=40px> -- </td>";
             }
             while ($i < mysql_num_fields($result)) {
                 $meta = mysql_fetch_field($result, $i);
                 if ($meta) {
                     $t = str_replace("_", " ", $meta->name);
                     $t = ucwords($t);
                     $header .= "<td align=center>{$t}</td>";
                 } else {
                     $header .= "<td>&nbsp;</td>";
                 }
                 $i++;
             }
             $header .= "</tr>";
             $header .= "</thead>";
         }
         $body .= "<tbody>";
         //while($row = mysql_fetch_array($result,MYSQL_NUM)) {//MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
         while ($row = _db()->fetchData($result, "array", MYSQL_NUM)) {
             //MYSQL_ASSOC, MYSQL_NUM, and MYSQL_BOTH
             $body .= "<tr id='ROW_" . $row[0] . "'>";
             if ($multiselect) {
                 $body .= "<td align=center><input type='checkbox' rel='" . $row[0] . "' row='ROW_" . $row[0] . "' /></td>";
             }
             $c = 0;
             foreach ($row as $a => $b) {
                 $meta = mysql_fetch_field($result, $c);
                 $type = $meta->type;
                 $name = $meta->name;
                 $tbl = $meta->table;
                 if ($type == "date") {
                     if (strlen($b) > 0) {
                         $df = str_replace("yy", "Y", getConfig("DATE_FORMAT"));
                         $b = _date($b, "Y/m/d", $df);
                         $bT = _date("0000-00-00", "Y/m/d", $df);
                         if ($b == $bT) {
                             $b = "";
                         }
                     }
                 } elseif ($autoLing) {
                     $b = _ling($b);
                 }
                 if ($meta->primary_key) {
                     $body .= "<td col='{$name}' class='serial_col'>{$b}</td>";
                 } else {
                     if ($type == "date") {
                         if ($b == "NA") {
                             $body .= "<td col='{$name}' class='calerroricon' >&nbsp;</td>";
                         } else {
                             $body .= "<td col='{$name}' align=center>{$b}</td>";
                         }
                     } elseif ($type == "int" || $type == "float" || $type == "double") {
                         $body .= "<td col='{$name}' align=right>{$b}</td>";
                     } elseif ($type == "bool" || $type == "boolean") {
                         $body .= "<td col='{$name}' align=center>{$b}</td>";
                     } elseif ($type == "blob") {
                         $body .= "<td col='{$name}' class='blobicon' onclick=\"viewBlobData('{$name}','{$tbl}')\">&nbsp;</td>";
                     } else {
                         $body .= "<td col='{$name}'>{$b}</td>";
                     }
                 }
                 $c++;
             }
             $body .= "</tr>";
         }
         $body .= "</tbody>";
         echo "<table width=100%>{$header} {$body}</table>";
     } else {
         printArray($data);
     }
 }
Ejemplo n.º 30
0
 function getRequestTime()
 {
     if (_server('REQUEST_PAGE_START')) {
         return microtime(true) - _server('REQUEST_PAGE_START');
     } elseif (_server('REQUEST_SERVICE_START')) {
         return microtime(true) - _server('REQUEST_SERVICE_START');
     }
 }