1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
regnow.php
См. документацию.
1<?
2if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
3
4$STAT_RIGHT = $APPLICATION->GetGroupRight("statistic");
5if($STAT_RIGHT=="D") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
6
7/***************************************************************************
8Convertation of the standard RegNow CSV file to the
9CSV file format of the Statistics module.
10***************************************************************************/
11
12/*
13 Input parameters:
14 INPUT_CSV_FILE - path to the source file
15 OUTPUT_CSV_FILE - path to the target file
16*/
17
18$SEPARATOR = ","; // CSV separator
19
20function CleanUpCsv(&$item)
21{
22 $item = trim($item, "\"");
23}
24
25function PrepareQuotes(&$item)
26{
27 $item = "\"".str_replace("\"","\"\"", $item)."\"";
28}
29
30if ($fp_in = fopen($INPUT_CSV_FILE,"rb"))
31{
32 $upload_dir = $_SERVER["DOCUMENT_ROOT"]."/".COption::GetOptionString("main","upload_dir","/upload/"). "/statistic";
33 if (mb_substr($OUTPUT_CSV_FILE, 0, mb_strlen($upload_dir)) == $upload_dir && $fp_out = fopen($OUTPUT_CSV_FILE,"wb"))
34 {
35 $i = 0; // counter of the read valuable lines
36 $j = 0; // counter of the written to the resulting file lines
37 $lang_date_format = FORMAT_DATE; // date format for the current language
38 $event1 = "regnow";
39 $event2 = "buy";
40 $EVENT_ID = CStatEventType::ConditionSet($event1, $event2, $arEventType)." (".$event1." / ".$event2.")";
41 $SITE_ID = GetEventSiteID(); // short site identifier (ID)
42 while (!feof($fp_in))
43 {
44 $arrCSV = fgetcsv($fp_in, 4096, $SEPARATOR);
45 if (is_array($arrCSV) && count($arrCSV)>1)
46 {
47 array_walk($arrCSV, "CleanUpCsv");
48 reset($arrCSV);
49 $i++;
50 // if it is the first line then
51 if ($i==1)
52 {
53 // get an array with the field numbers
54 $arrS = array_flip($arrCSV);
55 }
56 elseif (is_array($arrS) && count($arrS)>0) // else form the CSV line in module format and write it to the resulting file
57 {
58 $arrRes = array();
59
60 // ID of an event type;
61 $arrRes[] = $EVENT_ID;
62
63 // event3
64 $arrRes[] = $arrCSV[$arrS["orderid"]]." / ".$arrCSV[$arrS["item"]];
65
66 // date
67 $arrRes[] = $DB->FormatDate(trim($arrCSV[$arrS["date"]]), "MM/DD/YYYY", $lang_date_format);
68
69 // additional parameter
70 $ADDITIONAL_PARAMETER = $arrCSV[$arrS["custom_linkid"]];
71 $arrRes[] = $ADDITIONAL_PARAMETER;
72
73 // money sum
74 $arrRes[] = $arrCSV[$arrS["total"]];
75
76 // currency
77 $arrRes[] = $arrCSV[$arrS["currency"]];
78
79 // if short site identifier exists in Additional parameter then
80 if (mb_strpos($ADDITIONAL_PARAMETER, $SITE_ID) !== false)
81 {
82 // write the line to the resulting file
83 $j++;
84 array_walk($arrRes, "PrepareQuotes");
85 $str = implode(",",$arrRes);
86 if ($j>1) $str = "\n".$str;
87 fputs($fp_out, $str);
88 }
89 }
90 }
91 }
92 @fclose($fp_out);
93 }
94 @fclose($fp_in);
95}
96
97/*
98
99Column headers:
100
101"orderid","date","status","referrer","custom_linkid","ip","currency","received_via","payment_method","payment_delivery_method","asp","product_choice","hear","cdrom","heardabout","ordertype","item","total","item_status","quantity","orderitem_profit","regname","regcode","reginfo","delivered","affiliate_fees","offer_id","affiliateid","user","accept_offers","languageid","fname","lname","company","add1","add2","city","state","zip","country","phone","email","ship_fname","ship_lname","ship_company","ship_add1","ship_add2","ship_city","ship_state","ship_zip","ship_country","ship_phone"
102
103*/
104?>
global $APPLICATION
Определения include.php:80
static GetOptionString($module_id, $name, $def="", $site=false, $bExactSite=false)
Определения option.php:8
static ConditionSet($event1, $event2, &$arEventType)
Определения stateventtype.php:106
$str
Определения commerceml2.php:63
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
const FORMAT_DATE
Определения include.php:63
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$SEPARATOR
Определения plimus.php:18
$STAT_RIGHT
Определения plimus.php:4
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
die
Определения quickway.php:367
PrepareQuotes(&$item)
Определения regnow.php:25
CleanUpCsv(&$item)
Определения regnow.php:20
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
GetEventSiteID()
Определения stat_tools.php:544
$SITE_ID
Определения yandex_run.php:607