function rmdir_Rf($directory) { foreach (glob("{$directory}/*") as $file) { if (is_dir($file)) { rmdir_Rf($file); } else { unlink($file); } } rmdir($directory); }
function cp_table_exit($req) { $from_db = $req['db_name']; $from_table = $req['table_name']; $copyto_db = $req['db_dest']; $is_remove = @$req['remove_src'] === 'true'; null_exit($from_db, $from_table, $copyto_db); $table_root = table_root($from_db, $from_table); if (!file_exists($table_root)) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'src table error')); } $copyto_table = get_bkable_table($copyto_db, $from_table); if ($copyto_table === false) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'too mach same tables')); } $copyto_root = table_root($copyto_db, $copyto_table); if (smartCopy($table_root, $copyto_root) === false) { jsonp_nocache_exit(array('status' => 'error', 'error' => 'copy exec error')); } wh_event($copyto_db, $copyto_table, 'create'); if ($is_remove) { rmdir_Rf($table_root); wh_event($from_db, $from_table, 'destroy'); } jsonp_nocache_exit(array('status' => 'ok')); }