Merge branch 'master' into interface
This commit is contained in:
commit
ba246d3b27
|
@ -2,7 +2,7 @@
|
|||
|
||||
OC_APP::register( array( "order" => 1, "id" => "admin", "name" => "Administration" ));
|
||||
|
||||
OC_APP::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" =>"System", "icon" => OC_HELPER::imagePath( "admin", "administration.png" )));
|
||||
// OC_APP::addAdminPage( array( "id" => "core_system", "order" => 1, "href" => OC_HELPER::linkTo( "admin", "system.php" ), "name" =>"System", "icon" => OC_HELPER::imagePath( "admin", "administration.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_users", "order" => 2, "href" => OC_HELPER::linkTo( "admin", "users.php" ), "name" => "Users", "icon" => OC_HELPER::imagePath( "admin", "users.png" )));
|
||||
OC_APP::addAdminPage( array( "id" => "core_apps", "order" => 3, "href" => OC_HELPER::linkTo( "admin", "apps.php?installed" ), "name" => "Apps", "icon" => OC_HELPER::imagePath( "admin", "apps.png" )));
|
||||
|
||||
|
|
|
@ -105,6 +105,9 @@ if($arguments['action']){
|
|||
|
||||
$ftype=OC_FILESYSTEM::getMimeType( $arguments['path'] );
|
||||
|
||||
$songId=OC_MEDIA_COLLECTION::getSongByPath($arguments['path']);
|
||||
OC_MEDIA_COLLECTION::registerPlay($songId);
|
||||
|
||||
header('Content-Type:'.$ftype);
|
||||
header('Expires: 0');
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
|
|
|
@ -206,6 +206,24 @@
|
|||
<length>4</length>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>song_playcount</name>
|
||||
<type>integer</type>
|
||||
<default>
|
||||
</default>
|
||||
<notnull>true</notnull>
|
||||
<length>4</length>
|
||||
</field>
|
||||
|
||||
<field>
|
||||
<name>song_lastplayed</name>
|
||||
<type>integer</type>
|
||||
<default>
|
||||
</default>
|
||||
<notnull>true</notnull>
|
||||
<length>4</length>
|
||||
</field>
|
||||
|
||||
</declaration>
|
||||
|
||||
</table>
|
||||
|
|
|
@ -270,7 +270,8 @@ class OC_MEDIA_COLLECTION{
|
|||
if($songId!=0){
|
||||
return $songId;
|
||||
}else{
|
||||
$query=OC_DB::prepare("INSERT INTO `*PREFIX*media_songs` (`song_id` ,`song_name` ,`song_artist` ,`song_album` ,`song_path` ,`song_user`,`song_length`,`song_track`,`song_size`) VALUES (NULL , ?, ?, ?, ?,?,?,?,?)");
|
||||
$query=OC_DB::prepare("INSERT INTO `*PREFIX*media_songs` (`song_id` ,`song_name` ,`song_artist` ,`song_album` ,`song_path` ,`song_user`,`song_length`,`song_track`,`song_size`,`song_playcount`,`song_lastplayed`)
|
||||
VALUES (NULL , ?, ?, ?, ?,?,?,?,?,0,0)");
|
||||
$query->execute(array($name,$artist,$album,$path,$uid,$length,$track,$size));
|
||||
$songId=OC_DB::insertid();
|
||||
// self::setLastUpdated();
|
||||
|
@ -346,6 +347,31 @@ class OC_MEDIA_COLLECTION{
|
|||
$query=OC_DB::prepare("DELETE FROM *PREFIX*media_songs WHERE song_path LIKE ?");
|
||||
$query->execute(array("$path%"));
|
||||
}
|
||||
|
||||
/**
|
||||
* increase the play count of a song
|
||||
* @param int songId
|
||||
*/
|
||||
public static function registerPlay($songId){
|
||||
$now=time();
|
||||
$query=OC_DB::prepare('UPDATE *PREFIX*media_songs SET song_playcount=song_playcount+1, song_lastplayed=? WHERE song_id=? AND song_lastplayed<?');
|
||||
$query->execute(array($now,$songId,$now-60));
|
||||
}
|
||||
|
||||
/**
|
||||
* get the id of the song by path
|
||||
* @param string $path
|
||||
* @return int
|
||||
*/
|
||||
public static function getSongByPath($path){
|
||||
$query=OC_DB::prepare("SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?");
|
||||
$result=$query->execute(array($path))->fetchAll();
|
||||
if(count($result)>0){
|
||||
return $result[0]['song_id'];
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -68,10 +68,48 @@ class OC_MEDIA_SCANNER{
|
|||
* @return boolean
|
||||
*/
|
||||
public static function scanFile($path){
|
||||
$file=OC_FILESYSTEM::getLocalFile($path);
|
||||
if(substr($path,-3)=='mp3' and OC_HELPER::canExecute("id3info") and OC_HELPER::canExecute("mp3info")){//use the command line tool id3info if possible
|
||||
$output=array();
|
||||
$size=filesize($file);
|
||||
$length=0;
|
||||
$title='unknown';
|
||||
$album='unknown';
|
||||
$artist='unknown';
|
||||
$track=0;
|
||||
exec('id3info "'.$file.'"',$output);
|
||||
$data=array();
|
||||
foreach($output as $line) {
|
||||
switch(substr($line,0,3)){
|
||||
case '***'://comments
|
||||
break;
|
||||
case '==='://tag information
|
||||
$key=substr($line,4,4);
|
||||
$value=substr($line,strpos($line,':')+2);
|
||||
switch(strtolower($key)){
|
||||
case 'tit1':
|
||||
case 'tit2':
|
||||
$title=$value;
|
||||
break;
|
||||
case 'tpe1':
|
||||
case 'tpe2':
|
||||
$artist=$value;
|
||||
break;
|
||||
case 'talb':
|
||||
$album=$value;
|
||||
break;
|
||||
case 'trck':
|
||||
$track=$value;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$length=exec('mp3info -p "%S" "'.$file.'"');
|
||||
}else{
|
||||
if(!self::$getID3){
|
||||
self::$getID3=@new getID3();
|
||||
}
|
||||
$file=OC_FILESYSTEM::getLocalFile($path);
|
||||
$data=@self::$getID3->analyze($file);
|
||||
getid3_lib::CopyTagsToComments($data);
|
||||
if(!isset($data['comments'])){
|
||||
|
@ -102,6 +140,7 @@ class OC_MEDIA_SCANNER{
|
|||
$size=$data['filesize'];
|
||||
$track=(isset($data['comments']['track']))?$data['comments']['track'][0]:0;
|
||||
$length=round($data['playtime_seconds']);
|
||||
}
|
||||
if(!isset(self::$artists[$artist])){
|
||||
$artistId=OC_MEDIA_COLLECTION::addArtist($artist);
|
||||
self::$artists[$artist]=$artistId;
|
||||
|
|
|
@ -329,27 +329,27 @@ function checkid ( $wait ) {
|
|||
user_session();
|
||||
|
||||
// Get the options, use defaults as necessary
|
||||
$return_to = @strlen($_REQUEST['openid_return_to'])
|
||||
$return_to = isset($_REQUEST['openid_return_to'])
|
||||
? $_REQUEST['openid_return_to']
|
||||
: error_400('Missing return1_to');
|
||||
: error_400('Missing return_to');
|
||||
|
||||
$identity = @strlen($_REQUEST['openid_identity'])
|
||||
$identity = isset($_REQUEST['openid_identity'])
|
||||
? $_REQUEST['openid_identity']
|
||||
: error_get($return_to, 'Missing identity');
|
||||
|
||||
$assoc_handle = @strlen($_REQUEST['openid_assoc_handle'])
|
||||
$assoc_handle = isset($_REQUEST['openid_assoc_handle'])
|
||||
? $_REQUEST['openid_assoc_handle']
|
||||
: null;
|
||||
|
||||
$trust_root = @strlen($_REQUEST['openid_trust_root'])
|
||||
$trust_root = isset($_REQUEST['openid_trust_root'])
|
||||
? $_REQUEST['openid_trust_root']
|
||||
: $return_to;
|
||||
|
||||
$sreg_required = @strlen($_REQUEST['openid_sreg_required'])
|
||||
$sreg_required = isset($_REQUEST['openid_sreg_required'])
|
||||
? $_REQUEST['openid_sreg.required']
|
||||
: '';
|
||||
|
||||
$sreg_optional = @strlen($_REQUEST['openid_sreg_optional'])
|
||||
$sreg_optional = isset($_REQUEST['openid_sreg_optional'])
|
||||
? $_REQUEST['openid_sreg.optional']
|
||||
: '';
|
||||
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
<form name="filesForm" action='#' method='post'>
|
||||
<?php if($_['htaccessWorking']):?>
|
||||
<label for="maxUploadSize"><?php echo $l->t( 'Maximum upload size' ); ?> </label><input name='maxUploadSize' id="maxUploadSize" value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
|
||||
<input type='submit' value='Save'/>
|
||||
<?php else:?>
|
||||
No settings currently available.
|
||||
<?php endif;?>
|
||||
<input type="checkbox" name="publicEnable" id="publicEnable" /><label for="publicEnable"> <?php echo $l->t( 'Allow public folders' ); ?></label><br>
|
||||
<!-- <input type="checkbox" name="publicEnable" id="publicEnable" /><label for="publicEnable"> <?php echo $l->t( 'Allow public folders' ); ?></label><br>
|
||||
|
||||
<div style="padding-left: 20px">
|
||||
<input type="radio" name="sharingaim" id="separated" /><label for="separated"> <?php echo $l->t( 'separated from webdav storage' ); ?></label><br>
|
||||
|
@ -13,6 +16,5 @@
|
|||
</div>
|
||||
|
||||
<input type="checkbox" id="downloadShared" /><label for="downloadShared"> <?php echo $l->t( 'Allow downloading shared files' ); ?></label><br>
|
||||
<input type="checkbox" id="uploadShared" /><label for="uploadShared"> <?php echo $l->t( 'Allow uploading in shared directory' ); ?></label><br>
|
||||
<input type='submit' value='Save'/>
|
||||
<input type="checkbox" id="uploadShared" /><label for="uploadShared"> <?php echo $l->t( 'Allow uploading in shared directory' ); ?></label><br>-->
|
||||
</form>
|
||||
|
|
|
@ -200,7 +200,7 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
|||
} else if (function_exists("mime_content_type")) {
|
||||
// use mime magic extension if available
|
||||
$mime_type = mime_content_type($this->datadir.$fspath);
|
||||
} else if (self::canExecute("file")) {
|
||||
} else if (OC_HELPER::canExecute("file")) {
|
||||
// it looks like we have a 'file' command,
|
||||
// lets see it it does have mime support
|
||||
$fp = popen("file -i -b '{$this->datadir}$fspath' 2>/dev/null", "r");
|
||||
|
@ -223,62 +223,6 @@ class OC_FILESTORAGE_LOCAL extends OC_FILESTORAGE{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* detect if a given program is found in the search PATH
|
||||
*
|
||||
* helper function used by _mimetype() to detect if the
|
||||
* external 'file' utility is available
|
||||
*
|
||||
* @param string program name
|
||||
* @param string optional search path, defaults to $PATH
|
||||
* @return bool true if executable program found in path
|
||||
*/
|
||||
private function canExecute($name, $path = false)
|
||||
{
|
||||
// path defaults to PATH from environment if not set
|
||||
if ($path === false) {
|
||||
$path = getenv("PATH");
|
||||
}
|
||||
|
||||
// check method depends on operating system
|
||||
if (!strncmp(PHP_OS, "WIN", 3)) {
|
||||
// on Windows an appropriate COM or EXE file needs to exist
|
||||
$exts = array(".exe", ".com");
|
||||
$check_fn = "file_exists";
|
||||
} else {
|
||||
// anywhere else we look for an executable file of that name
|
||||
$exts = array("");
|
||||
$check_fn = "is_executable";
|
||||
}
|
||||
|
||||
// Default check will be done with $path directories :
|
||||
$dirs = explode(PATH_SEPARATOR, $path);
|
||||
|
||||
// WARNING : We have to check if open_basedir is enabled :
|
||||
$obd = ini_get('open_basedir');
|
||||
|
||||
if($obd != "none")
|
||||
$obd_values = explode(PATH_SEPARATOR, $obd);
|
||||
|
||||
if(count($obd_values) > 0)
|
||||
{
|
||||
// open_basedir is in effect !
|
||||
// We need to check if the program is in one of these dirs :
|
||||
$dirs = $obd_values;
|
||||
}
|
||||
|
||||
foreach($dirs as $dir)
|
||||
{
|
||||
foreach($exts as $ext)
|
||||
{
|
||||
if($check_fn("$dir/$name".$ext))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function toTmpFile($path){
|
||||
$tmpFolder=sys_get_temp_dir();
|
||||
$filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.')));
|
||||
|
|
|
@ -267,6 +267,51 @@ class OC_HELPER {
|
|||
if((isset($_REQUEST[$s]) && $_REQUEST[$s]==$v) || $v == $d)
|
||||
print "checked=\"checked\" ";
|
||||
}
|
||||
|
||||
/**
|
||||
* detect if a given program is found in the search PATH
|
||||
*
|
||||
* @param string program name
|
||||
* @param string optional search path, defaults to $PATH
|
||||
* @return bool true if executable program found in path
|
||||
*/
|
||||
public static function canExecute($name, $path = false){
|
||||
// path defaults to PATH from environment if not set
|
||||
if ($path === false) {
|
||||
$path = getenv("PATH");
|
||||
}
|
||||
// check method depends on operating system
|
||||
if (!strncmp(PHP_OS, "WIN", 3)) {
|
||||
// on Windows an appropriate COM or EXE file needs to exist
|
||||
$exts = array(".exe", ".com");
|
||||
$check_fn = "file_exists";
|
||||
} else {
|
||||
// anywhere else we look for an executable file of that name
|
||||
$exts = array("");
|
||||
$check_fn = "is_executable";
|
||||
}
|
||||
// Default check will be done with $path directories :
|
||||
$dirs = explode(PATH_SEPARATOR, $path);
|
||||
// WARNING : We have to check if open_basedir is enabled :
|
||||
$obd = ini_get('open_basedir');
|
||||
if($obd != "none")
|
||||
$obd_values = explode(PATH_SEPARATOR, $obd);
|
||||
if(count($obd_values) > 0 and $obd_values[0])
|
||||
{
|
||||
// open_basedir is in effect !
|
||||
// We need to check if the program is in one of these dirs :
|
||||
$dirs = $obd_values;
|
||||
}
|
||||
foreach($dirs as $dir)
|
||||
{
|
||||
foreach($exts as $ext)
|
||||
{
|
||||
if($check_fn("$dir/$name".$ext))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -51,7 +51,7 @@ class OC_LOG {
|
|||
* This function adds another entry to the log database
|
||||
*/
|
||||
public static function add( $appid, $subject, $predicate, $object = ' ' ){
|
||||
$query=OC_DB::prepare("INSERT INTO *PREFIX*log(moment,appid,user,action,info) VALUES(NOW(),?,?,?,?)");
|
||||
$query=OC_DB::prepare("INSERT INTO `*PREFIX*log`(moment,appid,user,action,info) VALUES(NOW(),?,?,?,?)");
|
||||
$result=$query->execute(array($appid,$subject,$predicate,$object));
|
||||
// Die if we have an error
|
||||
if( PEAR::isError($result)) {
|
||||
|
@ -79,7 +79,7 @@ class OC_LOG {
|
|||
* - app: only entries for this app
|
||||
*/
|
||||
public static function get( $filter = array()){
|
||||
$queryString='SELECT * FROM *PREFIX*log WHERE 1=1 ORDER BY moment DESC';
|
||||
$queryString='SELECT * FROM `*PREFIX*log` WHERE 1=1 ORDER BY moment DESC';
|
||||
$params=array();
|
||||
if(isset($filter['from'])){
|
||||
$queryString.='AND moment>? ';
|
||||
|
@ -116,7 +116,7 @@ class OC_LOG {
|
|||
* This function deletes all entries that are older than $date.
|
||||
*/
|
||||
public static function deleteBefore( $date ){
|
||||
$query=OC_DB::prepare("DELETE FROM *PREFIX*log WHERE moment<?");
|
||||
$query=OC_DB::prepare("DELETE FROM `*PREFIX*log` WHERE moment<?");
|
||||
$query->execute(array($date));
|
||||
return true;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class OC_LOG {
|
|||
* This function deletes all log entries.
|
||||
*/
|
||||
public static function deleteAll(){
|
||||
$query=OC_DB::prepare("DELETE FROM *PREFIX*log");
|
||||
$query=OC_DB::prepare("DELETE FROM `*PREFIX*log`");
|
||||
$query->execute();
|
||||
return true;
|
||||
}
|
||||
|
|
72
lib/ocs.php
72
lib/ocs.php
|
@ -463,7 +463,6 @@ class OC_OCS {
|
|||
$xml[$i]['key']=$log['key'];
|
||||
$xml[$i]['app']=$log['app'];
|
||||
$xml[$i]['value']=$log['value'];
|
||||
$xml[$i]['timestamp']=$log['timestamp'];
|
||||
}
|
||||
|
||||
|
||||
|
@ -511,28 +510,26 @@ class OC_OCS {
|
|||
* @param bool $like use LIKE instead of = when comparing keys
|
||||
* @return array
|
||||
*/
|
||||
public static function getData($user,$app="",$key="",$like=false) {
|
||||
$key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy, needs to be replaced with a seperate user field the next time we break db compatibiliy
|
||||
$compareFunction=($like)?'LIKE':'=';
|
||||
|
||||
public static function getData($user,$app="",$key="") {
|
||||
if($app){
|
||||
if (!trim($key)) {
|
||||
$query = OC_DB::prepare('select app, `key`,value,`timestamp` from *PREFIX*privatedata where app=? order by `timestamp` desc');
|
||||
$result=$query->execute(array($app))->fetchAll();
|
||||
$apps=array($app);
|
||||
}else{
|
||||
$query = OC_DB::prepare("select app, `key`,value,`timestamp` from *PREFIX*privatedata where app=? and `key` $compareFunction ? order by `timestamp` desc");
|
||||
$result=$query->execute(array($app,$key))->fetchAll();
|
||||
$apps=OC_PREFERENCES::getApps($user);
|
||||
}
|
||||
if($key){
|
||||
$keys=array($key);
|
||||
}else{
|
||||
if (!trim($key)) {
|
||||
$query = OC_DB::prepare('select app, `key`,value,`timestamp` from *PREFIX*privatedata order by `timestamp` desc');
|
||||
$result=$query->execute()->fetchAll();
|
||||
} else {
|
||||
$query = OC_DB::prepare("select app, `key`,value,`timestamp` from *PREFIX*privatedata where `key` $compareFunction ? order by `timestamp` desc");
|
||||
$result=$query->execute(array($key))->fetchAll();
|
||||
foreach($apps as $app){
|
||||
$keys=OC_PREFERENCES::getKeys($user,$app);
|
||||
}
|
||||
}
|
||||
$result=array();
|
||||
foreach($apps as $app){
|
||||
foreach($keys as $key){
|
||||
$value=OC_PREFERENCES::getValue($user,$app,$key);
|
||||
$result[]=array('app'=>$app,'key'=>$key,'value'=>$value);
|
||||
}
|
||||
}
|
||||
$result=self::trimKeys($result,$user);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -545,25 +542,7 @@ class OC_OCS {
|
|||
* @return bool
|
||||
*/
|
||||
public static function setData($user, $app, $key, $value) {
|
||||
$key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy
|
||||
//TODO: locking tables, fancy stuff, error checking/handling
|
||||
$query=OC_DB::prepare("select count(*) as co from *PREFIX*privatedata where `key` = ? and app = ?");
|
||||
$result=$query->execute(array($key,$app))->fetchAll();
|
||||
$totalcount=$result[0]['co'];
|
||||
if ($totalcount != 0) {
|
||||
$query=OC_DB::prepare("update *PREFIX*privatedata set value=?, `timestamp` = now() where `key` = ? and app = ?");
|
||||
|
||||
} else {
|
||||
$result = OC_DB::prepare("insert into *PREFIX*privatedata(value, `key`, app, `timestamp`) values(?, ?, ?, now())");
|
||||
}
|
||||
$result = $query->execute(array($value,$key,$app));
|
||||
if (PEAR::isError($result)){
|
||||
$entry='DB Error: "'.$result->getMessage().'"<br />';
|
||||
error_log($entry);
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
return OC_PREFERENCES::setValue($user,$app,$key,$value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -574,26 +553,7 @@ class OC_OCS {
|
|||
* @return string xml/json
|
||||
*/
|
||||
public static function deleteData($user, $app, $key) {
|
||||
$key="$user::$key";//ugly hack for the sake of keeping database scheme compatibiliy
|
||||
//TODO: prepared statements, locking tables, fancy stuff, error checking/handling
|
||||
$query=OC_DB::prepare("delete from *PREFIX*privatedata where `key` = ? and app = ?");
|
||||
$result = $query->execute(array($key,$app));
|
||||
if (PEAR::isError($result)){
|
||||
$entry='DB Error: "'.$result->getMessage().'"<br />';
|
||||
error_log($entry);
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//trim username prefixes from $array
|
||||
private static function trimKeys($array,$user){
|
||||
$length=strlen("$user::");
|
||||
foreach($array as &$item){
|
||||
$item['key']=substr($item['key'],$length);
|
||||
}
|
||||
return $array;
|
||||
return OC_PREFERENCES::deleteKey($user,$app,$key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue