Skip to content

Commit

Permalink
Try to make a better filename
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel authored and daniel committed Jul 8, 2017
1 parent 4459788 commit 3055705
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion objects/downloadVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$obj->title = __("Congratulations!");
$obj->text = sprintf(__("Your video (%s) is downloading"), $title);
$filename = preg_replace("/[^A-Za-z0-9]+/", "_", $title);
$filename = uniqid("{$filename}_", true).".mp4";
$filename = uniqid("{$filename}_uniqid_", true).".mp4";
$cmd = PHP_BINDIR."/php -f youtubeDl.php {$filename} {$_POST['videoURL']} {$userId} > /dev/null 2>/dev/null &";
exec($cmd);
$obj->command = $cmd;
Expand Down
3 changes: 2 additions & 1 deletion objects/youtubeDl.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
// save and encode video
$_FILES['upl'] = array();
$_FILES['upl']['error'] = 0;
$_FILES['upl']['name'] = $filename;
$videoNamePart = explode("_uniqid_", $filename);
$_FILES['upl']['name'] = $videoNamePart[0];
$_FILES['upl']['tmp_name'] = "{$dir}{$filename}";
$_FILES['upl']['dontMoveUploadedFile'] = true;

Expand Down
2 changes: 1 addition & 1 deletion view/include/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<div>
<a href="<?php echo $global['webSiteRootURL']; ?>charts" class="btn btn-info btn-xs btn-block">
<span class="fa fa-bar-chart"></span>
<?php echo __("Video Chart"); ?>
<?php echo __("Video Statistics"); ?>
</a>
</div>
</li>
Expand Down
4 changes: 2 additions & 2 deletions view/mini-upload-form/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@

$path_parts = pathinfo($_FILES['upl']['name']);
$mainName = preg_replace("/[^A-Za-z0-9]/", "", $path_parts['filename']);
$filename = uniqid($mainName . "_", true);

$filename = uniqid($mainName . "_uniqid_", true);
$video = new Video(preg_replace("/_+/", " ", $_FILES['upl']['name']), $filename, @$_FILES['upl']['videoId']);
$video->setDuration($duration);
if ($type == 'audio') {
Expand Down

0 comments on commit 3055705

Please sign in to comment.