- 0)
- echo "". _LISTS_PREV." ";
- if ($idxEnd < sizeof($arr))
- echo "". _LISTS_NEXT." ";
-
- ?>
-
-
-
-
-
-
-
-
-
- $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) {
+ ?>
+
+
+
+
+
+
+
+