Пример #1
0
 private function UpdateHtaccess($file)
 {
     $rewriter = new Rewriter(new Writer());
     $text = File::GetContents($file);
     $startPos = strpos($text, (string) $rewriter->PageStartComment($this->item));
     $endPos = false;
     if ($startPos !== false) {
         $endPos = strpos($text, (string) $rewriter->PageEndComment($this->item));
         if ($endPos !== false) {
             $endPos += strlen((string) $rewriter->PageEndComment($this->item));
         }
     }
     if ($startPos === false || $endPos === false) {
         return;
     }
     $newText = substr($text, 0, $startPos) . substr($text, $endPos);
     File::CreateWithText($file, $newText);
 }
Пример #2
0
 /**
  * Adds necessary rewrite commands
  */
 private function AdjustHtaccess()
 {
     $file = Path::Combine(PHINE_PATH, 'Public/.htaccess');
     if (!File::Exists($file)) {
         return;
     }
     $writer = new Writer();
     $rewriter = new Rewriter($writer);
     $text = File::GetContents($file);
     $startPos = strpos($text, (string) $rewriter->PageStartComment($this->page));
     $endPos = false;
     $pageFound = false;
     if ($startPos === false) {
         $startPos = strpos($text, (string) $rewriter->EndComment());
         $endPos = $startPos;
     } else {
         $endPos = strpos($text, (string) $rewriter->PageEndComment($this->page));
         if ($endPos !== false) {
             $pageFound = true;
             $endPos += strlen((string) $rewriter->PageEndComment($this->page));
         }
     }
     if ($startPos === false || $endPos === false) {
         return;
     }
     $rewriter->AddPageCommands($this->page);
     $newText = substr($text, 0, $startPos) . $writer->ToString() . substr($text, $endPos);
     File::CreateWithText($file, $newText);
 }