Useful PHP Codes

 

1. Clean all logs created under /home named like cron.php?2323 once in 12 hours using cronjob:


Write this code in clean-cron-logs.php:

array_map('unlink', glob("../cron.php?*"));


Add clean-cron-logs.php to cronjob:

/usr/bin/php /home/public_html/clean-cron-logs.php


2. How to change moodle's root path:

1.   Moodle the line below in config.php to the path you want to be the root path:

$CFG->wwwroot   = 'http://yourdomain.com';

//$CFG->wwwroot   = 'http://yourdomain.com/the_path_to_be_the_root';


3. Change moodle's root path according to the domain the client comes vfrom:


İf (false !== strpos($_SERVER['HTTP_HOST'],"yourrefdomain")){

    $CFG->wwwroot   = 'https://yourrefdomain.com';

}else{

    $CFG->wwwroot   = 'https://yournormaldomain.com';

}



Comments