Пример #1
0
function display_form_lists()
{
    global $wpdb;
    $where = '';
    $sort["custom_style"] = "";
    $sort["1_or_2"] = "";
    $order = "";
    $sort["default_style"] = "";
    $sort["sortid_by"] = '';
    if (isset($_POST['page_number'])) {
        if ($_POST['asc_or_desc']) {
            $sort["sortid_by"] = $wpdb->escape($_POST['order_by']);
            if ($_POST['asc_or_desc'] == 1) {
                $sort["custom_style"] = "manage-column column-title sorted asc";
                $sort["1_or_2"] = "2";
                $order = "ORDER BY " . $sort["sortid_by"] . " ASC";
            } else {
                $sort["custom_style"] = "manage-column column-title sorted desc";
                $sort["1_or_2"] = "1";
                $order = "ORDER BY " . $sort["sortid_by"] . " DESC";
            }
        }
        if ($_POST['page_number']) {
            $limit = ((int) $_POST['page_number'] - 1) * 20;
        } else {
            $limit = 0;
        }
    } else {
        $limit = 0;
    }
    if (isset($_POST['search_events_by_title'])) {
        $search_tag = esc_html($_POST['search_events_by_title']);
    } else {
        $search_tag = "";
    }
    if ($search_tag) {
        $where = ' WHERE title LIKE "%' . $search_tag . '%"';
        $where .= " AND `id` NOT IN(" . get_option('contact_form_forms', 0) . ")";
    } else {
        $where = " WHERE `id` NOT IN(" . get_option('contact_form_forms', 0) . ")";
    }
    // Get the total number of records.
    $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker" . $where;
    $total = $wpdb->get_var($query);
    $pageNav['total'] = $total;
    $pageNav['limit'] = $limit / 20 + 1;
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker" . $where . " " . $order . " " . " LIMIT " . $limit . ",20";
    $rows = $wpdb->get_results($query);
    $old_version = FALSE;
    foreach ($rows as $row) {
        if (strpos($row->form, "wdform_table1") === FALSE) {
            $old_version = TRUE;
            break;
        }
    }
    $can_update_form = TRUE;
    if ($old_version) {
        $old_n = 0;
        foreach ($rows as $row) {
            $count_words_in_form = count(explode("_element_section", $row->form)) - count(explode("and_element_section", $row->form));
            if (!(strpos($row->form, "type_map") === FALSE)) {
                $can_update_form = FALSE;
                break;
            }
            if (!(strpos($row->form, "type_file") === FALSE)) {
                $can_update_form = FALSE;
                break;
            }
            if ($count_words_in_form > 5) {
                $can_update_form = FALSE;
                break;
            }
            if (strpos($row->form, "wdform_table1") === FALSE) {
                $old_n++;
            }
        }
        @session_start();
        $_SESSION['all_updates'] = $old_n;
        $_SESSION['current_updates'] = 0;
    }
    html_display_form_lists($rows, $pageNav, $sort, $old_version, $can_update_form);
}
Пример #2
0
function display_form_lists()
{
    global $wpdb;
    $sort["default_style"] = "manage-column column-autor sortable desc";
    $sort["sortid_by"] = "";
    if (isset($_POST['page_number'])) {
        if ($_POST['asc_or_desc']) {
            $sort["sortid_by"] = $wpdb->escape($_POST['order_by']);
            if ($_POST['asc_or_desc'] == 1) {
                $sort["custom_style"] = "manage-column column-title sorted asc";
                $sort["1_or_2"] = "2";
                $order = "ORDER BY " . $sort["sortid_by"] . " ASC";
            } else {
                $sort["custom_style"] = "manage-column column-title sorted desc";
                $sort["1_or_2"] = "1";
                $order = "ORDER BY " . $sort["sortid_by"] . " DESC";
            }
        } else {
            $order = "";
        }
        if ($_POST['page_number']) {
            $limit = ((int) $_POST['page_number'] - 1) * 20;
        } else {
            $limit = 0;
        }
    } else {
        $order = "";
        $limit = 0;
    }
    if (isset($_POST['search_events_by_title'])) {
        $search_tag = esc_html($_POST['search_events_by_title']);
    } else {
        $search_tag = "";
    }
    if ($search_tag) {
        $where = ' WHERE title LIKE "%' . $search_tag . '%"';
    } else {
        $where = "";
    }
    get_option('contact_form_forms');
    if (get_option('contact_form_forms') != '') {
        if ($where) {
            $where .= ' AND `id` IN (' . get_option('contact_form_forms') . ')';
        } else {
            $where .= ' WHERE `id` IN (' . get_option('contact_form_forms') . ')';
        }
    } else {
        if ($where) {
            $where .= ' AND `id` IN (0)';
        } else {
            $where .= ' WHERE `id` IN (0)';
        }
    }
    // get the total number of records
    $query = "SELECT COUNT(*) FROM " . $wpdb->prefix . "formmaker" . $where;
    $total = $wpdb->get_var($query);
    $pageNav['total'] = $total;
    $pageNav['limit'] = $limit / 20 + 1;
    $query = "SELECT * FROM " . $wpdb->prefix . "formmaker" . $where . " " . $order . " " . " LIMIT " . $limit . ",20";
    $rows = $wpdb->get_results($query);
    $old_version = false;
    foreach ($rows as $row) {
        if (strpos($row->form, "wdform_table1") === false) {
            $old_version = true;
            break;
        }
    }
    if ($old_version) {
        $old_n = 0;
        foreach ($rows as $row) {
            if (strpos($row->form, "wdform_table1") === false) {
                $old_n++;
            }
        }
        @session_start();
        $_SESSION['all_updates'] = $old_n;
        $_SESSION['current_updates'] = 0;
    }
    html_display_form_lists($rows, $pageNav, $sort, $old_version);
}