Skip to content

Instantly share code, notes, and snippets.

@web-zen
Created September 4, 2009 15:22
Show Gist options
  • Save web-zen/180940 to your computer and use it in GitHub Desktop.
Save web-zen/180940 to your computer and use it in GitHub Desktop.
<?php
require_once "connections/oMyConn.php"; // DB Connection created
// validate Ajax request
function is_ajax() {
return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
}
$ajaxState = is_ajax();
//$ajaxState = 1; // for testing
// echo '$ajaxState: ' . gettype($ajaxState);
if (((int) $ajaxState) == 1){
switch ($_POST['action'])
{
case 'writefile': // list document actions
// echo "action is: " . $_POST['action'] . "\n";
$fh = "documents\zztestFile.xml";
$fh = fopen($fh, 'w') or die("can't open file");
fwrite($fh, $_POST['content']);
fclose($fh);
// echo "content is: " . $_POST['content'];
break;
default:
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment