Location: PHPKode > scripts > WH Social > wh_social/framework/functions/backup.php
<?php

    $path = './backup/';

    function dirsize($dir) {
        $dirsize = 0;
        $handle = opendir($dir);

        while(FALSE !== ($file = readdir($handle))) {
            $dirsize+=filesize($dir.$file);
            }

    closedir($handle);

    return $dirsize;
    }

    echo '<p><strong>' . $lang['backup_configuration'] . '</strong></p>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="200">' . $lang['backup_selection'] . ':</td>
        <td>' . $mysql_data . '</td>
    </tr>
    <tr>
        <td width="200">' . $lang['backup_autodelete'] . ' >:</td>
        <td>' . $lang['backup_in_more_than'] . ' ' . $backups . ' ' . $lang['backup_plural'] . '</td>
    </tr>
    <tr>
        <td width="200">' . $lang['backup_compression'] . ':</td>
        <td><span class="green_span">' . $lang['backup_active'] . '</span></td>
    </tr>
    <tr>
        <td width="200">' . $lang['backup_total_root'] . ':</td>
        <td>' . round(dirsize($path)/(1024*1024),2) . ' MB</td>
    </tr>
    </table>
    <br><br>
    <p><em>' . $lang['backup_progress'] . '...</em><br><br>
    <span class="green_span" id="dspan"><strong>|</strong></span></p>';

    echo '<script type="text/javascript">
    <!--
        function js_dots() {
            dspan.innerText = dspan.innerText + "|";
            jstimer = setTimeout("js_dots();", 200);
            }
        
        if(document.all) {
            js_dots();
            }
    //-->
    </script>';

    if(!is_dir($path)) mkdir($path, 0777);
        $dh = opendir($path);
    
    while(FALSE !== ($filename = readdir($dh))) {
        if($filename != $filename) $files_unlink[] = $filename;
        }

    @rsort($files_unlink);

    if(sizeof($files_unlink) >= $backups) {

        for($n = sizeof($files_unlink)-1; $n >= $backups; $n--) {
            unlink($path.$files_unlink[$n]);
            }
        }

    $backup_file = date("d\.m\.Y\_H",time())."_Backup_".date("i",time());
    $backup_file .= ".gz";

    if(file_exists($backup_file)) unlink($backup_file);

        $path = str_replace(".", "", $path);

        exec("/usr/bin/mysqldump -u$mysql_user -p$mysql_pass -h $mysql_host $mysql_data | gzip > " . dirname(__FILE__) . "$path/$backup_file", $fp);

    if($fp == 0)

    $msg = $lang['backup_success'];

        else

        $msg = $lang['backup_failed'];

    echo '<script type="text/javascript">
    <!--
        if(document.all) {
            clearTimeout(jstimer);
            }
    //-->
    </script>';

    echo '<p>' . $msg . '</p>';

?>
Return current item: WH Social