Hello, I have this code to show adsense code randomly in thread 1st and 2nd posts but it keep showing the ads in the same place on page refresh unlike DP forum where I can see ad changes their place on refresh and this is really amazing and will increase the PCT rate //&&stripos($post['pagetext'], '[/quote]') == false if(!$show['search_engine']&&vbstrlen(strip_bbcode($post['pagetext'], true))>$this->registry->options['copyright_minlen']) { $BypassGroup = '13,18,20'; if(!in_array($GLOBALS['vbulletin']->userinfo['usergroupid'], explode(',', $BypassGroup))) { $isinpost = '1,2'; $countpost = $post['postcount'] % $GLOBALS['vbulletin']->options['maxposts']; if (in_array($countpost, explode(',', $isinpost))) { srand($post['dateline']); $repchar = '<br'; $inserts = intval(vbstrlen(strip_bbcode($post['pagetext'], true))/$this->registry->options['copyright_interval']); if($inserts<1) $inserts=1; if($inserts>$this->registry->options['copyright_maxinserts']) $inserts=$this->registry->options['copyright_maxinserts']; //error_log($post['postid'].":".$inserts); //eval('$adsense_text .= "' . fetch_template('adsense_text') . '";'); $templater = vB_Template::create('adsense_text'); $adsense_text .= $templater->render(); $msglen = strlen($post['message']); //$find = vbstrlen(strip_bbcode($post['pagetext'])); if(strpos($post['message'], $repchar) !== false) { for($i=0;$i<$inserts;$i++) { $poses = array(); $lastpos = -1; while(strpos($post['message'], $repchar, $lastpos+1) !== false){ $lastpos = strpos($post['message'], $repchar, $lastpos+1); $poses[] = $lastpos; } $pickme = $poses[rand(0, sizeof($poses)-1)]; //$pos = strpos($post['message'], $repchar, rand(0, $msglen-1)); if($pickme !== false) { $post['message'] = substr_replace($post['message'], '<br />'.$adsense_text.$repchar, $pickme, strlen($repchar)); } } } else { $post['message'] = $post['message'].'<br />'.$adsense_text; } } } } PHP: Please if any one can help me to fix this code! Thanks.
Well I finally knew where is the problem that was affecting and always show ads in the same place. This should be removed, but not sure why it was causing the issue although it was affecting the post date only! srand($post['dateline']); PHP: Thanks.