Exemple #1
0
/**
 * Provides a hook for file synchronisation between mirrored servers.
 *
 * @param  PATH				File/directory name to sync on (may be full or relative path)
 */
function co_sync_file($filename)
{
    global $FILE_BASE;
    if (file_exists($FILE_BASE . '/data_custom/sync_script.php')) {
        require_once $FILE_BASE . '/data_custom/sync_script.php';
        if (substr($filename, 0, strlen($FILE_BASE)) == $FILE_BASE) {
            $filename = substr($filename, strlen($FILE_BASE));
        }
        if (function_exists('master__sync_file')) {
            master__sync_file($filename);
        }
    }
}
Exemple #2
0
/**
 * Provides a hook for file synchronisation between mirrored servers. Called after any file creation, deletion or edit.
 *
 * @param  PATH				File/directory name to sync on (full path)
 */
function sync_file($filename)
{
    global $FILE_BASE, $_MODIFIED_FILES, $_CREATED_FILES;
    static $has_sync_script = NULL;
    if (is_null($has_sync_script)) {
        $has_sync_script = is_file($FILE_BASE . '/data_custom/sync_script.php');
    }
    if (!$has_sync_script && !isset($_MODIFIED_FILES)) {
        return;
    }
    if (substr($filename, 0, strlen($FILE_BASE) + 1) == $FILE_BASE . '/') {
        $filename = substr($filename, strlen($FILE_BASE) + 1);
    }
    if ($has_sync_script) {
        require_once $FILE_BASE . '/data_custom/sync_script.php';
        if (function_exists('master__sync_file')) {
            master__sync_file($filename);
        }
    }
    if (isset($_MODIFIED_FILES)) {
        foreach ($_MODIFIED_FILES as $i => $x) {
            if ($x == $FILE_BASE . '/' . $filename || $x == $filename) {
                unset($_MODIFIED_FILES[$i]);
            }
        }
    }
    if (isset($_CREATED_FILES)) {
        foreach ($_CREATED_FILES as $i => $x) {
            if ($x == $FILE_BASE . '/' . $filename || $x == $filename) {
                unset($_CREATED_FILES[$i]);
            }
        }
    }
}