Home » Archive

Articles tagged with: PHP

Code »

[3 Aug 2008 | No Comment | ]
Joomla Joomlart 1.0.xx WYSIWYG editor not loading

Code:
<?php if ( $my->id ) { initEditor(); } ?>
</head>

Code, Headline »

[6 Jul 2008 | 10 Comments | ]
Amazon s3 backup for web server files and SQL using bash

I needed a solid backup method for my clients websites, where I wanted to improve from the previous method of backing up to a separate host in the US Hostmonster. Hostmonster expires in 80 days, so why renew for $100+/year just to house a few GB of client backups.
I wanted to use the Amazon S3 service for my backups with an amazing reliability and a low monthly cost, so I  went ahead crawling the web for bash scripts that would suit my situation. The one I liked the most was Here, but …

Code »

[3 Jul 2008 | No Comment | ]

define(’PATH’, ‘/www/public/images/’);
function destroy($dir) {
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir))) {
if($file != “.” && $file != “..”) {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir(’.’);
destroy($dir.$file.’/’);
rmdir($dir.$file) or DIE(”couldn’t delete $dir$file
“);
}
else
unlink($dir.$file) or DIE(”couldn’t delete $dir$file
“);
}
}
closedir($mydir);
}
destroy(PATH);

Code »

[16 Apr 2008 | No Comment | ]

<?php
$to = “someone@example.com”; $subject = “Test mail”; $message = “Hello! This is a simple email message.”; $from = “someonelse@example.com”; $headers = “From: $from”; mail($to,$subject,$message,$headers); echo “Mail Sent.”;
?>

Code »

[12 Apr 2008 | No Comment | ]

 
 

Sometimes, you might want to get the current page URL that is shown in the browser URL window. For example if you want to let your visitors submit a blog post to Digg you need to get that same exact URL. There are plenty of other reasons as well. Here is how you can do that.
Add the following code to a page:
<?php
function curPageURL() {
$pageURL = ‘http’;
if ($_SERVER["HTTPS"] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER["SERVER_PORT"] != “80″) {
$pageURL .= $_SERVER["SERVER_NAME"].”:”.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>