Property changes on: . ___________________________________________________________________ Added: svn:ignore + themes Index: PHP/admin.php =================================================================== --- PHP/admin.php (revision 19823) +++ PHP/admin.php (working copy) @@ -3,7 +3,7 @@ require_once("ini.php"); require_once("tools.php"); -include_once("top.php"); +include("top.php"); if(@$_SESSION['loggedin'] === true) { Index: PHP/by-sa.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = image/png Index: PHP/index.php =================================================================== --- PHP/index.php (revision 19823) +++ PHP/index.php (working copy) @@ -2,60 +2,65 @@ include('top.php'); +require_once('ini.php'); require_once('tools.php'); -require_once('ini.php'); if(isset($_GET['model'])) - $modelid = get_modelid($_GET['model']); +{ + $id = $_GET['model']; + $model = $models[$id]; +} else - $modelid = -1; + $model = NULL; -if ($modelid == -1) +if (!$model) { # HOME PAGE - print "

Rockbox Themes

\n"; - print "

Welcome to the official Rockbox Themes repository - a collection of themes designed and created by the Rockbox community. For more information, please visit:

\n"; + include('intro.php'); - print "\n"; - - show_main_table(); + echo "

\n"; + foreach ($models as $id => $model) + { + echo "
image\" alt=\""; + echo "$model->name\" />

$model->name

\n"; + } + echo "

\n"; } else { - print "

Rockbox Themes - $modelnames[$modelid] ($mainlcdtypes[$modelid])

\n"; + echo "

Rockbox Themes - $model->name ($model->display)

\n"; # LIST OF THEMES FOR A SINGLE TARGET - print "

Return to themes home page

\n"; + echo "

Return to themes home page

\n"; - $themes = filter($mainlcdtypes[$modelid],''); + $themes = filter($model->display,''); if (count($themes)==0) - print "

Sorry, no themes are available for the $modelnames[$modelid].

\n"; + echo "

Sorry, no themes are available for the $model->name.

\n"; else { if(isset($_GET['skip'])) $skip = (int)$_GET['skip']; else $skip = 3; - + if($skip < 1 || $skip > 10) $skip = 3; ?>

- + Set column size: @@ -63,16 +68,16 @@

display; if ($lcd == 'charcell') { $width = 132; # Width of the LCD in the sim for the Player } else { list($width,$height,$depth) = split("x",$lcd); } - - print "\n"; - print "\n"; + + echo "
Click On The Image To Download The Theme
\n"; + echo "\n"; for ($i = 0; $i < count($themes); $i++) { $status = $i % $skip; @@ -80,44 +85,44 @@ if(file_exists(DATADIR."/".$lcd."/".$shortname.".zip")) { if($status == 0) - print "\n"; - print "\n"; + echo " Size: ".round($filesize/1024, 2)." KiB\n"; + echo "

\n"; + echo "\n"; + echo "Submitter:
\n"; + echo " $author
\n"; + echo "Notes:
\n"; + echo " $description
\n"; + echo "
\n"; + echo "\n"; if($status == $skip-1) - print "\n"; + echo "\n"; } } if($status != $skip-1) - print "\n"; - print "
Click On The Image To Download The Theme
\n"; - print "

$name

\n"; - - print "

\n"; - print "\n"; + echo "

\n"; + echo "

$name

\n"; + + echo "

\n"; + echo "\n"; + echo "onmouseout=\"MM_swapImgRestore()\" "; + echo "onmouseover=\"MM_swapImage('$shortname','','".THEMEDIR."/$lcd/".$shortname."_b.png',1)\">\n"; } else - print ">\n"; - print ""; - print "
\n"; - $filesize = filesize(DATADIR."/".$lcd."/".$shortname.".zip"); + echo ">\n"; + echo ""; + echo "
\n"; + $filesize = filesize(DATADIR."/$lcd/$shortname.zip"); if($filesize > 1024*1024) - print " Size: ".round(filesize(DATADIR."/".$lcd."/".$shortname.".zip")/1024/1024, 2)." MiB\n"; + echo " Size: ".round($filesize/1024/1024, 2)." MiB\n"; else - print " Size: ".round(filesize(DATADIR."/".$lcd."/".$shortname.".zip")/1024, 2)." KiB\n"; - print "

\n"; - print "\n"; - print "Submitter:
\n"; - print " $author
\n"; - print "Notes:
\n"; - print " $description
\n"; - print "
\n"; - print "
\n"; + echo "\n"; + echo "\n"; } } include('bottom.php'); -?> \ No newline at end of file +?> Index: PHP/ini.php =================================================================== --- PHP/ini.php (revision 19823) +++ PHP/ini.php (working copy) @@ -1,12 +1,76 @@ name = $name; + $this->display = $display; + $this->image = $image; + } +} + +$models['player'] = new model('Archos Player/Studio', 'charcell', 'player-small.png'); +$models['recorder'] = new model('Archos Recorder v1', '112x64x1', 'recorder-small.png'); +$models['recorder8mb'] = new model('Archos Recorder 8MB', '112x64x1', 'recorder-small.png'); +$models['fmrecorder'] = new model('Archos FM Recorder', '112x64x1', 'recorderv2fm-small.png'); +$models['recorderv2'] = new model('Archos Recorder v2', '112x64x1', 'recorderv2fm-small.png'); +$models['ondiofm'] = new model('Archos Ondio FM', '112x64x1', 'ondiofm-small.png'); +$models['ondiosp'] = new model('Archos Ondio SP', '112x64x1', 'ondiosp-small.png'); +$models['iaudiom5'] = new model('iAudio M5', '160x128x2', 'm5-small.png'); +$models['iaudiox5'] = new model('iAudio X5', '160x128x16', 'x5-small.png'); +$models['iaudiom3'] = new model('iAudio M3', '128x96x2', 'm3-small.png'); +$models['h100'] = new model('iriver H100/115', '160x128x2', 'h100-small.png'); +$models['h120'] = new model('iriver H120/140', '160x128x2', 'h100-small.png'); +$models['h300'] = new model('iriver H320/340', '220x176x16', 'h300-small.png'); +$models['h10_5gb'] = new model('iriver H10 5GB', '128x128x16', 'h10_5gb-small.png'); +$models['h10'] = new model('iriver H10 20GB', '160x128x16', 'h10-small.png'); +$models['ipod1g2g'] = new model('iPod 1st and 2nd gen', '160x128x2', 'ipod1g2g-small.png'); +$models['ipod3g'] = new model('iPod 3rd gen', '160x128x2', 'ipod3g-small.png'); +$models['ipod4gray'] = new model('iPod 4th gen Grayscale', '160x128x2', 'ipod4g-small.png'); +$models['ipodcolor'] = new model('iPod color/Photo', '220x176x16', 'ipodcolor-small.png'); +$models['ipodvideo'] = new model('iPod Video 30GB', '320x240x16', 'ipodvideo-small.png'); +$models['ipodvideo64mb'] = new model('iPod Video 60/80GB', '320x240x16', 'ipodvideo-small.png'); +$models['ipodmini1g'] = new model('iPod Mini 1st gen', '138x110x2', 'ipodmini-small.png'); +$models['ipodmini2g'] = new model('iPod Mini 2nd gen', '138x110x2', 'ipodmini-small.png'); +$models['ipodnano'] = new model('iPod Nano 1st gen', '176x132x16', 'ipodnano-small.png'); +$models['gigabeatf'] = new model('Toshiba Gigabeat F/X', '240x320x16', 'gigabeatf-small.png'); +$models['sansae200'] = new model('SanDisk Sansa e200', '176x220x16', 'e200-small.png'); +$models['sansac200'] = new model('SanDisk Sansa c200', '132x80x16', 'c200-small.png'); +$models['mrobe100'] = new model('Olympus M-Robe 100', '160x128x1', 'mrobe100-small.png'); + ?> Index: PHP/intro.php =================================================================== --- PHP/intro.php (revision 0) +++ PHP/intro.php (revision 0) @@ -0,0 +1,24 @@ + +

Rockbox Themes

+ +

Welcome to the official Rockbox Themes repository - a collection + of themes designed and created by the Rockbox community, a testament to the + creativity of many of the people who have visited and participated in the + Rockbox site. This is the result of their desire to make their player look + the way they want it to, and to share that vision with others.

+

Please note + that some of these themes may require custom builds which are not + supported by the Rockbox team or the themes may be out of date and may + not appear as intended.

+ +

+ + Make your own WPS · + + WPS syntax · + + Theme Installation · + + Theme Submission Guidelines +

+

Upload your theme

Index: PHP/tools.php =================================================================== --- PHP/tools.php (revision 19823) +++ PHP/tools.php (working copy) @@ -2,38 +2,6 @@ require_once('ini.php'); -# The main list of devices. - -$models = array('player','recorder','recorder8mb','fmrecorder','recorderv2','ondiofm','ondiosp','iaudiom5','iaudiox5','iaudiom3','h100','h120','h300','h10_5gb','h10','ipod1g2g','ipod3g','ipod4gray','ipodcolor','ipodvideo','ipodvideo64mb','ipodmini1g','ipodmini2g','ipodnano','gigabeatf','sansae200','sansac200','mrobe100'); - -$nummodels = count($models); - -$modelnames = array('Archos Player/Studio','Archos Recorder v1','Archos Recorder 8MB','Archos FM Recorder','Archos Recorder v2','Archos Ondio FM','Archos Ondio SP','iAudio M5','iAudio X5','iAudio M3','iriver H100/115','iriver H120/140','iriver H320/340','iriver H10 5GB','iriver H10 20GB','iPod 1st and 2nd gen','iPod 3rd gen','iPod 4th gen Grayscale','iPod color/Photo','iPod Video 30GB','iPod Video 60/80GB','iPod Mini 1st gen','iPod Mini 2nd gen','iPod Nano 1st gen','Toshiba Gigabeat F/X','SanDisk Sansa e200','SanDisk Sansa c200','Olympus M-Robe 100'); - -$mainlcdtypes = array('charcell','112x64x1','112x64x1','112x64x1','112x64x1','112x64x1','112x64x1','160x128x2','160x128x16','128x96x2','160x128x2','160x128x2','220x176x16','128x128x16','160x128x16','160x128x2','160x128x2','160x128x2','220x176x16','320x240x16','320x240x16','138x110x2','138x110x2','176x132x16','240x320x16','176x220x16','132x80x16','160x128x1'); - -$imagenames = array('player-small.png','recorder-small.png','recorder-small.png','recorderv2fm-small.png','recorderv2fm-small.png','ondiofm-small.png','ondiosp-small.png','m5-small.png','x5-small.png','m3-small.png','h100-small.png','h100-small.png','h300-small.png','h10_5gb-small.png','h10-small.png','ipod1g2g-small.png','ipod3g-small.png','ipod4g-small.png','ipodcolor-small.png','ipodvideo-small.png','ipodvideo-small.png','ipodmini-small.png','ipodmini-small.png','ipodnano-small.png','gigabeatf-small.png','e200-small.png','c200-small.png','mrobe100-small.png'); - -function get_modelid($model) -{ - global $models; - - return array_search($model, $models); -} - -function show_main_table() -{ - global $nummodels; - global $modelnames,$imagenames,$models; - - print "

\n"; - for ($i=0;$i<$nummodels;$i++) - { - print "
\"$modelnames[$i]\"

$modelnames[$i]

\n"; - } - print "

\n"; -} - # Filter the themes.txt by LCD type and return an array of matching themes function filter($mainlcdfilter,$remotelcdfilter) { @@ -50,18 +18,16 @@ fclose($fh); } - if ($count==0) + if ($count==0) return array(); else return $themes; -} +} # Validate an uploaded theme zip file, exercising extreme paranoia -function validate_zip($filename, $new_model) +function validate_zip($filename, $id) { - global $mainlcdtypes; - $errors = array(); $validdir['wps']=1; @@ -71,12 +37,12 @@ $validdir['fonts']=1; # Step 1 - get a listing of the files inside the zip file - $fh = popen("/usr/bin/unzip -l $filename","r"); + $fh = popen(UNZIP." -l $filename","r"); if (!$fh) return array('Not a valid ZIP file'); - + $buf = ''; - while (!feof($fh)) + while (!feof($fh)) { $buf .= fgets($fh, 4096); } @@ -87,10 +53,15 @@ # Do some sanity checks on the unzip output if(count($recs) == 7) # Number of lines with one file in the zip return array("Zip contains only 1 file."); - - if (count($recs) < 7 || + + if (count($recs) < 7) /*|| ($recs[1] != " Length Date Time Name") || ($recs[2] != " -------- ---- ---- ----")) +Need a more generic error checking, my unzip produces +[1] => Length EAs ACLs Date Time Name +[2] => -------- --- ---- ---- ---- ---- + +*/ { return array('Unexpected ZIP file error.'); } @@ -98,14 +69,15 @@ # Check the total uncompressed size $s = preg_replace('/\ +/'," ",$recs[count($recs)-2]); $s = preg_replace('/^\ +/','',$s); - list($size,$numfiles,$s) = split(" ",$s); - if ($s != 'files') + $data = split(" ",$s); + $count = count($data); + if ($data[$count-1] != 'files') return array('Unexpected ZIP file error.'); - if ($numfiles > MAXFILESINZIP) + if ($data[$count-2] > MAXFILESINZIP) return array("Too many files in ZIP file ($numfiles)"); - if ($size > MAXUNZIPPEDSIZE) + if ($data[0] > MAXUNZIPPEDSIZE) return array("ZIP contents too large ($size bytes)"); # Now go through each file in turn. @@ -118,7 +90,7 @@ for ($i=3;$i 4) + if (count($a) > MAXTHEMEPATHDEPTH) { $errors[] = "Invalid directory structure for $f"; continue; @@ -155,13 +127,13 @@ $errors[] = "Invalid file in .rockbox - $f"; continue; } - } + } # We know there are at least 3 elements in path if ($validdir[$a[1]] != 1) $errors[] = "Invalid directory - $f"; - # Check for known bad files + # Check for known bad files switch(strtolower($a[count($a)-1])) { case "thumbs.db": @@ -172,22 +144,22 @@ break; } } - + if(count($errors) == 0) { $checked = array(); - + $tempname = tempnam("/tmp", "rbthemes-"); if (!$tempname) die("Cannot create a temporary file!"); $tmp_path = $tempname."_dir"; if(!mkdir($tmp_path)) die("Cannot create a temporary directory!"); - - exec("/usr/bin/unzip -d $tmp_path $filename"); + + exec(UNZIP." -d $tmp_path $filename"); foreach(glob("$tmp_path/.rockbox/backdrops/*") as $bmp) { - $lcd_size = explode("x", $mainlcdtypes[$new_model]); + $lcd_size = explode("x", $models[$id]->display); array_pop($lcd_size); $lcd_size = implode("x", $lcd_size); switch(validate_bmp($bmp, $lcd_size)) @@ -209,7 +181,7 @@ } foreach(glob("$tmp_path/.rockbox/wps/*.?wps") as $wps) { - $ret = shell_exec(DATADIR."/../checkwps.$new_model \"$wps\""); + $ret = shell_exec(DATADIR."../bin/checkwps.$id \"$wps\""); $ret = explode("\n", $ret); foreach($ret as $el) { @@ -239,7 +211,7 @@ $errors[] = "WPS in config doesn't exist: ".$path_disp; else { - $ret = shell_exec(DATADIR."/../checkwps.$new_model \"$path\""); + $ret = shell_exec(SITEURL."bin/checkwps.$id \"$path\""); $ret = explode("\n", $ret); foreach($ret as $el) { @@ -255,7 +227,7 @@ $errors[] = "Backdrop in config doesn't exist: ".$path_disp; else { - $lcd_size = explode("x", $mainlcdtypes[$new_model]); + $lcd_size = explode("x", $models[$id]->display); array_pop($lcd_size); $lcd_size = implode("x", $lcd_size); switch(validate_bmp($path, $lcd_size)) @@ -337,16 +309,19 @@ while(($el = fgetcsv($fh, 1000, "|")) !== FALSE) $ret = ((int)$el[0])+1; fclose($fh); - + $fh = fopen(DATADIR."/pre_themes.txt", "r"); while(($el = fgetcsv($fh, 1000, "|")) !== FALSE) $ret = max($ret, ((int)$el[0])+1); fclose($fh); - + + if (!$ret) //Make sure we return an ID when there is no theme added yet. + $ret = 1; + return $ret; } else return false; -} +} ?> Index: PHP/upload.php =================================================================== --- PHP/upload.php (revision 19823) +++ PHP/upload.php (working copy) @@ -26,7 +26,7 @@ if(strlen(trim($element)) == 0) $err[] = $name; } - + foreach($_FILES as $name => $values) { if(strlen(trim($values["name"])) == 0 && $name != "menuimg") @@ -34,28 +34,30 @@ if(!is_uploaded_file($values["tmp_name"]) && strlen(trim($values["name"])) > 0) $err[] = $name; } - + /* Check if valid email address */ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST["email"])) $err[] = "email"; - + /* Check if valid target */ - if(array_search($_POST['target'], $models) === false) + $id = $_POST['target']; + if(!$model = $models[$id]) $err[] = "target"; - + /* Require a first and last name */ if(count(explode(" ", $_POST['author'])) < 2) $err[] = "author"; - - if($_FILES['zip']['type'] != "application/zip") + + if(!($_FILES['zip']['type'] = "application/x-zip-compressed" || + $_FILES['zip']['type'] = "application/zip")) $err[] = "zip"; - + if($_FILES['wpsimg']['type'] != "image/png") $err[] = "wpsimg"; - + if($_FILES['menuimg']['type'] != "image/png" && strlen($_FILES['menuimg']['name']) > 0) $err[] = "menuimg"; - + if(count($err)==0) { if(md5_file($_FILES['wpsimg']['tmp_name']) == md5_file($_FILES['menuimg']['tmp_name']) @@ -64,18 +66,18 @@ $err[] = "wpsimg"; $err[] = "menuimg"; } - - $lcd_size = explode("x", $mainlcdtypes[array_search($_POST['target'], $models)]); + + $lcd_size = explode("x", $model->display); array_pop($lcd_size); $lcd_size = implode("x", $lcd_size); if(!validate_png($_FILES['wpsimg']['tmp_name'], $lcd_size)) $err[] = "wpsimg"; - + if(!validate_png($_FILES['menuimg']['tmp_name'], $lcd_size) && strlen($_FILES['menuimg']['name']) > 0) $err[] = "menuimg"; - - $ziptest = validate_zip($_FILES['zip']['tmp_name'], array_search($_POST['target'], $models)); - + + $ziptest = validate_zip($_FILES['zip']['tmp_name'], $id); + if(count($ziptest) > 0) { $err[] = "zip"; @@ -88,19 +90,25 @@ $email = htmlspecialchars(trim($_POST['email'])); $description = str_replace(array("\n","\r","\t"), "", htmlspecialchars(trim($_POST['description']))); $date = date("Y-m-d"); - $model = array_search($_POST['target'], $models); - $shortname = substr($name, 0, 15); - - if(file_exists(DATADIR."/".$mainlcdtypes[$model]."/".$shortname.".zip")) + # make a filesystem save filename + $shortname = strtr(mb_convert_encoding($fileName,'ASCII'),' ,;:?*#!§$%&/(){}<>=`´|\\\'"',''); + //$shortname = substr($name, 0, 15); + + if(file_exists(DATADIR."/".$model->display."/".$shortname.".zip")) $shortname .= substr(md5(time().$_SERVER['REMOTE_PORT'].$name.$description), 0, 5); - - $new = get_new_id()."|$name|$shortname|1|".(strlen($_FILES['menuimg']['name']) > 0 ? "1" : "")."|$author|$email|$mainlcdtypes[$model]|/|$description|$date\n"; - - move_uploaded_file($_FILES['wpsimg']['tmp_name'], DATADIR."/".$mainlcdtypes[$model]."/".$shortname.".png"); + + $new = get_new_id()."|$name|$shortname|1|"; + $new .= (strlen($_FILES['menuimg']['name']) > 0 ? "1" : ""); + $new .= "|$author|$email|$model->display|/|$description|$date\n"; + + if (!file_exists(DATADIR.$model->display)) + mkdir(DATADIR.$model->display); // Make sure the dir is available + + move_uploaded_file($_FILES['wpsimg']['tmp_name'], DATADIR.$model->display."/".$shortname.".png"); if(strlen($_FILES['menuimg']['name']) > 0) - move_uploaded_file($_FILES['menuimg']['tmp_name'], DATADIR."/".$mainlcdtypes[$model]."/".$shortname."_b.png"); - move_uploaded_file($_FILES['zip']['tmp_name'], DATADIR."/".$mainlcdtypes[$model]."/".$shortname.".zip"); - $handle = fopen(DATADIR."/pre_themes.txt", "a"); + move_uploaded_file($_FILES['menuimg']['tmp_name'], DATADIR.$model->display."/".$shortname."_b.png"); + move_uploaded_file($_FILES['zip']['tmp_name'], DATADIR.$model->display."/".$shortname.".zip"); + $handle = fopen(DATADIR."pre_themes.txt", "a"); if(!$handle) die("Database is missing; please report to administrator!"); fwrite($handle, $new); @@ -112,7 +120,7 @@ } ?>

Rockbox Themes - Upload a theme

- + 0): ?>
There were some errors while procesing your information; please check if everything is filled in correctly! @@ -133,7 +141,7 @@

Section 1 - Theme information

- + @@ -147,12 +155,12 @@ @@ -179,25 +187,25 @@

Section 2 - File uploads

- - - - >
Don't forget to match the theme guidelines. -
- - - >
The dimensions should be the same as the LCD size -
- - - >
The dimensions should be the same as the LCD size -
+ + + >
Don't forget to match the theme guidelines. +
+ + + >
The dimensions should be the same as the LCD size +
+ + + >
The dimensions should be the same as the LCD size +
Main zip file
WPS screenshot
PNG format only
Menu screenshot
PNG format only
(Optional)
Main zip file
WPS screenshot
PNG format only
Menu screenshot
PNG format only
(Optional)

Section 3 - The legal stuff

- +

In line with the spirit of Rockbox itself, all themes on this website are freely redistributable (in both modified and unmodified forms) without any restriction (e.g. commercial/non-commercial) on their use.

-

By uploading your theme to this site, you are agreeing to license your work under the license.

+

By uploading your theme to this site, you are agreeing to license your work under the

+

Creative Commons License Creative Commons Attribution-Share Alike 3.0 Unported License.