Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/sergejey/alpha'
Browse files Browse the repository at this point in the history
  • Loading branch information
nick7zmail committed Apr 14, 2017
2 parents 8cf03cd + d75b01a commit f3cdd9b
Show file tree
Hide file tree
Showing 228 changed files with 70,800 additions and 4,249 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -13,4 +13,4 @@ reboot
*.phpproj.user
.vs/
backup/
debmes/
debmes/
3 changes: 3 additions & 0 deletions .htaccess
Expand Up @@ -8,6 +8,9 @@ RewriteBase /
ReWriteCond %{REQUEST_URI} pda$
RewriteRule .* /popup/pda.html [R,L]

ReWriteCond %{REQUEST_URI} ^api/
RewriteRule .* /api.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ReWriteCond %{REQUEST_URI} \.html$
Expand Down
76 changes: 64 additions & 12 deletions admin.php
Expand Up @@ -8,15 +8,20 @@
*/

include_once("./config.php");
include_once("./lib/perfmonitor.class.php");
startMeasure('TOTAL');

startMeasure('loader');
include_once("./lib/loader.php");
include_once(DIR_MODULES . "panel.class.php");
endMeasure('loader');

startMeasure('TOTAL');
include_once(DIR_MODULES . "panel.class.php");

$session = new session("prj");

startMeasure('db connection');
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);

endMeasure('db connection');
include_once("./load_settings.php");
include_once(DIR_MODULES . "control_modules/control_modules.class.php");

Expand All @@ -28,8 +33,11 @@
else
$app->getParams();

startMeasure('apprun');
$result = $app->run();
endMeasure('apprun');

startMeasure('part2');
// BEGIN: filter output
if ($filterblock != '')
{
Expand All @@ -43,16 +51,8 @@
if (preg_match_all('/&\#060\#LANG_(.+?)\#&\#062/is', $result, $matches))
{
$total = count($matches[0]);

for ($i = 0; $i < $total; $i++)
{
/*
if (preg_match('/value=["\']' . preg_quote($matches[0][$i]) . '["\']/is', $result))
{
continue;
}
*/

if (defined('LANG_' . $matches[1][$i]))
{
$result = str_replace($matches[0][$i], constant('LANG_' . $matches[1][$i]), $result);
Expand All @@ -72,10 +72,62 @@
//ob_start("ob_gzhandler"); // should be un-commented for production server
}


$result = str_replace("nf.php", "admin.php", $result);

require(ROOT.'lib/utils/postprocess_result.inc.php');


if (!defined('DISABLE_PANEL_ACCELERATION') || DISABLE_PANEL_ACCELERATION!=1) {
if (preg_match_all('/href="(\/admin\.php.+?)">/is',$result,$matches)) {
$total = count($matches[1]);
for ($i = 0; $i < $total; $i++) {
$result=str_replace($matches[0][$i],'href="'.$matches[1][$i].'" onclick="return partLoad(this.href);">',$result);
}
}
}


endMeasure('part2');


if ($_GET['part_load']) {
$res=array();

$cut_begin='<div id="partLoadContent">';
$cut_begin_index=mb_strpos($result, $cut_begin);
$cut_end='</div><!--partloadend-->';
$cut_end_index=mb_strpos($result, $cut_end);

if (is_integer($cut_begin_index) && is_integer($cut_end_index)) {
$cut_begin_index+=mb_strlen($cut_begin)+2;
$res['CONTENT']=mb_substr($result,$cut_begin_index,($cut_end_index-$cut_begin_index));
$res['NEED_RELOAD']=0;
if (is_integer(mb_strpos($res['CONTENT'], '$(document).ready')) || is_integer(mb_strpos($res['CONTENT'], 'js/codemirror'))) {
$res['CONTENT']='';
$res['NEED_RELOAD']=1;
}
} else {
$res['CONTENT']='';
$res['NEED_RELOAD']=1;
}

$result=json_encode($res);
if (is_integer(mb_strpos($result, '"CONTENT":null')) && !$res['NEED_RELOAD']) {
$res['CONTENT']='';
$res['NEED_RELOAD']=1;
$result=json_encode($res);
}

echo $result;exit;
$session->save();
$db->Disconnect(); // closing database connection
exit;

}

startMeasure('echoall');
echo $result;
endMeasure('echoall');

$session->save();
$db->Disconnect(); // closing database connection
Expand Down
72 changes: 72 additions & 0 deletions api.php
@@ -0,0 +1,72 @@
<?php
include_once("./config.php");
include_once("./lib/loader.php");
// connecting to database
$db = new mysql(DB_HOST, '', DB_USER, DB_PASSWORD, DB_NAME);
// get settings
$settings = SQLSelect('SELECT NAME, VALUE FROM settings');
$total = count($settings);
for ($i = 0; $i < $total; $i ++)
Define('SETTINGS_' . $settings[$i]['NAME'], $settings[$i]['VALUE']);
// language selection by settings
if (SETTINGS_SITE_LANGUAGE && file_exists(ROOT . 'languages/' . SETTINGS_SITE_LANGUAGE . '.php'))
include_once (ROOT . 'languages/' . SETTINGS_SITE_LANGUAGE . '.php');
include_once (ROOT . 'languages/default.php');
if (defined('SETTINGS_SITE_TIMEZONE'))
{
ini_set('date.timezone', SETTINGS_SITE_TIMEZONE);
}
header ('Content-Type: text/html; charset=utf-8');

$method = $_SERVER['REQUEST_METHOD'];
$url=$_SERVER['REQUEST_URI'];
$url=preg_replace('/\?.+/','',$url);
$request = explode('/', trim($url,'/'));
array_shift($request);

$input = json_decode(file_get_contents('php://input'),true);

$result=array();
if (strtolower($request[0])=='data' && isset($request[1])) {
$tmp=explode('.',$request[1]);
if ($method=='GET') {
if (isset($tmp[1])) {
$result['data']=getGlobal($request[1]);
} else {
$object=getObject($tmp[0]);
include_once(DIR_MODULES.'classes/classes.class.php');
$cl=new classes();
$props=$cl->getParentProperties($object->class_id, '', 1);
$my_props=SQLSelect("SELECT ID,TITLE FROM properties WHERE OBJECT_ID='".$object->id."'");
if (IsSet($my_props[0])) {
foreach($my_props as $p) {
$props[]=$p;
}
}
foreach($props as $k=>$v) {
$result['data'][$v['TITLE']]=$object->getProperty($v['TITLE']);
}
}
}
} elseif (strtolower($request[0])=='method' && isset($request[1])) {
$res=callMethod($request[1],$_GET);
if (!is_null($res)) {
$result['result']=$res;
} else {
$result['result']='OK';
}
} elseif (strtolower($request[0])=='script' && isset($request[1])) {
$res=runScript($request[1],$_GET);
if (!is_null($res)) {
$result['result']=$res;
} else {
$result['result']='OK';
}
}

echo json_encode($result);

// closing database connection
$db->Disconnect();

?>

0 comments on commit f3cdd9b

Please sign in to comment.