Made it so we can change the name of index and downloader. Corrected a bug with downloader not working right Some additional fixes
Jeremy D

Jeremy D commited on 2011-12-30 20:12:35
Showing 8 changed files, with 24 additions and 16 deletions.

... ...
@@ -12,14 +12,14 @@ if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access re
12 12
 */
13 13
 function index_section()
14 14
 {
15
-	global $text;
15
+	global $text, $scriptname;
16 16
 
17 17
 	echo '
18 18
 		<br clear="all" />
19 19
 		<p id="welcome">', $text['index_welcome'], '.</p>
20 20
 		<ol id="steps">
21
-			<li><a href="index.php?action=mod">', $text['index_mod'], '</a></li>
22
-			<li><a href="index.php?action=info">', $text['index_info'], '</a></li>
21
+			<li><a href="', $scriptname, '?action=mod">', $text['index_mod'], '</a></li>
22
+			<li><a href="', $scriptname, '?action=info">', $text['index_info'], '</a></li>
23 23
 			<li>', $text['index_compress'], '</li>
24 24
 		</ol>';
25 25
 }
... ...
@@ -12,7 +12,7 @@ if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access re
12 12
 */
13 13
 function info_section()
14 14
 {
15
-	global $text;
15
+	global $text, $use_php;
16 16
 
17 17
 	echo '
18 18
 			<fieldset id="basic_info">
... ...
@@ -12,7 +12,7 @@ if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access re
12 12
 */
13 13
 function mod_section()
14 14
 {
15
-	global $text;
15
+	global $text, $use_php;
16 16
 
17 17
 	echo '
18 18
 			<fieldset id="basic_info">
... ...
@@ -388,9 +388,9 @@ function download_action_generate()
388 388
 	show_instruct_preview();
389 389
 
390 390
 	$.generateaction({
391
-		actionname	: "install.xml",
391
+		actionname	: 'install.xml',
392 392
 		content		: $('#preview').text(),
393
-		script		: "downloader.php?download"
393
+		script		: $('#downloadername').val() + '?download'
394 394
 	});
395 395
 }
396 396
 
... ...
@@ -401,7 +401,7 @@ function download_action_data()
401 401
 	data = $.base64.encode($('#preview').text());
402 402
 
403 403
 	/* No actionname can be specified by a data URI */
404
-	window.location = "data:application/octet-stream;charset=utf-8;base64," + data;
404
+	window.location = 'data:application/octet-stream;charset=utf-8;base64,' + data;
405 405
 }
406 406
 
407 407
 /* Updates our details counters */
... ...
@@ -292,9 +292,9 @@ function download_file_generate()
292 292
 	show_edit_preview();
293 293
 
294 294
 	$.generateFile({
295
-		filename	: "install.xml",
295
+		filename	: 'install.xml',
296 296
 		content		: $('#preview').text(),
297
-		script		: "downloader.php?download"
297
+		script		: $('#downloadername').val() + '?download'
298 298
 	});
299 299
 }
300 300
 
... ...
@@ -305,7 +305,7 @@ function download_file_data()
305 305
 	data = $.base64.encode($('#preview').text());
306 306
 
307 307
 	/* No filename can be specified by a data URI */
308
-	window.location = "data:application/octet-stream;charset=utf-8;base64," + data;
308
+	window.location = 'data:application/octet-stream;charset=utf-8;base64,' + data;
309 309
 }
310 310
 
311 311
 /* Updates our details counters */
... ...
@@ -13,10 +13,6 @@ require_once(dirname(__FILE__) . '/settings.php');
13 13
 if (!$use_php || !isset($_GET['download']))
14 14
 	exit ('Invalid Download content');
15 15
 
16
-// We should at least try to verify the referrer
17
-if (!isset($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME']) === false)
18
-	exit('Invalid Request Detected');
19
-
20 16
 // Give them a download.
21 17
 header('Cache-Control: ');
22 18
 header('Content-type: text/plain');
... ...
@@ -48,13 +48,18 @@ if (!empty($logo))
48 48
 				<a href="', $logo_url, '"><img src="', $logo, '" alt="', $page_title, '" class="alignleft"></a>';
49 49
 
50 50
 echo '
51
-				<h1><a href="index.php">', $text['script_name'], '</a></h1></div>
51
+				<h1><a href="', $scriptname, '">', $text['script_name'], '</a></h1></div>
52 52
 		</div>
53 53
 		<div class="clear"></div>
54 54
 	</div>
55 55
 	<div id="container">
56 56
 		<div id="wrap" class="action_', $action, '">';
57 57
 
58
+// If we are using the PHP downloader, we need this.
59
+if ($use_php)
60
+	echo '
61
+			<input type="hidden" id="downloadername" value="', $downloadname, '" />';
62
+
58 63
 // Call up the right section.
59 64
 $function = $action . '_section';
60 65
 $function();
... ...
@@ -10,6 +10,12 @@ if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access re
10 10
 // Assets URL location.
11 11
 $assets = '/PacManGen/assets';
12 12
 
13
+// The name of this script (can also be the url).
14
+$scriptname = 'index.php';
15
+
16
+// The name of this script (can also be the url).
17
+$downloadname = 'downloader.php';
18
+
13 19
 // Style to use.
14 20
 $style = 'default';
15 21
 
... ...
@@ -22,4 +28,5 @@ $page_title = 'SleePyCode Package Manager Generator';
22 28
 $logo = $assets . '/logo.png';
23 29
 $logo_url = 'http://sleepycode.com';
24 30
 
31
+// Language we selected.
25 32
 $language = 'english';
26 33
\ No newline at end of file
27 34