<# # Language overrule if($CHANNEL['Code']<>"DEF") { $suffix = "_".$CHANNEL['Code']; } # reverse define the physical field based on the friendly field $qu = "select FieldName,title,`group` from site_contenttypefields where contenttype=".$PAGE['contenttype']." and `group`<>'Admin'"; $q = mysql_query($qu); while( list($fieldName,$friendlyName,$group)=mysql_fetch_row($q)) { $allArray[$fieldName]['fieldName'] = $fieldName; $allArray[$fieldName]['friendlyName'] = $friendlyName; $allArray[$fieldName]['group'] = $group; } foreach($allArray as $field) { # Map the fields in default group to possible other Channel Code if($field['group']=="") { $search = $field['friendlyName'].$suffix; if($return = getParentStack($search,$allArray)) { $returnKey = array_keys($return); #echo "mapping ".$field['friendlyName']." to: ".$returnKey[0]." \n\n"; $FIELDS[$field['friendlyName']] = $returnKey[0]; $pagesearch = $field['friendlyName'].$suffix; $pagevalue = $field['friendlyName']; #overrule $PAGE array here $PAGE[$pagevalue] = $PAGE[$pagesearch]; #echo ">>".$field['friendlyName']. "($pagesearch) = ".$PAGE[$pagesearch]."\n"; } else { # Cannot find in the array, map the FIELDS to default $FIELDS[$field['friendlyName']] = $field['fieldName']; } } } #> <# if($CHANNEL['Code']=='REL'){ $mcListId = '066f2bbf4c'; } else { $mcListId = '890e56bc9f'; } $bannerClickUrl = URL(380); #> <# #vaste positie -> exclusiviteit //haal voor elke positie één banner op $channel = 'BIP'; //add channel to where $where = " AND Variabele1 LIKE \"%'".$channel."';%\" "; //add where for exact days $where .= " AND ( Text1 LIKE \"%".date("Y-m-d")."%\" or Text1 = '')"; $q = "SELECT nr, Title, Variabele2 as type, Variabele3 as positie, Variabele5 as url, Variabele9 FROM vw_activeContent WHERE contenttype = 31 and Text4 !=1 and Variabele2!='' and parent != 221 $where ORDER by Variabele3 DESC"; #echo ""; $r = mysql_query($q) or die(mysql_error()); $banners = array( 'liggend' => array( 'boven' => array(), 'midden' => array(), 'onder' => array() ), 'vierkant'=> array( 'rechts1' => array(), 'rechts2' => array(), 'rechts3' => array() ) ); if($CHANNEL['Code'] == 'DEF'){ $banners = array( 'liggend' => array( 'boven' => array(), 'midden' => array(), 'onder' => array() ), 'vierkant'=> array( 'rechts1' => array(), 'rechts2' => array(), 'rechts3' => array(), 'rechts4' => array() ) ); } $exclusives = array(); $linked = array(); while($row = mysql_fetch_assoc($r)){ $row['url'] = urlencode($row['url']); $row['Title'] = $row['Title']; if(!empty($row['Variabele9'])){ if(isset($linked[$row['Variabele9']])){ $linked[$row['Variabele9']][] = $row; }else{ $linked[$row['nr']][] = $row; } } #echo 'banner type: '.$row['type'].", position:".$row['positie']."
"; if(!empty($row['positie']) && isset($banners[$row['type']][$row['positie']])){ //vastte positie ? array_push($banners[$row['type']][$row['positie']],$row); //geef aan dat deze positie een exclusieve banner heeft $exclusives[$row['type']][$row['positie']]= true; }else{ //zoek een leeg plekje $emptyPos = getEmpty($banners[$row['type']]); if(!empty($emptyPos) && isset($banners[$row['type']][$emptyPos])){ //put in empty spot array_push($banners[$row['type']][$emptyPos],$row); }else{ //zoek plekje met minste banners, exclusieve niet meegerekend $lowPos = getLowest($banners[$row['type']], $row['type'], $exclusives); if(!empty($lowPos) && isset($banners[$row['type']][$lowPos])){ //put in lowest spot array_push($banners[$row['type']][$lowPos],$row); } /*//put in random position rand(5, 15); $allKeys = array_keys($banners[$row['type']]); //strip exclusive spots foreach($exclusives[$row['type']] as $spot => $ex){ if($ex){ foreach($allKeys as $index => $spotName){ if($spot == $spotName){ unset($allKeys[$index]); } } } } $spots = count($allKeys); if($spots>0){ $rand = mt_rand(0, ($spots-1)); if(isset($banners[$row['type']][$allKeys[$rand]])){ array_push($banners[$row['type']][$allKeys[$rand]],$row); } }*/ } } } $viewsNrs = ''; foreach($banners as $type => $positions){ foreach($positions as $pos => $value){ if(!empty($value)){ $rand_keys = array_rand($value, 1); $allKeys = array_keys($value); $banners[$type][$pos] = $value[$allKeys[$rand_keys]]; //save views if(!empty($value[$allKeys[$rand_keys]]['nr'])){ $viewsNrs.=$value[$allKeys[$rand_keys]]['nr'].","; } } } } //check if all linked banners are shown if(isset($_GET['bTest'])){ echo "Banners:
\n"; var_dump($banners); echo "linked:
\n"; var_dump($linked); } $i=0; foreach($linked as $coupleArr){ $found = false; foreach( $coupleArr as $bann){ //check exacte positie if(!empty($bann["positie"])){ if($banners[$bann["type"]][$bann["positie"]]['nr'] == $bann['nr']){ $found = true; } }else{ //loop door alle posities foreach($banners[$bann["type"]] as $positie){ if($positie['nr'] == $bann['nr']){ $found = true; } } } } if(!$found){ if(isset($_GET['bTest'])){ echo "couple $i not found
"; } //pick a random one out of the couple and place it $removeId = ''; while($removeId == '' && $x<10){ $rand = mt_rand(0, 1); //empty pos ? if(empty($coupleArr[$rand]["positie"])){ //zoek random positie in type $posCount = count($banners[$coupleArr[$rand]["type"]]); $randPos = mt_rand(0, ($posCount-1)); $posKeys = array_keys($banners[$coupleArr[$rand]["type"]]); if(isset($_GET['bTest'])){ echo "geen vaste positie zoek random pos in:".$coupleArr[$rand]["type"]."
"; echo "Totaal aantal plaatsen:".$posCount.", gekozen positie:".$randPos."
"; var_dump($posKeys); echo $posKeys[$randPos]."
"; } $coupleArr[$rand]["positie"] = $posKeys[$randPos]; } $removeId = $banners[$coupleArr[$rand]["type"]][$coupleArr[$rand]["positie"]]['nr']; if(isset($_GET['bTest'])){ echo "zoek banner om te replacen: ".$coupleArr[$rand]["type"].", ".$coupleArr[$rand]["positie"]."
"; //remove id also linked banner ? echo 'removing:'.$removeId." (".$banners[$coupleArr[$rand]["type"]][$coupleArr[$rand]["positie"]]['Variabele9'].")
"; } if(!empty($banners[$coupleArr[$rand]["type"]][$coupleArr[$rand]["positie"]]['Variabele9'])){ $removeId = ''; if(isset($_GET['bTest'])){ echo "cant rmove linked banner, empty and try again

\n\n\ "; } } $x++; } ///replace id in the update query $viewsNrs = str_replace($removeId,$coupleArr[$rand]['nr'],$viewsNrs); //replace the actual banner $banners[$coupleArr[$rand]["type"]][$coupleArr[$rand]["positie"]] = $coupleArr[$rand]; if(isset($_GET['bTest'])){ echo '
replaced '.$removeId.' with '.$coupleArr[$rand]['nr']."
"; } } $i++; } $viewsNrs = substr($viewsNrs,0,-1); $q = "UPDATE site_content set Variabele4 = Variabele4+1 WHERE nr IN (".$viewsNrs.")"; #echo ""; if(!empty($viewsNrs)){ mysql_query($q) or die(mysql_error()); } //add interne banners $q = "SELECT nr, Title, Body FROM vw_activeContent WHERE contenttype = 33 AND Variabele1 LIKE \"%'".$channel."';%\" order by RAND() LIMIT 3"; $r = mysql_query($q) or die(mysql_error()); #echo $q; $i=0; while($row = mysql_fetch_assoc($r)){ $row['Body'] = str_replace('%channel%', $CHANNEL['Title'], $row['Body']); $banners['intern'][$i] = $row; $i++; } function getEmpty($bannerTypes){ $return = ''; $emptys = array(); foreach($bannerTypes as $key => $positie){ if(empty($positie)){ $emptys[] = $key; //return $key; } } //return false; if(count($emptys)>0){ $rand = mt_rand(0, count($emptys) - 1); return $emptys[$rand]; }else{ return false; } } function getLowest($bannerTypes, $type, $exclusives){ $lowestArr = array(); $lowest = null; $lowestKey = null; foreach($bannerTypes as $key => $arr){ #echo ""; if(!$exclusives[$type][$key]){ if(!isset($lowest)){ $lowest = $arr; $lowestKey = $key; $lowestArr[] = $key; }else{ if(count($arr) < count($lowest) ){ $lowest = $arr; $lowestKey = $key; //empty array and start over $lowestArr = array(); $lowestArr[] = $key; }else if(count($arr) == count($lowest) ) { $lowestArr[] = $key; } } } } $rand = mt_rand(0, count($lowestArr) - 1); return $lowestArr[$rand]; //return $lowestKey; } #> PDF artikelen archief | BI-Platform | Business Intelligence & Analytics

PDF artikelen archief

Online archief van PDF artikelen van enkele gerelateerde Array-vaktijdschriften, zoals Database Magazine, Software Release en Java Magazine, uit de periode 2000 - 2011.

3710 resultaten gevonden