Пример #1
0
Файл: Save.php Проект: pohly/mts
 public function init()
 {
     // PARSE FILE //
     $parts = split("<div id=\"storeArea\">", $this->source);
     if (count($parts) == 2) {
         if (preg_match('/(.*)(\\s*<\\/div>\\s*<!--POST-BODY-START-->.*)/s', $parts[1], $regs)) {
             $this->prestore = $parts[0] . "<div id=\"storeArea\">";
             $this->store = $regs[1];
             $this->poststore = $regs[2];
             $this->storeTiddlerMap = createTiddlerMap($this->store);
             $this->parseError = "0";
         } else {
             $pieces = explode("<!--POST-STOREAREA-->", $parts[1], 2);
             if ($pieces != $parts[1] && count($pieces) == 2) {
                 $this->prestore = $parts[0] . "<div id=\"storeArea\">\n";
                 $this->store = $pieces[0];
                 $this->poststore = "</div>\n<!--POST-STOREAREA-->" . $pieces[1];
                 $this->storeTiddlerMap = createTiddlerMap($this->store);
                 $this->parseError = "0";
                 //$this->serverResponse->throwError($this->parseError);
             } else {
                 $this->serverResponse->throwError("The source file ({$this->sourceFile}) was not found or is corruped.  Please open manually to fix.  Your save was redirected to {$this->sourcename}.err");
                 $this->parseError = "1";
             }
         }
     } else {
         $this->serverResponse->throwError("The source file ({$this->sourceFile}) was not found or is corruped.  Please open manually to fix.  Your save was redirected to {$this->sourcename}.err");
         $this->parseError = "1";
     }
 }
Пример #2
0
function getTiddlersList($map)
{
    return array_keys($map);
}
$source = file_get_contents("../../../" . $_GET['file']);
// PARSE FILE //
$parts = split("<div id=\"storeArea\">", $source);
if (count($parts) == 2 && preg_match('/(.*)(\\s*<\\/div>\\s*<!--POST-BODY-START-->.*)/s', $parts[1], $regs)) {
    $prestore = $parts[0] . "<div id=\"storeArea\">";
    $store = $regs[1];
    $poststore = $regs[2];
    $storeTiddlerMap = createTiddlerMap($store);
} elseif (count($parts) == 2) {
    $pieces = explode("<!--POST-STOREAREA-->", $parts[1], 2);
    if ($pieces != $parts[1] && count($pieces) == 2) {
        $prestore = $parts[0] . "<div id=\"storeArea\">\n";
        $store = $pieces[0];
        $poststore = "</div>\n<!--POST-STOREAREA-->" . $pieces[1];
        $storeTiddlerMap = createTiddlerMap($store);
    }
    //else
    //   exit();
}
$action = $_GET['action'];
if ($action == 'index') {
    $output = "var data = {tiddlerList:'" . implode(",", getTiddlersList($storeTiddlerMap)) . "',success:true,storeType:" . $storeFormat . "};";
} elseif ($action == 'fetch') {
    $title == $_GET['title'];
    $output = getTiddler($title);
}
echo $output;