예제 #1
0
파일: purge.php 프로젝트: noikiy/owaspbwa
function purge_events($ids)
{
    global $preview, $c;
    // db connection
    global $sqlLog;
    $tables = array(array('webcal_entry_user', 'cal_id'), array('webcal_entry_repeats', 'cal_id'), array('webcal_entry_repeats_not', 'cal_id'), array('webcal_entry_log', 'cal_entry_id'), array('webcal_import_data', 'cal_id'), array('webcal_site_extras', 'cal_id'), array('webcal_reminder_log', 'cal_id'), array('webcal_entry_ext_user', 'cal_id'), array('webcal_entry', 'cal_id'));
    //var_dump($tables);exit;
    $num = array();
    for ($i = 0; $i < count($tables); $i++) {
        $num[$i] = 0;
    }
    foreach ($ids as $cal_id) {
        for ($i = 0; $i < count($tables); $i++) {
            $clause = $cal_id == 'ALL' ? '' : " WHERE {$tables[$i][1]} = {$cal_id}";
            if ($preview) {
                $sql = "SELECT COUNT(" . $tables[$i][1] . ") FROM {$tables[$i][0]}" . $clause;
                //echo "cal_id = '$cal_id'<br>clause = '$clause'<br>";
                //echo "$sql <br/>\n";
                $res = dbi_query($sql);
                $sqlLog .= $sql . "<br/>\n";
                if ($res) {
                    if ($row = dbi_fetch_row($res)) {
                        $num[$i] += $row[0];
                    }
                    dbi_free_result($res);
                }
            } else {
                $sql = "DELETE FROM {$tables[$i][0]}" . $clause;
                $sqlLog .= $sql . "<br/>\n";
                $res = dbi_query($sql);
                if ($cal_id == 'ALL') {
                    $num[$i] = translate("All");
                } else {
                    $num[$i] += dbi_affected_rows($c, $res);
                }
            }
        }
    }
    for ($i = 0; $i < count($tables); $i++) {
        $table = $tables[$i][0];
        echo "[" . translate("Preview") . "] " . translate("Records deleted from") . " {$table}: {$num[$i]}<br />\n";
    }
}
예제 #2
0
파일: purge.php 프로젝트: rhertzog/lcs
function purge_events($ids)
{
    global $preview, $previewStr, $c;
    // db connection
    global $sqlLog, $allStr;
    $tables = array(array('webcal_entry_user', 'cal_id'), array('webcal_entry_repeats', 'cal_id'), array('webcal_entry_repeats_not', 'cal_id'), array('webcal_entry_log', 'cal_entry_id'), array('webcal_entry_categories', 'cal_id'), array('webcal_import_data', 'cal_id'), array('webcal_site_extras', 'cal_id'), array('webcal_reminders', 'cal_id'), array('webcal_entry_ext_user', 'cal_id'), array('webcal_blob', 'cal_id'), array('webcal_entry', 'cal_id'));
    //var_dump($tables);exit;
    $num = array();
    $cnt = count($tables);
    for ($i = 0; $i < $cnt; $i++) {
        $num[$i] = 0;
    }
    foreach ($ids as $cal_id) {
        for ($i = 0; $i < $cnt; $i++) {
            $clause = $cal_id == 'ALL' ? '' : " WHERE {$tables[$i][1]} = {$cal_id}";
            if ($preview) {
                $sql = 'SELECT COUNT(' . $tables[$i][1] . ") FROM {$tables[$i][0]}" . $clause;
                $res = dbi_execute($sql);
                $sqlLog .= $sql . "<br />\n";
                if ($res) {
                    if ($row = dbi_fetch_row($res)) {
                        $num[$i] += $row[0];
                    }
                    dbi_free_result($res);
                }
            } else {
                $sql = "DELETE FROM {$tables[$i][0]}" . $clause;
                $sqlLog .= $sql . "<br />\n";
                $res = dbi_execute($sql);
                if ($cal_id == 'ALL') {
                    $num[$i] = $allStr;
                } else {
                    $num[$i] += dbi_affected_rows($c, $res);
                }
            }
        }
    }
    for ($i = 0; $i < $cnt; $i++) {
        $table = $tables[$i][0];
        echo '[' . $previewStr . '] ' . translate('Records deleted from') . " {$table}: {$num[$i]}<br />\n";
    }
}
예제 #3
0
function purge_events($ids)
{
    global $c;
    // db connection
    $tables = array();
    $tables[0][T] = 'webcal_entry_user';
    $tables[0][C] = 'cal_id';
    $tables[1][T] = 'webcal_entry_repeats';
    $tables[1][C] = 'cal_id';
    $tables[2][T] = 'webcal_entry_repeats_not';
    $tables[2][C] = 'cal_id';
    $tables[3][T] = 'webcal_entry_log';
    $tables[3][C] = 'cal_entry_id';
    $tables[4][T] = 'webcal_import_data';
    $tables[4][C] = 'cal_id';
    $tables[5][T] = 'webcal_site_extras';
    $tables[5][C] = 'cal_id';
    $tables[6][T] = 'webcal_reminder_log';
    $tables[6][C] = 'cal_id';
    $tables[7][T] = 'webcal_entry';
    $tables[7][C] = 'cal_id';
    $tables[8][T] = 'webcal_import_data';
    $tables[8][C] = 'cal_id';
    $TT = sizeof($tables);
    //var_dump($tables);exit;
    foreach ($ids as $cal_id) {
        for ($i = 0; $i < $TT; $i++) {
            $res = dbi_query("DELETE FROM {$tables[$i][T]} WHERE {$tables[$i][C]} like '{$cal_id}'");
            $num[$tables[$i][T]] += dbi_affected_rows($c, $res);
        }
    }
    for ($i = 0; $i < $TT; $i++) {
        $table = $tables[$i][T];
        echo translate("Records deleted from") . " {$table}: {$num[$table]}<br />\n";
    }
}