function dod_modify_details($generator_id)
{
    global $tables, $available_fields, $optional_fields, $skip_striptags_fields, $date_fields;
    /*if (empty($generator_id)) {
          return array(false, 'generator Id was not provided');
      }*/
    global $generator_data;
    if (empty($generator_data) || !is_array($generator_data)) {
        return array(true, null);
    }
    $error = null;
    $data = array();
    $excl_from_base_list = array('generator_id');
    foreach ($excl_from_base_list as $field) {
        if (isset($available_fields[$field])) {
            unset($available_fields[$field]);
        }
    }
    $additional_lang_data = array();
    foreach ($date_fields as $field) {
        if (isset($generator_data[$field]) && !empty($generator_data[$field])) {
            $generator_data[$field] = cw_core_strtotime($generator_data[$field]);
        }
    }
    foreach ($available_fields as $field => $field_type) {
        if (isset($generator_data[$field])) {
            $result = settype($generator_data[$field], $field_type);
            if ($result === false) {
                $error = 'msg_dod_incorrect_field_type';
                $additional_lang_data = array('field_name' => $field);
                break;
            }
            if ($field == 'description') {
                if ($generator_data[$field] == '<p>&#160;</p>') {
                    $generator_data[$field] = null;
                }
            }
            if (empty($generator_data[$field])) {
                if (in_array($field, $optional_fields)) {
                    $data[$field] = null;
                } else {
                    $error = 'msg_dod_empty_fields';
                    break;
                }
            } else {
                if ($field_type == 'string' && !in_array($field, $skip_striptags_fields)) {
                    $generator_data[$field] = cw_strip_tags($generator_data[$field]);
                }
                $data[$field] =& $generator_data[$field];
            }
        } else {
            if ($field_type == 'bool') {
                $data[$field] = 0;
            } else {
                if (in_array($field, $optional_fields)) {
                    $data[$field] = null;
                } else {
                    $error = 'msg_dod_empty_fields';
                    break;
                }
            }
        }
    }
    $sess_generator_data =& cw_session_register('_generator_data');
    $GLOBALS['_generator_data'] =& $generator_data;
    cw_session_register('_generator_data');
    if (!empty($error)) {
        return array(false, cw_get_langvar_by_name($error, $additional_lang_data));
    }
    global $attributes;
    $data['attributes'] = $attributes;
    $error = cw_error_check($data, array(), dod_ATTR_ITEM_TYPE);
    //cw_attributes_check($array_to_check['attribute_class_id'], $array_to_check['attributes'], $attributes_type, $index)
    if (!empty($error)) {
        return array(false, $error);
    }
    global $file_upload_data;
    if (empty($generator_id)) {
        if (empty($data)) {
            return array(false, null);
        }
        $generator_id = cw_array2insert($tables['dod_generators'], cw_addslashes($data));
    } else {
        cw_array2update($tables['dod_generators'], cw_addslashes($data), 'generator_id = \'' . $generator_id . '\'');
    }
    cw_call('cw_attributes_save', array('item_id' => $generator_id, 'item_type' => dod_ATTR_ITEM_TYPE, 'attributes' => $attributes));
    cw_session_unregister('_generator_data');
    return array($generator_id, null);
}
if ($payment_data['payment_type'] == 'cc') {
    $rules = array('card_type' => '', 'card_name' => '', 'card_number' => '', 'card_expire' => '', 'card_cvv2' => '');
    if ($payment_data['ccinfo'] || !$payment_data['ccinfo'] && $config['General']['enable_manual_cc_cvv2'] == 'Y') {
        $rules['card_cvv2'] = '';
    }
    if ($config['General']['uk_oriented_ccinfo'] == 'Y') {
        $rules['card_valid_from'] = '';
        $rules['card_issue_no'] = '';
    }
} elseif ($payment_data['payment_type'] == 'ch') {
    $rules = array('check_name' => '', 'check_ban' => '', 'check_brn' => '', 'check_number' => '');
} elseif ($payment_data['payment_type'] == 'dd') {
    $rules = array('debit_name' => '', 'debit_bank_account' => '', 'debit_bank_number' => '', 'debit_bank_name' => '');
}
if ($rules) {
    $fillerror = cw_error_check($_POST, $rules);
    if ($fillerror) {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        cw_header_location('index.php?target=cart&mode=checkout');
    }
    $ord_tmp = array();
    foreach ($rules as $k => $tmp) {
        //        $ord_tmp[] = $k.": ".stripslashes($request_prepared[$k]);
        $ord_tmp[] = $k . ": --not saved--";
    }
    $order_details = implode("\n", $ord_tmp);
}
cw_payment_header();
global $userinfo, $app_catalogs;
if ($customer_id) {
    $userinfo = cw_user_get_info($customer_id, 65535);
$fill_error =& cw_session_register('fill_error');
$prefilled_transaction =& cw_session_register('prefilled_transaction');
if (isset($record_id)) {
    $record_saved_data =& cw_session_register('record_saved_data');
    if ($record_id) {
        $record = cw_accounting_get_record($record_id);
    } elseif ($user) {
        $record['customer_id'] = $user;
    }
    if ($action == 'update_transation') {
        $record_data['customer_id'] = $user;
        $rules = array('accounting_category_id' => '', 'date_ref' => '', 'customer_id' => '');
        if (!$record_id || !$record['reference']) {
            $rules['total'] = '';
        }
        $fillerror = cw_error_check($record_data, $rules);
        if ($fillerror) {
            $record_saved_data = $record_data;
            $top_message = array('content' => $fillerror, 'type' => 'E');
            cw_header_location("index.php?target={$target}&mode={$mode}&user={$user}&record_id={$record_id}");
        }
        if (!$record_id) {
            $record_id = cw_array2insert('accounting_records', array('date' => cw_core_get_time()));
        }
        $to_update = array('customer_id' => $record_data['customer_id'], 'accounting_category_id' => $record_data['accounting_category_id'], 'descr' => $record_data['descr'], 'date_ref' => cw_core_strtotime($record_data['date_ref']), 'bank_code' => $record_data['bank_code'], 'payment_code' => $record_data['payment_code'], 'status' => $record_data['status']);
        if (!$record['reference']) {
            $to_update['total'] = $record_data['total'];
        }
        cw_array2update('accounting_records', $to_update, "accounting_record_id='{$record_id}'");
        cw_accounting_category_recalc_subcat_count($record_data['accounting_category_id']);
        if (count($_FILES)) {
<?php

cw_load('category', 'image', 'user', 'group_edit', 'attributes');
$saved_category =& cw_session_register('saved_category');
$file_upload_data =& cw_session_register('file_upload_data');
$top_message =& cw_session_register('top_message', array());
cw_image_clear(array('categories_images_thumb'));
if ($ge_id && cw_group_edit_count($ge_id) == 0) {
    $ge_id = false;
}
if ($action == 'update') {
    $rules = array('category' => '');
    $category_update['attributes'] = $attributes;
    $fillerror = cw_error_check($category_update, $rules, 'C');
    if ($fillerror) {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        $saved_category = $category_update;
        if ($file_upload_data['categories_images_thumb']) {
            $file_upload_data['categories_images_thumb']['is_redirect'] = false;
            $saved_category['image'] = $file_upload_data['categories_images_thumb'];
        }
        cw_header_location("index.php?target={$target}&mode={$mode}&cat={$cat}&ge_id={$ge_id}");
    }
    if ($mode == 'add') {
        $cat = cw_array2insert('categories', array('parent_id' => $cat));
        cw_category_update_path($cat);
    }
    $update_fields = array('category', 'description', 'featured', 'order_by', 'short_list');
    array_push($update_fields, 'meta_descr', 'meta_keywords');
    if ($edited_language != $config['default_admin_language']) {
        cw_unset($update_fields, 'category', 'description');
function ps_modify_details($offer_id)
{
    global $tables, $available_fields, $optional_fields, $skip_striptags_fields, $date_fields;
    /*if (empty($offer_id)) {
          return array(false, 'Offer Id was not provided');
      }*/
    global $offer_data;
    if (empty($offer_data) || !is_array($offer_data)) {
        return array(true, null);
    }
    $error = null;
    $data = array();
    $excl_from_base_list = array('offer_id');
    foreach ($excl_from_base_list as $field) {
        if (isset($available_fields[$field])) {
            unset($available_fields[$field]);
        }
    }
    $additional_lang_data = array();
    foreach ($date_fields as $field) {
        if (isset($offer_data[$field]) && !empty($offer_data[$field])) {
            $offer_data[$field] = cw_core_strtotime($offer_data[$field]);
        }
    }
    foreach ($available_fields as $field => $field_type) {
        if (isset($offer_data[$field])) {
            $result = settype($offer_data[$field], $field_type);
            if ($result === false) {
                $error = 'msg_ps_incorrect_field_type';
                $additional_lang_data = array('field_name' => $field);
                break;
            }
            if ($field == 'description') {
                if ($offer_data[$field] == '<p>&#160;</p>') {
                    $offer_data[$field] = null;
                }
            }
            if (empty($offer_data[$field])) {
                if (in_array($field, $optional_fields)) {
                    $data[$field] = null;
                } else {
                    $error = 'msg_ps_empty_fields';
                    break;
                }
            } else {
                if ($field_type == 'string' && !in_array($field, $skip_striptags_fields)) {
                    $offer_data[$field] = cw_strip_tags($offer_data[$field]);
                }
                $data[$field] =& $offer_data[$field];
            }
        } else {
            if ($field_type == 'bool') {
                $data[$field] = 0;
            } else {
                if (in_array($field, $optional_fields)) {
                    $data[$field] = null;
                } else {
                    $error = 'msg_ps_empty_fields';
                    break;
                }
            }
        }
    }
    $sess_offer_data =& cw_session_register('_offer_data');
    $GLOBALS['_offer_data'] =& $offer_data;
    cw_session_register('_offer_data');
    if (!empty($error)) {
        return array(false, cw_get_langvar_by_name($error, $additional_lang_data));
    }
    global $attributes;
    $data['attributes'] = $attributes;
    $error = cw_error_check($data, array(), PS_ATTR_ITEM_TYPE);
    //cw_attributes_check($array_to_check['attribute_class_id'], $array_to_check['attributes'], $attributes_type, $index)
    if (!empty($error)) {
        return array(false, $error);
    }
    global $file_upload_data;
    if (empty($offer_id)) {
        if (empty($data)) {
            return array(false, null);
        }
        $offer_id = cw_array2insert($tables['ps_offers'], cw_addslashes($data));
        $is_image = false;
        if (!empty($file_upload_data) && isset($file_upload_data[PS_IMG_TYPE]) && is_array($file_upload_data[PS_IMG_TYPE])) {
            $is_image = true;
            if (isset($sess_offer_data['image']) && !empty($sess_offer_data['image'])) {
                $file_upload_data[PS_IMG_TYPE]['is_redirect'] = false;
            }
            $GLOBALS['_offer_data']['image'] = $file_upload_data[PS_IMG_TYPE];
            $file_upload_data[PS_IMG_TYPE]['is_redirect'] = false;
        }
        if (!empty($offer_id)) {
            if ($is_image == true) {
                $image_posted = cw_image_check_posted($file_upload_data[PS_IMG_TYPE]);
                if ($image_posted) {
                    $image_id = cw_image_save($file_upload_data[PS_IMG_TYPE], array('alt' => $data['title'], 'id' => $offer_id));
                }
            }
        }
    } else {
        $image_id = 0;
        if (!empty($file_upload_data) && isset($file_upload_data[PS_IMG_TYPE]) && is_array($file_upload_data[PS_IMG_TYPE])) {
            $image_posted = cw_image_check_posted($file_upload_data[PS_IMG_TYPE]);
            if ($image_posted) {
                $image_id = cw_image_save($file_upload_data[PS_IMG_TYPE], array('alt' => $data['title'], 'id' => $offer_id));
            }
        }
        if (empty($data) && empty($image_id)) {
            $error = 'msg_ps_nothing_to_update';
            return array(false, cw_get_langvar_by_name($error, $additional_lang_data));
        }
        cw_array2update($tables['ps_offers'], cw_addslashes($data), 'offer_id = \'' . $offer_id . '\'');
    }
    cw_call('cw_attributes_save', array('item_id' => $offer_id, 'item_type' => PS_ATTR_ITEM_TYPE, 'attributes' => $attributes));
    cw_session_unregister('_offer_data');
    return array($offer_id, null);
}
<?php

cw_load('image', 'attributes');
$file_upload_data =& cw_session_register('file_upload_data');
$search_data =& cw_session_register('search_data', array());
$saved_manufacturer =& cw_session_register('saved_manufacturer', array());
cw_image_clear(array('manufacturer_images'));
$top_message =& cw_session_register('top_message', array());
if ($action == 'search') {
    $search_data['manufacturers']['substring'] = $posted_data['substring'];
    cw_header_location('index.php?target=' . $target);
}
if ($action == 'details') {
    $rules = array('manufacturer' => '');
    $manufacturer_update['attributes'] = $attributes;
    $fillerror = cw_error_check($manufacturer_update, $rules, 'M');
    if ($fillerror) {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        $saved_manufacturer = $manufacturer_update;
        cw_header_location("index.php?target={$target}&" . ($manufacturer_id ? "manufacturer_id={$manufacturer_id}" : 'mode=add'));
    }
    $to_update = array('manufacturer' => $manufacturer_update['manufacturer'], 'url' => $manufacturer_update['url'], 'descr' => $manufacturer_update['descr'], 'featured' => $manufacturer_update['featured'], 'avail' => $manufacturer_update['avail'], 'orderby' => $manufacturer_update['orderby'], 'show_image' => $manufacturer_update['show_image']);
    $to_update_lng = array('manufacturer_id' => $manufacturer_id, 'code' => $edited_language, 'descr' => $manufacturer_update['descr'], 'manufacturer' => $manufacturer_update['manufacturer']);
    if ($edited_language != $config['default_admin_language'] && $manufacturer_id) {
        cw_unset($to_update, 'manufacturer', 'descr');
    }
    if (!$manufacturer_id) {
        $top_message['content'] = cw_get_langvar_by_name("msg_adm_err_manufacturer_add");
        $manufacturer_id = cw_array2insert('manufacturers', $to_update);
        $to_update_lng['manufacturer_id'] = $manufacturer_id;
    } else {
        if ($v['del']) {
            cw_speed_bar_delete($k);
            continue;
        }
        $v['item_id'] = $k;
        if ($v['item_id']) {
            cw_array2update('speed_bar', $v, "item_id='{$v['item_id']}'", array('active', 'orderby'));
        }
    }
    cw_header_location("index.php?target={$target}");
}
if ($action == 'update_one') {
    $rules = array('link' => '', 'title' => '');
    $update_speed_bar['item_id'] = $item_id;
    $update_speed_bar['attributes'] = $attributes;
    $fillerror = cw_error_check($update_speed_bar, $rules, 'B');
    if (!$fillerror) {
        if (!$item_id) {
            $update_speed_bar['item_id'] = $item_id = cw_array2insert('speed_bar', $update_speed_bar, 1, array('link', 'title', 'active', 'orderby'));
        }
        cw_array2update('speed_bar', $update_speed_bar, "item_id='{$item_id}'", array('link', 'title', 'active', 'orderby'));
        $update_speed_bar['code'] = $edited_language;
        cw_array2insert('speed_bar_lng', $update_speed_bar, 1, array('item_id', 'code', 'title'));
        cw_call('cw_attributes_save', array('item_id' => $item_id, 'item_type' => 'B', 'attributes' => $attributes, 'language' => $edited_language));
    } else {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        $bar_modified_data = $update_speed_bar;
    }
    cw_header_location("index.php?target={$target}&speed_id={$item_id}");
}
if (isset($speed_id)) {
<?php

cw_load('config');
$saved_user_data =& cw_session_register('saved_user_data');
$top_message =& cw_session_register('top_message');
if ($action == 'clear_meter_number') {
    cw_config_update('shipping_fedex', array('meter_number' => ''));
    cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex");
}
if ($action == 'get_meter_number') {
    $rules = array('person_name' => '', 'phone_number' => '', 'address_1' => '', 'city' => '', 'zipcode' => '', 'country' => '');
    $fillerror = cw_error_check($posted_data, $rules);
    $saved_user_data = $posted_data;
    if ($fillerror) {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex");
    }
    $meter_number = cw_fedex_get_meter_number($posted_data, $error);
    if ($meter_number) {
        $saved_user_data = '';
        cw_config_update('shipping_fedex', array('meter_number' => $meter_number));
    } else {
        $top_message = array('content' => $error['msg'], 'type' => 'E');
    }
    cw_header_location("index.php?target={$target}&mode=addons&addon=shipping_fedex");
}
$smarty->assign('prepared_user_data', $saved_user_data);
Exemplo n.º 9
0
    }
    cw_faq_log_views($id);
    $article = cw_faq_get_article($id, $current_language);
    if (!$article) {
        cw_header_location('index.php');
    }
    //    $votes = cw_faq_get_votes($id);
    //    $views = cw_faq_get_views($id);
    //    $smarty->assign('votes', $votes);
    //    $smarty->assign('views', $views);
    $smarty->assign('faq_article', $article);
    $smarty->assign('main', 'article');
} elseif ($mode == 'ask') {
    if ($action == 'save_question') {
        $rules = array('author' => '', 'email' => 'cw_faq_checkemail', 'rubrik_id' => '', 'content' => '');
        $fillerror = cw_error_check($faq, $rules);
        if (!$fillerror && cw_faq_ipcheck($_SERVER['REMOTE_ADDR'])) {
            $faq['date'] = cw_core_get_time();
            $faq['thema'] = cw_get_langvar_by_name('lbl_faq_question', array(), false, true);
            $result = cw_array2insert('faq_questions', $faq);
            $smarty->assign('faq', $faq);
            cw_call('cw_send_mail', array($faq['mail'], $config['Company']['support_department'], 'mail/faq/subj.tpl', 'mail/faq/body.tpl'));
            $top_message = array('content' => cw_get_langvar_by_name('txt_ask_a_question_send'), 'type' => 'I');
        } else {
            if (cw_faq_ipcheck($_SERVER['REMOTE_ADDR']) == false) {
                $top_message = array('content' => cw_get_langvar_by_name("txt_ask_a_question_banned"), 'type' => 'E');
            } else {
                $top_message = array('content' => cw_get_langvar_by_name("txt_ask_a_question_required"), 'type' => 'E');
            }
        }
        cw_header_location("index.php?target={$target}&mode=ask&cat_id={$cat_id}");
Exemplo n.º 10
0
        }
    }
    cw_header_location('index.php?target=' . $target);
}
if ($action == 'update_list') {
    if (is_array($posted_data)) {
        foreach ($posted_data as $page_id => $v) {
            db_query("update {$tables['pages']} set orderby='" . $v["orderby"] . "' where page_id='{$page_id}'");
        }
    }
    cw_header_location('index.php?target=' . $target);
}
if ($action == "update") {
    $rules = array('title' => '');
    $page_data['attributes'] = $attributes;
    $fillerror = cw_error_check($page_data, $rules, 'S');
    if (!$fillerror) {
        $page_data['title'] = htmlspecialchars($page_data['title']);
        if (empty($page_id)) {
            $page_id = cw_pages_create($page_data);
            $top_message["content"] = "Page added";
        } else {
            cw_pages_update($page_id, $page_data);
        }
        cw_call('cw_attributes_save', array('item_id' => $page_id, 'item_type' => 'S', 'attributes' => $attributes, 'language' => $edited_language));
    } else {
        $top_message = array('content' => $fillerror, 'type' => 'E');
    }
    cw_header_location("index.php?target={$target}&page_id={$page_id}");
}
if (isset($page_id)) {
            cw_array2update("shipping", $arr, "shipping_id = '{$id}'");
        }
    }
    if (!empty($add['shipping'])) {
        $add['weight_min'] = cw_convert_number($add['weight_min']);
        $add['weight_limit'] = cw_convert_number($add['weight_limit']);
        $id = cw_array2insert("shipping", $add);
    }
    $top_message['content'] = cw_get_langvar_by_name("msg_adm_shipping_methods_upd");
    cw_header_location("index.php?target={$target}");
}
if ($action == 'update') {
    $rules = array('shipping' => '');
    $update['shipping_id'] = $shipping_id;
    $update['attributes'] = $attributes;
    $fillerror = cw_error_check($update, $rules, 'D');
    if (!$fillerror) {
        if (!$shipping_id) {
            $update['shipping_id'] = $shipping_id = cw_array2insert('shipping', $update, 1, array('shipping', 'active', 'orderby'));
        }
        cw_array2update('shipping', $update, "shipping_id='{$shipping_id}'", array('carrier_id', 'shipping', 'shipping_time', 'destination', 'active', 'weight_min', 'weight_limit', 'insurance', 'fee_basic', 'fee_basic_limit', 'fee_ex_flat', 'fee_ex_percent'));
        cw_shipping_update_cods($shipping_id, $update['cod_type_id']);
        cw_call('cw_attributes_save', array('item_id' => $shipping_id, 'item_type' => 'D', 'attributes' => $attributes, 'language' => $edited_language));
    } else {
        $top_message = array('content' => $fillerror, 'type' => 'E');
        $shipping_modified_data = $update;
    }
    cw_header_location("index.php?target={$target}&shipping_id={$shipping_id}");
}
if ($action == 'delete' && is_array($del_shippings)) {
    foreach ($del_shippings as $shipping_id => $v) {