Merged (accidental split)
authorDan
Fri, 30 Apr 2010 22:15:03 -0400
changeset 1248 3914c9a95879
parent 1247 30f023a13a71 (diff)
parent 1245 62763b17be2d (current diff)
child 1249 81b03b3e88d0
Merged (accidental split)
--- a/includes/clientside/static/ajax.js	Tue Apr 20 11:38:59 2010 -0400
+++ b/includes/clientside/static/ajax.js	Fri Apr 30 22:15:03 2010 -0400
@@ -1786,3 +1786,35 @@
 			}
 		});
 }
+
+window.ajaxVerifyFilePath = function(input)
+{
+	input._lastkeyup = new Date();
+	// 500ms between keyup and trigger
+	setTimeout(function()
+		{
+			var now = new Date();
+			if ( input._lastkeyup.getTime() + 499 < now.getTime() )
+			{
+				// do the ajaxverify
+				ajaxVerifyFilePathReal(input);
+			}
+		}, 500);
+}
+
+window.ajaxVerifyFilePathReal = function(input)
+{
+	if ( input.nextSibling && input.nextSibling.tagName == 'IMG' )
+		input.parentNode.removeChild(input.nextSibling);
+	var img = document.createElement('img');
+	img.src = cdnPath + '/images/loading.gif';
+	img.hspace = '7';
+	ajaxPost(makeUrlNS('Admin', 'UploadConfig', 'act=verify_path'), 'path=' + ajaxEscape(input.value), function(ajax)
+		{
+			if ( ajax.readyState == 4 && ajax.status == 200 )
+			{
+				img.src = ( ajax.responseText == 'true' ) ? cdnPath + '/images/mini-success.png' : cdnPath + '/images/mini-error.png';
+			}
+		});
+	insertAfter(input.parentNode, img, input);
+}
--- a/plugins/SpecialAdmin.php	Tue Apr 20 11:38:59 2010 -0400
+++ b/plugins/SpecialAdmin.php	Fri Apr 30 22:15:03 2010 -0400
@@ -1110,6 +1110,14 @@
 		return;
 	}
 	
+	if ( isset($_GET['act']) && $_GET['act'] == 'verify_path' )
+	{
+		$path = $_POST['path'];
+		$result = @file_exists($path) && @is_file($path) && @is_executable($path);
+		echo $result ? 'true' : 'false';
+		return;
+	}
+	
 	if(isset($_POST['save']))
 	{
 		if(isset($_POST['enable_uploads']) && getConfig('enable_uploads') != '1')
@@ -1218,7 +1226,7 @@
 			<?php echo $lang->get('acpup_field_magick_enable'); ?>
 		</label>
 		<br />
-		<?php echo $lang->get('acpup_field_magick_path'); ?> <input type="text" name="imagemagick_path" value="<?php if(getConfig('imagemagick_path')) echo getConfig('imagemagick_path'); else echo '/usr/bin/convert'; ?>" /><br />
+		<?php echo $lang->get('acpup_field_magick_path'); ?> <input type="text" name="imagemagick_path" value="<?php echo htmlspecialchars(getConfig('imagemagick_path', '/usr/bin/convert')); ?>" onkeyup="ajaxVerifyFilePath(this);" /><br />
 		<?php echo $lang->get('acpup_field_magick_path_hint'); ?>
 	</p>