includes/functions.php
changeset 1301 bd9e124f5904
parent 1299 29601ba3c448
parent 1295 3c9c1b18567b
child 1310 41ac3758ba79
equal deleted inserted replaced
1300:1f97ee3ec614 1301:bd9e124f5904
   307  * @return bool
   307  * @return bool
   308  */
   308  */
   309 
   309 
   310 function have_blank_urlname_page()
   310 function have_blank_urlname_page()
   311 {
   311 {
   312 	return getConfig('main_page', 'Main_Page') == '' || getConfig('main_page', getConfig('main_page', 'Main_Page')) == '';
   312 	return getConfig('main_page', 'Main_Page') == '' || ( getConfig('main_page_alt_enable', 0) == 1 && getConfig('main_page_alt', getConfig('main_page', 'Main_Page')) == '' );
   313 }
   313 }
   314 
   314 
   315 /**
   315 /**
   316  * Enano replacement for date(). Accounts for individual users' timezone preferences.
   316  * Enano replacement for date(). Accounts for individual users' timezone preferences.
   317  * @param string Date-formatted string
   317  * @param string Date-formatted string
  1948 
  1948 
  1949 function mysql_encode_column($input, $type)
  1949 function mysql_encode_column($input, $type)
  1950 {
  1950 {
  1951 	global $db, $session, $paths, $template, $plugins; // Common objects
  1951 	global $db, $session, $paths, $template, $plugins; // Common objects
  1952 	// Decide whether to quote the string or not
  1952 	// Decide whether to quote the string or not
  1953 	if(substr($type, 0, 7) == 'varchar' || $type == 'datetime' || $type == 'text' || $type == 'tinytext' || $type == 'smalltext' || $type == 'longtext' || substr($type, 0, 4) == 'char')
  1953 	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')
  1954 	{
  1954 	{
  1955 		$str = "'" . $db->escape($input) . "'";
  1955 		$str = "'" . $db->escape($input) . "'";
  1956 	}
  1956 	}
  1957 	elseif(in_array($type, Array('blob', 'longblob', 'mediumblob', 'smallblob')) || substr($type, 0, 6) == 'binary' || substr($type, 0, 9) == 'varbinary')
  1957 	elseif(in_array($type, Array('blob', 'longblob', 'mediumblob', 'smallblob')) || substr($type, 0, 6) == 'binary' || substr($type, 0, 9) == 'varbinary')
  1958 	{
  1958 	{
  4220 			break;
  4220 			break;
  4221 		default:
  4221 		default:
  4222 			throw new Exception('Invalid extension of input file.');
  4222 			throw new Exception('Invalid extension of input file.');
  4223 	}
  4223 	}
  4224 		
  4224 		
  4225 	$magick_path = getConfig('imagemagick_path');
  4225 	$magick_path = getConfig('imagemagick_path', '/usr/bin/convert');
  4226 	$can_use_magick = (
  4226 	$can_use_magick = (
  4227 			getConfig('enable_imagemagick') == '1' &&
  4227 			getConfig('enable_imagemagick') == '1' &&
  4228 			file_exists($magick_path)              &&
  4228 			file_exists($magick_path)              &&
  4229 			is_executable($magick_path)
  4229 			is_executable($magick_path)
  4230 		);
  4230 		);
  5406 					$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
  5406 					$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
  5407 				break;
  5407 				break;
  5408 		}
  5408 		}
  5409 	}
  5409 	}
  5410 }
  5410 }
       
  5411 
       
  5412 /**
       
  5413  * Echo out the HTML and Javascript used to make a form with files in it upload via ajax.
       
  5414  * @param string The DOM ID of the form (<form id="...">)
       
  5415  * @return null
       
  5416  */
       
  5417 
       
  5418 function ajax_upload_js($formid)
       
  5419 {
       
  5420 	$upkey = md5(mt_rand() . microtime());
       
  5421 	$php_has_progress_support = @ini_get('session.upload_progress.enabled') == '1' ? 'true' : 'false';
       
  5422 	
       
  5423 	$field_name = ini_get("session.upload_progress.name");
       
  5424 	
       
  5425 	?>
       
  5426 	<input type="hidden" name="upload_progress_name" value="<?php echo !empty($field_name) ? $field_name : ''; ?>" />
       
  5427 	<?php if ( !empty($field_name) ): ?>
       
  5428 	<input type="hidden" name="<?php echo $field_name; ?>" value="<?php echo $upkey; ?>" />
       
  5429 	<?php endif; ?>
       
  5430 	<input type="hidden" name="progress_support" value="<?php echo $php_has_progress_support; ?>" />
       
  5431 	
       
  5432 	<script type="text/javascript">
       
  5433 	//<![CDATA[
       
  5434 	
       
  5435 	addOnloadHook(function()
       
  5436 		{
       
  5437 			load_component('upload');
       
  5438 			var ajaxupload = new AjaxUpload('<?php echo $formid; ?>');
       
  5439 			eval(setHook('<?php echo $formid; ?>_ajaxupload_init'));
       
  5440 		});
       
  5441 	//]]>
       
  5442 	</script>
       
  5443 	
       
  5444 	<?php
       
  5445 }
       
  5446