Exemplo n.º 1
0
function writeFile($inPath, $inContent)
{
    makePath(popPath($inPath));
    $f = @fopen($inPath, 'w');
    if (!$f) {
        return false;
    } else {
        $bytes = fwrite($f, $inContent);
        fclose($f);
        return $bytes;
    }
}
Exemplo n.º 2
0
function main($argc, $argv)
{
    sizeof($argv) == 3 or sizeof($argv) == 4 or die(usage());
    $jsonDocs = new JsonDocs(new JsonLoader());
    list($schemaFile, $schemaPointer) = makePath($argv[1]) or die("Invalid schema file\n");
    $schemaDoc = $jsonDocs->loadUri(new Uri($schemaFile));
    $schema = new JsonSchema($schemaDoc);
    print "Schema created from {$schemaFile}\n";
    $target = json_decode(file_get_contents($argv[2])) or die("Invalid JSON file\n");
    print "Target loaded\n";
    if (isset($argv[3])) {
        $target = $jsonDocs::getPointer($target, $argv[3]);
    }
    print "Validate [at {$schemaPointer}]:\n";
    $valid = $schema->validate($target, $schemaPointer);
    if ($valid === true) {
        print "OK\n";
    } else {
        print $valid;
    }
}
function grabData($filename)
{
    $rowNumber = 0;
    if (($handle = fopen($filename, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
            //pp($rowNumber);
            // //-----------------------------------------------------------------------convert to usable array
            $convertedData = convertData($data, $rowNumber);
            // //-----------------------------------------------------------------------create new file location
            makePath($convertedData);
            // //-----------------------------------------------------------------------if tiff convert to pdf and move to new location
            convertAndCreate($convertedData);
            // //-----------------------------------------------------------------------crates xml file
            createXMLFile($convertedData);
            //Needs file create first
            //ppr($convertedData);
            $rowNumber++;
        }
        // add 1 to row number and reepeat on next line of data
    }
    //Close file
    fclose($handle);
}
 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;
 }
Exemplo n.º 5
0
<?php

require_once "./config.php";
require_once "./param.php";
require_once "./fileapi.php";
session_start();
$root = @$_SESSION["root"] or "";
if (!$root) {
    print '"write: permission denied, no logged in user"';
    exit;
}
param("path", "");
makePath($FILES_PATH . $root . $path);
Exemplo n.º 6
0
 function makeUploadDir($fileType, $storageType = 'user')
 {
     $dir = timeDir();
     switch ($fileType) {
         case 'image':
             $segment1 = wolf('IMAGE_LOCAL_PATH');
             break;
         case 'video':
             $segment1 = wolf('VIDEO_LOCAL_PATH');
             break;
     }
     switch ($storageType) {
         case 'user':
             $segment2 = 'user/';
             break;
     }
     $path = $segment1 . $segment2 . $dir;
     makePath($path);
     return ['segment' => $dir, 'whole' => $path];
 }
 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());
 }
Exemplo n.º 8
0
 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');
 }
Exemplo n.º 9
0
function createCatTree($assigned_groups)
{
    global $db;
    $tbl_cat = MYSQL_TABLE_PREFIX . 'media_categories';
    $list = getAllowedCategories($assigned_groups);
    // Generate a list of all categories allowed to use
    // This is needed, for later checking of parentcategories
    $allowedCategories = array();
    foreach ($list as $curCategory) {
        $allowedCategories[] = $curCategory['categoryid'];
    }
    $categories = array();
    foreach ($list as $curCategory) {
        $category = $curCategory;
        $path = makePath($category['name']);
        // Iterate through the parent categories and find the root node
        while ($category['parentid'] != 0) {
            $category = $db->selectOneRow($tbl_cat, "*", "`categoryid`=" . $category['parentid']);
            $path = makePath($category['name']) . "\\" . $path;
            if (!in_array($category['categoryid'], $allowedCategories)) {
                break 2;
            }
        }
        $categories[$curCategory['categoryid']] = array('categoryid' => $curCategory['categoryid'], 'name' => makePath($curCategory['name']), 'path' => "\\" . $path, 'path_internal' => $curCategory['uniqid'], 'parentid' => $curCategory['parentid']);
    }
    return $categories;
}
Exemplo n.º 10
0
 function __construct($key = false, $value = false)
 {
     $filename = getDataPath() . "cache/";
     makePath($filename);
     file_put_contents($filename . md5($key), $value);
 }
Exemplo n.º 11
0
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;
}
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
//
// Strip out one flavor of BOM marker (the VWD kind)
if (strlen($pass) > 3 && ord($pass[0]) == 239 && ord($pass[1]) == 187 && ord($pass[2]) == 191) {
    $pass = substr($pass, 3);
}
/*
// For examining the contents of the user file character by character
for ($i = 0; $i < strlen($pass); $i++) {
	print ord($pass[$i]) . ": " . $pass[$i] . "\n";
}
*/
//
//if (strcmp($pass, $password)) {
if ($pass != $password) {
    //print "---";
    //var_dump($pass);
    //print "---";
    //var_dump($password);
    //print "[$pass][$password] " + strcmp($pass, $password);
    //print "---";
    //print "bad password (" . $pass . " vs " . $password . ")";
    print "bad password";
    exit;
}
session_start();
// don't allow session fixation (require a fresh id)
session_regenerate_id();
$_SESSION["user"] = $user;
$root = $_SESSION["root"] = $user . "/";
makePath($FILES_PATH . $root);