[add] upload thumbnail for dir
This commit is contained in:
parent
a0ef7f8865
commit
692be89354
|
@ -11,7 +11,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'login') {
|
|||
<input type="hidden" name="op" value="2"/>
|
||||
<input type="hidden" name="ac" value="login"/>
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="submit" />
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -25,7 +25,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'newDir') {
|
|||
<input type="hidden" name="op" value="1"/>
|
||||
<input type="hidden" name="ac" value="newDir" />
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -41,7 +41,7 @@ if (!empty($ci['ac']) && $ci['ac'] === 'renDir') {
|
|||
<input type="hidden" name="op" value="1"/>
|
||||
<input type="hidden" name="ac" value="renDir" />
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
|
@ -66,12 +66,25 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addVideo') {
|
|||
<input type="hidden" name="op" value="1"/>
|
||||
<input type="hidden" name="ac" value="addVideo" />
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'addThumbnail') {
|
||||
echo '<form action="?" method="post" enctype="multipart/form-data">
|
||||
<fieldset>
|
||||
<legend>Add thumbnail</legend>
|
||||
<label>Thumbnail</label>
|
||||
<input type="file" name="file" />
|
||||
<input type="hidden" name="op" value="1"/>
|
||||
<input type="hidden" name="ac" value="addThumbnail" />
|
||||
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
|
||||
<input type="hidden" name="token" value="', genToken(), '"/>
|
||||
<input type="submit"/>
|
||||
</fieldset>
|
||||
</form>';
|
||||
}
|
||||
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'view') {
|
||||
if (!empty($ci['op']) && (int)$ci['op'] === 1) {
|
||||
verifToken($ci['token']);
|
||||
|
@ -174,7 +187,7 @@ if ($ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Url</th>
|
||||
<td><a href="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
<td><a href="', htmlentities($videoInfo['url']), '">', $videoInfo['url'], '</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Duration</th>
|
||||
|
@ -187,7 +200,7 @@ if ($ci['ac'] === 'view' && !empty($listCurrentFile)) {
|
|||
<th>Via</th>
|
||||
<td>';
|
||||
if (!empty($videoInfo['via'])) {
|
||||
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
||||
echo '<a href="', htmlentities($videoInfo['via']), '">', $videoInfo['via'], '</a>';
|
||||
} else {
|
||||
echo '';
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
echo '
|
||||
<li><a href="?ac=newDir&bc=', $ci['bc'], '">New directory</a></li>
|
||||
<li><a href="?ac=renDir&bc=', $ci['bc'], '">Rename directory</a></li>
|
||||
<li><a href="?ac=addVideo&bc=', $ci['bc'], '">Add videos</a></li>';
|
||||
<li><a href="?ac=addVideo&bc=', $ci['bc'], '">Add video</a></li>
|
||||
<li><a href="?ac=addThumbnail&bc=', $ci['bc'], '">Add thumbnail</a></li>';
|
||||
} else {
|
||||
echo '<li><a href="?ac=login&bc=', $ci['bc'], '">Login</a></li>';
|
||||
}
|
||||
|
|
67
index.php
67
index.php
|
@ -25,7 +25,8 @@ $GLOBALS['config']['BAN_DURATION'] = 1800;
|
|||
$GLOBALS['config']['PAGECACHE'] = 'pagecache';
|
||||
|
||||
if (get_magic_quotes_gpc()) {
|
||||
function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
||||
function stripslashes_deep($value) {
|
||||
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
@ -64,7 +65,6 @@ function install($ci) {
|
|||
if (!copy('inc/.htaccess', $GLOBALS['config']['TMPDIR'].'/.htaccess')) {
|
||||
die('Error on create .httaccess in dir "'.$GLOBALS['config']['TMPDIR'].'"');
|
||||
}
|
||||
|
||||
if (!is_file($GLOBALS['config']['CONFIG_FILE'])) {
|
||||
touch($GLOBALS['config']['CONFIG_FILE']);
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ function n_print($data, $name = '') {
|
|||
<fieldset style="border: 1px solid orange; padding: 5px;color:#1E1915; background-color: #fff;">';
|
||||
echo '
|
||||
<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '
|
||||
</legend>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '<pre style="color:#1E1915;">', htmlentities(print_r($data, 1)), '</pre>';
|
||||
echo '
|
||||
</fieldset>
|
||||
<br />';
|
||||
|
@ -315,6 +315,61 @@ function defineThumb($bc, $file) {
|
|||
}
|
||||
}
|
||||
|
||||
function addThumbnail($bc) {
|
||||
if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
|
||||
echo 'Error on upload file.';
|
||||
}
|
||||
if ($_FILES['file']['error'] > 0) {
|
||||
$msgError = array(
|
||||
'1' => 'Le fichier excède le poids autorisé par la directive upload_max_filesize de php.ini',
|
||||
'2' => 'Le fichier excède le poids autorisé par le champ MAX_FILE_SIZE s\'il a été donné',
|
||||
'3' => 'Thumbnail are partially upload',
|
||||
'4' => 'Thumbnail are not upload'
|
||||
);
|
||||
echo $msgError[$_FILES["file"]["error"]];
|
||||
}
|
||||
$tmpName = $_FILES["file"]["tmp_name"];
|
||||
if ((int) extension_loaded('fileinfo') === 1) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$type = finfo_file($finfo, $tmpName);
|
||||
finfo_close($finfo);
|
||||
} else {
|
||||
echo 'Please active fileinfo extension';
|
||||
}
|
||||
$permitImage = array(
|
||||
'image/gif',
|
||||
'image/jpg',
|
||||
'image/jpeg',
|
||||
'image/pjpeg',
|
||||
'image/png'
|
||||
);
|
||||
if (!in_array($type, $permitImage)) {
|
||||
echo 'This type '.$type.' file is not permit. Convert it and retry.';
|
||||
}
|
||||
$path = chunk_split($bc, 8, '/');
|
||||
if (!move_uploaded_file($_FILES['file']['tmp_name'], $GLOBALS['config']['VIDEODIR'].'/'.$path.'thumb'.'.tmp')) {
|
||||
echo 'Error on move file to final destination.';
|
||||
} else {
|
||||
convertToJpeg($path, $type);
|
||||
}
|
||||
}
|
||||
|
||||
function convertToJpeg($path, $type) {
|
||||
$pathAndNameFile = $GLOBALS['config']['VIDEODIR'].'/'.$path.'thumb'.'.tmp';
|
||||
if ($type == 'image/jpeg') {
|
||||
$image = imagecreatefromjpeg($pathAndNameFile);
|
||||
}
|
||||
if ($type == 'image/png') {
|
||||
$image = imagecreatefrompng($pathAndNameFile);
|
||||
}
|
||||
if ($type == 'image/gif') {
|
||||
$image = imagecreatefromgif($pathAndNameFile);
|
||||
}
|
||||
imagejpeg($image, $GLOBALS['config']['VIDEODIR'].'/'.$path.'thumb'.'.jpg', 100);
|
||||
imagedestroy($image);
|
||||
unlink($pathAndNameFile);
|
||||
}
|
||||
|
||||
if (!empty($ci['ac']) && $ci['ac'] === 'login' && !empty($ci['op']) && (int)$ci['op'] === 2) {
|
||||
verifToken($ci['token']);
|
||||
if (login($ci) === true) {
|
||||
|
@ -340,6 +395,10 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
|
|||
verifToken($ci['token']);
|
||||
$addVideo = addVideo($ci, $fullListFile);
|
||||
}
|
||||
if ($ci['ac'] === 'addThumbnail' && !empty($ci['op']) && (int)$ci['op'] === 1) {
|
||||
verifToken($ci['token']);
|
||||
$addThumbnail = addThumbnail($ci['bc']);
|
||||
}
|
||||
if ($ci['ac'] === 'view' && !empty($ci['op']) && (int)$ci['op'] === 3) {
|
||||
verifToken($ci['token']);
|
||||
if ($_SESSION['log'] !== true) {
|
||||
|
|
17
style.css
17
style.css
|
@ -66,32 +66,37 @@ body {
|
|||
text-align: center;
|
||||
overflow: hidden;
|
||||
text-overflow: "...";
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#listFile img {
|
||||
width: 100%;
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
vertical-align: middle;
|
||||
max-height: 170px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.dir, .video {
|
||||
background-image: url("folder.svg");
|
||||
background-repeat: no-repeat;
|
||||
background-size: 100%;
|
||||
background-size: 48px;
|
||||
position: absolute;
|
||||
height: 48px;
|
||||
width: 48px;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.video {
|
||||
background-image: url("video.svg");
|
||||
background-image: url("video.svg");
|
||||
}
|
||||
|
||||
.fulldir {
|
||||
background-image: url("folder.svg");
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: auto 100%;
|
||||
background-size: auto 170px;
|
||||
display: block;
|
||||
height: 170px;
|
||||
width: 270px;
|
||||
|
@ -135,6 +140,10 @@ input[type="submit"] {
|
|||
color: #262626;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
color: #DFDFDF;
|
||||
}
|
||||
|
||||
video {
|
||||
width: 55%;
|
||||
}
|
Loading…
Reference in New Issue