Zoekscript
ik heb een probleem met mijn zoekscript hij ziet namelijk special characters als een spatie
vraag hoe los ik dat het beste op?
Toon eens wat je doet
het is van mijn baas
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
<?php
class Search {
private $indexes_dir='./data/search_indexes';
public $indexes=array();
function __construct($lang='') {
if (!file_exists($this->indexes_dir)) { mkdir($this->indexes_dir); }
$files = $this->scan_dir($this->indexes_dir);
$files = array_filter($files,create_function('$param','return preg_match(\'/'.$lang.'\..+\.lst/iU\',$param);'));
$this->indexes = array_values($files);
$this->buildsearchindex = 0;
foreach ($this->indexes as $v) { if (!file_exists($this->indexes_dir.'/'.$v)) { $this->buildsearchindex = 1; } }
}
private function artSortArray($theArray) {
switch ($_SESSION['sortart']) {
case "2": $theArray = sort_arr_of_obj($theArray,'price','asc'); break;
case "3": $theArray = sort_arr_of_obj($theArray,'price','desc'); break;
case "4": $theArray = sort_arr_of_obj($theArray,'name','asc'); break;
case "5": $theArray = sort_arr_of_obj($theArray,'name','desc'); break;
default : ; // do nothing
}
return $theArray;
}
public function artsWithAttributes($attrList, $pricefrom, $priceto) {
$i = 0;
$artList = '';
$attrArray = explode(',', $attrList);
if (($pricefrom==0) && ($priceto >= $LV_ATTR_MAXPRICE)) { $filterOnPrice = 0; } else { $filterOnPrice = 1; }
if ($filterOnPrice == 1) {
$vatMustBeAddedToArticle = $GLOBALS['conf']->data['LV_OPTIONS']['LV_SHOWPRICE_MODE'];
$vatitems_xml=new CustomXML('lvconfig/vatitems.xml');
$vatitems=array();
foreach ($vatitems_xml->xml['LV_VATITEMS']['LV_VATITEM'] as $v) { $vatitems[$v['LV_NUMBER']]=$v; }
unset($vatitems_xml);
}
$index_handle = fopen(($this->indexes_dir.'/'.$this->indexes[0]),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
$found = 0;
if ($buff['attr'] == $attrList) {
$found = 1;
} else {
$artAttrArray = explode(',', $buff['attr']);
$attrFound = 0;
foreach ($attrArray as $v) { if (in_array($v, $artAttrArray)) { $attrFound++; } }
if (count($attrArray) == $attrFound) { $found = 1; }
}
if (($found) && ($filterOnPrice == 1)) {
if (isset($buff['additional']['price'])) {
if ($vatMustBeAddedToArticle) {
$real_vat = 0;
if (isset($vatitems[$buff['additional']['vat']])) {
if (isset($vatitems[$buff['additional']['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$buff['additional']['vat']]['LV_PERCENTAGE']; }
}
$theArticlePrice = round($buff['additional']['price'] + (($buff['additional']['price']*$real_vat)/100),2);
} else { $theArticlePrice = round($buff['additional']['price'],2); }
} else { $theArticlePrice = 0; }
if (($theArticlePrice >= $pricefrom) && ($theArticlePrice <= $priceto)) { $found = 1; } else { $found = 0; }
}
if ($found) { $artListArray[$i]['aid']=$buff['aid']; $artListArray[$i]['name']=$buff['name']; $artListArray[$i]['price']=$buff['additional']['price']; $i++; }
}
$artListArray = $this->artSortArray($artListArray);
foreach ($artListArray as $v) { if ($artList != '') { $artList .= ','; }; $artList .= $v['aid']; }
unset($artListArray);
return $artList;
}
public function artsWithArttags($artTag, &$tagname) {
$i = 0;
$artList = '';
$index_handle = fopen(($this->indexes_dir.'/'.$this->indexes[0]),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
$arttagFound = 0;
if ($buff['arttag'] == $artTag) { $arttagFound = 1; } else { $artArttagArray = explode(',', $buff['arttag']); $arttagFound = (in_array($artTag, $artArttagArray)); }
if ($arttagFound) { $artListArray[$i]['aid']=$buff['aid']; $artListArray[$i]['name']=$buff['name']; $artListArray[$i]['price']=$buff['additional']['price']; $i++; }
}
$artListArray = $this->artSortArray($artListArray);
foreach ($artListArray as $v) { if ($artList != '') { $artList .= ','; }; $artList .= $v['aid']; }
unset($artListArray);
if (!lvfile_exists("lvconfig/tags.xml")) {
$tagnam = '';
} else {
$tags = new ConfigLoader(array("lvconfig/tags.xml"));
if (!isset($tags->data['LV_TAGS']['LV_TAG'][0])) { $tags->data['LV_TAGS']['LV_TAG']= array(0=>$tags->data['LV_TAGS']['LV_TAG']); }
$tagslist = $tags->data['LV_TAGS']['LV_TAG'];
foreach ($tagslist as $tlvalue) { if ($tlvalue['LV_ID'] == $artTag) { $tagname = $tlvalue['LV_NAME_'.strtoupper($GLOBALS['currentLanguage'])]; break; } }
}
return $artList;
}
public function find($str, $advanced = null) {
preg_match_all('/\w{1,}+/',$str,$matches);
$res = array();
$matches = array_unique($matches[0]);
if ($advanced!=null && isset($advanced['categories']) && strpos($advanced['categories'],',')!==false) { $advanced['categories'] = explode(',',$advanced['categories']); }
$vatMustBeAddedToArticle = $GLOBALS['conf']->data['LV_OPTIONS']['LV_SHOWPRICE_MODE'];
$vatitems_xml=new CustomXML('lvconfig/vatitems.xml');
$vatitems=array();
foreach ($vatitems_xml->xml['LV_VATITEMS']['LV_VATITEM'] as $v) { $vatitems[$v['LV_NUMBER']]=$v; }
unset($vatitems_xml);
$countSearchCriterion = 0;
if (isset($matches) && !empty($matches)) { $countSearchCriterion = count($matches); }
if ($advanced!=null) {
if (isset($advanced['categories'])) {$countSearchCriterion++;}
if (isset($advanced['manufacturer'])) {$countSearchCriterion++;}
if (isset($advanced['from_price'])) {$countSearchCriterion++;}
if (isset($advanced['to_price'])) {$countSearchCriterion++;}
if (isset($advanced['treelistvalue']) && ($advanced['treelistvalue'] != "")) {$countSearchCriterion++;}
if (!is_array($advanced['categories'])) { $advanced['categories'] = array(0 => $advanced['categories']); }
}
foreach ($this->indexes as $v) {
$index_handle = fopen(($this->indexes_dir.'/'.$v),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
if (isset($buff['additional']['price'])) {
if ($vatMustBeAddedToArticle) {
$real_vat = 0;
if (isset($vatitems[$buff['additional']['vat']])) {
if (isset($vatitems[$buff['additional']['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$buff['additional']['vat']]['LV_PERCENTAGE']; }
}
$theArticlePrice = round($buff['additional']['price'] + (($buff['additional']['price']*$real_vat)/100),2);
} else { $theArticlePrice = round($buff['additional']['price'],2); }
} else { $theArticlePrice = 0; }
if (isset($advanced['manufacturer'],$buff['additional']['manufacturer'])) {
$buff['additional']['manufacturer'] = str_replace('<![CDATA[','',$buff['additional']['manufacturer']);
$buff['additional']['manufacturer'] = str_replace(']]>','',$buff['additional']['manufacturer']);
}
$rating=0;
foreach ($matches as $v1) { if ((strpos($buff['data'],strtolower($v1))!==false) || (strpos(strtolower($buff['name']),strtolower($v1))!==false)) { $rating++; } }
if ($advanced!=null && !empty($buff['additional'])) {
if (isset($advanced['manufacturer'])) {
if ($advanced['manufacturer']=="all") {
$rating++;
} elseif (isset($advanced['manufacturer'],$buff['additional']['manufacturer']) && ($advanced['manufacturer']==$buff['additional']['manufacturer'])) {
$rating++;
} else { $rating=0; }
}
$found=0;
if (isset($advanced['categories'],$buff['additional']['categories'])) {
if (strpos($buff['additional']['categories'],',')!==false) { $buff['additional']['categories'] = explode(',',$buff['additional']['categories']); }
if (!is_array($buff['additional']['categories'])) { $buff['additional']['categories'] = array(0 => $buff['additional']['categories']); }
if (is_array($advanced['categories'])) {
$rate_old=$rating;
foreach ($advanced['categories'] as $v2) { if ($found > 0) {break;}; foreach ($buff['additional']['categories'] as $v3) { if ($v3 == $v2) { $rating++; $found=1; break; } } }
if (($rate_old==$rating) && !isset($buff['additional']['variantcats'])) { $rating=0; }
} elseif (!isset($buff['additional']['variantcats'])) { $rating=0; }
}
if ($found==0) {
if (isset($advanced['categories'],$buff['additional']['variantcats'])) {
if (is_array($advanced['categories'])) {
$rate_old=$rating;
foreach ($advanced['categories'] as $v2) { if ($buff['additional']['variantcats'] == $v2) { $rating++; break; } }
if ($rate_old==$rating) { $rating=0; }
} elseif ($buff['additional']['variantcats'] == $advanced['categories']) { $rating++; } else { $rating=0; }
}
}
if (isset($advanced['price'])) {
if (isset($advanced['from_price']) && isset($advanced['to_price'])) {
if ($advanced['from_price']<=$theArticlePrice && $advanced['to_price']>=$theArticlePrice) { $rating = $rating + 2; }
} elseif (isset($advanced['from_price']) && $advanced['from_price']<=$theArticlePrice) {
$rating++;
} elseif (isset($advanced['to_price']) && $advanced['to_price']>=$theArticlePrice) {
$rating++;
}
}
foreach ($buff['additional'] as $k1=>$v1) {
if ($k1=='manufacturer' || $k1=='categories' || $k1=='price' || $k1=='variantcats') { continue; }
if (isset($advanced[$k1]) && ((strpos($advanced[$k1],$v1)!==false) || ($advanced[$k1]==$v1))) { $rating++; }
}
if (isset($advanced['treelistvalue']) && ($advanced['treelistvalue'] != "")) {
if (stripos($buff['searchtree'],$advanced['treelistvalue']) !== false) { $rating++; }
}
}
if ($rating == $countSearchCriterion) {
if ($theArticlePrice==0) { $currname=''; } else { $currname=$GLOBALS['language']->xml_array['LV_CUR_NAME']; };
parse_str(urldecode($buff['url']),$output);
$res[]=array('rating'=>$rating,'url'=>urldecode($buff['url']),'name'=>$buff['name'],'group_id'=>$output['group_id'],'aid'=>$output['aid'],
'pictbig'=>$buff['pictbig'],'pictsmall'=>$buff['pictsmall'],'pictmini'=>$buff['pictmini'],
'currname'=>$currname,'price'=>$theArticlePrice);
}
}
}
function compare($a,$b){ if($a['rating']==$b['rating']) return 0; return($a['rating']>$b['rating'])?-1:1; }
usort($res,"compare");
$res = $this->artSortArray($res);
return($res);
}
private function scan_dir($dir) {
if (function_exists('scandir')) { $files=scandir($dir); } else { $dh=@opendir($dir); if ($dh!==false) { $files=array(); while (($file=readdir($dh))!==false) { $files[]=$file; } } else { $files=false; } }
return $files;
}
}?>
class Search {
private $indexes_dir='./data/search_indexes';
public $indexes=array();
function __construct($lang='') {
if (!file_exists($this->indexes_dir)) { mkdir($this->indexes_dir); }
$files = $this->scan_dir($this->indexes_dir);
$files = array_filter($files,create_function('$param','return preg_match(\'/'.$lang.'\..+\.lst/iU\',$param);'));
$this->indexes = array_values($files);
$this->buildsearchindex = 0;
foreach ($this->indexes as $v) { if (!file_exists($this->indexes_dir.'/'.$v)) { $this->buildsearchindex = 1; } }
}
private function artSortArray($theArray) {
switch ($_SESSION['sortart']) {
case "2": $theArray = sort_arr_of_obj($theArray,'price','asc'); break;
case "3": $theArray = sort_arr_of_obj($theArray,'price','desc'); break;
case "4": $theArray = sort_arr_of_obj($theArray,'name','asc'); break;
case "5": $theArray = sort_arr_of_obj($theArray,'name','desc'); break;
default : ; // do nothing
}
return $theArray;
}
public function artsWithAttributes($attrList, $pricefrom, $priceto) {
$i = 0;
$artList = '';
$attrArray = explode(',', $attrList);
if (($pricefrom==0) && ($priceto >= $LV_ATTR_MAXPRICE)) { $filterOnPrice = 0; } else { $filterOnPrice = 1; }
if ($filterOnPrice == 1) {
$vatMustBeAddedToArticle = $GLOBALS['conf']->data['LV_OPTIONS']['LV_SHOWPRICE_MODE'];
$vatitems_xml=new CustomXML('lvconfig/vatitems.xml');
$vatitems=array();
foreach ($vatitems_xml->xml['LV_VATITEMS']['LV_VATITEM'] as $v) { $vatitems[$v['LV_NUMBER']]=$v; }
unset($vatitems_xml);
}
$index_handle = fopen(($this->indexes_dir.'/'.$this->indexes[0]),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
$found = 0;
if ($buff['attr'] == $attrList) {
$found = 1;
} else {
$artAttrArray = explode(',', $buff['attr']);
$attrFound = 0;
foreach ($attrArray as $v) { if (in_array($v, $artAttrArray)) { $attrFound++; } }
if (count($attrArray) == $attrFound) { $found = 1; }
}
if (($found) && ($filterOnPrice == 1)) {
if (isset($buff['additional']['price'])) {
if ($vatMustBeAddedToArticle) {
$real_vat = 0;
if (isset($vatitems[$buff['additional']['vat']])) {
if (isset($vatitems[$buff['additional']['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$buff['additional']['vat']]['LV_PERCENTAGE']; }
}
$theArticlePrice = round($buff['additional']['price'] + (($buff['additional']['price']*$real_vat)/100),2);
} else { $theArticlePrice = round($buff['additional']['price'],2); }
} else { $theArticlePrice = 0; }
if (($theArticlePrice >= $pricefrom) && ($theArticlePrice <= $priceto)) { $found = 1; } else { $found = 0; }
}
if ($found) { $artListArray[$i]['aid']=$buff['aid']; $artListArray[$i]['name']=$buff['name']; $artListArray[$i]['price']=$buff['additional']['price']; $i++; }
}
$artListArray = $this->artSortArray($artListArray);
foreach ($artListArray as $v) { if ($artList != '') { $artList .= ','; }; $artList .= $v['aid']; }
unset($artListArray);
return $artList;
}
public function artsWithArttags($artTag, &$tagname) {
$i = 0;
$artList = '';
$index_handle = fopen(($this->indexes_dir.'/'.$this->indexes[0]),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
$arttagFound = 0;
if ($buff['arttag'] == $artTag) { $arttagFound = 1; } else { $artArttagArray = explode(',', $buff['arttag']); $arttagFound = (in_array($artTag, $artArttagArray)); }
if ($arttagFound) { $artListArray[$i]['aid']=$buff['aid']; $artListArray[$i]['name']=$buff['name']; $artListArray[$i]['price']=$buff['additional']['price']; $i++; }
}
$artListArray = $this->artSortArray($artListArray);
foreach ($artListArray as $v) { if ($artList != '') { $artList .= ','; }; $artList .= $v['aid']; }
unset($artListArray);
if (!lvfile_exists("lvconfig/tags.xml")) {
$tagnam = '';
} else {
$tags = new ConfigLoader(array("lvconfig/tags.xml"));
if (!isset($tags->data['LV_TAGS']['LV_TAG'][0])) { $tags->data['LV_TAGS']['LV_TAG']= array(0=>$tags->data['LV_TAGS']['LV_TAG']); }
$tagslist = $tags->data['LV_TAGS']['LV_TAG'];
foreach ($tagslist as $tlvalue) { if ($tlvalue['LV_ID'] == $artTag) { $tagname = $tlvalue['LV_NAME_'.strtoupper($GLOBALS['currentLanguage'])]; break; } }
}
return $artList;
}
public function find($str, $advanced = null) {
preg_match_all('/\w{1,}+/',$str,$matches);
$res = array();
$matches = array_unique($matches[0]);
if ($advanced!=null && isset($advanced['categories']) && strpos($advanced['categories'],',')!==false) { $advanced['categories'] = explode(',',$advanced['categories']); }
$vatMustBeAddedToArticle = $GLOBALS['conf']->data['LV_OPTIONS']['LV_SHOWPRICE_MODE'];
$vatitems_xml=new CustomXML('lvconfig/vatitems.xml');
$vatitems=array();
foreach ($vatitems_xml->xml['LV_VATITEMS']['LV_VATITEM'] as $v) { $vatitems[$v['LV_NUMBER']]=$v; }
unset($vatitems_xml);
$countSearchCriterion = 0;
if (isset($matches) && !empty($matches)) { $countSearchCriterion = count($matches); }
if ($advanced!=null) {
if (isset($advanced['categories'])) {$countSearchCriterion++;}
if (isset($advanced['manufacturer'])) {$countSearchCriterion++;}
if (isset($advanced['from_price'])) {$countSearchCriterion++;}
if (isset($advanced['to_price'])) {$countSearchCriterion++;}
if (isset($advanced['treelistvalue']) && ($advanced['treelistvalue'] != "")) {$countSearchCriterion++;}
if (!is_array($advanced['categories'])) { $advanced['categories'] = array(0 => $advanced['categories']); }
}
foreach ($this->indexes as $v) {
$index_handle = fopen(($this->indexes_dir.'/'.$v),'r');
while (!feof($index_handle)) {
$buff=fgets($index_handle);
$buff=unserialize($buff);
if (isset($buff['additional']['price'])) {
if ($vatMustBeAddedToArticle) {
$real_vat = 0;
if (isset($vatitems[$buff['additional']['vat']])) {
if (isset($vatitems[$buff['additional']['vat']]['LV_PERCENTAGE'])) { $real_vat = $vatitems[$buff['additional']['vat']]['LV_PERCENTAGE']; }
}
$theArticlePrice = round($buff['additional']['price'] + (($buff['additional']['price']*$real_vat)/100),2);
} else { $theArticlePrice = round($buff['additional']['price'],2); }
} else { $theArticlePrice = 0; }
if (isset($advanced['manufacturer'],$buff['additional']['manufacturer'])) {
$buff['additional']['manufacturer'] = str_replace('<![CDATA[','',$buff['additional']['manufacturer']);
$buff['additional']['manufacturer'] = str_replace(']]>','',$buff['additional']['manufacturer']);
}
$rating=0;
foreach ($matches as $v1) { if ((strpos($buff['data'],strtolower($v1))!==false) || (strpos(strtolower($buff['name']),strtolower($v1))!==false)) { $rating++; } }
if ($advanced!=null && !empty($buff['additional'])) {
if (isset($advanced['manufacturer'])) {
if ($advanced['manufacturer']=="all") {
$rating++;
} elseif (isset($advanced['manufacturer'],$buff['additional']['manufacturer']) && ($advanced['manufacturer']==$buff['additional']['manufacturer'])) {
$rating++;
} else { $rating=0; }
}
$found=0;
if (isset($advanced['categories'],$buff['additional']['categories'])) {
if (strpos($buff['additional']['categories'],',')!==false) { $buff['additional']['categories'] = explode(',',$buff['additional']['categories']); }
if (!is_array($buff['additional']['categories'])) { $buff['additional']['categories'] = array(0 => $buff['additional']['categories']); }
if (is_array($advanced['categories'])) {
$rate_old=$rating;
foreach ($advanced['categories'] as $v2) { if ($found > 0) {break;}; foreach ($buff['additional']['categories'] as $v3) { if ($v3 == $v2) { $rating++; $found=1; break; } } }
if (($rate_old==$rating) && !isset($buff['additional']['variantcats'])) { $rating=0; }
} elseif (!isset($buff['additional']['variantcats'])) { $rating=0; }
}
if ($found==0) {
if (isset($advanced['categories'],$buff['additional']['variantcats'])) {
if (is_array($advanced['categories'])) {
$rate_old=$rating;
foreach ($advanced['categories'] as $v2) { if ($buff['additional']['variantcats'] == $v2) { $rating++; break; } }
if ($rate_old==$rating) { $rating=0; }
} elseif ($buff['additional']['variantcats'] == $advanced['categories']) { $rating++; } else { $rating=0; }
}
}
if (isset($advanced['price'])) {
if (isset($advanced['from_price']) && isset($advanced['to_price'])) {
if ($advanced['from_price']<=$theArticlePrice && $advanced['to_price']>=$theArticlePrice) { $rating = $rating + 2; }
} elseif (isset($advanced['from_price']) && $advanced['from_price']<=$theArticlePrice) {
$rating++;
} elseif (isset($advanced['to_price']) && $advanced['to_price']>=$theArticlePrice) {
$rating++;
}
}
foreach ($buff['additional'] as $k1=>$v1) {
if ($k1=='manufacturer' || $k1=='categories' || $k1=='price' || $k1=='variantcats') { continue; }
if (isset($advanced[$k1]) && ((strpos($advanced[$k1],$v1)!==false) || ($advanced[$k1]==$v1))) { $rating++; }
}
if (isset($advanced['treelistvalue']) && ($advanced['treelistvalue'] != "")) {
if (stripos($buff['searchtree'],$advanced['treelistvalue']) !== false) { $rating++; }
}
}
if ($rating == $countSearchCriterion) {
if ($theArticlePrice==0) { $currname=''; } else { $currname=$GLOBALS['language']->xml_array['LV_CUR_NAME']; };
parse_str(urldecode($buff['url']),$output);
$res[]=array('rating'=>$rating,'url'=>urldecode($buff['url']),'name'=>$buff['name'],'group_id'=>$output['group_id'],'aid'=>$output['aid'],
'pictbig'=>$buff['pictbig'],'pictsmall'=>$buff['pictsmall'],'pictmini'=>$buff['pictmini'],
'currname'=>$currname,'price'=>$theArticlePrice);
}
}
}
function compare($a,$b){ if($a['rating']==$b['rating']) return 0; return($a['rating']>$b['rating'])?-1:1; }
usort($res,"compare");
$res = $this->artSortArray($res);
return($res);
}
private function scan_dir($dir) {
if (function_exists('scandir')) { $files=scandir($dir); } else { $dh=@opendir($dir); if ($dh!==false) { $files=array(); while (($file=readdir($dh))!==false) { $files[]=$file; } } else { $files=false; } }
return $files;
}
}?>
Gewijzigd op 03/10/2013 14:10:38 door Mathijs Adriaansen
Als je even kunt uitleggen wat er precies gedaan wordt met het script bij elke functie zou fijn zijn. Mits je weet wat er gebeurd natuurlijk (copy paste => vraag??)
NOLot - op 03/10/2013 14:35:48:
Als je even kunt uitleggen wat er precies gedaan wordt met het script bij elke functie zou fijn zijn. Mits je weet wat er gebeurd natuurlijk (copy paste => vraag??)
ik snap je vraag maar ik kan je helaas niet exact vertellen wat heel het script nou doet ben ook nog bezig met ontleden van het script.
Als ik wat heb maak ik er gelijk commentaar van
dit stuk is ontcijferd
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
/*zoekt naar het bestand search_indexes*/
private $indexes_dir='./data/search_indexes';
public $indexes=array();
/*begin construct*/
function __construct($lang='') {
/* hier wordt er gekeken of het bestand indexes_dir bestaat zo niet wordt het aangemaakt*/
if (!file_exists($this->indexes_dir)) { mkdir($this->indexes_dir); }
/*functie gaat door een array om te checken of er bestande zijn met $lang zoniet opniew aan maken*/
$files = $this->scan_dir($this->indexes_dir);
$files = array_filter($files,create_function('$param','return preg_match(\'/'.$lang.'\..+\.lst/iU\',$param);'));
$this->indexes = array_values($files);
$this->buildsearchindex = 0;
foreach ($this->indexes as $v) { if (!file_exists($this->indexes_dir.'/'.$v)) { $this->buildsearchindex = 1; } }
}/*end construct*/?>
/*zoekt naar het bestand search_indexes*/
private $indexes_dir='./data/search_indexes';
public $indexes=array();
/*begin construct*/
function __construct($lang='') {
/* hier wordt er gekeken of het bestand indexes_dir bestaat zo niet wordt het aangemaakt*/
if (!file_exists($this->indexes_dir)) { mkdir($this->indexes_dir); }
/*functie gaat door een array om te checken of er bestande zijn met $lang zoniet opniew aan maken*/
$files = $this->scan_dir($this->indexes_dir);
$files = array_filter($files,create_function('$param','return preg_match(\'/'.$lang.'\..+\.lst/iU\',$param);'));
$this->indexes = array_values($files);
$this->buildsearchindex = 0;
foreach ($this->indexes as $v) { if (!file_exists($this->indexes_dir.'/'.$v)) { $this->buildsearchindex = 1; } }
}/*end construct*/?>
Gewijzigd op 03/10/2013 14:47:50 door Mathijs Adriaansen
zal encoding zijn, dus controleer of en zoja welke charset er in het gegenereerde document staat (dus de html, <meta name="charset=" content="UTF-8" />), welke headers er evt worden meegestuurd (Content-Type: text/html;charset=utf8, oid) en in welke encodering de verbinding met de database is en de database/zelf. dit moet overal gelijk zijn, en meestal voldoet UTF-8 encodering.
De meta kan ik bij maar bij de verbinding en de database heb ik geen toestemming voor dus dat wordt en probleem