X-Git-Url: http://git.sourceforge.jp/view?p=nucleus-jp%2Fnucleus-jp-ancient.git;a=blobdiff_plain;f=utf8%2Fnucleus%2Fmedia.php;h=ff2cc2ac12f104fd66905f05afd1a9b1ac7897cc;hp=271a8160868e7b044021bccbd20c5dd5850be27a;hb=2c0a28348cedc6d943a46776bfb8456123b97832;hpb=e9da0691badbea4435ee5ec184364204e4ffec8e diff --git a/utf8/nucleus/media.php b/utf8/nucleus/media.php index 271a816..ff2cc2a 100755 --- a/utf8/nucleus/media.php +++ b/utf8/nucleus/media.php @@ -1,7 +1,7 @@ isLoggedIn()) { - media_loginAndPassThrough(); - exit; -} - -// check if member is on at least one teamlist -$query = 'SELECT * FROM ' . sql_table('team'). ' WHERE tmember=' . $member->getID(); -$teams = mysql_query($query); -if (mysql_num_rows($teams) == 0) - media_doError(_ERROR_DISALLOWEDUPLOAD); - -// get action -$action = requestVar('action'); -if ($action == '') - $action = 'selectmedia'; - -// check ticket -$aActionsNotToCheck = array('selectmedia', _MEDIA_FILTER_APPLY, _MEDIA_COLLECTION_SELECT); -if (!in_array($action, $aActionsNotToCheck)) -{ - if (!$manager->checkTicket()) - media_doError(_ERROR_BADTICKET); -} - - -switch($action) { - case 'chooseupload': - case _MEDIA_UPLOAD_TO: - case _MEDIA_UPLOAD_NEW: - if (!$member->isAdmin() and $CONF['AllowUpload'] != true) { - media_doError(_ERROR_DISALLOWED); - } else { - media_choose(); - } - break; - case 'uploadfile': - if (!$member->isAdmin() and $CONF['AllowUpload'] != true) { - media_doError(_ERROR_DISALLOWED); - } else { - media_upload(); - } - break; - case _MEDIA_FILTER_APPLY: - case 'selectmedia': - case _MEDIA_COLLECTION_SELECT: - default: - media_select(); - break; -} - -// select a file -function media_select() { - global $member, $CONF, $DIR_MEDIA, $manager; - - // show 10 files + navigation buttons - // show msg when no files - // show upload form - // files sorted according to last modification date - - // currently selected collection - $currentCollection = requestVar('collection'); - if (!$currentCollection || !@is_dir($DIR_MEDIA . $currentCollection)) - $currentCollection = $member->getID(); - - // avoid directory travarsal and accessing invalid directory - if (!MEDIA::isValidCollection($currentCollection)) media_doError(_ERROR_DISALLOWED); - - media_head(); - - // get collection list - $collections = MEDIA::getCollectionList(); - - if (sizeof($collections) > 1) { - ?> -
- - - - - addTicketHidden() ?> -
- -
- - - addTicketHidden() ?> -
- -
- - - - - -
- - - - - - - - - 0) { - - if (($offset + $CONF['MediaPerPage']) >= sizeof($arr)) - $offset = sizeof($arr) - $CONF['MediaPerPage']; - - if ($offset < 0) $offset = 0; - - $idxStart = $offset; - $idxEnd = $offset + $CONF['MediaPerPage']; - $idxNext = $idxEnd; - $idxPrev = $idxStart - $CONF['MediaPerPage']; - - if ($idxPrev < 0) $idxPrev = 0; - - if ($idxEnd > sizeof($arr)) - $idxEnd = sizeof($arr); - - for($i=$idxStart;$i<$idxEnd;$i++) { - $obj = $arr[$i]; - $filename = $DIR_MEDIA . $currentCollection . '/' . $obj->filename; - - $old_level = error_reporting(0); - $size = @GetImageSize($filename); - error_reporting($old_level); - $width = $size[0]; - $height = $size[1]; - $filetype = $size[2]; - - echo ""; - echo ""; - - // strings for javascript - $jsCurrentCollection = str_replace("'","\\'",$currentCollection); - $jsFileName = str_replace("'","\\'",$obj->filename); - - if ($filetype != 0) { - // image (gif/jpg/png/swf) - echo ""; - } else { - // no image (e.g. mpg) - echo ""; - - } - echo ''; - echo ''; - } - } // if (sizeof($arr)>0) - ?> - -
". date("Y-m-d",$obj->timestamp) ."filename). "\">" - . htmlspecialchars(shorten($obj->filename,25,'...')) - .""; - echo ' (',_MEDIA_VIEW,')'; - echo "filename). "\">" - . htmlspecialchars(shorten($obj->filename,30,'...')) - ."' , htmlspecialchars($width) , 'x' , htmlspecialchars($height) , '
- 0) - echo "". _LISTS_PREV." "; - if ($idxEnd < sizeof($arr)) - echo "". _LISTS_NEXT." "; - - ?> - - - -

- -

- -
-
- - addTicketHidden() ?> - - File: -
- - 1) { - ?> -

-
- - - -

- -
-
- - $CONF['MaxUploadSize']) - media_doError(_ERROR_FILE_TOO_BIG); - - // check file type against allowed types - $ok = 0; - $allowedtypes = explode (',', $CONF['AllowedTypes']); - foreach ( $allowedtypes as $type ) - if (eregi("\." .$type. "$",$filename)) $ok = 1; - if (!$ok) media_doError(_ERROR_BADFILETYPE); - - if (!is_uploaded_file($filetempname)) - media_doError(_ERROR_BADREQUEST); - - // prefix filename with current date (YYYY-MM-DD-) - // this to avoid nameclashes - if ($CONF['MediaPrefix']) - $filename = strftime("%Y%m%d-", time()) . $filename; - - $collection = requestVar('collection'); - $res = MEDIA::addMediaObject($collection, $filetempname, $filename); - - if ($res != '') - media_doError($res); - - // shows updated list afterwards - media_select(); -} - -function media_loginAndPassThrough() { - media_head(); - ?> -

- -
-
- - - : -
: -
-
-
-

- -

-

-

- - - > - - - Nucleus Media - - - - - - - - +$CONF = array(); + +// defines how much media items will be shown per page. You can override this +// in config.php if you like. (changing it in config.php instead of here will +// allow your settings to be kept even after a Nucleus upgrade) +$CONF['MediaPerPage'] = 10; + +// include all classes and config data +$DIR_LIBS = ''; +require_once('../config.php'); +//include($DIR_LIBS . 'MEDIA.php'); // media classes +include_libs('MEDIA.php',false,false); + +sendContentType('application/xhtml+xml', 'media'); + +// user needs to be logged in to use this +if (!$member->isLoggedIn()) { + media_loginAndPassThrough(); + exit; +} + +// check if member is on at least one teamlist +$query = 'SELECT * FROM ' . sql_table('team'). ' WHERE tmember=' . $member->getID(); +$teams = sql_query($query); +if (sql_num_rows($teams) == 0 && !$member->isAdmin()) + media_doError(_ERROR_DISALLOWEDUPLOAD); + +// get action +$action = requestVar('action'); +if ($action == '') + $action = 'selectmedia'; + +// check ticket +$aActionsNotToCheck = array('selectmedia', _MEDIA_FILTER_APPLY, _MEDIA_COLLECTION_SELECT); +if (!in_array($action, $aActionsNotToCheck)) +{ + if (!$manager->checkTicket()) + media_doError(_ERROR_BADTICKET); +} + + +switch($action) { + case 'chooseupload': + case _MEDIA_UPLOAD_TO: + case _MEDIA_UPLOAD_NEW: + if (!$member->isAdmin() and $CONF['AllowUpload'] != true) { + media_doError(_ERROR_DISALLOWED); + } else { + media_choose(); + } + break; + case 'uploadfile': + if (!$member->isAdmin() and $CONF['AllowUpload'] != true) { + media_doError(_ERROR_DISALLOWED); + } else { + media_upload(); + } + break; + case _MEDIA_FILTER_APPLY: + case 'selectmedia': + case _MEDIA_COLLECTION_SELECT: + default: + media_select(); + break; +} + +// select a file +function media_select() { + global $member, $CONF, $DIR_MEDIA, $manager; + + // show 10 files + navigation buttons + // show msg when no files + // show upload form + // files sorted according to last modification date + + // currently selected collection + $currentCollection = requestVar('collection'); + if (!$currentCollection || !@is_dir($DIR_MEDIA . $currentCollection)) + $currentCollection = $member->getID(); + + // avoid directory travarsal and accessing invalid directory + if (!MEDIA::isValidCollection($currentCollection)) media_doError(_ERROR_DISALLOWED); + + media_head(); + + // get collection list + $collections = MEDIA::getCollectionList(); + + if (sizeof($collections) > 1) { + ?> +
+ + + + + addTicketHidden() ?> +
+ +
+ + + addTicketHidden() ?> +
+ +
+ + + + + +
+ + + + + + + + + 0) { + + if (($offset + $CONF['MediaPerPage']) >= sizeof($arr)) + $offset = sizeof($arr) - $CONF['MediaPerPage']; + + if ($offset < 0) $offset = 0; + + $idxStart = $offset; + $idxEnd = $offset + $CONF['MediaPerPage']; + $idxNext = $idxEnd; + $idxPrev = $idxStart - $CONF['MediaPerPage']; + + if ($idxPrev < 0) $idxPrev = 0; + + if ($idxEnd > sizeof($arr)) + $idxEnd = sizeof($arr); + + for($i=$idxStart;$i<$idxEnd;$i++) { + $obj = $arr[$i]; + $filename = $DIR_MEDIA . $currentCollection . '/' . $obj->filename; + + $old_level = error_reporting(0); + $size = @GetImageSize($filename); + error_reporting($old_level); + $width = $size[0]; + $height = $size[1]; + $filetype = $size[2]; + + echo ""; + echo ""; + + // strings for javascript + $jsCurrentCollection = str_replace("'","\\'",$currentCollection); + $jsFileName = str_replace("'","\\'",$obj->filename); + + if ($filetype != 0) { + // image (gif/jpg/png/swf) + echo ""; + } else { + // no image (e.g. mpg) + echo ""; + + } + echo ''; + echo ''; + } + } // if (sizeof($arr)>0) + ?> + +
". date("Y-m-d",$obj->timestamp) ."filename). "\">" + . htmlspecialchars(shorten($obj->filename,25,'...')) + .""; + echo ' (',_MEDIA_VIEW,')'; + echo "filename). "\">" + . htmlspecialchars(shorten($obj->filename,30,'...')) + ."' , htmlspecialchars($width) , 'x' , htmlspecialchars($height) , '
+ 0) + echo "". _LISTS_PREV." "; + if ($idxEnd < sizeof($arr)) + echo "". _LISTS_NEXT." "; + + ?> + + + +

+ +

+ +
+
+ + addTicketHidden() ?> + + File: +
+ + 1) { + ?> +

+
+ + + +

+ notify( + 'MediaUploadFormExtras', + array() + ); + ?> +

+ +
+
+ + $CONF['MaxUploadSize']) + media_doError(_ERROR_FILE_TOO_BIG); + + // check file type against allowed types + $ok = 0; + $allowedtypes = explode (',', $CONF['AllowedTypes']); + foreach ( $allowedtypes as $type ) + { + //if (eregi("\." .$type. "$",$filename)) $ok = 1; + if (preg_match("#\." .$type. "$#i",$filename)) $ok = 1; + } + if (!$ok) media_doError(_ERROR_BADFILETYPE); + + if (!is_uploaded_file($filetempname)) + media_doError(_ERROR_BADREQUEST); + + // prefix filename with current date (YYYY-MM-DD-) + // this to avoid nameclashes + if ($CONF['MediaPrefix']) + $filename = strftime("%Y%m%d-", time()) . $filename; + + $collection = requestVar('collection'); + $res = MEDIA::addMediaObject($collection, $filetempname, $filename); + + if ($res != '') + media_doError($res); + + // shows updated list afterwards + media_select(); +} + +function media_loginAndPassThrough() { + media_head(); + ?> +

+ +
+
+ + + : +
: +
+
+
+

+ +

+

+

+ + + > + + + Nucleus Media + + + + + + + +