Ejemplo n.º 1
0
<?php

defined('ABSPATH') or die('Cheating, huh?');
global $fc_addons, $fc_templates, $fc_meta, $fc_forms_table, $fc_submissions_table, $fc_views_table, $wpdb;
$time = date('Y-m-d 00:00:00', time() + fc_offset());
$date_format = get_option('date_format');
$forms = $wpdb->get_results("SELECT id, name FROM {$fc_forms_table} WHERE name<>''");
$total_subs = $wpdb->get_var("SELECT COUNT(*) FROM {$fc_submissions_table}");
$total_forms = $wpdb->get_var("SELECT COUNT(*) FROM {$fc_forms_table} WHERE name<>''");
$total_payments = $wpdb->get_var("SELECT SUM(payment) FROM {$fc_views_table}");
$class_col = $total_payments == 0 ? 'small-4' : 'small-3';
$total_subs = $total_subs == null ? 0 : $total_subs;
$total_forms = $total_forms == null ? 0 : $total_forms;
$templates = array();
foreach ($fc_templates as $key => $templatesGroup) {
    if (empty($templatesGroup)) {
        continue;
    }
    if (!file_exists($templatesGroup)) {
        continue;
    }
    $templatesTemp = scandir($templatesGroup);
    if (!$templatesTemp) {
        continue;
    }
    $templates[$key] = array();
    foreach ($templatesTemp as $key2 => $value) {
        $temp1 = explode('.', $value);
        if (isset($temp1[count($temp1) - 1]) && $temp1[count($temp1) - 1] == 'txt') {
            $templates[$key][] = array('name' => str_replace('.txt', '', $value), 'path' => str_replace(WP_PLUGIN_DIR, '', $templatesGroup) . $value);
        }
Ejemplo n.º 2
0
function formcraft3_new_submission($form_id, $payment)
{
    global $fc_meta, $fc_forms_table, $fc_submissions_table, $fc_views_table, $wpdb;
    if (!strpos($_SERVER["REQUEST_URI"], '?preview=true') && ctype_digit($form_id)) {
        setcookie("fc_sb_" . $form_id, true, time() + 10 * 365 * 24 * 60 * 60, '/');
        $time = date('Y-m-d 00:00:00', time() + fc_offset());
        $existing = $wpdb->get_var("SELECT counter FROM {$fc_forms_table} WHERE id = '{$form_id}'");
        $wpdb->update($fc_forms_table, array('counter' => $existing + 1), array('id' => $form_id));
        if ($wpdb->get_var("SELECT COUNT(*) FROM {$fc_views_table} WHERE _date = '{$time}' AND form = {$form_id}")) {
            $existing = $wpdb->get_var("SELECT submissions FROM {$fc_views_table} WHERE _date = '{$time}' AND form = {$form_id}");
            $existing_pay = $wpdb->get_var("SELECT payment FROM {$fc_views_table} WHERE _date = '{$time}' AND form = {$form_id}");
            $rows_affected = $wpdb->update($fc_views_table, array('submissions' => $existing + 1, 'payment' => $existing_pay + $payment), array('form' => $form_id, '_date' => $time));
        } else {
            $rows_affected = $wpdb->insert($fc_views_table, array('form' => $form_id, 'submissions' => 1, 'payment' => $payment, '_date' => $time));
        }
        /* Check if we need to disable form */
        $existing++;
        $meta = $wpdb->get_var("SELECT meta_builder FROM {$fc_forms_table} WHERE id = '{$form_id}'");
        $meta = json_decode(stripslashes($meta), 1);
        if (isset($meta['config']['disable_after']) && isset($meta['config']['disable_after_nos']) && $meta['config']['disable_after'] == true && ctype_digit($meta['config']['disable_after_nos'])) {
            if ($meta['config']['disable_after_nos'] == $existing) {
                $meta['config']['form_disable'] = true;
                $meta = esc_sql(json_encode($meta));
                $wpdb->update($fc_forms_table, array('meta_builder' => $meta), array('id' => $form_id));
            }
        }
    }
}