当前位置: 首页>>代码示例>>PHP>>正文


PHP fn_filter_uploaded_data函数代码示例

本文整理汇总了PHP中fn_filter_uploaded_data函数的典型用法代码示例。如果您正苦于以下问题:PHP fn_filter_uploaded_data函数的具体用法?PHP fn_filter_uploaded_data怎么用?PHP fn_filter_uploaded_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fn_filter_uploaded_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fn_vendor_data_premoderation_update_company_pre

function fn_vendor_data_premoderation_update_company_pre(&$company_data, &$company_id, &$lang_code)
{
    if (fn_allowed_for('MULTIVENDOR') && Registry::get('runtime.company_id')) {
        $orig_company_data = fn_get_company_data($company_id, $lang_code);
        $vendor_profile_updates_approval = Registry::get('addons.vendor_data_premoderation.vendor_profile_updates_approval');
        if ($orig_company_data['status'] == 'A' && ($vendor_profile_updates_approval == 'all' || $vendor_profile_updates_approval == 'custom' && !empty($orig_company_data['pre_moderation_edit_vendors']) && $orig_company_data['pre_moderation_edit_vendors'] == 'Y')) {
            $logotypes = fn_filter_uploaded_data('logotypes_image_icon');
            // FIXME: dirty comparison
            // check that some data is changed
            if (array_diff_assoc($company_data, $orig_company_data) || !empty($logotypes)) {
                $company_data['status'] = 'P';
            }
        }
    }
}
开发者ID:askzap,项目名称:ask-zap,代码行数:15,代码来源:func.php

示例2: fn_update_attachments

function fn_update_attachments($attachment_data, $attachment_id, $object_type, $object_id, $type = 'M', $files = null, $lang_code = DESCR_SL)
{
    $object_id = intval($object_id);
    $directory = $object_type . '/' . $object_id;
    if ($files != null) {
        $uploaded_data = $files;
    } else {
        $uploaded_data = fn_filter_uploaded_data('attachment_files');
    }
    if (!empty($attachment_id)) {
        $rec = array('usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '0' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
        db_query("UPDATE ?:attachment_descriptions SET description = ?s WHERE attachment_id = ?i AND lang_code = ?s", $attachment_data['description'], $attachment_id, $lang_code);
        db_query("UPDATE ?:attachments SET ?u WHERE attachment_id = ?i AND object_type = ?s AND object_id = ?i AND type = ?s", $rec, $attachment_id, $object_type, $object_id, $type);
        fn_set_hook('attachment_update_file', $attachment_data, $attachment_id, $object_type, $object_id, $type, $files, $lang_code, $uploaded_data);
    } elseif (!empty($uploaded_data)) {
        $rec = array('object_type' => $object_type, 'object_id' => $object_id, 'usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '0' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
        if ($type !== null) {
            $rec['type'] = $type;
        } elseif (!empty($attachment_data['type'])) {
            $rec['type'] = $attachment_data['type'];
        }
        $attachment_id = db_query("INSERT INTO ?:attachments ?e", $rec);
        if ($attachment_id) {
            // Add file description
            foreach (fn_get_translation_languages() as $lang_code => $v) {
                $rec = array('attachment_id' => $attachment_id, 'lang_code' => $lang_code, 'description' => is_array($attachment_data['description']) ? $attachment_data['description'][$lang_code] : $attachment_data['description']);
                db_query("INSERT INTO ?:attachment_descriptions ?e", $rec);
            }
            $uploaded_data[$attachment_id] = $uploaded_data[0];
            unset($uploaded_data[0]);
        }
        fn_set_hook('attachment_add_file', $attachment_data, $object_type, $object_id, $type, $files, $attachment_id, $uploaded_data);
    }
    if ($attachment_id && !empty($uploaded_data[$attachment_id]) && $uploaded_data[$attachment_id]['size']) {
        $filename = $uploaded_data[$attachment_id]['name'];
        $old_filename = db_get_field("SELECT filename FROM ?:attachments WHERE attachment_id = ?i", $attachment_id);
        if ($old_filename) {
            Storage::instance('attachments')->delete($directory . '/' . $old_filename);
        }
        list($filesize, $filename) = Storage::instance('attachments')->put($directory . '/' . $filename, array('file' => $uploaded_data[$attachment_id]['path']));
        if ($filesize) {
            $filename = fn_basename($filename);
            db_query("UPDATE ?:attachments SET filename = ?s, filesize = ?i WHERE attachment_id = ?i", $filename, $filesize, $attachment_id);
        }
    }
    return $attachment_id;
}
开发者ID:ambient-lounge,项目名称:site,代码行数:47,代码来源:func.php

示例3: fn_companies_update_logos

function fn_companies_update_logos($company_id, $old_logos)
{
    $logotypes = fn_filter_uploaded_data('logotypes');
    $areas = fn_companies_get_manifest_definition();
    // Update company logotypes
    if (!empty($logotypes)) {
        $logos = $old_logos;
        foreach ($logotypes as $type => $logo) {
            $area = $areas[$type];
            $short_name = "company/{$company_id}/{$type}_{$logo['name']}";
            $filename = DIR_IMAGES . $short_name;
            fn_mkdir(dirname($filename));
            if (fn_copy($logo['path'], $filename)) {
                list($w, $h, ) = fn_get_image_size($filename);
                $logos[$area['name']] = array('vendor' => 1, 'filename' => $short_name, 'width' => $w, 'height' => $h);
            } else {
                $text = fn_get_lang_var('text_cannot_create_file');
                $text = str_replace('[file]', $filename, $text);
                fn_set_notification('E', fn_get_lang_var('error'), $text);
            }
            @unlink($logo['path']);
        }
        $logos = serialize($logos);
        db_query("UPDATE ?:companies SET logos = ?s WHERE company_id = ?i", $logos, $company_id);
    }
    fn_save_logo_alt($areas, $company_id);
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:27,代码来源:fn.companies.php

示例4: empty

             $url = empty($url) ? fn_url('exim.export?section=' . $_REQUEST['section']) : $url;
             return array(CONTROLLER_STATUS_OK, $url);
         } else {
             $delete_range_url = fn_url("exim.delete_range?section={$pattern['section']}&pattern_id={$pattern['pattern_id']}");
             fn_set_notification('E', __('error'), __('error_exim_no_data_exported_new', array("[url]" => $delete_range_url)));
         }
     } else {
         fn_set_notification('E', __('error'), __('error_exim_fields_not_selected'));
     }
     exit;
 }
 //
 // Perform import
 //
 if ($mode == 'import') {
     $file = fn_filter_uploaded_data('csv_file');
     if (!empty($file)) {
         if (empty($_REQUEST['pattern_id'])) {
             fn_set_notification('E', __('error'), __('error_exim_pattern_not_found'));
         } else {
             $pattern = fn_get_pattern_definition($_REQUEST['pattern_id'], 'import');
             if (($data = fn_get_csv($pattern, $file[0]['path'], $_REQUEST['import_options'])) != false) {
                 fn_import($pattern, $data, $_REQUEST['import_options']);
             }
         }
     } else {
         fn_set_notification('E', __('error'), __('error_exim_no_file_uploaded'));
     }
     return array(CONTROLLER_STATUS_OK, 'exim.import?section=' . $_REQUEST['section'] . '&pattern_id=' . $_REQUEST['pattern_id']);
 }
 if ($mode == 'delete_file' && !empty($_REQUEST['filename'])) {
开发者ID:arpad9,项目名称:bygmarket,代码行数:31,代码来源:exim.php

示例5: fn_save_languages_integrity

                 }
             }
         }
         if (!$errors) {
             $lc = Languages::update($lang_data, $_REQUEST['lang_id']);
         }
         if ($lc !== false) {
             fn_save_languages_integrity();
         }
     }
     if ($lc == false) {
         fn_delete_notification('changes_saved');
     }
 }
 if ($mode == 'install_from_po') {
     $uploaded_data = fn_filter_uploaded_data('language_data', array('po', 'zip'));
     if (!empty($uploaded_data['po_file']['path'])) {
         $ext = fn_get_file_ext($uploaded_data['po_file']['name']);
         if ($ext == 'po') {
             $result = Languages::installLanguagePack($uploaded_data['po_file']['path']);
         } else {
             $result = Languages::installZipPack($uploaded_data['po_file']['path']);
         }
         if (!$result) {
             fn_delete_notification('changes_saved');
         }
     }
 }
 if ($mode == 'install' && !empty($_REQUEST['pack'])) {
     $pack_path = Registry::get('config.dir.lang_packs') . fn_basename($_REQUEST['pack']);
     if (Languages::installCrowdinPack($pack_path, array())) {
开发者ID:askzap,项目名称:ultimate,代码行数:31,代码来源:languages.php

示例6: fn_restore_dump

 // Restore
 if ($mode == 'restore') {
     if (!empty($_REQUEST['backup_files'])) {
         fn_restore_dump($_REQUEST['backup_files']);
     }
     fn_set_notification('N', __('notice'), __('done'));
 }
 if ($mode == 'm_delete') {
     if (!empty($_REQUEST['backup_files'])) {
         foreach ($_REQUEST['backup_files'] as $file) {
             @unlink(Registry::get('config.dir.database') . fn_basename($file));
         }
     }
 }
 if ($mode == 'upload') {
     $sql_dump = fn_filter_uploaded_data('sql_dump', array('sql', 'tgz'));
     if (!empty($sql_dump)) {
         $sql_dump = array_shift($sql_dump);
         if (fn_copy($sql_dump['path'], Registry::get('config.dir.database') . $sql_dump['name'])) {
             fn_set_notification('N', __('notice'), __('done'));
         } else {
             fn_set_notification('N', __('notice'), __('dump_cant_create_file'));
         }
     } else {
         fn_set_notification('N', __('notice'), __('cant_upload_file'));
     }
 }
 if ($mode == 'optimize') {
     // Log database optimization
     fn_log_event('database', 'optimize');
     $all_tables = db_get_fields("SHOW TABLES");
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:31,代码来源:database.php

示例7: fn_set_notification

         if ($restore_result === true) {
             fn_set_notification('N', __('notice'), __('done'));
         } else {
             fn_set_notification('E', __('error'), $restore_result);
         }
     }
 }
 if ($mode == 'm_delete') {
     if (!empty($_REQUEST['backup_files'])) {
         foreach ($_REQUEST['backup_files'] as $file) {
             @unlink(Registry::get('config.dir.backups') . fn_basename($file));
         }
     }
 }
 if ($mode == 'upload') {
     $dump = fn_filter_uploaded_data('dump', array('sql', 'tgz', 'zip'));
     if (!empty($dump)) {
         $dump = array_shift($dump);
         // Check if backups folder exists. If not - create it
         if (!is_dir(Registry::get('config.dir.backups'))) {
             fn_mkdir(Registry::get('config.dir.backups'));
         }
         if (fn_copy($dump['path'], Registry::get('config.dir.backups') . $dump['name'])) {
             fn_set_notification('N', __('notice'), __('done'));
         } else {
             fn_set_notification('E', __('error'), __('cant_create_backup_file'));
         }
     } else {
         fn_set_notification('E', __('error'), __('cant_upload_file'));
     }
 }
开发者ID:askzap,项目名称:ultimate,代码行数:31,代码来源:datakeeper.php

示例8: _getUploadedLogos

 private static function _getUploadedLogos()
 {
     $logos = fn_filter_uploaded_data('tw_settings');
     $logo_names = array('logo', 'favicon');
     $options = array();
     foreach ($logo_names as $logo_name) {
         if ($logos and !empty($logos[$logo_name])) {
             $logo = $logos[$logo_name];
             $filename = fn_twg_get_images_path() . $logo['name'];
             // On some hosts files copy buggy
             touch($filename);
             if (!fn_copy($logo['path'], $filename)) {
                 $_text = __('text_cannot_create_file');
                 $text = str_replace('[file]', $filename, $_text);
                 fn_set_notification('E', __('error'), $text);
             } else {
                 $options[$logo_name . '_url'] = $filename;
             }
             @unlink($logo['path']);
         }
     }
     return $options;
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:23,代码来源:TwigmoSettings.php

示例9: fn_put_contents

            fn_put_contents($file_path, $_REQUEST['file_content']);
            fn_set_notification('N', __('notice'), __('text_file_saved', array('[file]' => fn_basename($file_path))));
            Tygh::$app['ajax']->assign('saved', true);
            // Clear template cache of updated template for the customer front-end
            $view = Tygh::$app['view'];
            $view->setArea('C', '', Registry::get('runtime.company_id'));
            $updated_template_path = str_replace($view->getTemplateDir(0), '', $file_path);
            $view->clearCompiledTemplate($updated_template_path);
            $view->setArea(AREA, '', Registry::get('runtime.company_id'));
        } else {
            fn_set_notification('E', __('error'), __('cannot_write_file', array('[file]' => fn_get_rel_dir($file_path))));
        }
        exit;
    }
    if ($mode == 'upload_file') {
        $uploaded_data = fn_filter_uploaded_data('uploaded_data');
        $pname = fn_normalize_path($root_dir . $_REQUEST['path'] . '/');
        foreach ((array) $uploaded_data as $udata) {
            if (fn_te_check_path($pname)) {
                if (!fn_copy($udata['path'], $pname . $udata['name'])) {
                    fn_set_notification('E', __('error'), __('cannot_write_file', array('[file]' => fn_get_rel_dir($pname . $udata['name']))));
                }
            }
        }
        return array(CONTROLLER_STATUS_OK, "templates.manage");
    }
}
if ($mode == 'manage') {
    if (!empty($_REQUEST['selected_path'])) {
        Tygh::$app['view']->assign('selected_path', '/' . fn_te_form_path($_REQUEST['selected_path']));
    }
开发者ID:askzap,项目名称:ultimate,代码行数:31,代码来源:templates.php

示例10: fn_add_product_options_files

function fn_add_product_options_files($product_data, &$cart, &$auth, $update = false, $location = 'cart')
{
    // Check if products have cusom images
    if (!$update) {
        $uploaded_data = fn_filter_uploaded_data('product_data');
    } else {
        $uploaded_data = fn_filter_uploaded_data('cart_products');
    }
    // Check for the already uploaded files
    if (!empty($product_data['custom_files']['uploaded'])) {
        foreach ($product_data['custom_files']['uploaded'] as $file_id => $file_data) {
            if (Storage::instance('images')->isExist('sess_data/' . fn_basename($file_data['path']))) {
                $id = $file_data['product_id'] . $file_data['option_id'] . $file_id;
                $uploaded_data[$id] = array('name' => $file_data['name'], 'path' => 'sess_data/' . fn_basename($file_data['path']));
                $product_data['custom_files'][$id] = $file_data['product_id'] . '_' . $file_data['option_id'];
            }
        }
    }
    if (!empty($uploaded_data) && !empty($product_data['custom_files'])) {
        $files_data = array();
        foreach ($uploaded_data as $key => $file) {
            $file_info = fn_pathinfo($file['name']);
            $file['extension'] = empty($file_info['extension']) ? '' : $file_info['extension'];
            $file['is_image'] = fn_get_image_extension($file['type']);
            $_data = explode('_', $product_data['custom_files'][$key]);
            $product_id = empty($_data[0]) ? 0 : $_data[0];
            $option_id = empty($_data[1]) ? 0 : $_data[1];
            $file_id = str_replace($option_id . $product_id, '', $key);
            if (empty($file_id)) {
                $files_data[$product_id][$option_id][] = $file;
            } else {
                $files_data[$product_id][$option_id][$file_id] = $file;
            }
        }
    }
    unset($product_data['custom_files']);
    foreach ($product_data as $key => $data) {
        $product_id = !empty($data['product_id']) ? $data['product_id'] : $key;
        // Check if product has cusom images
        if ($update || isset($files_data[$key])) {
            $hash = $key;
        } else {
            $hash = $product_id;
        }
        $_options = fn_get_product_options($product_id);
        if (!empty($files_data[$hash]) && is_array($files_data[$hash])) {
            foreach ($files_data[$hash] as $option_id => $files) {
                foreach ($files as $file_id => $file) {
                    // Check for the allowed extensions
                    if (!empty($_options[$option_id]['allowed_extensions'])) {
                        if (empty($file['extension']) && !empty($_options[$option_id]['allowed_extensions']) || !preg_match("/\\b" . $file['extension'] . "\\b/i", $_options[$option_id]['allowed_extensions'])) {
                            fn_set_notification('E', __('error'), $file['name'] . ': ' . __('text_forbidden_uploaded_file_extension', array('[ext]' => $file['extension'], '[exts]' => $_options[$option_id]['allowed_extensions'])));
                            unset($files_data[$hash][$option_id][$file_id]);
                            continue;
                        }
                    }
                    // Check for the max file size
                    if (!empty($_options[$option_id]['max_file_size'])) {
                        if (empty($file['size'])) {
                            $file['size'] = filesize($file['path']);
                        }
                        if ($file['size'] > $_options[$option_id]['max_file_size'] * 1024) {
                            fn_set_notification('E', __('error'), $file['name'] . ': ' . __('text_forbidden_uploaded_file_size', array('[size]' => $_options[$option_id]['max_file_size'] . ' kb')));
                            unset($files_data[$hash][$option_id][$file_id]);
                            continue;
                        }
                    }
                    $_file_path = 'sess_data/file_' . uniqid(TIME);
                    list(, $_file_path) = Storage::instance('custom_files')->put($_file_path, array('file' => $file['path']));
                    if (!$_file_path) {
                        fn_set_notification('E', __('error'), __('text_cannot_create_file', array('[file]' => $file['name'])));
                        unset($files_data[$hash][$option_id][$file_id]);
                        continue;
                    }
                    $file['path'] = $_file_path;
                    $file['file'] = fn_basename($file['path']);
                    if ($file['is_image']) {
                        $file['thumbnail'] = 'image.custom_image?image=' . $file['file'] . '&type=T';
                        $file['detailed'] = 'image.custom_image?image=' . $file['file'] . '&type=D';
                    }
                    $file['location'] = $location;
                    if ($update) {
                        $cart['products'][$key]['extra']['custom_files'][$option_id][] = $file;
                    } else {
                        $data['extra']['custom_files'][$option_id][] = $file;
                    }
                }
                if ($update) {
                    if (!empty($cart['products'][$key]['product_options'][$option_id])) {
                        $cart['products'][$key]['product_options'][$option_id] = md5(serialize($cart['products'][$key]['extra']['custom_files'][$option_id]));
                    }
                } else {
                    if (!empty($data['extra']['custom_files'][$option_id])) {
                        $data['product_options'][$option_id] = md5(serialize($data['extra']['custom_files'][$option_id]));
                    }
                }
            }
            // Check the required options
            if (empty($data['extra']['parent'])) {
                foreach ($_options as $option) {
//.........这里部分代码省略.........
开发者ID:heg-arc-ne,项目名称:cscart,代码行数:101,代码来源:fn.cart.php

示例11: fn_update_attachments

function fn_update_attachments($attachment_data, $attachment_id, $object_type, $object_id, $type = 'M', $lang_code = CART_LANGUAGE)
{
    $object_id = intval($object_id);
    if (!fn_mkdir(DIR_ATTACHMENTS)) {
        return false;
    }
    $revision_id = 0;
    if (AREA == 'A' && Registry::is_exist('revisions') && !Registry::get('revisions.working')) {
        $revisions = Registry::get('revisions');
        if (!empty($revisions['objects'][$object_type]) && !empty($revisions['objects'][$object_type]['tables'])) {
            $object_data = $revisions['objects'][$object_type];
            if ($object_data['attachments']) {
                $entry = array($object_data['key'] => $object_id);
                list($revision, $revision_id) = fn_revisions_get_last($object_type, $entry, 0, 'attachments');
            }
        }
    }
    if ($revision_id) {
        $_ = 'rev_';
        $revision_condition = db_quote(" AND revision = ?s AND revision_id = ?i", $revision, $revision_id);
    } else {
        $_ = '';
        $revision_condition = '';
    }
    $directory = DIR_ATTACHMENTS . '/' . $object_type . ($revision_condition ? '_rev' : '') . '/' . $object_id;
    if (!fn_mkdir($directory)) {
        return false;
    }
    $uploaded_data = fn_filter_uploaded_data('attachment_files');
    $rec = array('usergroup_ids' => empty($attachment_data['usergroup_ids']) ? '' : implode(',', $attachment_data['usergroup_ids']), 'position' => $attachment_data['position']);
    db_query("UPDATE ?:{$_}attachment_descriptions SET description = ?s WHERE attachment_id = ?i AND lang_code = ?s ?p", $attachment_data['description'], $attachment_id, $lang_code, $revision_condition);
    db_query("UPDATE ?:{$_}attachments SET ?u WHERE attachment_id = ?i AND object_type = ?s AND object_id = ?i AND type = ?s ?p", $rec, $attachment_id, $object_type, $object_id, $type, $revision_condition);
    if ($attachment_id && !empty($uploaded_data[$attachment_id]) && $uploaded_data[$attachment_id]['size']) {
        $filename = $uploaded_data[$attachment_id]['name'];
        $old_filename = db_get_field("SELECT filename FROM ?:{$_}attachments WHERE attachment_id = ?i ?p", $attachment_id, $revision_condition);
        if (!$revision_id && $old_filename && is_file($directory . '/' . $old_filename)) {
            unlink($directory . '/' . $old_filename);
        }
        $i = 1;
        while (is_file($directory . '/' . $filename)) {
            $filename = substr_replace($uploaded_data[$attachment_id]['name'], sprintf('%03d', $i) . '.', strrpos($uploaded_data[$attachment_id]['name'], '.'), 1);
            $i++;
        }
        fn_copy($uploaded_data[$attachment_id]['path'], $directory . '/' . $filename);
        if (is_file($directory . '/' . $filename)) {
            $filesize = filesize($directory . '/' . $filename);
            db_query("UPDATE ?:{$_}attachments SET filename = ?s, filesize = ?i WHERE attachment_id = ?i ?p", $filename, $filesize, $attachment_id, $revision_condition);
        }
    }
    return true;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:51,代码来源:func.php

示例12: fn_send_form

function fn_send_form($page_id, $form_values)
{
    $result = false;
    if (!empty($form_values)) {
        $page_data = fn_get_page_data($page_id);
        if (!empty($page_data['form']['elements'])) {
            $result = true;
            $attachments = array();
            $fb_files = fn_filter_uploaded_data('fb_files');
            if (!empty($fb_files)) {
                foreach ($fb_files as $k => $v) {
                    $attachments[$v['name']] = $v['path'];
                    $form_values[$k] = $v['name'];
                }
            }
            $max_length = 0;
            $sender = '';
            foreach ($page_data['form']['elements'] as $k => $v) {
                if (($l = strlen($v['description'])) > $max_length) {
                    $max_length = $l;
                }
                // Check if sender email exists
                if ($v['element_type'] == FORM_EMAIL) {
                    $sender = $form_values[$k];
                }
                if ($v['element_type'] == FORM_DATE) {
                    $form_values[$k] = fn_parse_date($form_values[$k]);
                }
                if ($v['element_type'] == FORM_REFERER) {
                    $form_values[$k] = $_SESSION['auth']['referer'];
                }
                if ($v['element_type'] == FORM_IP_ADDRESS) {
                    $ip = fn_get_ip();
                    $form_values[$k] = $ip['host'];
                }
            }
            $max_length += 2;
            if ($result == true) {
                $from = 'default_company_support_department';
                $is_html = true;
                fn_set_hook('send_form', $page_data, $form_values, $result, $from, $sender, $attachments, $is_html);
                if ($result == true) {
                    Mailer::sendMail(array('to' => $page_data['form']['general'][FORM_RECIPIENT], 'from' => $from, 'reply_to' => $sender, 'data' => array('max_length' => $max_length, 'elements' => $page_data['form']['elements'], 'form_title' => $page_data['page'], 'form_values' => $form_values), 'attachments' => $attachments, 'tpl' => 'addons/form_builder/form.tpl', 'is_html' => $is_html), 'A');
                }
            }
        }
    }
    return $result;
}
开发者ID:askzap,项目名称:ultimate,代码行数:49,代码来源:func.php

示例13: fn_send_form

function fn_send_form($page_id, $form_values)
{
    if (!empty($form_values)) {
        $page_data = fn_get_page_data($page_id);
        if (empty($page_data['form']['elements'])) {
            return false;
        }
        $attachments = array();
        $fb_files = fn_filter_uploaded_data('fb_files');
        if (!empty($fb_files)) {
            foreach ($fb_files as $k => $v) {
                $attachments[$v['name']] = $v['path'];
                $form_values[$k] = $v['name'];
            }
        }
        $max_length = 0;
        $sender = '';
        foreach ($page_data['form']['elements'] as $k => $v) {
            if (($l = strlen($v['description'])) > $max_length) {
                $max_length = $l;
            }
            if ($v['element_type'] == FORM_EMAIL_CONFIRM) {
                if (!is_array($form_values[$k]) || $form_values[$k][0] != $form_values[$k][1] || empty($form_values[$k][0]) || $form_values[$k][1]) {
                    return false;
                }
                $form_values[$k] = $form_values[$k][0];
            }
            // Check if sender email exists
            if ($v['element_type'] == FORM_EMAIL || $v['element_type'] == FORM_EMAIL_CONFIRM) {
                $sender = $form_values[$k];
            }
            if ($v['element_type'] == FORM_DATE) {
                $form_values[$k] = fn_parse_date($form_values[$k]);
            }
            if ($v['element_type'] == FORM_REFERER) {
                $form_values[$k] = $_SESSION['auth']['referer'];
            }
            if ($v['element_type'] == FORM_IP_ADDRESS) {
                $ip = fn_get_ip();
                $form_values[$k] = $ip['host'];
            }
        }
        $max_length += 2;
        fn_set_hook('send_form', $page_data, $form_values);
        Registry::get('view_mail')->assign('max_length', $max_length);
        Registry::get('view_mail')->assign('elements', $page_data['form']['elements']);
        Registry::get('view_mail')->assign('form_title', $page_data['page']);
        Registry::get('view_mail')->assign('form_values', $form_values);
        fn_send_mail($page_data['form']['general'][FORM_RECIPIENT], Registry::get('settings.Company.company_support_department'), 'addons/form_builder/form_subject.tpl', 'addons/form_builder/form_body.tpl', $attachments, CART_LANGUAGE, $sender);
    }
    return false;
}
开发者ID:diedsmiling,项目名称:busenika,代码行数:52,代码来源:func.php

示例14: fn_stop_scroller

         }
         fn_stop_scroller();
         fn_rm(DIR_CACHE, false);
         // cleanup cache
     }
     $suffix = '?selected_section=restore';
 }
 if ($mode == 'delete') {
     if (!empty($_REQUEST['backup_files'])) {
         foreach ($_REQUEST['backup_files'] as $file) {
             @unlink(DIR_DATABASE . 'backup/' . $file);
         }
     }
 }
 if ($mode == 'upload') {
     $sql_dump = fn_filter_uploaded_data('sql_dump');
     if (!empty($sql_dump)) {
         $sql_dump = array_shift($sql_dump);
         fn_copy($sql_dump['path'], DIR_DATABASE . 'backup/' . $sql_dump['name']);
     }
 }
 if ($mode == 'optimize') {
     // Log database optimization
     fn_log_event('database', 'optimize');
     $all_tables = db_get_fields("SHOW TABLES");
     fn_start_scroller();
     foreach ($all_tables as $table) {
         fn_echo(fn_get_lang_var('optimizing_table') . "&nbsp;<b>{$table}</b>...<br />");
         db_query("OPTIMIZE TABLE {$table}");
         db_query("ANALYZE TABLE {$table}");
         $fields = db_get_hash_array("SHOW COLUMNS FROM {$table}", 'Field');
开发者ID:diedsmiling,项目名称:busenika,代码行数:31,代码来源:database.php

示例15: fn_add_product_options_files

function fn_add_product_options_files($product_data, &$cart, &$auth, $update = false, $location = 'cart')
{
    // Check if products have cusom images
    if (!$update) {
        $uploaded_data = fn_filter_uploaded_data('product_data');
    } else {
        $uploaded_data = fn_filter_uploaded_data('cart_products');
    }
    $dir_path = DIR_CUSTOM_FILES . 'sess_data';
    // Check for the already uploaded files
    if (!empty($product_data['custom_files']['uploaded'])) {
        foreach ($product_data['custom_files']['uploaded'] as $file_id => $file_data) {
            if (file_exists($dir_path . '/' . basename($file_data['path']))) {
                $id = $file_data['product_id'] . $file_data['option_id'] . $file_id;
                $uploaded_data[$id] = array('name' => $file_data['name'], 'path' => $dir_path . '/' . basename($file_data['path']));
                $product_data['custom_files'][$id] = $file_data['product_id'] . '_' . $file_data['option_id'];
            }
        }
    }
    if (!empty($uploaded_data) && !empty($product_data['custom_files'])) {
        $files_data = array();
        foreach ($uploaded_data as $key => $file) {
            $file_info = pathinfo($file['name']);
            $file['extension'] = empty($file_info['extension']) ? '' : $file_info['extension'];
            $file_info = getimagesize($file['path']);
            $file['type'] = $file_info['mime'];
            $file['is_image'] = fn_get_image_extension($file_info['mime']);
            $_data = explode('_', $product_data['custom_files'][$key]);
            $product_id = empty($_data[0]) ? 0 : $_data[0];
            $option_id = empty($_data[1]) ? 0 : $_data[1];
            $file_id = str_replace($option_id . $product_id, '', $key);
            if (empty($file_id)) {
                $files_data[$product_id][$option_id][] = $file;
            } else {
                $files_data[$product_id][$option_id][$file_id] = $file;
            }
        }
        if (!is_dir($dir_path)) {
            if (!fn_mkdir($dir_path)) {
                // Unable to create a directory
                fn_set_notification('E', fn_get_lang_var('error'), str_replace('[directory]', DIR_CUSTOM_FILES, fn_get_lang_var('text_cannot_write_directory')));
            }
        }
    }
    unset($product_data['custom_files']);
    foreach ($product_data as $key => $data) {
        $product_id = !empty($data['product_id']) ? $data['product_id'] : $key;
        // Check if product has cusom images
        if ($update || isset($files_data[$key])) {
            $hash = $key;
        } else {
            $hash = $product_id;
        }
        if (!empty($files_data[$hash]) && is_array($files_data[$hash])) {
            $_options = fn_get_product_options($product_id);
            foreach ($files_data[$hash] as $option_id => $files) {
                foreach ($files as $file_id => $file) {
                    // Check for the allowed extensions
                    if (!empty($_options[$option_id]['allowed_extensions'])) {
                        if (empty($file['extension']) && !empty($_options[$option_id]['allowed_extensions']) || !preg_match("/\\b" . $file['extension'] . "\\b/i", $_options[$option_id]['allowed_extensions'])) {
                            $message = fn_get_lang_var('text_forbidden_uploaded_file_extension');
                            $message = str_replace('[ext]', $file['extension'], $message);
                            $message = str_replace('[exts]', $_options[$option_id]['allowed_extensions'], $message);
                            fn_set_notification('E', fn_get_lang_var('error'), $file['name'] . ': ' . $message);
                            unset($files_data[$hash][$option_id][$file_id]);
                            continue;
                        }
                    }
                    // Check for the max file size
                    if (!empty($_options[$option_id]['max_file_size'])) {
                        if (empty($file['size'])) {
                            $file['size'] = filesize($file['path']);
                        }
                        if ($file['size'] > $_options[$option_id]['max_file_size'] * 1024) {
                            fn_set_notification('E', fn_get_lang_var('error'), str_replace('[size]', $_options[$option_id]['max_file_size'] . ' kb', $file['name'] . ': ' . fn_get_lang_var('text_forbidden_uploaded_file_size')));
                            unset($files_data[$hash][$option_id][$file_id]);
                            continue;
                        }
                    }
                    $_file_path = tempnam($dir_path, 'file_');
                    if (!fn_copy($file['path'], $_file_path)) {
                        fn_set_notification('E', fn_get_lang_var('error'), str_replace('[file]', $file['name'], fn_get_lang_var('text_cannot_create_file')));
                        unset($files_data[$hash][$option_id][$file_id]);
                        continue;
                    }
                    $file['path'] = $_file_path;
                    $file['file'] = basename($file['path']);
                    if ($file['is_image']) {
                        $file['thumbnail'] = 'image.custom_image&image=' . $file['file'] . '&type=T';
                        $file['detailed'] = 'image.custom_image&image=' . $file['file'] . '&type=D';
                    }
                    $file['location'] = $location;
                    if ($update) {
                        $cart['products'][$key]['extra']['custom_files'][$option_id][] = $file;
                    } else {
                        $data['extra']['custom_files'][$option_id][] = $file;
                    }
                }
                if ($update) {
                    if (!empty($cart['products'][$key]['product_options'][$option_id])) {
//.........这里部分代码省略.........
开发者ID:diedsmiling,项目名称:busenika,代码行数:101,代码来源:fn.cart.php


注:本文中的fn_filter_uploaded_data函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。