static function clear() { $files = glob(getDataPath() . "cache/*"); if ($files) { foreach ($files as $file) { @unlink($file); } } return; }
static function uploadFile($filename, $file_guid, $allowed_extensions = array("png", "jpg", "jpeg", "gif", "doc", "docx", "ods")) { if (!$filename || !$file_guid) { return false; } $file_entity = getEntity($file_guid); $target_dir = getDataPath() . "files" . "/" . $file_guid . "/"; makePath($target_dir, 0777); $name = basename($_FILES[$filename]["name"]); $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $name); $name = preg_replace("([\\.]{2,})", '', $name); $target_file = $target_dir . $name; $file_entity->path = $target_file; $file_entity->extension = pathinfo($target_file, PATHINFO_EXTENSION); $file_entity->save(); $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); if (!empty($allowed_extensions) && is_array($allowed_extensions)) { if (!in_array(strtolower($imageFileType), $allowed_extensions)) { $file_entity->delete(); new SystemMessage("Allowed file types: " . implode(" ", $allowed_extensions)); forward(); } } $error = move_uploaded_file($_FILES[$filename]["tmp_name"], $target_file); $finfo = \finfo_open(FILEINFO_MIME_TYPE); $mime = \finfo_file($finfo, $target_file); \finfo_close($finfo); if ($mime == "image/jpeg" || $mime == "image/jpg" || $mime == "image/gif") { Image::fixImageRotation($target_file); } $file_entity->file_location = $target_file; $file_entity->mime_type = $mime; $file_entity->filename = $name; $file_entity->save(); return $name; }
* All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; denyDirect(); $filename = getDataPath() . "cache" . "/" . "*"; $files = glob($filename); foreach ($files as $file) { if (file_exists($file)) { $contents = gzuncompress(file_get_contents($file)); if (@unserialize($contents)) { $contents = unserialize($contents); } } echo "<p><strong>{$file}</strong></p>"; ob_start(); var_dump($contents); $var = ob_get_contents(); ob_end_clean(); echo $var; }
public function __construct() { $container_guid = getInput("container_guid"); $title = getInput("title"); $description = getInput("description"); $access_id = getInput("access_id"); for ($i = 0; $i < count($_FILES['avatar']['name']); $i++) { $photo = new Photo(); $photo->container_guid = $container_guid; $photo->owner_guid = getLoggedInUserGuid(); $photo->title = $title; $photo->description = $description; $photo->save(); $file = new File(); $file->container_guid = $photo->guid; $file->owner_guid = getLoggedInUserGuid(); $file->access_id = $photo->access_id; $file_guid = $file->save(); $file_entity = getEntity($file_guid); $target_dir = getDataPath() . "files" . "/" . $file_guid . "/"; if (!file_exists($target_dir)) { makePath($target_dir, 0777, true); } else { $files = glob($target_dir . '*', GLOB_MARK); foreach ($files as $file) { @unlink($file); } } $name = basename($_FILES['avatar']["name"][$i]); $name = preg_replace("([^\\w\\s\\d\\-_~,;:\\[\\]\\(\\).])", '', $name); $name = preg_replace("([\\.]{2,})", '', $name); $target_file = $target_dir . $name; $file_entity->path = $target_file; $file_entity->extension = pathinfo($target_file, PATHINFO_EXTENSION); $file_entity->save(); $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); if (!empty($allowed_extensions)) { if (!in_array(strtolower($imageFileType), $allowed_extensions)) { $file_entity->delete(); new SystemMessage("Allowed file types: " . implode(" ", $allowed_extensions)); forward(); } } $error = move_uploaded_file($_FILES['avatar']["tmp_name"][$i], $target_file); $finfo = \finfo_open(FILEINFO_MIME_TYPE); $mime = \finfo_file($finfo, $target_file); \finfo_close($finfo); if ($mime == "image/jpeg" || $mime == "image/jpg" || $mime == "image/gif" || $mime == "image/png") { Image::fixImageRotation($target_file); } $file_entity->file_location = $target_file; $file_entity->mime_type = $mime; $file_entity->filename = $name; $file_entity->save(); $filename = $name; $file = getEntity($file_guid); $file->filename = $filename; $file->save(); $photo->icon = $file->guid; $photo->save(); Image::createThumbnail($file->guid, TINY); Image::createThumbnail($file->guid, SMALL); Image::createThumbnail($file->guid, MEDIUM); Image::createThumbnail($file->guid, LARGE); Image::createThumbnail($file->guid, EXTRALARGE); Image::createThumbnail($file->guid, HUGE); } new SystemMessage("Your Photo has been Uploaded"); $album_guid = $container_guid; $album = getEntity($album_guid); if (!$album->title != "Profile Avatars" && $album->title != "General") { new Activity(getLoggedInUserGuid(), "activity:add:photo", array(getLoggedInUser()->getURL(), getLoggedInUser()->full_name, $album->getURL(), $album->title, "<a href='" . $album->getURL() . "'>" . $photo->icon(MEDIUM, "img-responsive") . "</a>")); } forward($album->getURL()); }
public function createAvatar($entity = false, $filename = false, $copy = false) { $target_dir = getDataPath() . "videos" . "/" . $this->video_guid . "/"; $file_entity = getEntity($this->video_guid); makePath($target_dir, 0777); $ffmpeg = \FFMpeg\FFMpeg::create(array('ffmpeg.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffmpeg", 'ffprobe.binaries' => Setting::get("ffmpeg_ffmprobe_executable_path") . "/ffprobe", 'timeout' => 7200, 'ffmpeg.threads' => 6)); $file_location = $file_entity->file_location; $video = $ffmpeg->open($file_location); $video->frame(\FFMpeg\Coordinate\TimeCode::fromSeconds(2))->save($target_dir . 'frame.jpg'); }
/* * *********************************************************************** * * SocialApparatus CONFIDENTIAL * __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; $guid = getInput("guid"); $path = getInput("path"); $file_location = getDataPath() . "videos" . "/" . $guid . "/" . "video.{$path}"; if (file_exists($file_location)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $file_location); $size = filesize($file_location); echo FileSystem::serveFilePartial($file_location, NULL, $mime); }
function uploadBase64Image($image) { $image = base64_decode($image); $file = new File(); $file_guid = $file->save(); $name = "avatar.jpg"; $target_dir = getDataPath() . "files" . "/" . $file_guid . "/"; makePath($target_dir, 0777); $file->path = $target_dir . $name; $file->extension = "jpg"; $file->mime_type = "image/jpeg"; $file->filename = "avatar.jpg"; $file->save(); file_put_contents($target_dir . $name, $image); Image::createThumbnail($file->guid, TINY); Image::createThumbnail($file->guid, SMALL); Image::createThumbnail($file->guid, MEDIUM); Image::createThumbnail($file->guid, LARGE); Image::createThumbnail($file->guid, EXTRALARGE); Image::createThumbnail($file->guid, HUGE); return $file->guid; }
* Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; require_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php"; $guid = getInput("guid"); if (!$guid) { $guid = Vars::get("guid"); } $file = getEntity($guid); $thumbnail = getInput("thumbnail"); if (!$thumbnail) { $thumbnail = Vars::get("thumbnail"); } if (!$thumbnail) { $thumbnail = HUGE; } $file_location = getDataPath() . "files" . "/" . $file->guid . "/" . "thumbnail" . "/" . $thumbnail . "/" . $file->filename; if (file_exists($file_location)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $file_location); $size = filesize($file_location); header('Content-Type:' . $mime); header("Content-length: {$size}"); readfile($file_location); }
static function createThumbnail($guid, $width) { $file = getEntity($guid); $mime_type = $file->mime_type; $path = $file->path; $filename = $file->filename; $owner_guid = $file->owner_guid; $im = imagecreatefromstring(file_get_contents($path)); // switch ($mime_type) { // case "image/jpeg": // $im = imagecreatefromjpeg($path); // break; // case "image/gif": // $im = imagecreatefromgif($path); // break; // case "image/png": // $im = imagecreatefrompng($path); // break; // default: // return false; // break; // } $ox = imagesx($im); $oy = imagesy($im); $nx = $width; $ny = floor($oy * ($width / $ox)); $nm = imagecreatetruecolor($nx, $ny); imagefilledrectangle($nm, 0, 0, $nx, $ny, imagecolorallocate($nm, 255, 255, 255)); imagecopyresampled($nm, $im, 0, 0, 0, 0, $nx, $ny, $ox, $oy); $thumbnail_path = getDataPath() . "files" . "/" . $guid . "/" . "thumbnail" . "/" . $width; if (!file_exists($thumbnail_path)) { makePath($thumbnail_path, 0777); } switch ($mime_type) { case "image/jpeg": imagejpeg($nm, getDataPath() . "files" . "/" . $guid . "/" . "thumbnail" . "/" . $width . "/" . $filename); break; case "image/gif": imagegif($nm, getDataPath() . "files" . "/" . $guid . "/" . "thumbnail" . "/" . $width . "/" . $filename); break; case "image/png": imagepng($nm, getDataPath() . "files" . "/" . $guid . "/" . "thumbnail" . "/" . $width . "/" . $filename); break; default: return false; break; } imagedestroy($nm); }
* __________________ * * [2002] - [2017] SocialApparatus (http://SocialApparatus.co) * All Rights Reserved. * * NOTICE: All information contained herein is, and remains the property of SocialApparatus * and its suppliers, if any. The intellectual and technical concepts contained herein * are proprietary to SocialApparatus and its suppliers and may be covered by U.S. and Foreign * Patents, patents in process, and are protected by trade secret or copyright law. * * Dissemination of this information or reproduction of this material is strictly forbidden * unless prior written permission is obtained from SocialApparatus. * * Contact Shane Barron admin@socia.us for more information. */ namespace SocialApparatus; require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . "/engine/start.php"; $guid = getInput("guid"); if (!$guid) { $guid = Vars::get("guid"); } $file_location = getDataPath() . "videos" . "/" . $guid . "/" . "frame.jpg"; if (file_exists($file_location)) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $file_location); $size = filesize($file_location); header('Content-Type:' . $mime); header("Content-length: {$size}"); readfile($file_location); }