/** * @desc 获取ebay所有站点下的帐号 * @return $arrSiteAccount = array( "UK"=>array("TON"=>"TON","SUK"=>"SUK"), * "DE"=>array("N13"=>"N13","BLW"=>"BLW"), * .... * ) */ function getSitesAccountArr() { //ebay所有站点,若ebay官方开通新的站点,请在这里添加,并补充填好配置文件(保持 url前缀名与站点数组名一致:详情请观察autoModel.ini文件的数据格式) $arrSites = array("US", "CA-En-", "CA-Fr", "UK", "AU", "AT", "BE-Fr", "BE-Nl", "FR", "FR", "DE", "US-Motors", "IT", "NL", "ES", "CH", "HK", "IN", "IE", "MY", "PH", "PL", "SG", "SE"); $fileName = "autoModel.ini"; foreach ($arrSites as $val) { $arrSiteAccount[$val] = returnINIArr($fileName, $val); //分别读取个站点的数组[US][UK][DE]... } return $arrSiteAccount; }
/** * @desc 处理不同参数(有小图,和分类名)2行2列的情况 * @param array $arrReplacement 用于替换的新内容组成的数组 * @param array $arrFunSP 经过fsInFunArr函数处理后的数组(包含需要循环的单元的数组) * @return string $strCirRestult 单元字符串经循环处理后的结果字符串 */ function cirDiffPara22($arrReplacement, $arrFunSP) { $beginEndDiffParaNameContPattern = "/\\<\\!--(\\ )*(beginDiffParaNameCont|endDiffParaNameCont)(\\ )*-->/i"; $smallPicSrcRP = "smallPicSrc"; $proClassify = "proClassify"; $diffParaName1RP = "diffParaName1"; $diffParaCont1RP = "diffParaCont1"; $diffParaName2RP = "diffParaName2"; $diffParaCont2RP = "diffParaCont2"; $diffParaName3RP = "diffParaName3"; $diffParaCont3RP = "diffParaCont3"; $diffParaName4RP = "diffParaName4"; $diffParaCont4RP = "diffParaCont4"; $str = ""; $strCirRestult = ""; $count = count($arrReplacement); //获取产品图片url前缀 $fileName = "autoModel.ini"; $arrName = "srcURL"; $arrPreURL = returnINIArr($fileName, $arrName); $proPicSrcPre = $arrPreURL["proPicSrcPre"]; //http://www.fasteasybuy.com/elite/ //如果arr为空不用循环 if (!empty($arrReplacement)) { foreach ($arrFunSP as $val) { if (strstr($val, $diffParaName1RP) || strstr($val, $diffParaCont1RP)) { for ($i = 0; $i < count($arrReplacement); $i++) { //替换小图和分类名 $str = str_replace($proClassify, $arrReplacement[$i][0], $val); //替换分类名 $str = str_replace($smallPicSrcRP, $proPicSrcPre . $arrReplacement[$i][2], $str); //替换小图src //再次分割该str 得到需要循环的 不同参数单元 $arrSPNameCont = preg_split($beginEndDiffParaNameContPattern, $str); $length = count($arrReplacement[$i][1]); //不同参数的条目 $mod = $length % 4; $countFloor = floor($length / 4); $countInter = $length / 4 - 1; $countPara = $mod == 0 ? $countInter : $countFloor; $strPara = ""; //不同参数的str $strParaClassify = ""; //一种分类的str foreach ($arrSPNameCont as $valNC) { if (strstr($valNC, $diffParaName1RP) || strstr($valNC, $diffParaCont1RP) || strstr($valNC, $diffParaName2RP) || strstr($valNC, $diffParaCont2RP)) { for ($j = 0, $k = 0; $j <= $countPara; $j++, $k += 4) { $str1 = str_replace($diffParaName1RP, $arrReplacement[$i][1][$k][0], $valNC); $str1 = str_replace($diffParaCont1RP, $arrReplacement[$i][1][$k][1], $str1); $str1 = str_replace($diffParaName2RP, $arrReplacement[$i][1][$k + 1][0], $str1); $str1 = str_replace($diffParaCont2RP, $arrReplacement[$i][1][$k + 1][1], $str1); if ($k + 2 < $length) { $str1 = str_replace($diffParaName3RP, $arrReplacement[$i][1][$k + 2][0], $str1); $str1 = str_replace($diffParaCont3RP, $arrReplacement[$i][1][$k + 2][1], $str1); } else { $str1 = str_replace($diffParaName3RP, "", $str1); $str1 = str_replace($diffParaCont3RP, "", $str1); } if ($k + 3 < $length) { $str1 = str_replace($diffParaName4RP, $arrReplacement[$i][1][$k + 3][0], $str1); $str1 = str_replace($diffParaCont4RP, $arrReplacement[$i][1][$k + 3][1], $str1); } else { $str1 = str_replace($diffParaName4RP, "", $str1); $str1 = str_replace($diffParaCont4RP, "", $str1); } $strPara .= $str1; } //end for j 不同参数数目 } //end if strstr $valNC } //end foreach srrSPNameCont $strParaClassify = $arrSPNameCont[0] . $strPara . $arrSPNameCont[2]; $strCirRestult .= $strParaClassify; } //end count count arrReplacement } //end if name || cont } //end foreach 第一次 } return $strCirRestult; }