10^x|1024->2^x] $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); $e=floor(log($bytes,$convention)); return round($bytes/pow($convention,$e),2).' '.$s[$e]; } function php_sync_package() { global $config; //synch cron tab configure_cron(); } function php_install_command() { global $config; conf_mount_rw(); config_lock(); if (!is_dir('/usr/local/www/packages/')) { exec("mkdir /usr/local/www/packages/"); } if (!is_dir('/usr/local/www/packages/cron/')) { exec("mkdir /usr/local/www/packages/cron/"); } //rename PHP files from .tmp to .php exec("cp /tmp/cron.tmp /usr/local/www/packages/cron/cron.php"); unlink_if_exists("/tmp/cron.tmp"); exec("cp /tmp/cron_edit.tmp /usr/local/www/packages/cron/cron_edit.php"); unlink_if_exists("/tmp/cron_edit.tmp"); //write_config(); //write_rcfile(array( // "file" => "cron.sh", // "start" => "/usr/local/bin/php /usr/local/pkg/cron.php >> /var/log/cron.log &", // "stop" => "rm /tmp/cron.pid" // ) //); php_sync_package(); //$handle = popen("/usr/local/etc/rc.d/cron.sh start", "r"); //pclose($handle); //if (pkg_is_service_running('cron')) { //documentation purposes //} conf_mount_ro(); config_unlock(); } function deinstall_command() { conf_mount_rw(); config_lock(); $handle = popen("/usr/local/etc/rc.d/cron.sh stop", "r"); unlink_if_exists("/usr/local/pkg/cron.xml"); unlink_if_exists("/usr/local/www/cron.inc"); exec("rm -R /usr/local/www/packages/cron"); //unlink_if_exists("/usr/local/etc/rc.d/cron.sh"); conf_mount_ro(); config_unlock(); } ?>