includes/functions.php
changeset 1295 3c9c1b18567b
parent 1283 cdbc7f48ab72
child 1301 bd9e124f5904
--- a/includes/functions.php	Sat Aug 21 23:30:56 2010 -0400
+++ b/includes/functions.php	Sat Aug 21 23:31:36 2010 -0400
@@ -309,7 +309,7 @@
 
 function have_blank_urlname_page()
 {
-	return getConfig('main_page', 'Main_Page') == '' || getConfig('main_page', getConfig('main_page', 'Main_Page')) == '';
+	return getConfig('main_page', 'Main_Page') == '' || ( getConfig('main_page_alt_enable', 0) == 1 && getConfig('main_page_alt', getConfig('main_page', 'Main_Page')) == '' );
 }
 
 /**
@@ -1950,7 +1950,7 @@
 {
 	global $db, $session, $paths, $template, $plugins; // Common objects
 	// Decide whether to quote the string or not
-	if(substr($type, 0, 7) == 'varchar' || $type == 'datetime' || $type == 'text' || $type == 'tinytext' || $type == 'smalltext' || $type == 'longtext' || substr($type, 0, 4) == 'char')
+	if(substr($type, 0, 7) == 'varchar' || $type == 'datetime' || $type == 'text' || $type == 'tinytext' || $type == 'smalltext' || $type == 'longtext' || substr($type, 0, 4) == 'char' || substr($type, 0, 4) == 'enum')
 	{
 		$str = "'" . $db->escape($input) . "'";
 	}
@@ -4222,7 +4222,7 @@
 			throw new Exception('Invalid extension of input file.');
 	}
 		
-	$magick_path = getConfig('imagemagick_path');
+	$magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
 	$can_use_magick = (
 			getConfig('enable_imagemagick') == '1' &&
 			file_exists($magick_path)              &&
@@ -5408,3 +5408,39 @@
 		}
 	}
 }
+
+/**
+ * Echo out the HTML and Javascript used to make a form with files in it upload via ajax.
+ * @param string The DOM ID of the form (<form id="...">)
+ * @return null
+ */
+
+function ajax_upload_js($formid)
+{
+	$upkey = md5(mt_rand() . microtime());
+	$php_has_progress_support = @ini_get('session.upload_progress.enabled') == '1' ? 'true' : 'false';
+	
+	$field_name = ini_get("session.upload_progress.name");
+	
+	?>
+	<input type="hidden" name="upload_progress_name" value="<?php echo !empty($field_name) ? $field_name : ''; ?>" />
+	<?php if ( !empty($field_name) ): ?>
+	<input type="hidden" name="<?php echo $field_name; ?>" value="<?php echo $upkey; ?>" />
+	<?php endif; ?>
+	<input type="hidden" name="progress_support" value="<?php echo $php_has_progress_support; ?>" />
+	
+	<script type="text/javascript">
+	//<![CDATA[
+	
+	addOnloadHook(function()
+		{
+			load_component('upload');
+			var ajaxupload = new AjaxUpload('<?php echo $formid; ?>');
+			eval(setHook('<?php echo $formid; ?>_ajaxupload_init'));
+		});
+	//]]>
+	</script>
+	
+	<?php
+}
+