コード例 #1
0
ファイル: admin_database.php プロジェクト: AroundPBT/PHPBoost
                $result->dispose();
            } catch (MySQLQuerierException $e) {
                $tpl->assign_block_vars('line', array());
                $tpl->assign_block_vars('line.field', array('FIELD_NAME' => $e->GetMessage(), 'STYLE' => ''));
            }
        } elseif (substr($lower_query, 0, 11) == 'insert into' || substr($lower_query, 0, 6) == 'update' || substr($lower_query, 0, 11) == 'delete from' || substr($lower_query, 0, 11) == 'alter table' || substr($lower_query, 0, 8) == 'truncate' || substr($lower_query, 0, 10) == 'drop table') {
            try {
                $result = PersistenceContext::get_querier()->inject(str_replace('phpboost_', PREFIX, $query));
                $affected_rows = $result->get_affected_rows();
            } catch (MySQLQuerierException $e) {
                $tpl->assign_block_vars('line', array());
                $tpl->assign_block_vars('line.field', array('FIELD_NAME' => $e->GetMessage(), 'STYLE' => ''));
            }
        }
    }
    $tpl->put_all(array('QUERY' => DatabaseService::indent_query($query), 'QUERY_HIGHLIGHT' => DatabaseService::highlight_query(str_replace('phpboost_', PREFIX, $query)), 'L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_EXPLAIN_QUERY' => $LANG['db_query_explain'], 'L_CONFIRM_QUERY' => $LANG['db_confirm_query'], 'L_EXECUTE' => $LANG['db_submit_query'], 'L_RESULT' => $LANG['db_query_result'], 'L_EXECUTED_QUERY' => $LANG['db_executed_query']));
} elseif ($action == 'restore') {
    //Suppression d'un fichier
    if (!empty($del)) {
        AppContext::get_session()->csrf_get_protect();
        //Protection csrf
        $file = TextHelper::strprotect($del);
        $file_path = PATH_TO_ROOT . '/cache/backup/' . $file;
        //Si le fichier existe
        if (preg_match('`[^/]+\\.sql$`', $file) && is_file($file_path)) {
            if (@unlink($file_path)) {
                AppContext::get_response()->redirect(HOST . DIR . url('/database/admin_database.php?action=restore&error=unlink_success', '', '&'));
            } else {
                AppContext::get_response()->redirect(HOST . DIR . url('/database/admin_database.php?action=restore&error=unlink_failure', '', '&'));
            }
        } else {