• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entities\File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Idno\Entities\File的典型用法代码示例。如果您正苦于以下问题:PHP File类的具体用法?PHP File怎么用?PHP File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了File类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getContent

 function getContent()
 {
     if (!empty($this->arguments[0])) {
         $object = \Idno\Entities\File::getByID($this->arguments[0]);
     }
     if (empty($object)) {
         $this->forward();
     }
     // TODO: 404
     $headers = apache_request_headers();
     if (isset($headers['If-Modified-Since'])) {
         if (strtotime($headers['If-Modified-Since']) < time() - 600) {
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     header("Pragma: public");
     header('Expires: ' . date(\DateTime::RFC1123, time() + 86400 * 365));
     // Cache files for a year!
     if (!empty($object->file['mime_type'])) {
         header('Content-type: ' . $object->file['mime_type']);
     } else {
         header('Content-type: application/data');
     }
     echo $object->getBytes();
 }
开发者ID:phpsource,项目名称:idno,代码行数:26,代码来源:View.php


示例2: post

 function post()
 {
     if (\Idno\Core\Idno::site()->session()->isLoggedOn()) {
         if (!empty($_FILES['file']['tmp_name'])) {
             if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
                 exit;
             }
             if (\Idno\Entities\File::isImage($_FILES['file']['tmp_name'])) {
                 $return = false;
                 $file = false;
                 if ($file = \Idno\Entities\File::createThumbnailFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], 1024)) {
                     $return = true;
                     $returnfile = new \stdClass();
                     $returnfile->file = ['_id' => $file];
                     $file = $returnfile;
                 } else {
                     if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true)) {
                         $return = true;
                     }
                 }
                 if ($return) {
                     $t = \Idno\Core\Idno::site()->template();
                     $t->file = $file;
                     echo $t->draw('file/picker/donejs');
                     exit;
                 }
             } else {
                 Idno::site()->session()->addErrorMessage("You can only upload images.");
             }
         }
         $this->forward($_SERVER['HTTP_REDIRECT']);
     }
 }
开发者ID:knownunknowns,项目名称:Known,代码行数:33,代码来源:Picker.php


示例3: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->title = \Idno\Core\site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\site()->currentPage()->getInput('body');
     $this->tags = \Idno\Core\site()->currentPage()->getInput('tags');
     $this->setAccess('PUBLIC');
     if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     // Get photo
     if ($new) {
         if (!empty($_FILES['photo']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name'])) {
                 if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true)) {
                     $this->attachFile($photo);
                     // Now get some smaller thumbnails, with the option to override sizes
                     $sizes = \Idno\Core\site()->events()->dispatch('photo/thumbnail/getsizes', new \Idno\Core\Event(array('sizes' => ['large' => 800, 'medium' => 400, 'small' => 200])));
                     foreach ($sizes->data()['sizes'] as $label => $size) {
                         $filename = $_FILES['photo']['name'];
                         // Experiment: let's not save thumbnails for GIFs, in order to enable animated GIF posting.
                         if ($_FILES['photo']['type'] != 'image/gif') {
                             if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], "{$filename}_{$label}", $size)) {
                                 $varname = "thumbnail_{$label}";
                                 $this->{$varname} = \Idno\Core\site()->config()->url . 'file/' . $thumbnail;
                                 $varname = "thumbnail_{$label}_id";
                                 $this->{$varname} = substr($thumbnail, 0, strpos($thumbnail, '/'));
                             }
                         }
                     }
                 } else {
                     \Idno\Core\site()->session()->addMessage('Image wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\site()->session()->addMessage('This doesn\'t seem to be an image ..');
             }
         } else {
             \Idno\Core\site()->session()->addMessage('We couldn\'t access your image. Please try again.');
             return false;
         }
     }
     if ($this->save()) {
         if ($new) {
             $this->addToFeed();
         }
         // Add it to the Activity Streams feed
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
         return true;
     } else {
         return false;
     }
 }
开发者ID:avewrigley,项目名称:idno,代码行数:62,代码来源:Photo.php


示例4: getContent

 function getContent()
 {
     // Check modified ts
     if ($cache = \Idno\Core\Idno::site()->cache()) {
         if ($modifiedts = $cache->load("{$this->arguments[0]}_modified_ts")) {
             $this->lastModifiedGatekeeper($modifiedts);
             // Set 304 and exit if we've not modified this object
         }
     }
     if (!empty($this->arguments[0])) {
         $object = \Idno\Entities\File::getByID($this->arguments[0]);
     }
     if (empty($object)) {
         $this->noContent();
     }
     session_write_close();
     // Close the session early
     //header("Pragma: public");
     // Determine uploaded timestamp
     if ($object instanceof \MongoGridFSFile) {
         $upload_ts = $object->file['uploadDate']->sec;
     } else {
         if (!empty($object->updated)) {
             $upload_ts = $object->updated;
         } else {
             if (!empty($object->created)) {
                 $upload_ts = $object->created;
             } else {
                 $upload_ts = time();
             }
         }
     }
     header("Pragma: public");
     header("Cache-Control: public");
     header('Expires: ' . date(\DateTime::RFC1123, time() + 86400 * 30));
     // Cache files for 30 days!
     $this->setLastModifiedHeader($upload_ts);
     if ($cache = \Idno\Core\Idno::site()->cache()) {
         $cache->store("{$this->arguments[0]}_modified_ts", $upload_ts);
     }
     if (!empty($object->file['mime_type'])) {
         header('Content-type: ' . $object->file['mime_type']);
     } else {
         header('Content-type: application/data');
     }
     //header('Accept-Ranges: bytes');
     //header('Content-Length: ' . filesize($object->getSize()));
     if (is_callable(array($object, 'passThroughBytes'))) {
         $object->passThroughBytes();
     } else {
         if ($stream = $object->getResource()) {
             while (!feof($stream)) {
                 echo fread($stream, 8192);
             }
         }
     }
 }
开发者ID:sintoris,项目名称:Known,代码行数:57,代码来源:View.php


示例5: getContent

 function getContent()
 {
     if (!empty($this->arguments[0])) {
         $object = \Idno\Entities\File::getByID($this->arguments[0]);
     }
     if (empty($object)) {
         $this->forward();
     }
     // TODO: 404
     session_write_close();
     // Close the session early
     //header("Pragma: public");
     // Determine uploaded timestamp
     if ($object instanceof \MongoGridFSFile) {
         $upload_ts = $object->file['uploadDate']->sec;
     } else {
         if (!empty($object->updated)) {
             $upload_ts = $object->updated;
         } else {
             if (!empty($object->created)) {
                 $upload_ts = $object->created;
             } else {
                 $upload_ts = time();
             }
         }
     }
     header("Pragma: public");
     header("Cache-Control: public");
     header('Expires: ' . date(\DateTime::RFC1123, time() + 86400 * 30));
     // Cache files for 30 days!
     $this->setLastModifiedHeader($upload_ts);
     if (!empty($object->file['mime_type'])) {
         header('Content-type: ' . $object->file['mime_type']);
     } else {
         header('Content-type: application/data');
     }
     //header('Accept-Ranges: bytes');
     //header('Content-Length: ' . filesize($object->getSize()));
     $headers = $this->getallheaders();
     if (isset($headers['If-Modified-Since'])) {
         if (strtotime($headers['If-Modified-Since']) <= $upload_ts) {
             //> time() - (86400 * 30)) {
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     if (is_callable(array($object, 'passThroughBytes'))) {
         $object->passThroughBytes();
     } else {
         if ($stream = $object->getResource()) {
             while (!feof($stream)) {
                 echo fread($stream, 8192);
             }
         }
     }
 }
开发者ID:johnellison,项目名称:90days,代码行数:56,代码来源:View.php


示例6: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     // Flag that a site export has been requested
     \Idno\Core\Idno::site()->config()->export_last_requested = time();
     \Idno\Core\Idno::site()->config()->export_in_progress = 1;
     \Idno\Core\Idno::site()->config()->save();
     $this->forward(\Idno\Core\Idno::site()->config()->getDisplayURL() . 'admin/export/', false);
     ignore_user_abort(true);
     // This is dangerous, but we need export to continue
     session_write_close();
     header('Connection: close');
     header('Content-length: ' . (string) ob_get_length());
     @ob_end_flush();
     // Return output to the browser
     @ob_end_clean();
     @flush();
     sleep(10);
     // Pause
     set_time_limit(0);
     // Eliminate time limit - this could take a while
     // Remove the previous export file
     if (!empty(\Idno\Core\Idno::site()->config()->export_file_id)) {
         if ($file = File::getByID(\Idno\Core\Idno::site()->config()->export_file_id)) {
             $file->remove();
             \Idno\Core\Idno::site()->config()->export_file_id = false;
             \Idno\Core\Idno::site()->config()->export_filename = false;
             \Idno\Core\Idno::site()->config()->save();
         }
     }
     if ($path = Migration::createCompressedArchive()) {
         $filename = \Idno\Core\Idno::site()->config()->host . '.zip';
         /*                    header('Content-disposition: attachment;filename=' . $filename);
                               if ($fp = fopen($path, 'r')) {
                                   while ($content = fread($fp, 4096)) {
                                       echo $content;
                                   }
                               }
                               fclose($fp);*/
         if ($file = File::createFromFile($path, $filename)) {
             @unlink($path);
             \Idno\Core\Idno::site()->config()->export_filename = $filename;
             \Idno\Core\Idno::site()->config()->export_file_id = $file;
             \Idno\Core\Idno::site()->config()->export_in_progress = 0;
             \Idno\Core\Idno::site()->config()->save();
             $mail = new Email();
             $mail->setHTMLBodyFromTemplate('admin/export');
             $mail->setTextBodyFromTemplate('admin/export');
             $mail->addTo(\Idno\Core\Idno::site()->session()->currentUser()->email);
             $mail->setSubject("Your data export is ready");
             $mail->send();
         }
         exit;
     }
 }
开发者ID:sintoris,项目名称:Known,代码行数:55,代码来源:Generate.php


示例7: post

 function post()
 {
     if (\Idno\Core\site()->session()->isLoggedOn()) {
         if (!empty($_FILES['file']['tmp_name'])) {
             if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true)) {
                 echo json_encode(\Idno\Core\site()->config()->url . 'file/' . $file->file['_id']);
                 error_log(\Idno\Core\site()->config()->url . 'file/' . $file->file['_id']);
             }
         }
     }
 }
开发者ID:avewrigley,项目名称:idno,代码行数:11,代码来源:Upload.php


示例8: post

 function post()
 {
     if (\Idno\Core\site()->session()->isLoggedOn()) {
         if (!empty($_FILES['file']['tmp_name'])) {
             if (!\Idno\Core\site()->triggerEvent("file/upload", [], true)) {
                 exit;
             }
             if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true, true)) {
                 echo json_encode(\Idno\Core\site()->config()->url . 'file/' . $file->file['_id']);
             }
         }
     }
 }
开发者ID:hank,项目名称:Known,代码行数:13,代码来源:Upload.php


示例9: postContent

 function postContent()
 {
     $this->adminGatekeeper();
     // Admins only
     if ($profile_user = $this->getInput('profile_user')) {
         \Idno\Core\Idno::site()->config->config['cherwell']['profile_user'] = $profile_user;
     }
     if (!empty($_FILES['background']) && $this->getInput('action') != 'clear') {
         if (in_array($_FILES['background']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
             if (getimagesize($_FILES['background']['tmp_name'])) {
                 if ($background = \Idno\Entities\File::createFromFile($_FILES['background']['tmp_name'], $_FILES['background']['name'])) {
                     // Remove previous bg
                     if (!empty(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
                         if ($file = File::getByID(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
                             if (is_callable([$file, 'delete'])) {
                                 // TODO: really need some abstraction here.
                                 $file->delete();
                             } else {
                                 if (is_callable([$file, 'remove'])) {
                                     $file->remove();
                                 }
                             }
                         }
                     }
                     \Idno\Core\Idno::site()->config->config['cherwell']['bg_id'] = $background;
                     $background = \Idno\Core\Idno::site()->config()->getDisplayURL() . 'file/' . $background;
                     \Idno\Core\Idno::site()->config->config['cherwell']['bg'] = $background;
                 }
             }
         }
     } else {
         // Remove previous bg
         if (!empty(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
             if ($file = File::getByID(\Idno\Core\Idno::site()->config()->cherwell['bg_id'])) {
                 if (is_callable([$file, 'delete'])) {
                     $file->delete();
                 } else {
                     if (is_callable([$file, 'remove'])) {
                         $file->remove();
                     }
                 }
             }
         }
         \Idno\Core\Idno::site()->config->cherwell = [];
     }
     \Idno\Core\Idno::site()->config->save();
     $this->forward(\Idno\Core\Idno::site()->config()->getDisplayURL() . 'admin/cherwell/');
 }
开发者ID:sintoris,项目名称:Known,代码行数:48,代码来源:Admin.php


示例10: post

 function post()
 {
     if (\Idno\Core\site()->session()->isLoggedOn()) {
         if (!empty($_FILES['file']['tmp_name'])) {
             if (!\Idno\Core\site()->triggerEvent("file/upload", [], true)) {
                 exit;
             }
             if ($file = \Idno\Entities\File::createFromFile($_FILES['file']['tmp_name'], $_FILES['file']['name'], $_FILES['file']['type'], true)) {
                 $t = \Idno\Core\site()->template();
                 $t->file = $file;
                 echo $t->draw('file/picker/donejs');
                 exit;
             }
         }
     }
 }
开发者ID:hank,项目名称:Known,代码行数:16,代码来源:Picker.php


示例11: saveDataFromInput

 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     if ($new) {
         if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
             return false;
         }
     }
     $body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
     if (!empty($_FILES['comic']['tmp_name']) || !empty($this->_id)) {
         $this->body = $body;
         $this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
         $this->description = \Idno\Core\Idno::site()->currentPage()->getInput('description');
         if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
             if ($time = strtotime($time)) {
                 $this->created = $time;
             }
         }
         if (!empty($_FILES['comic']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['comic']['tmp_name'])) {
                 if ($size = getimagesize($_FILES['comic']['tmp_name'])) {
                     $this->width = $size[0];
                     $this->height = $size[1];
                 }
                 if ($comic = \Idno\Entities\File::createFromFile($_FILES['comic']['tmp_name'], $_FILES['comic']['name'], $_FILES['comic']['type'], true)) {
                     $this->attachFile($comic);
                 }
             }
         }
         $this->setAccess(\Idno\Core\Idno::site()->currentPage()->getInput('access', 'PUBLIC'));
         if ($this->save($new)) {
             if ($this->getAccess() == 'PUBLIC') {
                 \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getDescription()));
             }
             return true;
         }
     } else {
         \Idno\Core\Idno::site()->session()->addErrorMessage('You can\'t save an empty comic.');
     }
     return false;
 }
开发者ID:sintoris,项目名称:Known,代码行数:45,代码来源:Comic.php


示例12: getContent

 function getContent()
 {
     if (!empty($this->arguments[0])) {
         $object = \Idno\Entities\File::getByID($this->arguments[0]);
     }
     if (empty($object)) {
         $this->forward();
     }
     // TODO: 404
     if (!function_exists('getallheaders')) {
         function getallheaders()
         {
             $headers = '';
             foreach ($_SERVER as $name => $value) {
                 if (substr($name, 0, 5) == 'HTTP_') {
                     $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
                 }
             }
             return $headers;
         }
     }
     $headers = getallheaders();
     if (isset($headers['If-Modified-Since'])) {
         if (strtotime($headers['If-Modified-Since']) < time() - 600) {
             header('HTTP/1.1 304 Not Modified');
             exit;
         }
     }
     //header("Pragma: public");
     header('Expires: ' . date(\DateTime::RFC1123, time() + 86400 * 30));
     // Cache files for 30 days!
     if (!empty($object->file['mime_type'])) {
         header('Content-type: ' . $object->file['mime_type']);
     } else {
         header('Content-type: application/data');
     }
     //header('Accept-Ranges: bytes');
     //header('Content-Length: ' . filesize($object->getSize()));
     if (is_callable([$object, 'passThroughBytes'])) {
         $object->passThroughBytes();
     } else {
         echo $object->getBytes();
     }
 }
开发者ID:avewrigley,项目名称:idno,代码行数:44,代码来源:View.php


示例13: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->title = \Idno\Core\site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\site()->currentPage()->getInput('body');
     $this->setAccess('PUBLIC');
     // Get photo
     if ($new) {
         if (!empty($_FILES['photo']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['photo']['tmp_name'])) {
                 if ($photo = \Idno\Entities\File::createFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'], $_FILES['photo']['type'], true)) {
                     $this->attachFile($photo);
                     if ($thumbnail = \Idno\Entities\File::createThumbnailFromFile($_FILES['photo']['tmp_name'], $_FILES['photo']['name'])) {
                         $this->thumbnail = \Idno\Core\site()->config()->url . 'file/' . $thumbnail;
                         $this->thumbnail_id = substr($thumbnail, 0, strpos($thumbnail, '/'));
                     }
                 } else {
                     \Idno\Core\site()->session()->addMessage('Image wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\site()->session()->addMessage('This doesn\'t seem to be an image ..');
             }
         } else {
             \Idno\Core\site()->session()->addMessage('We couldn\'t access your image. Please try again.');
             return false;
         }
     }
     if ($this->save()) {
         if ($new) {
             $this->addToFeed();
         }
         // Add it to the Activity Streams feed
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
         \Idno\Core\site()->session()->addMessage('Your photo was successfully saved.');
         return true;
     } else {
         return false;
     }
 }
开发者ID:phpsource,项目名称:idno,代码行数:47,代码来源:Photo.php


示例14: saveDataFromInput

 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $body = \Idno\Core\site()->currentPage()->getInput('body');
     if (!empty($_FILES['comic']['tmp_name']) || !empty($this->_id)) {
         $this->body = $body;
         $this->title = \Idno\Core\site()->currentPage()->getInput('title');
         $this->description = \Idno\Core\site()->currentPage()->getInput('description');
         if ($time = \Idno\Core\site()->currentPage()->getInput('created')) {
             if ($time = strtotime($time)) {
                 $this->created = $time;
             }
         }
         if (!empty($_FILES['comic']['tmp_name'])) {
             if (\Idno\Entities\File::isImage($_FILES['comic']['tmp_name'])) {
                 if ($size = getimagesize($_FILES['comic']['tmp_name'])) {
                     $this->width = $size[0];
                     $this->height = $size[1];
                 }
                 if ($comic = \Idno\Entities\File::createFromFile($_FILES['comic']['tmp_name'], $_FILES['comic']['name'], $_FILES['comic']['type'], true)) {
                     $this->attachFile($comic);
                 }
             }
         }
         $this->setAccess('PUBLIC');
         if ($this->save()) {
             if ($new) {
                 // Add it to the Activity Streams feed
                 $this->addToFeed();
             }
             \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
             return true;
         }
     } else {
         \Idno\Core\site()->session()->addMessage('You can\'t save an empty comic.');
     }
     return false;
 }
开发者ID:avewrigley,项目名称:idno,代码行数:42,代码来源:Comic.php


示例15: postContent

 function postContent()
 {
     $this->gatekeeper();
     // Logged-in only please
     $user = \Idno\Core\site()->session()->currentUser();
     $name = $this->getInput('name');
     //$handle = $this->getInput('handle');
     $email = $this->getInput('email');
     $password = $this->getInput('password');
     $password2 = $this->getInput('password2');
     if (!empty($name)) {
         $user->setTitle($name);
     }
     if (!empty($email) && $email != $user->email && filter_var($email, FILTER_VALIDATE_EMAIL)) {
         if (!\Idno\Entities\User::getByEmail($email)) {
             $user->email = $email;
         } else {
             \Idno\Core\site()->session()->addMessage('Someone is already using ' . $email . ' as their email address.', 'alert-error');
         }
     }
     if (!empty($password) && $password == $password2) {
         $user->setPassword($password);
     }
     if (!empty($_FILES['avatar'])) {
         if (in_array($_FILES['avatar']['type'], array('image/png', 'image/jpg', 'image/jpeg', 'image/gif'))) {
             if (getimagesize($_FILES['avatar']['tmp_name'])) {
                 if ($icon = \Idno\Entities\File::createThumbnailFromFile($_FILES['avatar']['tmp_name'], $_FILES['avatar']['name'], 300)) {
                     $user->icon = (string) $icon;
                 } else {
                     if ($icon = \Idno\Entities\File::createFromFile($_FILES['avatar']['tmp_name'], $_FILES['avatar']['name'])) {
                         $user->icon = (string) $icon;
                     }
                 }
             }
         }
     }
     if ($user->save()) {
         \Idno\Core\site()->session()->addMessage("Your details were saved.");
     }
     $this->forward($_SERVER['HTTP_REFERER']);
 }
开发者ID:phpsource,项目名称:idno,代码行数:41,代码来源:Settings.php


示例16: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     $this->title = \Idno\Core\site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\site()->currentPage()->getInput('body');
     $this->setAccess('PUBLIC');
     // Get video
     if ($new) {
         if (!empty($_FILES['video']['tmp_name'])) {
             if (true) {
                 if ($video = \Idno\Entities\File::createFromFile($_FILES['video']['tmp_name'], $_FILES['video']['name'], $_FILES['video']['type'], true)) {
                     $this->attachFile($video);
                 } else {
                     \Idno\Core\site()->session()->addMessage('Video wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\site()->session()->addMessage('This doesn\'t seem to be a video ..');
             }
         } else {
             \Idno\Core\site()->session()->addMessage('We couldn\'t access your video. Please try again.');
             return false;
         }
     }
     if ($this->save()) {
         if ($new) {
             $this->addToFeed();
         }
         // Add it to the Activity Streams feed
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\site()->template()->parseURLs($this->getDescription()));
         \Idno\Core\site()->session()->addMessage('Your video was successfully saved.');
         return true;
     } else {
         return false;
     }
 }
开发者ID:phpsource,项目名称:idno,代码行数:43,代码来源:Video.php


示例17: saveDataFromInput

 /**
  * Saves changes to this object based on user input
  * @return bool
  */
 function saveDataFromInput()
 {
     if (empty($this->_id)) {
         $new = true;
     } else {
         $new = false;
     }
     if ($new) {
         if (!\Idno\Core\Idno::site()->triggerEvent("file/upload", [], true)) {
             return false;
         }
     }
     $this->title = \Idno\Core\Idno::site()->currentPage()->getInput('title');
     $this->body = \Idno\Core\Idno::site()->currentPage()->getInput('body');
     $this->tags = \Idno\Core\Idno::site()->currentPage()->getInput('tags');
     $access = \Idno\Core\Idno::site()->currentPage()->getInput('access');
     $this->setAccess($access);
     if ($time = \Idno\Core\Idno::site()->currentPage()->getInput('created')) {
         if ($time = strtotime($time)) {
             $this->created = $time;
         }
     }
     // This flag will tell us if it's safe to save the object later on
     if ($new) {
         $ok = false;
     } else {
         $ok = true;
     }
     // Get media
     if ($new) {
         // This is awful, but unfortunately, browsers can't be trusted to send the right mimetype.
         $ext = pathinfo($_FILES['media']['name'], PATHINFO_EXTENSION);
         if (!empty($ext)) {
             if (in_array($ext, array('mp4', 'mov', 'webm', 'ogg', 'mpeg', 'mp3', 'vorbis'))) {
                 $media_file = $_FILES['media'];
                 if ($media_file['type'] == 'application/octet-stream') {
                     switch ($ext) {
                         case 'mp4':
                             $media_file['type'] = 'video/mp4';
                             break;
                         case 'mov':
                             $media_file['type'] = 'video/mov';
                             break;
                         case 'webm':
                             $media_file['type'] = 'video/webm';
                             break;
                         case 'ogg':
                             $media_file['type'] = 'audio/ogg';
                             break;
                         case 'mp3':
                             $media_file['type'] = 'audio/mpeg';
                             break;
                         case 'mpeg':
                             $media_file['type'] = 'video/mpeg';
                             break;
                         case 'ogv':
                             $media_file['type'] = 'audio/ogv';
                             break;
                     }
                 }
                 $this->media_type = $media_file['type'];
                 if ($media = \Idno\Entities\File::createFromFile($media_file['tmp_name'], $media_file['name'], $media_file['type'], true)) {
                     $this->attachFile($media);
                     $ok = true;
                 } else {
                     \Idno\Core\Idno::site()->session()->addErrorMessage('Media wasn\'t attached.');
                 }
             } else {
                 \Idno\Core\Idno::site()->session()->addErrorMessage('This doesn\'t seem to be a media file .. ' . $_FILES['media']['type']);
             }
         } else {
             \Idno\Core\Idno::site()->session()->addErrorMessage('We couldn\'t access your media. Please try again.');
             return false;
         }
     }
     // If a media file wasn't attached, don't save the file.
     if (!$ok) {
         return false;
     }
     if ($this->save($new)) {
         \Idno\Core\Webmention::pingMentions($this->getURL(), \Idno\Core\Idno::site()->template()->parseURLs($this->getTitle() . ' ' . $this->getDescription()));
         return true;
     } else {
         return false;
     }
 }
开发者ID:jirkadus,项目名称:Known,代码行数:90,代码来源:Media.php


示例18: addWebmentionItem

 /**
  * Recursive helper function for parsing webmentions.
  *
  * @param $item
  * @param $mentions
  * @return array
  */
 function addWebmentionItem($item, $mentions, $source, $target, $title = '')
 {
     if (!empty($item['properties']['author'])) {
         foreach ($item['properties']['author'] as $author) {
             if (!empty($author['type'])) {
                 foreach ($author['type'] as $type) {
                     if ($type == 'h-card') {
                         if (!empty($author['properties']['name'])) {
                             $mentions['owner']['name'] = $author['properties']['name'][0];
                         }
                         if (!empty($author['properties']['url'])) {
                             $mentions['owner']['url'] = $author['properties']['url'][0];
                         }
                         if (!empty($author['properties']['photo'])) {
                             //$mentions['owner']['photo'] = $author['properties']['photo'][0];
                             $tmpfname = tempnam(sys_get_temp_dir(), 'webmention_avatar');
                             file_put_contents($tmpfname, \Idno\Core\Webservice::file_get_contents($author['properties']['photo'][0]));
                             $name = md5($author['properties']['url'][0]);
                             // TODO: Don't update the cache image for every webmention
                             if ($icon = \Idno\Entities\File::createThumbnailFromFile($tmpfname, $name, 300)) {
                                 $mentions['owner']['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
                             } else {
                                 if ($icon = \Idno\Entities\File::createFromFile($tmpfname, $name)) {
                                     $mentions['owner']['photo'] = \Idno\Core\Idno::site()->config()->url . 'file/' . (string) $icon;
                                 }
                             }
                             unlink($tmpfname);
                         }
                     }
                 }
             }
         }
     }
     if (!empty($item['type'])) {
         if (in_array('h-entry', $item['type'])) {
             $mention = array();
             if (!empty($item['properties'])) {
                 if (!empty($item['properties']['content'])) {
                     $mention['content'] = '';
                     if (is_array($item['properties']['content'])) {
                         foreach ($item['properties']['content'] as $content) {
                             if (!empty($content['value'])) {
                                 $parsed_content = \Idno\Core\Idno::site()->template()->sanitize_html($content['value']);
                                 if (!substr_count($mention['content'], $parsed_content)) {
                                     $mention['content'] .= $parsed_content;
                                 }
                             }
                         }
                     } else {
                         $mention['content'] = $item['properties']['content'];
                     }
                 } else {
                     if (!empty($item['properties']['summary'])) {
                         if (is_array($item['properties']['summary'])) {
                             $mention['content'] = \Idno\Core\Idno::site()->template()->sanitize_html(implode(' ', $item['properties']['summary']));
                         } else {
                             $mention['content'] = $item['properties']['summary'];
                         }
                     } else {
                         if (!empty($item['properties']['name'])) {
                             if (is_array($item['properties']['name'])) {
                                 $mention['content'] = \Idno\Core\Idno::site()->template()->sanitize_html(implode(' ', $item['properties']['name']));
                             } else {
                                 $mention['content'] = $item['properties']['name'];
                             }
                         }
                     }
                 }
                 if (!empty($item['properties']['published'])) {
                     if (is_array($item['properties']['published'])) {
                         $mention['created'] = @strtotime(array_shift(array_pop($item['properties']['published'])));
                     } else {
                         $mention['created'] = @strtotime($item['properties']['content']);
                     }
                 }
                 if (empty($mention['created'])) {
                     $mention['created'] = time();
                 }
                 if (!empty($item['properties']['url'])) {
                     if (!empty($item['properties']['uid'])) {
                         $mention['url'] = array_intersect($item['properties']['uid'], $item['properties']['url']);
                     }
                     if (empty($mention['url'])) {
                         $mention['url'] = $item['properties']['url'];
                     }
                 }
                 if (!empty($item['properties']['like']) && is_array($item['properties']['like'])) {
                     if (in_array($target, static::getStringURLs($item['properties']['like']))) {
                         $mention['type'] = 'like';
                     }
                 }
                 if (!empty($item['properties']['like-of']) && is_array($item['properties']['like-of'])) {
                     if (in_array($target, static::getStringURLs($item['properties']['like-of']))) {
//.........这里部分代码省略.........
开发者ID:sensiblemn,项目名称:Known,代码行数:101,代码来源:Entity.php


示例19: post

 function post()
 {
     $this->gatekeeper();
     // If we're here, we're authorized
     \Idno\Core\Idno::site()->triggerEvent('indiepub/post/start', ['page' => $this]);
     // Get details
     $type = $this->getInput('h', 'entry');
     $content = $this->getInput('content');
     $name = $this->getInput('name');
     $in_reply_to = $this->getInput('in-reply-to');
     $syndicate = $this->getInput('mp-syndicate-to', $this->getInput('syndicate-to'));
     $posse_link = $this->getInput('syndication');
     $like_of = $this->getInput('like-of');
     $repost_of = $this->getInput('repost-of');
     $categories = $this->getInput('category');
     $mp_type = $this->getInput('mp-type');
     if (!empty($mp_type)) {
         $type = $mp_type;
     }
     if ($type == 'entry') {
         $type = 'note';
         if (!empty($_FILES['photo'])) {
             $type = 'photo';
         } else {
             if ($photo_url = $this->getInput('photo')) {
                 $type = 'photo';
                 $success = $this->uploadFromUrl($photo_url);
                 if (!$success) {
                     \Idno\Core\Idno::site()->triggerEvent('indiepub/post/failure', ['page' => $this]);
                     $this->setResponse(500);
                     echo "Failed uploading photo from {$photo_url}";
                     exit;
                 }
             } else {
                 if (!empty($name)) {
                     $type = 'article';
                 }
             }
         }
     }
     if ($type == 'checkin') {
         $place_name = $this->getInput('place_name');
         $location = $this->getInput('location');
         $photo = $this->getInput('photo');
         $lat 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entities\User类代码示例发布时间:2022-05-23
下一篇:
PHP Core\Webservice类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap