function checkExists(myVar) { if (typeof myVar === 'undefined') { return false; } if ( myVar === null ) { return false; } if ( myVar.length == 0) { return false; } return true; }
Friday, October 30, 2015
Javascript: If undefined or null or string length equals zero return false
Thursday, October 15, 2015
PHP disk_free_space
$diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024);Nice little uptimeRobot alert script:
isset($_REQUEST['threshold']) ? $driveThresold=$_REQUEST['threshold'] : $driveThresold=11; function killMe($input) { header('HTTP/1.1 500 Internal Server Error'); die(); } function allGood($input) { header("Content-Type:text/plain") ; die($input); } $diskFreeSpace = round(disk_free_space($data_drive) / 1024 / 1024 / 1024); $diskfreespace < $driveThresold ? killMe($diskfreespace) : allGood(strval($diskfreespace)); die();
Friday, October 2, 2015
Directory List to XML
<?php header("Content-type: text/xml"); print "<?xml version='1.0' encoding='UTF-8'?>\n<response?>\n"; $files = glob('*.xml'); foreach($files as $file) { print "<file?>".$file."</file?>\n<!-- ".date("F d Y H:i:s.",filemtime($file))."--?>\n"; } die(''); ?>
Subscribe to:
Posts (Atom)