function imageExists($dir, $image)
{
    $image_name = substr($image, 0, strrpos($image, "."));
    $image_ext = strrchr($image, ".");
    while (file_exists($dir . $image)) {
        $image = generateName() . $image_ext;
    }
    return $image;
}
function getExistingFilenames()
{
    $existingFiles = array();
    for ($i = 0; $i < 10; $i++) {
        $tbc = generateName($i);
        if (checkForExistance(explode(";", $tbc)[0])) {
            array_push($existingFiles, $tbc);
            // Die Datei für den aktuellen Typ wurde gefunden, springe zum nächsten Typ bzw. Ende
            $i = 5 * (floor($i / 5) + 1) - 1;
        }
    }
    return $existingFiles;
}
Beispiel #3
0
 public function testCallableGenerator()
 {
     function generateName()
     {
         return func_get_arg(0);
     }
     $generator = new Custom("FileUpload\\FileNameGenerator\\generateName");
     $playground_path = __DIR__ . '/../playground';
     $filename = "picture.jpg";
     $server = array('CONTENT_TYPE' => 'image/jpg', 'CONTENT_LENGTH' => 30321);
     $file = array('tmp_name' => $playground_path . '/real-image.jpg', 'name' => 'real-image.jpg', 'size' => 30321, 'type' => 'image/jpg', 'error' => 0);
     $fileUpload = new FileUpload($file, $server, $generator);
     $fileUpload->setFileSystem(new Mock());
     $fileUpload->setPathResolver(new Simple($playground_path . "/uploaded"));
     $new_filename = generateName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload);
     $this->assertEquals($generator->getFileName($filename, "image/jpg", "asdf.jpg", 0, "100", $fileUpload), $new_filename);
 }
function generateName()
{
    $animals = getAnimals();
    $animals = $animals[array_rand($animals)];
    shuffle($animals);
    $adjectives = getJson(__DIR__ . '/lib/adjectives.json');
    shuffle($adjectives);
    $adjective = $adjectives[array_rand($adjectives)];
    foreach ($animals as $animal) {
        if (strtoupper($animal[0]) === strtoupper($adjective[0])) {
            return ucwords(sprintf('%s %s', $adjective, $animal));
        } else {
            return generateName();
        }
    }
    return null;
}
function drawField($team)
{
    $field = imagecreatefromjpeg("img/field.jpg");
    foreach ($team->players as $player) {
        $img = drawPlayer($player->number, $player->name);
        $width = imagesx($img);
        $height = imagesy($img);
        $posX = $player->x - ($width - 26) / 2;
        $posY = $player->y - 10;
        imageAlphaBlending($field, true);
        // копировать сюда будем вместе с настройками
        imageSaveAlpha($field, true);
        // сохраняем
        imageCopy($field, $img, $posX, $posY, 0, 0, $width, $height);
        //копируем картинку с формой в пустой бокс
    }
    $copyright = drawCaption("http://www.ezheloko.ru/tactic", 12, 0);
    imagecopymerge_alpha($field, $copyright, 240, imagesY($field) - 25, 0, 0, imagesX($copyright), imagesY($copyright), 30);
    $name = generateName();
    $name = "formations/" . $name . ".png";
    imagePng($field, $name);
    return $name;
}
Beispiel #6
0
    $name = '';
    $file = '';
    require VIEWS . 'paste.php';
});
$app->post('/', function () use($app) {
    $paste = $app->request->post('paste');
    $name = generateName();
    file_put_contents(UPLOAD . $name, $paste);
    $app->response->redirect('/' . $name, 303);
});
// Paste.
$app->get(':paste+', function ($paste) use($app) {
    $name = $paste[1];
    $of = '';
    $isFork = file_exists(FORKS . $name);
    if ($isFork) {
        $of = file_get_contents(FORKS . $name);
    }
    $file = file_get_contents(UPLOAD . $name);
    require VIEWS . 'paste.php';
});
// Fork a paste.
$app->post(':paste+/f', function ($paste) use($app) {
    $of = $paste[1];
    $content = $app->request->post('paste');
    $name = generateName();
    file_put_contents(UPLOAD . $name, $content);
    file_put_contents(FORKS . $name, $of);
    $app->response->redirect('/' . $name, 303);
});
$app->run();
Beispiel #7
0
$aws_key = '15JQ4C5YE4T94J0TC582';
$aws_secret = 'CwBZjX4xWW/CZL3pigonVMXJ/boE+lPneggijjb9';
//
$file_temp = $_FILES['dropfile']['tmp_name'];
$file_name = $_FILES['dropfile']['name'];
$file_type = $_FILES['dropfile']['type'];
echo $file_temp . "<hr />" . $file_name . "<hr />";
echo $file_type . "<hr />";
$x = explode('.', $file_name);
$file_ext = '.' . end($x);
echo $file_ext . "<hr />";
$file_name = generateName();
echo $file_name . "<hr />";
while (dropFileExits($file_name . $file_ext)) {
    $file_name = generateName();
}
$source_file = $file_temp;
// file to upload to S3
if (!(substr($file_type, 0, 5) == "image")) {
    $file_type = "application/force-download";
    // or other file type like "image/jpeg" for JPEG image,
    // or "binary/octet-stream" for binary file
}
echo $file_type;
$aws_bucket = 'files.dropbin.com';
// AWS bucket
$aws_object = $file_name . $file_ext;
// AWS object name (file name)
if (strlen($aws_secret) != 40) {
    die("{$aws_secret} should be exactly 40 bytes long");
Beispiel #8
0
				</select> 
				<br />
				<input class="submit" style="color:#121212;" type="submit" value="Create" /> 
				<!-- <p style="padding-top:1em;"><i>Or would you rather <a href="cellular.php">generate a map?</a></i></p> -->
			</form>
		</div>
	<?php 
} else {
    ?>
		<!-- IF $_GET!=null -->
		<?php 
    if (isset($_GET['created'])) {
        ?>
			<!-- IF $_GET['created'] -->
			<?php 
        $_SESSION['theName'] = generateName($_POST);
        $theString = '<h1>' . $_SESSION['theName'] . '</h1>';
        ?>
			<div class="container">
				<h1 style="letter-spacing:0.2em;text-transform:uppercase;font-size:0.8em">your generated name was</h1>
				<!-- the comment -->
				<?php 
        echo $theString;
        ?>
				<form class="form" action="name.php?created=1" method="post">
					<select name="size" style="display:none"><option value="<?php 
        echo $_POST['size'];
        ?>
" selected><?php 
        echo $_POST['size'];
        ?>
Beispiel #9
0
    } while (!empty($url));
    return $name;
}
$app->get('/', function () use($app) {
    return view('index');
});
$app->post('create', function (Request $request) use($app) {
    $requested = $request->input('url');
    if (empty($requested)) {
        return 'Sorry, you can not enter nothing.';
    }
    // Do a quick check.
    if (substr($requested, 0, 4) !== "http") {
        $requested = "http://" . $requested;
    }
    $url = Url::create(['name' => generateName(), 'url' => $requested, 'hits' => 0]);
    return view('created', compact('url'));
});
// URL stats.
$app->get('{name:.*}/s', function ($name) {
    $url = Url::where('name', '=', $name)->first();
    if (empty($url)) {
        return 'Not found: ' . $name;
    }
    return view('stats', compact('url'));
});
// URL deletion.
$app->get('{name:.*}/d', function ($name) {
    $url = Url::where('name', '=', $name)->first();
    if (empty($url)) {
        return 'Not found: ' . $name;
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
require_once "../../../maincore.php";
require_once INFUSIONS . "mg/infusion_db.php";
require_once INFUSIONS . "mg/functions.php";
require_once INCLUDES . "photo_functions_include.php";
global $userdata;
// 5 minutes execution time
@set_time_limit(5 * 60);
$photo_name = str_replace(" ", "_", strtolower(substr($_FILES['file']['name'], 0, strrpos($_FILES['file']['name'], "."))));
$photo_ext = strtolower(strrchr($_FILES['file']['name'], "."));
$targetPath = IMAGES . "mg_photos/";
$new_name = generateName();
while (file_exists($targetPath . $new_name . $photo_ext)) {
    $new_name = generateName();
}
$targetName = $new_name . $photo_ext;
$tempFile = $_FILES['file']['tmp_name'];
$targetFile = $targetPath . $targetName;
move_uploaded_file($tempFile, $targetFile);
$origin = $targetName;
$size = @getimagesize($targetPath . $origin);
if ($size[0] > $mg_settings['photo_width'] || $size[1] > $mg_settings['photo_height']) {
    $t1 = imageExists($targetPath, $new_name . "_t1" . $photo_ext);
    createthumbnail($size[2], $targetPath . $origin, $targetPath . $t1, $mg_settings['photo_width'], $mg_settings['photo_height']);
} else {
    $t1 = $origin;
}
if ($size[0] > $mg_settings['thumb_width'] || $size[1] > $mg_settings['thumb_height']) {
    $t2 = imageExists($targetPath, $new_name . "_t2" . $photo_ext);