Exemplo n.º 1
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     User::created(function (User $user) {
         Folder::create(['name' => '/', 'user_id' => $user->id]);
         Activity::create(['type' => 'user_created', 'user_id' => $user->id]);
     });
     Folder::deleting(function (Folder $folder) {
         foreach ($folder->folders as $_folder) {
             $_folder->_delete();
         }
         foreach ($folder->files as $file) {
             $file->delete();
         }
     });
     File::deleting(function (File $file) {
         $file = updateFile($file, fileInfo($file));
         $filenames = [];
         if ($file->type == 'image') {
             $altImages = ['opt', 'xs'];
             foreach ($altImages as $suffix) {
                 $name = explode('.', $file->filename)[0];
                 $extension = explode('.', $file->filename)[1];
                 array_push($filenames, "{$name}.{$suffix}.{$extension}");
             }
         }
         Storage::delete($file->filename);
         if (!empty($filenames)) {
             foreach ($filenames as $filename) {
                 Storage::delete($filename);
             }
         }
     });
 }
Exemplo n.º 2
0
 function show(Activity $activity)
 {
     $file = false;
     $_file = false;
     if ($activity->item_id) {
         $file = FileModel::findOrFail($activity->item_id);
         $_file = fileInfo($file);
         $file = updateFile($file, $_file);
     }
     if ($file) {
         switch ($file->type) {
             case 'audio':
                 return "<audio preload='none' class=\"file-view\" controls>" . "<source src=\"{$file->src}\">" . "Your browser does not support the audio element." . "</audio>";
             case 'video':
                 return "<video preload='none' class=\"file-view\" controls>" . "<source src=\"{$file->src}\">" . "Your browser does not support the video tag." . "</video>";
             case 'image':
                 return "<img id=\"image-view\" class=\"file-view\" " . "src=\"{$file->src}/opt\"" . ">";
             default:
                 return '<div class="text-center text-danger">' . '<i class="fa fa-ban"></i> No Preview Available</div>';
         }
     }
 }
Exemplo n.º 3
0
$sErr .= $aVldt["error"];
if (isset($_POST["contents"])) {
    $sContents = $_POST["contents"];
}
//$aVldt["contents"];//$_POST["contents"];
//
switch ($sAction) {
    case "new":
        if (file_exists($sSFile)) {
            $sErr .= "File exists";
        } else {
            $oFile = fopen($sSFile, "w");
            fputs($oFile, stripslashes($sContents));
            fclose($oFile);
            chmod($sSFile, 0644);
            $oFNfo = fileInfo($sSFile);
            $sData = $oFNfo["stringdata"];
            $sMsg .= "new file created ... almost that is ... ";
        }
        break;
    case "edit":
        if (file_exists($sSFile)) {
            $oFile = fopen($sSFile, "w");
            fputs($oFile, stripslashes($sContents));
            fclose($oFile);
            $sMsg .= "File edited";
        } else {
            $sErr .= "File could not be found";
        }
        break;
    case "cont":
Exemplo n.º 4
0
<tbody>
<?php 
$d = $this->m_language->getAllLanguageFile($lang);
foreach ($d as $r) {
    $c = $this->m_language->getCountSection($lang, $r);
    $path = APPPATH . 'language/' . $lang . '/' . $r . '_lang.php';
    ?>
	<tr>
		<td><?php 
    echo ucfirst($r);
    ?>
</td>
		<td>
			<?php 
    $lastMod = fileInfo($path, 'date');
    $size = number_format(fileInfo($path, 'size') / 1024, 2);
    echo '<li>Jumlah item : ' . $c . '</li>';
    echo '<li>Diperbaharui : ' . date("d-M-Y H:i:s", $lastMod) . '</li>';
    echo '<li>Ukuran : ' . $size . ' KB</li>';
    ?>
		</td>		
		<td width="20%">
			<a href="<?php 
    echo base_url();
    ?>
editor/getsection?lang=<?php 
    echo $lang;
    ?>
&file=<?php 
    echo $r;
    ?>
Exemplo n.º 5
0
<?php

$path = $_GET['path'];
$value = $_COOKIE["stibium"];
$auth = json_decode($value, 1);
$service = $auth["service"];
if ($service == "ubuntuone") {
    @(include "backend/ubuntuone/login.php");
    $myoauth = loadAuth();
    $mylist = fileInfo($myoauth, $path);
    print $mylist;
}
if ($service == "dropbox") {
    print "Sorry, actually Stibium does not work with Dropbox. But our monkeys are working on it.";
}
if ($service == "owncloud") {
    print "Sorry, actually Stibium does not work with ownCloud. But our monkeys are working on it.";
}
if ($service == "googledocs") {
    print "Sorry, actually Stibium does not work with Google Docs. But our monkeys are working on it.";
}
?>
 
Exemplo n.º 6
0
             }
         }
     }
     break;
 case "addFolder":
     // add folder
     if (isset($_POST["folder"])) {
         $sFolderName = isset($_POST["foldername"]) ? $_POST["foldername"] : "new folder";
         $iRpt = 1;
         $sFolder = $sConnBse . $_POST["folder"] . $sFolderName;
         while (file_exists($sFolder)) {
             $sFolder = $sConnBse . $_POST["folder"] . $sFolderName . $iRpt++;
         }
         if (mkdir($sFolder)) {
             $sMsg .= "folderCreated";
             $oFNfo = fileInfo($sFolder);
             if ($oFNfo) {
                 $sData = $oFNfo["stringdata"];
             } else {
                 $sErr .= "folderFailed";
             }
         } else {
             $sErr .= "folderFailed";
         }
     }
     break;
 case "moveFiles":
     // move files
     if (isset($_POST["file"]) && isset($_POST["folder"]) && isset($_POST["nfolder"])) {
         //
         $sFolder = $_POST["folder"];
Exemplo n.º 7
0
function update()
{
    global $cfg, $db, $lastGenre_id, $getID3, $dirsCounter, $filesCounter, $curFilesCounter, $curDirsCounter;
    authenticate('access_admin', false, true);
    require_once 'getid3/getid3/getid3.php';
    require_once 'include/play.inc.php';
    // Needed for mpdUpdate()
    $cfg['cli_update'] = false;
    $startTime = new DateTime();
    $path = $cfg['media_dir'];
    $curFilesCounter = 0;
    $curDirsCounter = 0;
    $dirsCounter = 0;
    $filesCounter = 0;
    $prevDirsCounter = 0;
    $prevFilesCounter = 0;
    $dirs = array();
    /* $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
    	foreach($objects as $name){
    		if ($name->isDir()) {
    			++$dirsCounter;
    		}
    		else {
    			++$filesCounter;
    		}
    	} */
    //mysql_query('DELETE FROM genre');
    //$lastGenre_id = 1;
    // formattedNavigator
    $nav = array();
    $nav['name'][] = 'Configuration';
    $nav['url'][] = 'config.php';
    $nav['name'][] = 'Update';
    require_once 'include/header.inc.php';
    ?>
<table width="100%" cellspacing="0" cellpadding="0" class="border">
<tr class="header">
	<td class="space"></td>
	<td class="update_text">Update</td>
	<td>Progress</td>
	<td class="space"></td>
</tr>
<tr class="line"><td colspan="4"></td></tr>
<tr class="odd">
	<td></td>
	<td>Structure &amp; image:</td>
	<td><span id="structure"></span></td>
	<td></td>
</tr>
<tr class="even">
	<td></td>
	<td>File info:</td>
	<td><span id="fileinfo"></span></td>
	<td></td>
</tr>
<tr class="odd">
	<td></td>
	<td>Cleanup:</td>
	<td><span id="cleanup"></span></td>
	<td></td>
</tr>
<tr class="even">
	<td></td>
	<td>Update time:</td>
	<td><span id="updateTime"></span></td>
	<td></td>
</tr>
</table>
<script>
	hideSpinner();
	window.setInterval(function() {
		show_update_progress();
	}, 500);
	
	function show_update_progress() {
		$.ajax({
			type: "POST",
			url: "ajax-update-progress.php",
			dataType : 'json',
			success : function(json) {
				var s = json['structure_image'];
				if (s.indexOf("fa-spin") > -1) {
					if (!$("#structure").hasClass("fa-spin"))
						$("#structure").html(json['structure_image']);
				}
				else
					$("#structure").html(json['structure_image']);
				
				s = json['file_info'];
				if (s.indexOf("fa-spin") > -1) {
					if (!$("#fileinfo").hasClass("fa-spin"))
						$("#fileinfo").html(json['file_info']);
				}	
				else
					$("#fileinfo").html(json['file_info']);
				
				s = json['cleanup'];
				if (s.indexOf("fa-spin") > -1) {
					if (!$("#cleanup").hasClass("fa-spin"))
						$("#cleanup").html(json['cleanup']);
				}
				else
					$("#cleanup").html(json['cleanup']);
				
				$("#updateTime").html(json['update_time']);
				
			}
		});
	}
	
	</script>
	
	<?php 
    @ob_flush();
    flush();
    $cfg['footer'] = 'dynamic';
    require 'include/footer.inc.php';
    $getID3 = new getID3();
    //initial settings for getID3:
    include 'include/getID3init.inc.php';
    $result = mysql_query('SELECT * FROM update_progress');
    if (mysql_num_rows($result) == 0) {
        mysql_query('INSERT INTO update_progress (update_status, structure_image, file_info, cleanup, update_time, last_update)
						VALUES ("0", "", "", "", "", "")');
        $update_status = 0;
    } else {
        $row = mysql_fetch_assoc($result);
        $update_status = $row["update_status"];
    }
    if ($update_status != 1) {
        mysql_query("update update_progress set \n\t\t\tupdate_status = 1,\n\t\t\tstructure_image = '',\n\t\t\tfile_info = '',\n\t\t\tcleanup = '',\n\t\t\tupdate_time = '',\n\t\t\tlast_update = 'Update in progress..'");
        //@ob_flush();
        //flush();
        mysql_query("update update_progress set \n\t\t\tstructure_image = 'Requesting MPD update...'");
        mpdUpdate();
        //@ob_flush();
        //flush();
        mysql_query("update update_progress set \n\t\t\tstructure_image = '<i class=\"fa fa-cog larger icon-selected fa-spin\"></i>'");
        // Short sleep to prevent update problems with a previous update process that has not stopped yet.
        sleep(1);
        $cfg['new_escape_char_hash'] = hmacmd5(print_r($cfg['escape_char'], true), file_get_contents(NJB_HOME_DIR . 'update.php'));
        $cfg['force_filename_update'] = $cfg['new_escape_char_hash'] != $cfg['escape_char_hash'] ? true : false;
        $cfg['force_filename_update'] = false;
        if ($cfg['image_size'] != NJB_IMAGE_SIZE || $cfg['image_quality'] != NJB_IMAGE_QUALITY) {
            mysql_query('TRUNCATE TABLE bitmap');
            mysql_query('UPDATE server SET value = "' . mysql_real_escape_string(NJB_IMAGE_SIZE) . '" WHERE name = "image_size" LIMIT 1');
            mysql_query('UPDATE server SET value = "' . mysql_real_escape_string(NJB_IMAGE_QUALITY) . '" WHERE name = "image_quality" LIMIT 1');
        }
        mysql_query('UPDATE album SET updated = 0');
        mysql_query('UPDATE track SET updated = 0');
        mysql_query('UPDATE bitmap SET updated = 0');
        mysql_query('UPDATE genre SET updated = 0');
        mysql_query('UPDATE album_id SET updated = 0');
        //mysql_query('TRUNCATE album_id');
        $query = mysql_query('SELECT MAX(CAST(genre_id AS UNSIGNED)) AS last_genre_id FROM genre');
        $rsGenre = mysql_fetch_assoc($query);
        if ($rsGenre['last_genre_id'] > 0) {
            $lastGenre_id = $rsGenre['last_genre_id'] + 1;
        } else {
            $lastGenre_id = 1;
        }
        $cfg['timer'] = 0;
        // force update
        //recursiveScanCount_add2table($cfg['media_dir']);
        recursiveScanCount($cfg['media_dir']);
        /* $result = mysql_query("update update_progress set 
        			update_status = 0,
        			update_time = '" . $updateTime . "',
        			last_update = '" . date('Y-m-d, H:i:s')   . "'
        			");
        		exit(); */
        recursiveScan($cfg['media_dir']);
        //exit();
        mysql_query('UPDATE update_progress SET	structure_image = "<div class=\'out\'><div class=\'in\' style=\'width: 200px\'></div></div> 100%"');
        sleep(1);
        mysql_query('DELETE FROM album WHERE NOT updated');
        mysql_query('DELETE FROM track WHERE NOT updated');
        mysql_query('DELETE FROM bitmap WHERE NOT updated');
        mysql_query('DELETE FROM genre WHERE NOT updated');
        mysql_query('UPDATE server SET value = "' . mysql_real_escape_string($cfg['new_escape_char_hash']) . '" WHERE name = "escape_char_hash" LIMIT 1');
        $no_image = mysql_num_rows(mysql_query('SELECT album_id FROM bitmap WHERE flag = 0'));
        /* if ($no_image > 0)	{
        			mysql_query('update update_progress set 
        			structure_image = "<a href=\'update.php?action=imageUpdate&amp;flag=0\'><img src=\'' . $cfg['img'] . 'small_image.png\' alt=\'\' class=\'small space\'>Update ' . $no_image . (($no_image == 1) ? ' image' : ' images') . ' from internet</a>"');
        		} */
        if ($no_image > 0) {
            mysql_query('update update_progress set 
			structure_image = "<a href=\'statistics.php?action=noImageFront\'>No image for ' . $no_image . ($no_image == 1 ? ' folder' : ' folers') . '</a>"');
        } else {
            mysql_query('update update_progress set 
			structure_image = "<i class=\\"fa fa-check icon-ok \\"></i> "');
        }
        // @ob_flush();
        // flush();
        mysql_query('update update_progress set 
			file_info = "<i class=\\"fa fa-cog larger icon-selected fa-spin\\"></i>"');
        $cfg['timer'] = 0;
        // force update
        fileInfo();
        mysql_query('UPDATE update_progress SET	file_info = "<div class=\'out\'><div class=\'in\' style=\'width: 200px\'></div></div> 100%"');
        sleep(1);
        $error = mysql_num_rows(mysql_query('SELECT error FROM track WHERE error != ""'));
        if ($error > 0) {
            mysql_query('update update_progress set 
			file_info = "<a href=\'statistics.php?action=fileError\'><i class=\\"fa fa-minus-circle icon-nok\\"></i> ' . $error . ($error == 1 ? ' error' : ' errors') . '</a>"');
        } else {
            mysql_query('update update_progress set 
			file_info = "<i class=\\"fa fa-check icon-ok\\"></i> "');
        }
        // @ob_flush();
        // flush();
        mysql_query('update update_progress set 
			cleanup = "<i class=\\"fa fa-cog larger icon-selected fa-spin\\"></i> "');
        databaseCleanup();
        // @ob_flush();
        // flush();
        mysql_query('update update_progress set 
			cleanup = "<i class=\\"fa fa-check icon-ok\\"></i> "');
        $stopTime = new DateTime();
        $updateTime = $stopTime->diff($startTime);
        $updateTime = $updateTime->h . 'h ' . $updateTime->i . 'm ' . $updateTime->s . 's';
        $result = mysql_query("update update_progress set \n\t\t\tupdate_status = 0,\n\t\t\tupdate_time = '" . $updateTime . "',\n\t\t\tlast_update = '" . date('Y-m-d, H:i:s') . "'\n\t\t\t");
    } else {
        $structure_image = $row["structure_image"];
        echo '<script type="text/javascript"> document.getElementById(\'structure\').innerHTML=" ' . $structure_image . '";</script>' . "\n";
        $file_info = $row["file_info"];
        echo '<script type="text/javascript"> document.getElementById(\'fileinfo\').innerHTML=" ' . $file_info . '";</script>' . "\n";
        $cleanup = $row["cleanup"];
        echo '<script type="text/javascript"> document.getElementById(\'cleanup\').innerHTML=" ' . $cleanup . '";</script>' . "\n";
        $update_time = $row["update_time"];
        echo '<script type="text/javascript"> document.getElementById(\'updateTime\').innerHTML=" ' . $update_time . '";</script>' . "\n";
    }
    $cfg['footer'] = 'close';
    require 'include/footer.inc.php';
}
Exemplo n.º 8
0
 public function download(FileModel $file)
 {
     if (!$file->shared) {
         $this->authorize('all', $file);
     }
     $_file = fileInfo($file);
     $filename_extension = File::extension($file->filename);
     $name_extension = File::extension($file->name);
     $saveFileName = $file->name;
     if ($filename_extension != $name_extension) {
         $saveFileName .= ".{$filename_extension}";
     }
     return Response::download($_file['path'], $saveFileName);
 }