Example #1
0
 * (at your option) any later version.
 *
 * Jeedom is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
require_once dirname(__FILE__) . '/../../core/php/core.inc.php';
include_file('core', 'authentification', 'php');
if (!isConnect()) {
    throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$pathfile = calculPath(urldecode(init('pathfile')));
if (strpos($pathfile, '.php') !== false) {
    throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
$rootPath = realpath(dirname(__FILE__) . '/../../');
if (strpos($pathfile, $rootPath) === false) {
    throw new Exception(__('401 - Accès non autorisé', __FILE__));
}
if (!file_exists($pathfile)) {
    throw new Exception(__('Fichier non trouvé : ', __FILE__) . $pathfile);
}
$path_parts = pathinfo($pathfile);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . $path_parts['basename']);
readfile($pathfile);
exit;
Example #2
0
    foreach ($argv as $arg) {
        $argList = explode('=', $arg);
        if (isset($argList[0]) && isset($argList[1])) {
            $_GET[$argList[0]] = $argList[1];
        }
    }
}
try {
    require_once dirname(__FILE__) . '/../core/php/core.inc.php';
    echo __("***************Lancement de la sauvegarde de Jeedom le ", __FILE__) . date('Y-m-d H:i:s') . "***************\n";
    global $CONFIG;
    $tmp = dirname(__FILE__) . '/../tmp/backup';
    if (!file_exists($tmp)) {
        mkdir($tmp, 0770, true);
    }
    $backup_dir = calculPath(config::byKey('backup::path'));
    echo __("Vérification du système de fichiers (corruption)...", __FILE__);
    if (jeedom::checkFilesystem()) {
        echo __("OK", __FILE__) . "\n";
    } else {
        echo __("NOK\n", __FILE__);
    }
    if (!file_exists($backup_dir)) {
        mkdir($backup_dir, 0770, true);
    }
    if (!is_writable($backup_dir)) {
        throw new Exception(__('Le dossier des sauvegardes n\'est pas accessible en écriture. Vérifiez les droits : ', __FILE__) . $backup_dir);
    }
    try {
        echo __("Mise à plat des droits...", __FILE__);
        jeedom::cleanFileSytemRight();