當前位置: 首頁>>代碼示例>>PHP>>正文


PHP str_putcsv函數代碼示例

本文整理匯總了PHP中str_putcsv函數的典型用法代碼示例。如果您正苦於以下問題:PHP str_putcsv函數的具體用法?PHP str_putcsv怎麽用?PHP str_putcsv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了str_putcsv函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array2csv

function array2csv($array)
{
    $rowStrs = array();
    foreach ($array as $row) {
        $rowStrs[] = str_putcsv($row);
    }
    return implode("\n", $rowStrs);
}
開發者ID:joequery,項目名稱:PHPIntro,代碼行數:8,代碼來源:csv.php

示例2: employersAction

 /**
   Kompletny Przykład użycia:
 
 
 @-Route("/employer/{id}", name="surveys.employer")
 
     public function employersAction (Request $request, $id) {
 
    $man = $this->get(CityManager::SERVICE);
 
    $city = $man->findOrThrow($id);
 
    $data = '';
 
    $dbal = AbstractApp::getDbal();
 
    $stmt = $dbal->prepare("
 SELECT              e.id eid, e.name, es.*
 FROM                employer_survey es
     INNER JOIN employers e
             ON e.id = es.employer_id
 WHERE               es.city_id = :id
 ");
    $stmt->bindValue('id', $city->getId());
 
    $stmt->execute();
 
    $first = true;
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        if ($first) {
            $first = false;
            $data .= UtilCsv::putCsv(array_keys($row))."\n";
        }
        $data .= UtilCsv::putCsv($row)."\n";
    }
 
    return DownloadFile::downloadGenerated($data, 'employer_survey-'.$city->getSlug().'.csv');
     }
 */
 public static function putCsv($input, $delimiter = ',', $enclosure = '"')
 {
     if (static::$isbuildin === null) {
         static::$isbuildin = function_exists('str_putcsv');
     }
     if (static::$isbuildin) {
         return str_putcsv($input, $delimiter, $enclosure);
     }
     return static::_str_putcsv($input, $delimiter, $enclosure);
 }
開發者ID:stopsopa,項目名稱:utils,代碼行數:49,代碼來源:UtilCsv.php

示例3: prepareBatchFile

 public function prepareBatchFile()
 {
     if ($this->batchZip && is_writable($this->batchZip)) {
         $zip = new ZipArchive();
         if ($zip->open($this->batchZip, \ZIPARCHIVE::CREATE) === true) {
             if ($this->format == 'csv') {
                 $request_array = $this->createCsvArray($this->toArray());
                 $request_string = str_putcsv($request_array);
             } else {
                 $request_string = json_encode($this->toArray());
             }
             $zip->addFromString('request.txt', $request_string);
             $zip->close();
         } else {
             throw new \Exception('Batch zip cannot be opened');
         }
     } else {
         throw new \Exception('Batch zip must be defined to use binary batches');
     }
 }
開發者ID:frankkessler,項目名稱:salesforce-laravel-oauth2-rest,代碼行數:20,代碼來源:BinaryBatch.php

示例4: export


//.........這裏部分代碼省略.........
     }
     $plugin_settings = nf_get_settings();
     $date_format = $plugin_settings['date_format'];
     $label_array = array();
     // Get our Form ID.
     $form_id = Ninja_Forms()->sub($sub_ids[0])->form_id;
     // Get our list of fields.
     $fields = Ninja_Forms()->form($form_id)->fields;
     // Add our sequential number.
     $label_array[0]['_seq_num'] = __('#', 'ninja-forms');
     // Add our "Date" label.
     $label_array[0]['_date_submitted'] = __('Date Submitted', 'ninja-forms');
     $label_array = apply_filters('nf_subs_csv_label_array_before_fields', $label_array, $sub_ids);
     foreach ($fields as $field_id => $field) {
         // Get our field type
         $field_type = $field['type'];
         // Check to see if our field type has been set as a "process_field".
         if (isset($ninja_forms_fields[$field_type])) {
             $reg_field = $ninja_forms_fields[$field_type];
             $process_field = $reg_field['process_field'];
         } else {
             $process_field = false;
         }
         // If this field's "process_field" is set to true, then add its label to the array.
         if ($process_field) {
             if (isset($field['data']['admin_label']) && $field['data']['admin_label'] != '') {
                 $label = $field['data']['admin_label'];
             } else {
                 if (isset($field['data']['label'])) {
                     $label = $field['data']['label'];
                 } else {
                     $label = '';
                 }
             }
             $label_array[0][$field_id] = apply_filters('nf_subs_csv_field_label', $label, $field_id);
         }
     }
     $label_array = ninja_forms_stripslashes_deep($label_array);
     $label_array = apply_filters('nf_subs_csv_label_array', $label_array, $sub_ids);
     $value_array = array();
     $x = 0;
     // Loop through our submissions and create a new row for each one.
     foreach ($sub_ids as $sub_id) {
         foreach ($label_array[0] as $field_id => $label) {
             // Make sure we aren't working with our date field, which will always have a field id of 0.
             if ($field_id !== 0) {
                 // Check to see if our field_id is numeric. If it isn't, then we're working with meta, not a field.
                 if (is_numeric($field_id)) {
                     // We're working with a field, grab the value.
                     $user_value = Ninja_Forms()->sub($sub_id)->get_field($field_id);
                 } else {
                     if ('_date_submitted' == $field_id) {
                         // Get the date of our submission.
                         $date = strtotime(Ninja_Forms()->sub($sub_id)->date_submitted);
                         // The first item is our date field.
                         $user_value = date($date_format, $date);
                     } else {
                         if ('_seq_num' == $field_id) {
                             $user_value = Ninja_Forms()->sub($sub_id)->get_seq_num();
                         } else {
                             // We're working with a piece of meta, grabe the value.
                             $user_value = Ninja_Forms()->sub($sub_id)->get_meta($field_id);
                         }
                     }
                 }
                 // Run our value through the appropriate filters before we flatten any arrays.
                 $user_value = apply_filters('nf_subs_export_pre_value', $user_value, $field_id);
                 // Implode any arrays we might have.
                 if (is_array($user_value)) {
                     $user_value = implode(',', $user_value);
                 }
                 // Add an ' to the beginning = sign to prevent any CSV/Excel security issues.
                 if (strpos($user_value, '=') === 0) {
                     $user_value = "'" . $user_value;
                 }
                 // Run our final value through the appropriate filters and assign it to the array.
                 $value_array[$x][$field_id] = htmlspecialchars_decode(apply_filters('nf_subs_csv_field_value', $user_value, $field_id), ENT_QUOTES);
             }
         }
         $x++;
     }
     $value_array = ninja_forms_stripslashes_deep($value_array);
     $value_array = apply_filters('nf_subs_csv_value_array', $value_array, $sub_ids);
     $array = array($label_array, $value_array);
     $today = date($date_format, current_time('timestamp'));
     $filename = apply_filters('nf_subs_csv_filename', 'nf_subs_' . $today);
     $filename = $filename . ".csv";
     if ($return) {
         return str_putcsv($array, apply_filters('nf_sub_csv_delimiter', ','), apply_filters('nf_sub_csv_enclosure', '"'), apply_filters('nf_sub_csv_terminator', "\n"));
     } else {
         header('Content-type: application/csv');
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         header('Pragma: no-cache');
         header('Expires: 0');
         echo apply_filters('nf_sub_csv_bom', "");
         // Byte Order Mark
         echo str_putcsv($array, apply_filters('nf_sub_csv_delimiter', ','), apply_filters('nf_sub_csv_enclosure', '"'), apply_filters('nf_sub_csv_terminator', "\n"));
         die;
     }
 }
開發者ID:RA2WP,項目名稱:RA2WP,代碼行數:101,代碼來源:subs.php

示例5: onCCK_Storage_LocationExport

 public static function onCCK_Storage_LocationExport($items, &$config = array())
 {
     // Init
     $excluded2 = array('cck' => '');
     $tables = array();
     $user = JFactory::getUser();
     // Prepare
     $table = self::_getTable();
     $fields = $table->getProperties();
     if (isset($config['fields']) && $config['fields'] === false) {
         $fields = array();
     } elseif (isset($config['fields']) && count($config['fields'])) {
         $fields = $config['fields'];
     } else {
         if (count(self::$columns_ignored)) {
             foreach (self::$columns_ignored as $exclude) {
                 unset($fields[$exclude]);
             }
         }
     }
     if (count($config['fields2'])) {
         foreach ($config['fields2'] as $k => $field) {
             if (!isset($storages[$field->storage_table])) {
                 $tables[$field->storage_table] = JCckDatabase::loadObjectList('SELECT * FROM ' . $field->storage_table, 'id');
             }
             if ($config['component'] == 'com_cck_exporter') {
                 $key = $field->name;
             } else {
                 $key = $field->label2 ? $field->label2 : ($field->label ? $field->label : $field->name);
             }
             $fields[$key] = '';
         }
     }
     $fields = array_keys($fields);
     if ($config['ftp'] == '1') {
         $config['buffer'] .= str_putcsv($fields, $config['separator']) . "\n";
     } else {
         fputcsv($config['handle'], $fields, $config['separator']);
     }
     // Set
     if (count($items)) {
         foreach ($items as $item) {
             // Check Permissions?
             if ($config['authorise'] == 0) {
                 continue;
             } elseif ($config['authorise'] == 2) {
                 if (!isset($config['types'][$item->cck])) {
                     $config['types'][$item->cck] = JCckDatabase::loadResult('SELECT id FROM #__cck_core_types WHERE name = "' . $item->cck . '"');
                 }
                 if (!$user->authorise('core.export', 'com_cck.form.' . $config['types'][$item->cck])) {
                     continue;
                 }
             }
             // Core
             $table = self::_getTable($item->pk);
             if (isset($config['fields']) && $config['fields'] === false) {
                 $fields = array();
             } elseif (isset($config['fields']) && count($config['fields'])) {
                 $fields = array();
                 $vars = get_object_vars($table);
                 foreach ($vars as $key => $val) {
                     if (isset($config['fields'][$key])) {
                         $fields[$key] = $val;
                     }
                 }
             } else {
                 $fields = $table->getProperties();
                 if (count(self::$columns_ignored)) {
                     foreach (self::$columns_ignored as $exclude) {
                         unset($fields[$exclude]);
                     }
                 }
             }
             // Core > Custom
             if (self::$custom && isset($fields[self::$custom])) {
                 preg_match_all(CCK_Content::getRegex(), $fields[self::$custom], $values);
                 $tables[self::$table][$item->pk]->{self::$custom} = array();
                 $fields[self::$custom] = '';
                 if (count($values[1])) {
                     foreach ($values[1] as $k => $v) {
                         if ($v == self::$custom) {
                             $fields[self::$custom] = $values[2][$k];
                         } elseif (!isset($excluded2[$v])) {
                             $tables[self::$table][$item->pk]->{self::$custom}[$v] = $values[2][$k];
                         }
                     }
                 }
             }
             // More
             if (count($config['fields2'])) {
                 foreach ($config['fields2'] as $name => $field) {
                     if ($field->storage == 'standard') {
                         if ($config['component'] == 'com_cck_exporter') {
                             $key = $field->name;
                         } else {
                             $key = $field->label2 ? $field->label2 : ($field->label ? $field->label : $field->name);
                         }
                         $fields[$key] = @$tables[$field->storage_table][$item->pk]->{$field->storage_field};
                     } else {
                         $name = $field->storage_field2 ? $field->storage_field2 : $name;
//.........這裏部分代碼省略.........
開發者ID:olafzieger,項目名稱:joomla3.x-seblod-test,代碼行數:101,代碼來源:exporter.php

示例6: str_putcsv

function str_putcsv($array, $delimiter = ',', $enclosure = '"', $terminator = "\n")
{
    // First convert associative array to numeric indexed array
    $workArray = array();
    foreach ($array as $key => $value) {
        $workArray[] = $value;
    }
    $returnString = '';
    # Initialize return string
    $arraySize = count($workArray);
    # Get size of array
    for ($i = 0; $i < $arraySize; $i++) {
        // Nested array, process nest item
        if (is_array($workArray[$i])) {
            $returnString .= str_putcsv($workArray[$i], $delimiter, $enclosure, $terminator);
        } else {
            switch (gettype($workArray[$i])) {
                // Manually set some strings
                case "NULL":
                    $_spFormat = '';
                    break;
                case "boolean":
                    $_spFormat = $workArray[$i] == true ? 'true' : 'false';
                    break;
                    // Make sure sprintf has a good datatype to work with
                // Make sure sprintf has a good datatype to work with
                case "integer":
                    $_spFormat = '%i';
                    break;
                case "double":
                    $_spFormat = '%0.2f';
                    break;
                case "string":
                    $_spFormat = '%s';
                    $workArray[$i] = str_replace("{$enclosure}", "{$enclosure}{$enclosure}", $workArray[$i]);
                    break;
                    // Unknown or invalid items for a csv - note: the datatype of array is already handled above, assuming the data is nested
                // Unknown or invalid items for a csv - note: the datatype of array is already handled above, assuming the data is nested
                case "object":
                case "resource":
                default:
                    $_spFormat = '';
                    break;
            }
            $returnString .= sprintf('%2$s' . $_spFormat . '%2$s', $workArray[$i], $enclosure);
            $returnString .= $i < $arraySize - 1 ? $delimiter : $terminator;
        }
    }
    // Done the workload, return the output information
    return $returnString;
}
開發者ID:baronwatts,項目名稱:folio,代碼行數:51,代碼來源:admin.php

示例7: ninja_forms_export_subs_to_csv

function ninja_forms_export_subs_to_csv($sub_ids = '', $return = false)
{
    global $ninja_forms_fields, $ninja_forms_processing;
    $plugin_settings = get_option("ninja_forms_settings");
    if (isset($plugin_settings['date_format'])) {
        $date_format = $plugin_settings['date_format'];
    } else {
        $date_format = 'm/d/Y';
    }
    //Create a $label_array that contains all of the field labels.
    //Get the Form ID.
    if (isset($ninja_forms_processing)) {
        $form_id = $ninja_forms_processing->get_form_ID();
    } else {
        if (isset($_REQUEST['form_id'])) {
            $form_id = absint($_REQUEST['form_id']);
        }
    }
    //Get the fields attached to the Form ID
    $field_results = ninja_forms_get_fields_by_form_id($form_id);
    //Set the label array to a blank
    $label_array = array();
    $value_array = array();
    $sub_id_array = array();
    $label_array[0][] = "Date";
    if (is_array($field_results) and !empty($field_results)) {
        foreach ($field_results as $field) {
            $field_type = $field['type'];
            $field_id = $field['id'];
            if (isset($ninja_forms_fields[$field_type]['process_field'])) {
                $process_field = $ninja_forms_fields[$field_type]['process_field'];
            } else {
                $process_field = true;
            }
            if (isset($field['data']['label'])) {
                $label = $field['data']['label'];
            } else {
                $label = '';
            }
            if ($process_field) {
                $label_array[0][$field_id] = apply_filters('ninja_forms_export_sub_label', $label, $field_id);
            }
        }
    }
    if (is_array($sub_ids) and !empty($sub_ids)) {
        $x = 0;
        foreach ($sub_ids as $id) {
            $sub_row = ninja_forms_get_sub_by_id($id);
            $sub_id_array[$x] = $id;
            $date_updated = date($date_format, strtotime($sub_row['date_updated']));
            $value_array[$x][] = $date_updated;
            if (is_array($sub_row['data']) and !empty($sub_row['data'])) {
                foreach ($label_array[0] as $field_id => $label) {
                    if ($field_id != 0) {
                        $found = false;
                        foreach ($sub_row['data'] as $data) {
                            $data['user_value'] = ninja_forms_stripslashes_deep($data['user_value']);
                            $data['user_value'] = ninja_forms_html_entity_decode_deep($data['user_value'], ENT_QUOTES);
                            if ($data['field_id'] == $field_id) {
                                if (is_array($data['user_value'])) {
                                    $user_value = implode_r(',', $data['user_value']);
                                } else {
                                    $user_value = $data['user_value'];
                                }
                                $found = true;
                            }
                        }
                        if (!$found) {
                            $user_value = '';
                        }
                        $value_array[$x][] = apply_filters('ninja_forms_export_sub_value', $user_value, $field_id);
                    }
                }
            }
            $x++;
        }
    }
    $value_array = ninja_forms_stripslashes_deep($value_array);
    $value_array = apply_filters('ninja_forms_export_subs_value_array', $value_array, $sub_id_array);
    $label_array = ninja_forms_stripslashes_deep($label_array);
    $label_array = apply_filters('ninja_forms_export_subs_label_array', $label_array, $sub_id_array);
    $array = array($label_array, $value_array);
    $today = date($date_format);
    $filename = apply_filters('ninja_forms_export_subs_csv_file_name', 'ninja_forms_subs_' . $today);
    $filename = $filename . ".csv";
    if ($return) {
        return str_putcsv($array, apply_filters('ninja_forms_csv_delimiter', ','), apply_filters('ninja_forms_csv_enclosure', '"'), apply_filters('ninja_forms_csv_terminator', "\n"));
    } else {
        header("Content-type: application/csv");
        header("Content-Disposition: attachment; filename=" . $filename);
        header("Pragma: no-cache");
        header("Expires: 0");
        echo apply_filters('ninja_forms_csv_bom', "");
        // Byte Order Mark
        echo str_putcsv($array, apply_filters('ninja_forms_csv_delimiter', ','), apply_filters('ninja_forms_csv_enclosure', '"'), apply_filters('ninja_forms_csv_terminator', "\n"));
        die;
    }
}
開發者ID:hoonio,項目名稱:PhoneAfrika,代碼行數:98,代碼來源:export-subs.php

示例8: ini_set

ini_set("auto_detect_line_endings", true);
$FN_FILE = './data/CSV_Database_of_First_Names.csv';
$LN_FILE = './data/CSV_Database_of_Last_Names.csv';
$NUM_RECORDS = checkSet('recordcount', 100, false);
$FN_Array = csvToArray($FN_FILE);
$FN_Array_Sz = count($FN_Array);
$LN_Array = csvToArray($LN_FILE);
$LN_Array_Sz = count($LN_Array);
$output = array();
//CSV Header
$output[] = array('Mother', 'DOB', 'Father', 'DOB', 'Son', 'DOB', 'Daughter', 'DOB');
for ($i = 0; $i < $NUM_RECORDS; $i++) {
    $surName = rand(1, $LN_Array_Sz - 1);
    $output[] = array($FN_Array[rand(1, $FN_Array_Sz - 1)][0] . ' ' . $LN_Array[rand(1, $LN_Array_Sz - 1)][0], date("m/d/Y"), $FN_Array[rand(1, $FN_Array_Sz - 1)][0] . ' ' . $LN_Array[$surName][0], date("m/d/Y"), $FN_Array[rand(1, $FN_Array_Sz - 1)][0] . ' ' . $LN_Array[$surName][0], date("m/d/Y"), $FN_Array[rand(1, $FN_Array_Sz - 1)][0] . ' ' . $LN_Array[$surName][0], date("m/d/Y"));
}
str_putcsv($output);
echo implode(PHP_EOL, $output);
function str_putcsv(&$array)
{
    $arraySz = count($array);
    for ($i = 0; $i < $arraySz; $i++) {
        $array[$i] = implode(',', $array[$i]);
    }
    return $array;
}
function csvToArray($fileName)
{
    $array = array();
    if (($handle = fopen($fileName, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
            $array[] = $data;
開發者ID:scirelli,項目名稱:jquerycsv,代碼行數:31,代碼來源:relationships.csv.php

示例9: str_putcsv

<?php

/* From: http://www.php.net/manual/en/function.str-getcsv.php#88773 and http://www.php.net/manual/en/function.str-getcsv.php#91170 */
/*
 * @see https://gist.github.com/2894568
 */
if (!function_exists('str_putcsv')) {
    function str_putcsv($input, $delimiter = ',', $enclosure = '"')
    {
        // Open a memory "file" for read/write...
        $fp = fopen('php://temp', 'r+');
        // ... write the $input array to the "file" using fputcsv()...
        fputcsv($fp, $input, $delimiter, $enclosure);
        // ... rewind the "file" so we can read what we just wrote...
        rewind($fp);
        // ... read the entire line into a variable...
        $data = fread($fp, 1048576);
        // ... close the "file"...
        fclose($fp);
        // ... and return the $data to the caller, with the trailing newline from fgets() removed.
        return rtrim($data, "\n");
    }
}
echo str_putcsv(['"a', '\\"b', 'b好,cd']);
開發者ID:dxy-php,項目名稱:csv,代碼行數:24,代碼來源:str_putcsv.php

示例10: file

 function file($datafeed, $separator, $filename)
 {
     $this->load->helper('download');
     $output = "";
     $row = array('SKU', 'Barcode', 'Manufacturer Part Number', 'Manufacturer Name', 'Brand', 'Title', 'Description', 'Category ID', 'Category Name', 'Weight', 'Ship Alone', 'Height', 'Width', 'Depth', 'Lead Time', 'Quantity In Stock', 'Selling Price', 'MSRP', 'Promo text', 'MAP', 'Shipping cost', 'Image 1', 'Image 2', 'Image 3', 'Image 4', 'Image 5', 'Image 6', 'Case Pack', 'Min Order');
     $output = $output . str_putcsv($row, $separator);
     foreach ($datafeed as $feed) {
         $feed->ic_retail_price = trim($feed->ic_retail_price) == '' || $feed->ic_retail_price == 0 ? $feed->ic_price * 3 : $feed->ic_retail_price;
         $row = array($feed->SKU, $feed->upc_ean, $feed->manuf_num, $feed->m_name, $feed->b_name, $feed->tr_title, str_replace(array("\n", "\r\n", "\t"), " ", strip_tags($feed->tr_desc)), $feed->c_id, $this->getFullCategoryName($feed->c_id), $feed->weight + " " + $feed->weightScale, $feed->ship_alone, $feed->d_height + " " + $feed->d_scale, $feed->d_width + " " + $feed->d_scale, $feed->d_dept + " " + $feed->d_scale, $feed->ic_leadtime, $feed->ic_quan, $feed->ic_price, $feed->ic_retail_price, str_replace(array("\n", "\r\n", "\t"), " ", $feed->ic_prom_text), $feed->ic_map, $feed->ic_ship_cost);
         $this->load->model('inventories');
         $image_list = $this->inventories->list_image($feed->i_id);
         $images = array('', '', '', '', '', '');
         for ($i = 0; $i < count($image_list); $i++) {
             if ($i >= count($images)) {
                 break;
             }
             $images[$i] = "http://shop.oceantailer.com/" . $image_list[$i]->ii_link;
         }
         $row = array_merge($row, $images, array($feed->ic_case_pack, $feed->ic_min_order));
         $output = $output . "\r\n" . str_putcsv($row, $separator);
     }
     $handle = fopen($filename, 'w');
     fwrite($handle, $output);
     fclose($handle);
     return;
 }
開發者ID:rnlduadia,項目名稱:LAMP-eCommerce-CodeIgniter,代碼行數:26,代碼來源:buyers_cron.php

示例11: ksort

            }
            ksort($ar_csv[$id_item]);
            if ($cnt > 1) {
                $str .= CRLF;
            }
            $str .= str_putcsv($ar_csv[$id_item], $ar['separator']);
            /* Second definitions */
            if (isset($ar_dpl[$id_item])) {
                /* */
                foreach ($ar_order_csv as $id_field => $cnt_order) {
                    if (!isset($ar_dpl[$id_item][$cnt_order])) {
                        $ar_dpl[$id_item][$cnt_order] = isset($ar_csv[$id_item][$cnt_order]) ? $ar_csv[$id_item][$cnt_order] : '';
                    }
                }
                ksort($ar_dpl[$id_item]);
                $str .= CRLF . str_putcsv($ar_dpl[$id_item], $ar['separator']);
            }
            break;
    }
    ++$cnt;
}
/* */
switch ($ar['format']) {
    case 1:
        /** Glossword XML **/
        $filename = 'gw_items_' . @date("Y-m[M]-d", $this->o->V->time_gmt) . '.xml';
        $str .= CRLF . '</glossword>';
        break;
    case 2:
        /** CSV/TSV **/
        $filename = 'gw_items_' . @date("Y-m[M]-d", $this->o->V->time_gmt) . '.csv';
開發者ID:Epistemoloji,項目名稱:glossword,代碼行數:31,代碼來源:items__export__onsubmit.php

示例12: ft_log_action

/**
 * Implementation of hook_action.
 */
function ft_log_action($act)
{
    global $ft;
    // Prune old records.
    if ($act == 'log_prune' && isset($ft['plugins']['log']['settings']['viewlogs']) && $ft['plugins']['log']['settings']['viewlogs'] === TRUE) {
        $offset = date('Y-m-d', strtotime('-7 months', gmmktime()));
        $sql = "DELETE FROM log WHERE timestamp <= '" . $ft['db']['link']->quote($offset) . "'";
        $result = $ft['db']['link']->query($sql);
        ft_set_message(t('Log pruned'));
        // Redirect.
        ft_redirect("act=log");
    }
    // View CSV log.
    if ($act == 'log_csv' && isset($ft['plugins']['log']['settings']['viewlogs']) && $ft['plugins']['log']['settings']['viewlogs'] === TRUE) {
        header('Content-type: text/plain;charset=UTF-8');
        $headers = array(t('Type'), t('Message'), t('Location'), t('Timestamp'), t('User'));
        $items = ft_log_do_query($_GET['type'], $_GET['from_day'], $_GET['from'], $_GET['to_day'], $_GET['to']);
        print str_putcsv($headers, ';') . "\n";
        foreach ($items as $row) {
            print str_putcsv($row, ';') . "\n";
        }
        exit;
    }
}
開發者ID:elmanet,項目名稱:Intersoft_Realty,代碼行數:27,代碼來源:log.plugin.php

示例13: file

 function file($datafeed, $separator, $filename, $user_id = '')
 {
     $temp_file = base_dir() . 'buyers_files' . DIRECTORY_SEPARATOR . $user_id . $filename;
     if (!file_exists($temp_file)) {
         $this->load->helper('download');
         $output = "";
         $row = array('SKU', 'Barcode', 'Manufacturer Part Number', 'Manufacturer Name', 'Brand', 'Title', 'Description', 'Category ID', 'Category Name', 'Weight', 'Ship Alone', 'Height', 'Width', 'Depth', 'Lead Time', 'Quantity In Stock', 'Selling Price', 'MSRP', 'Promo text', 'MAP', 'Shipping cost', 'Image 1', 'Image 2', 'Image 3', 'Image 4', 'Image 5', 'Image 6', 'Case Pack', 'Min Order');
         $output = $output . str_putcsv($row, $separator);
         foreach ($datafeed as $feed) {
             $feed->ic_retail_price = trim($feed->ic_retail_price) == '' || $feed->ic_retail_price == 0 ? $feed->ic_price * 3 : $feed->ic_retail_price;
             $row = array($feed->SKU, $feed->upc_ean, $feed->manuf_num, $feed->m_name, $feed->b_name, $feed->tr_title, str_replace(array("\n", "\r\n", "\t"), " ", strip_tags($feed->tr_desc)), $feed->c_id, $this->getFullCategoryName($feed->c_id), $feed->weight + " " + $feed->weightScale, $feed->ship_alone, $feed->d_height + " " + $feed->d_scale, $feed->d_width + " " + $feed->d_scale, $feed->d_dept + " " + $feed->d_scale, $feed->ic_leadtime, $feed->ic_quan, $feed->ic_price, $feed->ic_retail_price, str_replace(array("\n", "\r\n", "\t"), " ", $feed->ic_prom_text), $feed->ic_map, $feed->ic_ship_cost);
             $this->load->model('inventories');
             $image_list = $this->inventories->list_image($feed->i_id);
             $images = array('', '', '', '', '', '');
             for ($i = 0; $i < count($image_list); $i++) {
                 if ($i >= count($images)) {
                     break;
                 }
                 $images[$i] = base_url() . $image_list[$i]->ii_link;
             }
             $row = array_merge($row, $images, array($feed->ic_case_pack, $feed->ic_min_order));
             $output = $output . "\r\n" . str_putcsv($row, $separator);
         }
         force_download($filename, $output);
     } else {
         set_time_limit(0);
         ini_set('memory_limit', '512M');
         my_force_download($temp_file);
     }
 }
開發者ID:rnlduadia,項目名稱:LAMP-eCommerce-CodeIgniter,代碼行數:30,代碼來源:datafeed.php


注:本文中的str_putcsv函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。