Posts Tagged ‘php’
Using Xubuntu as a web server
For those who are interested in running Linux, especially on an older PC, Xubuntu just might fit the bill. Its installation files fit on one disc and include a versatile window manager to boot. However, the basic install isn’t really capable of being a LAMP and FTP-enabled web server. This tutorial explains how to get [...]
Filed under: Uncategorized | 13 Comments
Tags: apache, lamp, linux, mysql, php, phpmyadmin, proftpd, xubuntu
Hiding a PHP include from users
If you have a PHP application with a few include files, chances are you don’t want your users to navigate to them, by mistake or otherwise. So here’s a tiny script that checks if a user is looking at the include file by itself and redirects them to the proper place:
if(preg_match(“/includename/”,$_SERVER['PHP_SELF'])){
header(“Location:properlocation.php”);}
You don’t need to put [...]
Filed under: Uncategorized | 2 Comments
Tags: hide, include, php, redirect, users
It’s a bit of a head-scratcher at first, seeing as the jQuery docs mysteriously disavow a postJSON possibility, let alone a function, but it’s definitely doable. So here’s the glorious code:
function postjson(url,data,bS,s,e){
$.ajax({type:”POST”,url:url,data:data,dataType:”json”,
beforeSend:bS,success:s,error:e});}
Use it like so:
postjson(“name.php”,”name=Bob”,
function(){$(“#name”).text(“…”);},
function(json){$(“#name”).text(json.name);},
function(){$(“#name”).text(“Error”);});
If name.php’s output looks like this…
{“name”:”Bob”}
…the above should, upon execution, change the ID “name” to contain the text “Bob.” [...]
Filed under: Uncategorized | 5 Comments
Tags: ajax, javascript, jquery, json, php, post, web