Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////// SELECTORSEARCH()
- function selectorSearch($main, $second, $grain)
- {
- $counter = 0;
- $resCounter = 0;
- $jumpCount = 40;
- $jump = 5; //51*5 = 255!!!
- $jumpS = 5; //51*5 = 255!!!
- $vypisy = false;
- $g_limit = 15; //pocet vystupu z hledani
- $mainR = hexdec($main[2].$main[3]);
- $mainG = hexdec($main[4].$main[5]);
- $mainB = hexdec($main[6].$main[7]);
- $secondR = hexdec($second[2].$second[3]);
- $secondG = hexdec($second[4].$second[5]);
- $secondB = hexdec($second[6].$second[7]);
- $id = array();
- myLog("NEW SEARCH: MainColor:".$mainR." ".$mainG." ".$mainB." SecondColor:".$secondR." ".$secondG." ".$secondB." GrainType:".$grain." limit:".$g_limit);
- $query = MySQL_Query("SELECT * FROM `content_type_page` WHERE field_group_name_value='$grain'") or die (mysql_error());
- while($result = mysql_fetch_array($query))
- {
- $pole["id"][$counter] = $result["nid"];
- $mainColor = explode(",", $result["field_dominant_color_value"]);
- $secondColor = explode(",", $result["field_minority_color_value"]);
- $pole["mainR"][$counter] = $mainColor[0];
- $pole["mainG"][$counter] = $mainColor[1];
- $pole["mainB"][$counter] = $mainColor[2];
- $pole["secondR"][$counter] = $secondColor[0];
- $pole["secondG"][$counter] = $secondColor[1];
- $pole["secondB"][$counter] = $secondColor[2];
- $counter++;
- }
- if($vypisy) echo "MainColor:".$mainR." ".$mainG." ".$mainB." SecondColor:".$secondR." ".$secondG." ".$secondB." GrainType:".$grain."<br/>";
- for($i=0;$i<=$jumpCount;$i++)
- {
- $border = $i*$jump;
- $borderS = $i*$jumpS;
- $borders["main_red_up"] = $mainR + $border;
- $borders["main_red_down"] = $mainR - $border;
- $borders["main_green_up"] = $mainG + $border;
- $borders["main_green_down"] = $mainG - $border;
- $borders["main_blue_up"] = $mainB + $border;
- $borders["main_blue_down"] = $mainB - $border;
- $borders["second_red_up"] = $secondR + $borderS;
- $borders["second_red_down"] = $secondR - $borderS;
- $borders["second_green_up"] = $secondG + $borderS;
- $borders["second_green_down"] = $secondG - $borderS;
- $borders["second_blue_up"] = $secondB + $borderS;
- $borders["second_blue_down"] = $secondB - $borderS;
- foreach($borders as $key => $value)
- {
- if($value >= 255) $borders[$key]=255;
- if($value <= 0) $borders[$key]=0;
- }
- for($x=0;$x<$counter;$x++)
- {
- $r_m = false;
- $g_m = false;
- $b_m = false;
- $r_s = false;
- $g_s = false;
- $b_s = false;
- $rgb_main = false;
- $rgb_second = false;
- if(($pole["mainR"][$x] >= $borders["main_red_down"]) && ($pole["mainR"][$x] <= $borders["main_red_up"])) $r_m = true;
- if(($pole["mainG"][$x] >= $borders["main_green_down"]) && ($pole["mainG"][$x] <= $borders["main_green_up"])) $g_m = true;
- if(($pole["mainB"][$x] >= $borders["main_blue_down"]) && ($pole["mainB"][$x] <= $borders["main_blue_up"])) $b_m = true;
- if(($pole["secondR"][$x] >= $borders["second_red_down"]) && ($pole["secondR"][$x] <= $borders["second_red_up"])) $r_s = true;
- if(($pole["secondG"][$x] >= $borders["second_green_down"]) && ($pole["secondG"][$x] <= $borders["second_green_up"])) $g_s = true;
- if(($pole["secondB"][$x] >= $borders["second_blue_down"]) && ($pole["secondB"][$x] <= $borders["second_blue_up"])) $b_s = true;
- if(($r_m == true) && ($g_m == true) && ($b_m == true)) $rgb_main = true;
- if(($r_s == true) && ($g_s == true) && ($b_s == true)) $rgb_second = true;
- if($vypisy)
- {
- if($r_m) echo "<br/>J: ".$pole["mainR"][$x]." >= ".$borders["main_red_down"]." & ".$pole["mainR"][$x]." <= ".$borders["main_red_up"];
- else echo "<br/>N: ".$pole["mainR"][$x]." !> ".$borders["main_red_down"]." & ".$pole["mainR"][$x]." !< ".$borders["main_red_up"];
- if($g_m) echo "<br/>J: ".$pole["mainG"][$x]." >= ".$borders["main_green_down"]." & ".$pole["mainG"][$x]." <= ".$borders["main_green_up"];
- else echo "<br/>N: ".$pole["mainG"][$x]." !> ".$borders["main_green_down"]." & ".$pole["mainG"][$x]." !< ".$borders["main_green_up"];
- if($b_m) echo "<br/>J: ".$pole["mainB"][$x]." >= ".$borders["main_blue_down"]." & ".$pole["mainB"][$x]." <= ".$borders["main_blue_up"];
- else echo "<br/>N: ".$pole["mainB"][$x]." !> ".$borders["main_blue_down"]." & ".$pole["mainB"][$x]." !< ".$borders["main_blue_up"];
- if($r_s) echo "<br/>J: ".$pole["secondR"][$x]." >= ".$borders["second_red_down"]." & ".$pole["secondR"][$x]." <= ".$borders["second_red_up"];
- else echo "<br/>N: ".$pole["secondR"][$x]." !> ".$borders["second_red_down"]." & ".$pole["secondR"][$x]." !< ".$borders["second_red_up"];
- if($g_s) echo "<br/>J: ".$pole["secondG"][$x]." >= ".$borders["second_green_down"]." & ".$pole["secondG"][$x]." <= ".$borders["second_green_up"];
- else echo "<br/>N: ".$pole["secondG"][$x]." !> ".$borders["second_green_down"]." & ".$pole["secondG"][$x]." !< ".$borders["second_green_up"];
- if($b_s) echo "<br/>J: ".$pole["secondB"][$x]." >= ".$borders["second_blue_down"]." & ".$pole["secondB"][$x]." <= ".$borders["second_blue_up"];
- else echo "<br/>N: ".$pole["secondB"][$x]." !> ".$borders["second_blue_down"]." & ".$pole["secondB"][$x]." !< ".$borders["second_blue_up"];
- }
- if(($rgb_main == true) && ($rgb_second == true))
- {
- array_push($id, $pole["id"][$x]);
- $pole["mainR"][$x] = 666;
- if($vypisy)
- {
- echo "<br/> NALEZEN!!!!!";
- echo $pole["id"][$x]." Xko: ".$x."ResC: ".$resCounter."<br/>";
- echo "<br/>";
- }
- }
- }
- }
- foreach($id as $v)
- {
- $query = MySQL_Query("SELECT nid, body FROM `content_type_page` LEFT JOIN `node_revisions` USING(nid) WHERE nid='$v' LIMIT 1") or die (mysql_error());
- $row = mysql_fetch_assoc($query);
- $ret = $row['body'];
- //ziskani image URL
- if(StrriPos($ret, "src=\"")===false) myLog("ImageUrl not found. Brand: ".$brandName." Nid: ".$row['nid ']);
- else
- {
- $ret=ereg_replace(".*src=\"", "", $ret);
- $ret=ereg_replace("\".*", "", $ret);
- $imageUrl=$ret;
- }
- $pom=$pom."-#-".$v;
- $pom=$pom."-#-".$imageUrl."<br/>";
- }
- //$output = implode(", ", $id);
- $output = $pom;
- //$output = "<br/><br/><br/>konec";
- return $output;
- };
- ///////////////////////////////////// END OF SELECTORSEARCH()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement