Exemple #1
0
 protected function addFile($params)
 {
     $path = "components/" . implode("/", array_slice($params, 1));
     $basicContent = "SELECT * WHERE{\n      ?s ?p ?o\n    }LIMIT 10";
     if (strpos($path, ".template") !== FALSE) {
         //It is not a query, but a template
         $basicContent = "<!DOCTYPE html>\n<html>\n  <head>\n    <meta http-equiv='Content-type' content='text/html; charset=utf-8'>\n  </head>\n  <body>\n  </body>\n</html>";
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         if (sizeof($params) < 3) {
             HTTPStatus::send404();
             exit(0);
         }
         $return_var = 0;
         if (file_exists($path)) {
             echo json_encode(array('success' => false));
             return;
         }
         $dirpath = $path;
         $dirArray = explode("/", $path);
         array_pop($dirArray);
         $dirpath = implode("/", $dirArray);
         if (!is_dir($dirpath)) {
             $oldumask = umask(0);
             $return_var = mkdir($dirpath, 0755, true);
             umask($oldumask);
             if ($return_var === FALSE) {
                 HTTPStatus::send500("mkdir " . var_export($return_var, true) . " " . $dirpath);
             }
         }
         $return_var = file_put_contents($path, $basicContent);
         //echo $return_var;exit(0);
         if ($return_var === FALSE) {
             HTTPStatus::send500("file_puts_content " . var_export($return_var, true) . " " . $path);
         } else {
             echo json_encode(array('success' => true, 'return' => $return_var));
         }
     } else {
         HTTPStatus::send406();
         exit(0);
     }
 }
Exemple #2
0
$uri = $conf['basedir'] . $_GET['q'];
$localUri = $uri;
if ($uri == $conf['basedir']) {
    header('Location: ' . $conf['root']);
    exit(0);
}
//Configure external URIs if necessary
$localUri = $conf['basedir'] . $_GET['q'];
$uri = Utils::getMirroredUri($localUri);
//Modules
foreach ($conf['modules']['available'] as $i) {
    $className = $i . 'Module';
    $currentModule = $conf['modules']['directory'] . $className . '.php';
    if (!is_file($currentModule)) {
        HTTPStatus::send500("<br/>Can't load or error in module <tt>" . $currentModule . "</tt>");
        exit(1);
    }
    require_once $currentModule;
    $module = new $className();
    $matching = $module->match($uri);
    if ($matching != FALSE) {
        $module->execute($matching);
        if ($conf['logfile'] != null) {
            fwrite($conf['logfile'], "]}");
            fclose($conf['logfile']);
        }
        exit(0);
    }
}
HTTPStatus::send404($uri);