[fix] error when import dir

This commit is contained in:
Knah Tsaeb 2015-02-20 11:51:52 +01:00
parent 35e5873456
commit c17942470e
3 changed files with 131 additions and 75 deletions

View File

@ -3,30 +3,40 @@ require 'inc/topMenu.php';
if (!empty($ci['ac']) && $ci['ac'] === 'login') {
echo '<form action="?" method="post">
<fieldset>
<legend>Login</login>
<label>Login</label>
<input type="text" name="loginName" required/>
<label>Password</label>
<input type="password" name="loginPass" required/>
<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="', $token, '"/>
<input type="submit" />
<legend>Login</legend>
<p>
<label>Login</label>
<input type="text" name="loginName" required />
</p>
<p>
<label>Password</label>
<input type="password" name="loginPass" required />
</p>
<p>
<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="', $token, '"/>
<input type="submit" />
</p>
</fieldset>
</form>';
}
if (!empty($ci['ac']) && $ci['ac'] === 'newDir' && isLog()) {
echo '<form action="?" method="post">
<fieldset>
<legend>New directory</legend>
<label>Name</label>
<input type="text" name="newDir" autofocus/>
<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="', $token, '"/>
<input type="submit"/>
<p>
<legend>New directory</legend>
<label>Name</label>
</p>
<p>
<input type="text" name="newDir" autofocus/>
<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="', $token, '"/>
<input type="submit"/>
</p>
</fieldset>
</form>';
}
@ -36,13 +46,17 @@ if (!empty($ci['ac']) && $ci['ac'] === 'renDir' && isLog()) {
echo '<form action="?" method="post">
<fieldset>
<legend>', $fullListDir[$currentDir], '</legend>
<label>New name</label>
<input type="text" name="renDir" value="', $fullListDir[$currentDir], '" autofocus/>
<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="', $token, '"/>
<input type="submit"/>
<p>
<label>New name</label>
<input type="text" name="renDir" value="', $fullListDir[$currentDir], '" autofocus autocomplete="off"/>
</p>
<p>
<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="', $token, '"/>
<input type="submit"/>
</p>
</fieldset>
</form>';
}
@ -51,25 +65,33 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addVideo' && isLog()) {
echo '<form action="?" method="post">
<fieldset>
<legend>New video</legend>
<label>Url</label>
<input type="url" name="url" autofocus/>
<label>Name</label>
<input type="text" name="name"/>
<label>Description</label>
<textarea name="desc"></textarea>
<label>Via</label>
<input type="url" name="via" />
<label>Licence</label>
<select name="licence">
<option>CC-NC</option>
</select>
<label>Direct download</label>
<input type="checkbox" name="ddl" value="1"/>
<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="', $token, '"/>
<input type="submit"/>
<p>
<label>Url</label>
<input type="url" name="url" autofocus autocomplete="off"/>
</p>
<p>
<label>Name</label>
<input type="text" name="name" autocomplete="off"/>
</p>
<p>
<label>Description</label>
<textarea name="desc"></textarea>
</p>
<p>
<label>Via</label>
<input type="url" name="via" autocomplete="off"/>
</p>
<p>
<label>Direct download</label>
<input type="checkbox" name="ddl" value="1"/>
</p>
<p>
<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="', $token, '"/>
<input type="submit"/>
</p>
</fieldset>
</form>';
}
@ -77,13 +99,17 @@ if (!empty($ci['ac']) && $ci['ac'] === 'addThumbnail' && isLog()) {
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="', $token, '"/>
<input type="submit"/>
<p>
<label>Thumbnail</label>
<input type="file" name="file" />
</p>
<p>
<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="', $token, '"/>
<input type="submit"/>
</p>
</fieldset>
</form>';
}
@ -91,13 +117,17 @@ if (!empty($ci['ac']) && $ci['ac'] === 'importDirForm' && isLog()) {
echo '<form action="?" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Add dir</legend>
<label>Directory</label>
<input type="file" name="file" />
<input type="hidden" name="op" value="1"/>
<input type="hidden" name="ac" value="importDir" />
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
<input type="hidden" name="token" value="', $token, '"/>
<input type="submit"/>
<p>
<label>Directory</label>
<input type="file" name="file" />
</p>
<p>
<input type="hidden" name="op" value="1"/>
<input type="hidden" name="ac" value="importDir" />
<input type="hidden" name="bc" value="'.$ci['bc'].'" />
<input type="hidden" name="token" value="', $token, '"/>
<input type="submit"/>
</p>
</fieldset>
</form>';
}
@ -282,16 +312,12 @@ if (!empty($ci['ac']) && $ci['ac'] === 'view' && !empty($listCurrentFile)) {
echo '</td>
</tr>
<tr>
<th>Licence</th>
<td>', $videoInfo['licence'], '</td>
<th>Download</th>
<td><a href="', $downloadLink, '">Download</a></td>
</tr>
<tr>
<th>Download</th>
<td><a href="', $downloadLink, '">Download</a></td>
</tr>
<tr>
<th>View image preview</th>
<td><a href="', $path.$videoInfo['hash'], '.jpg">Image preview</a></td>
<th>View image preview</th>
<td><a href="', $path.$videoInfo['hash'], '.jpg">Image preview</a></td>
</tr>
</table>
</div>';

View File

@ -131,6 +131,12 @@ function logout() {
session_unset();
}
// In a string, converts urls to clickable links.
// src = https://github.com/sebsauvage/Shaarli/blob/master/index.php
function text2clickable($url) {
return preg_replace('!(((?:https?|ftp|file)://|apt:|magnet:)\S+[[:alnum:]]/?)!si', '<a href="'.$redir.'$1" rel="nofollow">$1</a>', $url);
}
function getCurrentDir($bc) {
$currentDir = end(str_split($bc, 8));
return $currentDir;
@ -231,7 +237,7 @@ function importDir($bc, $fullListDir, $fullListFile) {
'uploadDateSort' => $value['uploadDateSort']
);
$url = escapeshellcmd($value['url']);
$data = $key.' '.$url.' '.$_SERVER['DOCUMENT_ROOT'].'/'.$GLOBALS['config']['VIDEODIR'].'/'.$path.$file['hash'].'/'."\n";
$data = '0 '.$key.' '.$url.' '.$_SERVER['DOCUMENT_ROOT'].'/'.$GLOBALS['config']['VIDEODIR'].'/'.$path.$file['hash'].'/'."\n";
file_put_contents($GLOBALS['config']['TMPDIR'].'/'.$key.'.hash', $data);
}
file_put_contents($GLOBALS['config']['LISTFILE'], "<?php\n\$fullListFile=".var_export($fullListFile, true).";\n?>");
@ -277,9 +283,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 />';
@ -513,12 +519,12 @@ function makeRss($breadcrumb, $fullListFile) {
exit();
}
function updateVideoInfo($dc,$file) {
function updateVideoInfo($dc, $file) {
$path = chunk_split($dc, 8, '/');
$file = escapeshellcmd($file);
$bc = escapeshellcmd($path);
if( !is_file('bin/getInfo.sh')){
return 'You need configure bin/getInfo.sh';
if (!is_file('bin/getInfo.sh')) {
return 'You need configure bin/getInfo.sh';
}
exec('bash bin/getInfo.sh '.$file.' '.$bc, $result);
$jsonFile = json_decode(file_get_contents($GLOBALS['config']['VIDEODIR'].'/'.$path.$file.'.info.json'));
@ -823,8 +829,8 @@ if (isset($ci['ac']) && !empty($ci['ac'])) {
die('Tinker say : Blinded you, with Science! ');
}
$updateInfo = updateVideoInfo($ci['bc'], $ci['file']);
if($updateInfo !== true){
echo '<div class="error">',$updateInfo,'</div>';
if ($updateInfo !== true) {
echo '<div class="error">', $updateInfo, '</div>';
}
}
if ($ci['ac'] === 'viewQueue' || $ci['ac'] === 'clearCache') {
@ -877,6 +883,7 @@ if ($ci['ac'] === 'logout') {
<meta charset="utf-8">
<title>SoViGall - Personal Video Gallery</title>
<link rel="stylesheet" href="style.css">
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes" />
</head>
<body>
<?php

View File

@ -238,6 +238,29 @@ a {
margin: 0.4em auto;
}
form {
width: 50%;
margin: 0 auto;
}
label {
display: block;
}
input, textarea {
display: block;
width: 100%;
}
textarea {
height: 8em;
}
input[type="checkbox"] {
display: inline;
width: auto;
}
input, select, options {
color: #262626;
}
@ -312,5 +335,5 @@ video {
border-radius: 0.2em;
padding: 1.2em;
width: 40%;
text-align:center;
text-align: center;
}