Witam,
z gory przepraszam za tytul ale siedze juz nad kodem ktoras godzine i jestem juz tam zly ze najchetniej cisnalbym komputerem przez okno najlepiej komus na leb... Ale do rzeczy.
public function index(){
if(!isset($_SESSION['stats_done']) || $_SESSION['stats_done']!="done"){
if(isset($_GET['keyword']) && isset($_GET['campaign']) && isset($_GET['advertisement'])){
self::stats($_GET['keyword'], $_GET['campaign'], $_GET['advertisement']);
}else{
self::stats("", "", "");
}
}
}
private function stats($keyword, $campaign, $advertisement){
if(!isset($_COOKIE['unique'])){
setcookie("unique", "true", time()+60*60*24*30*365, "/", $_SESSION['page_data']['company_name']);
setcookie("keyword", $keyword, time()+60*60*24*30, "/", $_SESSION['page_data']['company_name']);
setcookie("campaign", $campaign, time()+60*60*24*30, "/", $_SESSION['page_data']['company_name']);
setcookie("advertisement", $advertisement, time()+60*60*24*30, "/", $_SESSION['page_data']['company_name']);
setcookie("reg_level", "0", time()+60*60*24*30, "/", $_SESSION['page_data']['company_name']);
$this->main_model->add_new($keyword, $campaign, $advertisement);
}else{
if(isset($_COOKIE['keyword']) && isset($_COOKIE['campaign']) && isset($_COOKIE['advertisement']) && ( !isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER']=="" || stristr($_SERVER['HTTP_REFERER'], base_url())==FALSE )){
$this->main_model->add_returning($_COOKIE['keyword'], $_COOKIE['campaign'], $_COOKIE['advertisement']);
}
}
$_SESSION['stats_done']="done";
}
public function add_new($keyword, $campaign, $advertisement){
$this->db->select('*');
$this->db->from('keywords');
$this->db->where('keyword', $keyword);
$this->db->where('campaign', $campaign);
$this->db->where('advertisement', $advertisement);
$this->db->where('date', date("Y-m-d"));
$this->db->limit(1);
$this->db->order_by('date', 'desc');
$query = $this->db->get();
if($query->num_rows()>0){
foreach($query->result() as $row){
$result[]=$row;
}
$this->db->where('id', $result[0]->id );
$this->db->set('new', 'new+1', FALSE);
$this->db->update('keywords');
}else{
$data = array(
'keyword' => $keyword,
'campaign' => $campaign,
'advertisement' => $advertisement,
'date' => date("Y-m-d"),
'new' => "1"
);
$this->db->insert('keywords', $data);
}
}
public function add_returning($keyword, $campaign, $advertisement){
$this->db->select('*');
$this->db->from('keywords');
$this->db->where('keyword', $keyword);
$this->db->where('campaign', $campaign);
$this->db->where('advertisement', $advertisement);
$this->db->where('date', date("Y-m-d"));
$this->db->limit(1);
$this->db->order_by('date', 'desc');
$query = $this->db->get();
if($query->num_rows()>0){
foreach($query->result() as $row){
$result[]=$row;
}
$this->db->where('id', $result[0]->id);
$this->db->set('returning', 'returning+1', FALSE);
$this->db->update('keywords');
}else{
$data = array(
'keyword' => $keyword,
'campaign' => $campaign,
'advertisement' => $advertisement,
'date' => date("Y-m-d"),
'returning' => "1"
);
$this->db->insert('keywords', $data);
}
}
Generalnie chodzi o to... ze w tym cholernym indeksie pomimo podwojnego warunku ifa w jakis cudowny cholera jasna sposob dochodzi do funkcji self::stats("", "", ""); pomimo nie spelniania warunkow ifow ( nie powinno w ogóle tam wlazic. Co najsmieszjniejsze jak dam jakies echo przed to self::stats("", "", ""); to nic nie wypluwa a jak wykomentuje self::stats("", "", ""); to rekordy w bazie nie ulegaja zmianie czyli to ta cholera funkcja a nie cos innego w kodzie.
Po prostu jestem zalamany, nie wspomne juz o tym ze ten chlerny kod dziala troche inaczej na chromie a inaczej na wszystkich innych przegladarkach... czy ja cos debilnego z tymi coockiesami robie czy o co cholera chodzi...
Bede dozgonnie wdzieczny jesli ktos podpowie mi co ja tu narobilem ( badz potwierdzi moje przypuszczenia ze jest jakis cholerny blad w php.