Beispiel #1
0
 public function fallback()
 {
     $parts = parse_url($this->objectId);
     if (!isset($parts['path'])) {
         return false;
     }
     $kikiFile = Core::getInstallPath() . "/htdocs/" . $parts['path'];
     if (file_exists($kikiFile)) {
         $ext = Storage::getExtension($kikiFile);
         switch ($ext) {
             case 'css':
             case 'gif':
             case 'jpg':
             case 'js':
             case 'png':
                 $this->altContentType = Storage::getMimeType($ext);
                 $this->template = null;
                 $this->status = 200;
                 $this->content = file_get_contents($kikiFile);
                 return true;
                 break;
             case 'php':
                 Log::debug("PHP file {$kikiFile}");
                 $this->status = 200;
                 $this->template = 'pages/default';
                 $user = Core::getUser();
                 $db = Core::getDb();
                 include_once $kikiFile;
                 return true;
                 break;
             case '':
                 if (file_exists($kikiFile . "index.php")) {
                     Log::debug("PHP index file {$kikiFile}" . "index.php");
                     $this->status = 200;
                     $this->template = 'pages/default';
                     $user = Core::getUser();
                     $db = Core::getDb();
                     include_once $kikiFile . "index.php";
                     return true;
                 }
                 break;
             default:
         }
         Log::debug("unsupported extension {$ext} for kiki htdocs file {$kikiFile}");
     } else {
         Log::debug("non-existing kikiFile {$kikiFile}");
     }
     return false;
 }
Beispiel #2
0
 public function exec()
 {
     list($dummy, $id, $w, $h, $dummy, $crop) = $this->objectId;
     $this->objectId = $id;
     if (!($fileName = \Kiki\Storage::localFile($this->objectId))) {
         return;
     }
     if (!file_exists($fileName)) {
         return;
     }
     $scaleFile = \Kiki\Storage::generateThumb($fileName, $w, $h, $crop);
     if (!file_exists($scaleFile)) {
         return;
     }
     $this->altContentType = \Kiki\Storage::getMimeType(\Kiki\Storage::getExtension($scaleFile));
     $this->template = null;
     // Send content directly, without a template.
     $this->status = 200;
     $this->content = file_get_contents($scaleFile);
 }
Beispiel #3
0
 public function postArticle(&$article)
 {
     $msg = '';
     $link = $article->url();
     $title = $article->title();
     $caption = preg_replace("#^https?://", "", $link);
     $description = strip_tags(\Kiki\Misc::textSummary($article->body(), 400));
     $storageId = $article->topImage();
     // 500x500 cropped is good enough for Facebook
     $picture = $storageId ? \Kiki\Storage::url($storageId, 500, 500, true) : \Kiki\Config::$siteLogo;
     $result = $this->post($article->objectId(), $msg, $link, $title, $caption, $description, $picture);
     return $result;
 }
Beispiel #4
0
$tmpFile = $_FILES['attachment']['tmp_name'];
$name = $_FILES['attachment']['name'];
$size = $_FILES['attachment']['size'];
$target = $_POST['target'];
$id = $tmpFile ? Storage::save($name, file_get_contents($tmpFile)) : 0;
$html = null;
$albumId = isset($_POST['albumId']) ? $_POST['albumId'] : null;
if ($albumId && $id) {
    $album = new Album($albumId);
    $pictures = $album->addPictures(null, null, array($id));
    $html = $album->formItem($pictures[0]['id']);
}
// fileUploadHandler is defined in htdocs/scripts/default.js
?>
<script type="text/javascript">
window.parent.fileUploadHandler( '<?php 
echo $target;
?>
', '<?php 
echo $id;
?>
', '<?php 
echo Storage::url($id);
?>
', <?php 
echo json_encode($html);
?>
 );
</script>
<?php 
exit;