-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotlight.php
34 lines (34 loc) · 1.23 KB
/
spotlight.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
session_start();
$x = addslashes(realpath(__FILE__));
// auto detect if \ consider come from windows else / from linux
$pos = strpos($x, "\\");
if ($pos !== false) {
$d = explode("\\", $x);
} else {
$d = explode("/", $x);
}
$newPath = null;
for ($i = 0; $i < count($d); $i++) {
// if find the library or package then stop
if ($d[$i] == 'library' || $d[$i] == 'package') {
break;
}
$newPath[] .= $d[$i] . "/";
}
$fakeDocumentRoot = null;
for ($z = 0; $z < count($newPath); $z++) {
$fakeDocumentRoot .= $newPath[$z];
}
$newFakeDocumentRoot = str_replace(basename($_SERVER['PHP_SELF']) . "/", "", str_replace("//", "/", $fakeDocumentRoot)); // start
require_once($newFakeDocumentRoot . "v3/portal/main/controller/portalController.php");
require_once($newFakeDocumentRoot . "library/class/classShared.php");
$portal = new \Core\Portal\Controller\PortalControllerClass();
if (isset($_POST['spotlightString']) && strlen($_POST['spotlightString']) > 0) {
$portal->setSpotlightString($_POST['spotlightString']);
}
$portal->execute();
header('Content-Type:application/json; charset=utf-8');
echo json_encode(array("success" => true, "spotlight" => $portal->spotlight(), "total" => $portal->getSpotlightTotal()));
exit();
?>