function store() { $database = JFactory::getDBO(); $db = JFactory::getDBO(); $link_label = 'ad_url'; $item = $this->getTable('adagencyAds'); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $notify = JRequest::getInt('id'); $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $data = JRequest::get('post'); if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } $adv_cmp = $data['adv_cmp']; //echo "<pre>";var_dump($adv_cmp);echo "</pre><hr />";//die(); if ($notify != '0') { $data['width'] = $data['parameters']['window_width']; $data['height'] = $data['parameters']['window_height']; } else { $data['parameters']['window_width'] = ''; $data['parameters']['window_height'] = ''; $data['parameters']['toolbar'] = ''; $data['parameters']['scrollbars'] = ''; $data['parameters']['status'] = ''; $data['parameters']['menubar'] = ''; $data['parameters']['resizable'] = ''; $data['parameters']['window_type'] = ''; } $data['parameters']['show_on'] = $data['show_on']; $data['parameters']['show_ad'] = $data['show_ad']; $showon = "window.onload = checkCount;"; /// : "window.onunload = checkCount;"; $cookie_name = md5(uniqid(rand(), 1)); $script = ''; //echo "<pre>";var_dump($data['parameters']);die('123'); $expday = "9999"; $data['parameters']["window_type"] = 'popup'; $data['parameters']["window_width"] = 600; $data['parameters']["window_height"] = 600; $data['parameters']["status"] = 'no'; $data['parameters']["toolbar"] = 'no'; $data['parameters']["resizable"] = 'yes'; $data['parameters']["scrollbars"] = 'yes'; switch ($data['parameters']["popup_type"]) { case 'webpage': $data['parameters']["preview_script"] = "window.open('" . $data['parameters']["page_url"] . "', 'popupad', 'width=" . $data['parameters']["window_width"] . ",height=" . $data['parameters']["window_height"] . ",toolbar=" . $data['parameters']["toolbar"] . ",status=" . $data['parameters']["status"] . ",menubar=" . $data['parameters']["menubar"] . ",scrollbars=" . $data['parameters']["scrollbars"] . ",location=no,resizable=" . $data['parameters']["resizable"] . "');"; if ($data['parameters']["window_type"] == 'popup') { $script = <<<EOD <script language="JavaScript"> var expDays = {$expday}; var page = "{$data['parameters']["page_url"]}"; var windowprops = "width={$data['parameters']["window_width"]},height={$data['parameters']["window_height"]},toolbar={$data['parameters']["toolbar"]},status={$data['parameters']["status"]},menubar={$data['parameters']["menubar"]},scrollbars={$data['parameters']["scrollbars"]},location=no,resizable={$data['parameters']["resizable"]}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\twindow.open(page, "popupad", windowprops); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']["window_type"] == 'popunder') { $script = <<<EOD <script language="JavaScript"> var expDays = {$expday}; var page = "{$data['parameters']["page_url"]}"; var windowprops = "width={$data['parameters']["window_width"]},height={$data['parameters']["window_height"]},toolbar={$data['parameters']["toolbar"]},status={$data['parameters']["status"]},menubar={$data['parameters']["menubar"]},scrollbars={$data['parameters']["scrollbars"]},location=no,resizable={$data['parameters']["resizable"]}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\twindow.open(page, "popupad", windowprops).blur(); \t\twindow.focus(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } break; case 'image': $mosConfig_live_site = JURI::base(); $data['parameters']['preview_script'] = "var newPopup=window.open('','PopupWindow','width=" . $data['parameters']['window_width'] . ",height=" . $data['parameters']['window_height'] . ",toolbar=" . $data['parameters']['toolbar'] . ",status=" . $data['parameters']['status'] . ",menubar=" . $data['parameters']['menubar'] . ",scrollbars=" . $data['parameters']['scrollbars'] . ",location=no,resizable=" . $data['parameters']['resizable'] . "'); var popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>';\n\t\t\t\tpopContent+= '<a target=\\'_blank\\' href=\\'{$data["target_url"]}\\'><img src=\\'{$mosConfig_live_site}/images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}\\' height=\\'{$data["height"]}\\' width=\\'{$data["width"]}\\' border=0></a>';\n\t\t\t\tpopContent+='</BODY></HTML>';\n\t\t\t\tnewPopup.document.write(popContent); newPopup.document.close(); newPopup.focus();"; if ($data['parameters']['window_type'] == 'popup') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>'; \t\tpopContent+= '<a target="_blank" href="{$link_label}"><img src="{$mosConfig_live_site}/images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}" height="{$data["height"]}" width="{$data["width"]}" border=0></a>'; \t\tpopContent+='</BODY></HTML>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.focus(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']['window_type'] == 'popunder') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>'; \t\tpopContent+= '<a target="_blank" href="{$link_label}"><img src="{$mosConfig_live_site}/images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}" height="{$data["height"]}" width="{$data["width"]}" border=0></a>'; \t\tpopContent+='</BODY></HTML>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.blur(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } break; case 'html': $crt = 1; $string = 'href="'; $fisier = $data['parameters']["html"]; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']['linktrack'][$crt] = $url; $crt++; $pos1 = strpos($fisier, $string); } $html_content = ""; $data['parameters']["html"] = preg_replace("/href((\\s+)?)=((\\s+)?)\"\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?]+)\\b/i", "href=\"ad_url", $data['parameters']['html']); $LINES = explode("\n", $data['parameters']["html"]); foreach ($LINES as $i => $v) { $v = trim($v); $html_content .= "popContent+='" . $v . "\\r\\n';\r\n"; } $preview_content = ""; $LINES = explode("\n", addslashes($data['parameters']["html"])); foreach ($LINES as $i => $v) { $v = trim($v); $preview_content .= "popContent+='" . $v . "\\r\\n';\r\n"; } $data['parameters']['preview_script'] = "var newPopup=window.open('','PopupWindow','width=" . $data['parameters']['window_width'] . ",height=" . $data['parameters']['window_height'] . ",toolbar=" . $data['parameters']['toolbar'] . ",status=" . $data['parameters']['status'] . ",menubar=" . $data['parameters']['menubar'] . ",scrollbars=" . $data['parameters']['scrollbars'] . ",location=no,resizable=" . $data['parameters']['resizable'] . "');\n\t\t\t\t\tvar popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>'; " . $preview_content . " popContent+='</BODY></HTML>';\n\t\t\t\t\tnewPopup.document.write(popContent); newPopup.document.close(); newPopup.focus(); "; if ($data['parameters']['window_type'] == 'popup') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>'; \t\t{$html_content} \t\tpopContent+='</BODY></HTML>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.focus(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']['window_type'] == 'popunder') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent='<HTML><HEAD><TITLE>Advertisement</TITLE></HEAD><BODY MARGINWIDTH=0 MARGINHEIGHT=0 LEFTMARGIN=0 TOPMARGIN=0 BOTTOMMARGIN=0>'; \t\t{$html_content} \t\tpopContent+='</BODY></HTML>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.blur(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } break; default: break; } $content = $script; if ($data['parameters']['popup_type'] != "image") { $data['width'] = $data['parameters']['window_width']; $data['height'] = $data['parameters']['window_height']; } // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); $ex_ad->parameters = @unserialize($ex_ad->parameters); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->parameters['popup_type'] == $data['parameters']['popup_type']) { if ($data['parameters']['popup_type'] == 'html' && $ex_ad->parameters['html'] == $data['parameters']['html']) { $data['approved'] = $ex_ad->approved; } elseif ($data['parameters']['popup_type'] == 'image' && $data['target_url'] == $ex_ad->target_url && $data["image_url"] == $ex_ad->image_url) { $data['approved'] = $ex_ad->approved; } elseif ($data['parameters']['popup_type'] == 'webpage' && $ex_ad->parameters['page_url'] == $data['parameters']['page_url']) { $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } // Check settings for auto-approve ads [end] //echo "<pre>";var_dump($data);die(); $data['parameters'] = serialize($data['parameters']); if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } if (isset($notify) && $notify != 0) { $where = $notify; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $campLimInfo = $adsModel->getCampLimInfo(); if (isset($adv_cmp)) { $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi) . " AND relative_weighting = 100"; $sqlz[] = $query; $db->setQuery($query); $db->query(); foreach ($adv_cmp as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { $query = "INSERT INTO `#__ad_agency_campaign_banner`\n (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`)\n VALUES ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . intval($data['czones'][$val]) . ");"; //$query = "INSERT INTO #__ad_agency_campaign_banner VALUES ({$val},{$idi},100)"; $db->setQuery($query); $db->query(); $sqlz[] = $query; } } } //var_dump($content);die('123'); $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . $db->escape($content) . "' WHERE `id`='" . intval($where) . "'"; $db = JFactory::getDBO(); $db->setQuery($sql); $db->query(); // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone as phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users as u on u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($where); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $where . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $where . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } // END - Send email to administrator $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $isWizzard = $this->isWizzard(); $item_id = JRequest::getInt('Itemid', '0', 'post'); if ($item_id != 0) { $Itemid = "&Itemid=" . $item_id; } else { $Itemid = NULL; } $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); global $mainframe; if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } //echo "<pre>";var_dump($sqlz);echo "</pre>";die('-END-'); return true; }
function store() { JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = $this->getInstance('adagencyAds', 'adagencyModel'); $database = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $_POST["parameters"]["ad_code"] = $_POST['transitioncode']; $data = JRequest::get('post'); $random_number = rand(1, 100); $sendmail = $data['sendmail']; $data['key'] = ''; // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); } else { $current_banner = $this->getAdById($data['id']); } $data['parameters']["ad_code"] = $_POST['transitioncode']; /*saving transition ad*/ $crt = 1; $string = 'href="'; $fisier = $data['parameters']["ad_code"]; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']["linktrack"][$crt] = $url; $crt++; $pos1 = strpos($fisier, $string); } $bordercolor = $data['parameters']["border_color"]; $backcolor = $data['parameters']["bg_color"]; $html_content = preg_replace("/(href((\\s+)?)=((\\s+)?)\")\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?\\&\\,\\%\\=]+)\\b/i", "href=\"ad_url", $data['parameters']["ad_code"]); $closead = "Close Ad"; $script = <<<EOD <script type="text/javascript"> function getAbsoluteLeft(objectId) { \t// Get an object left position from the upper left viewport corner \t// Tested with relative and nested objects \to = document.getElementById(objectId); \toLeft = o.offsetLeft; // Get left position from the parent object \twhile(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element \t\toParent = o.offsetParent; // Get parent object reference \t\toLeft += oParent.offsetLeft; // Add parent left position \t\to = oParent; \t} \t// Return left postion \treturn oLeft; } function getAbsoluteTop(objectId) { \t// Get an object top position from the upper left viewport corner \t// Tested with relative and nested objects \to = document.getElementById(objectId); \toTop = o.offsetTop; // Get top position from the parent object \twhile(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element \t\toParent = o.offsetParent; // Get parent object reference \t\toTop += oParent.offsetTop; // Add parent top position \t\to = oParent; \t} \t// Return top position \treturn oTop; } function leftposition() { \tvar left=getAbsoluteLeft("floatvert"); \tdocument.getElementById("floatvert").style.left = (-1) * left + "px"; } function topposition() { \tvar top = getAbsoluteTop("floatvert"); \tdocument.getElementById("floatvert").style.top = (-1) * top + "px"; } function initbox(){ \tdocument.getElementById("floatvert").style.visibility="visible"; \tif (!document.all) { \tasd = document.getElementById("floatvert"); \tasd.parentNode.removeChild(asd); \tdocument.body.appendChild(asd); } \tleftposition(); \ttopposition(); } function HideVert(number) { //document.getElementById("floatvert").style.visibility="hidden"; \t//document.getElementById("floatvert").parentNode.removeChild(document.getElementById("floatvert")); \t \tvar divs = document.getElementsByClassName('floatvert'+number); \tfor(var i=0; i<divs.length; i++){ \t\tdivs[i].parentNode.removeChild(divs[i]); \t} } var screenWidth = screen.width; var screenHeight = screen.height; </script> \t <div id="floatvert" class="floatvert{$random_number} mod_ijoomlazone" style="z-index:1000; position:absolute; top:1px; left:1px; visibility:hidden; background-color:#{$backcolor}; border-color: #{$bordercolor}; border:{$data['parameters']["border"]}px solid #{$bordercolor};"> <table cellpadding="5" cellspacing="0" style="border-collapse: collapse" id="continut4" > <tr> \t<td align="left"> \t\t<a href="" onClick="HideVert({$random_number});return false;">{$closead}</a> \t</td> </tr> <tr> \t<td id="continut" class="continut" valign="top" > \t\t{$html_content} \t</td> </tr> </table> \t<script type="text/javascript"> initbox(); var divs = document.getElementsByClassName('continut'); for(var i=0; i<divs.length; i++){ divs[i].width = screen.width; divs[i].height = screen.height; } /*document.getElementById("continut").width = screen.width; document.getElementById("continut").height = screen.height; document.getElementById("continut2").width = screen.width; document.getElementById("continut2").height = screen.height; document.getElementById("continut3").width = screen.width; document.getElementById("continut3").height = screen.height; document.getElementById("continut4").width = screen.width; document.getElementById("continut4").height = screen.height;*/ </script> </div> EOD; $adcodu = $script; $data['parameters'] = serialize($data['parameters']); //$data['location'] = json_encode($data['limitation']); if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($_POST['id']); $db = JFactory::getDBO(); if (isset($_POST['id']) && $_POST['id'] != 0) { $where = $_POST['id']; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (isset($where)) { $this->store_geo($where); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; $helper = new JomSocialTargeting(); $helper->save($where); } $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($where) . "'"; $db->setQuery($sql); $db->query(); $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($where) . "', '100', NULL, " . $data['czones'][$val] . ");"; $db->setQuery($query); $db->query(); } } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes(trim($adcodu)) . "' WHERE `id`='" . intval($where) . "'"; $db = JFactory::getDBO(); $db->setQuery($sql); $db->query(); if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return true; }
function store() { $db = JFactory::getDBO(); $database = JFactory::getDBO(); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $item = $this->getTable('adagencyAds'); $data = JRequest::get('post'); $item_id = JRequest::getInt('Itemid', '0', 'post'); if ($item_id != 0) { $Itemid = "&Itemid=" . intval($item_id); } else { $Itemid = NULL; } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } $post_id = JRequest::getInt('id'); $notify = $post_id; $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $adcode = JRequest::getVar('ad_code', '', 'POST', 'string', JREQUEST_ALLOWRAW); $adcodu = stripslashes($adcode); /* remove break lines */ $adcodu = preg_replace("/\r|\n/", ' ', $adcodu); /*allow only one space */ $adcodu = preg_replace('/\\s+/', ' ', $adcodu); /* transfor HREF into href */ $adcodu = str_replace('HREF', 'href', $adcodu); /* cases of href */ $adcodu = str_replace('href = "', 'href="', $adcodu); $adcodu = str_replace('href ="', 'href="', $adcodu); $adcodu = str_replace('href= "', 'href="', $adcodu); $adcodu = str_replace('<!--', '<!--' . "\n", $adcodu); $adcodu = str_replace('//-->', "\n" . '//-->', $adcodu); $adcodu = str_replace('s-cript', 'script', $adcodu); $content = $adcodu; $string = 'href="'; $fisier = $adcodu; $pos1 = strpos($fisier, $string); $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']['linktrack'] = $url; $adcodu = preg_replace('/href="(.*?)"/', 'href="ad_url"', $adcodu); $content = $adcodu; $data['parameters'] = serialize($data['parameters']); // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->ad_code == $content && $ex_ad->width == $data['width'] && $ex_ad->height == $data['height']) { $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } // Check settings for auto-approve ads [end] $parameters = $data["parameters"]; $parameters = unserialize($parameters); if (!isset($parameters["target_window"])) { $parameters["target_window"] = "_blank"; $data["parameters"] = serialize($parameters); } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $db =& JFactory::getDBO(); $this->setError($db->getErrorMsg()); return false; } if (isset($post_id) && $post_id) { $where = $post_id; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi); $db->setQuery($query); $db->query(); $campLimInfo = $adsModel->getCampLimInfo(); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if (strstr($val, "|yes|")) { $yes_no = 1; } else { $yes_no = 0; } $val = str_replace("|yes|", "", $val); $val = str_replace("|no|", "", $val); if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . intval(trim($data['czones'][$val])) . ");"; $db->setQuery($query); $db->query(); } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes($content) . "' WHERE `id`='" . intval($where) . "'"; $db->setQuery($sql); $db->query(); // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone as phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users as u on u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($where); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $where . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $where . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $isWizzard = $this->isWizzard(); $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); global $mainframe; if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } // END - Send email to administrator return true; }
function store() { JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = JModelLegacy::getInstance('adagencyAds', 'adagencyModel'); $database =& JFactory::getDBO(); $item =& $this->getTable('adagencyAds'); $data = JRequest::get('post'); $sendmail = $data['sendmail']; $data['key'] = ''; // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); } else { $current_banner = $this->getAdById($data['id']); } $data['parameters'] = serialize($data['parameters']); $data["linktext"] = str_replace("\r\n", " ", $data["linktext"]); $data["parameters"]["alt_text"] = str_replace("\r\n", " ", $data["parameters"]["alt_text"]); $res = true; if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } if (!$item->bind($data)) { $res = false; } if (!$item->check()) { $res = false; } if (!$item->store()) { $res = false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($_POST['id']); $db =& JFactory::getDBO(); if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; JomSocialTargeting::save($idi); } require_once JPATH_BASE . "/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($idi) . "'"; $db->setQuery($sql); $db->query(); $JPATH_BASE = str_replace('administrator', '', JPATH_BASE); if (isset($data['image_url']) && $data['image_url'] != NULL) { $img_url = $JPATH_BASE . 'images' . DS . 'stories' . DS . $configs->imgfolder . DS . $data['advertiser_id'] . DS . $data['image_url']; @(list($width_orig, $height_orig, $type, $attr) = @getimagesize($img_url)); } $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . $data['czones'][$val] . ");"; $db->setQuery($query); $db->query(); } $query = "SELECT z.adparams,z.textadparams FROM #__ad_agency_zone AS z WHERE z.zoneid = " . intval($data['czones'][$val]); $db->setQuery($query); $result_query = $db->loadObject(); $zparams = @unserialize($result_query->adparams); $paramz = @unserialize($result_query->textadparams); if (isset($paramz['mxsize']) && intval($paramz['mxsize']) > 0 && isset($paramz['mxtype'])) { if ($paramz['mxtype'] == 'w' && $paramz['mxsize'] < $zparams['width'] || $zparams['width'] == '') { //$ratio = $zparams['width']/$zparams['height'];$zparams['height'] = $zparams['width']/$ratio; $zparams['width'] = $paramz['mxsize']; } elseif ($paramz['mxtype'] == 'h' && $paramz['mxsize'] < $zparams['height'] || $zparams['height'] == '') { //$ratio = $zparams['width']/$zparams['height'];$zparams['width'] = $ratio * $zparams['height']; $zparams['height'] = $paramz['mxsize']; } } if (isset($zparams['width']) && isset($zparams['height']) && $width_orig != NULL && isset($width_orig) && isset($height_orig) && ($width_orig > $zparams['width'] || $height_orig > $zparams['height'])) { // make the thumb with the maximum size or the zone //echo "<pre>";var_dump($zparams);echo "<br />*** Cid: ".$val."</pre><hr />"; $thumb = $this->makeThumb($img_url, $zparams['width'], $zparams['height']); if ($thumb != NULL && $thumb != false) { $sql = "UPDATE `#__ad_agency_campaign_banner` SET `thumb` = '" . $thumb . "' WHERE `campaign_id` =" . $val . " AND `banner_id` =" . intval($idi) . ";"; } else { $sql = "UPDATE `#__ad_agency_campaign_banner` SET `thumb` = NULL WHERE `campaign_id` =" . $val . " AND `banner_id` =" . intval($idi) . ";"; } $db->setQuery($sql); $db->query(); $fls[] = $thumb; } } } } if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return $res; }
function store($new_camp = "") { global $mainframe; $item = $this->getTable('adagencyAds'); $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $notify = JRequest::getInt('id'); $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $database = JFactory::getDBO(); $db = JFactory::getDBO(); $data = JRequest::get('post'); $selected_camps = array(); if (isset($data['adv_cmp']) && is_array($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $key => $val) { if ($val) { $selected_camps[] = $val; } } } // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // Check settings for auto-approve ads [end] if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); $ex_ad->parameters = @unserialize($ex_ad->parameters); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->target_url == $data['target_url'] && $ex_ad->width == $data['width'] && $ex_ad->height == $data['height'] && $ex_ad->image_url == $data['image_url']) { //&&($ex_ad->parameters['alt_text'] == $data['parameters']['alt_text']) $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } $data['parameters']['alt_text'] = $data['target_url']; $data['parameters'] = @serialize($data['parameters']); if (!isset($data['adv_cmp'])) { $data['adv_cmp'] = NULL; } $adv_cmp = $data['adv_cmp']; $parameters = $data["parameters"]; $parameters = unserialize($parameters); if (!isset($parameters["target_window"])) { $parameters["target_window"] = "_blank"; $data["parameters"] = serialize($parameters); } $target_url = $data["target_url"]; if (strpos(" " . $target_url, "http") === FALSE) { $data["target_url"] = "http://" . $data["target_url"]; } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = @mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); $data['id'] = $idi; } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi); $db->setQuery($query); $db->query(); $campLimInfo = $adsModel->getCampLimInfo(); //echo "<pre>";var_dump($campLimInfo);die(); if (isset($selected_camps)) { foreach ($selected_camps as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { $query = "INSERT INTO `#__ad_agency_campaign_banner`\n (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`)\n VALUES\n ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . intval(@$data['czones'][$val]) . ");"; $db->setQuery($query); $db->query(); } } } // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone as phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users as u on u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($idi); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $idi . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $idi . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $idi . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $idi . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $idi . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $idi . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $isWizzard = $this->isWizzard(); $item_id = JRequest::getInt('Itemid', '0', 'post'); if ($item_id != 0) { $Itemid = "&Itemid=" . $item_id; } else { $Itemid = NULL; } $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); if (trim($new_camp) == "new_camp") { $itemid = JRequest::getVar("Itemid", "0"); $url = JURI::root() . "index.php?option=com_adagency&controller=adagencyCampaigns&task=edit&cid=0&ad=" . intval($data["id"]) . "&Itemid=" . intval($itemid); $mainframe->redirect($url); } if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } return true; }
function store() { JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = $this->getInstance('adagencyAds', 'adagencyModel'); global $mainframe; // $livesite = $mainframe->getSiteURL(); $database = JFactory::getDBO(); $link_label = 'ad_url'; $item = $this->getTable('adagencyAds'); $data = JRequest::get('post'); $data['parameters']["html"] = addslashes($data['parameters']["html"]); $sendmail = $data['sendmail']; // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); } else { $current_banner = $this->getAdById($data['id']); } $data['key'] = ''; $data['width'] = $data['parameters']['window_width']; $data['height'] = $data['parameters']['window_height']; $row->parameters['show_on'] = "onload"; $expday = $data['parameters']['show_ad'] == 0 ? 0 * 24 * 60 * 60 * 1000 : $data['parameters']["show_ad"] * 24 * 60 * 60 * 1000; $showon = "window.onload = checkCount();"; $cookie_name = md5(uniqid(rand(), 1)); $script = ''; if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } $site_url = JURI::root(); switch ($data['parameters']["popup_type"]) { case 'webpage': $data['parameters']["preview_script"] = "window.open('" . $data['parameters']["page_url"] . "', 'popupad', 'width=" . $data['parameters']["window_width"] . ",height=" . $data['parameters']["window_height"] . ",toolbar=" . $data['parameters']["toolbar"] . ",status=" . $data['parameters']["status"] . ",menubar=" . $data['parameters']["menubar"] . ",scrollbars=" . $data['parameters']["scrollbars"] . ",location=no,resizable=" . $data['parameters']["resizable"] . "');"; if ($data['parameters']["window_type"] == 'popup') { $script = <<<EOD <script language="JavaScript"> var expDays = {$expday}; var page = "{$data['parameters']["page_url"]}"; var windowprops = "width={$data['parameters']["window_width"]},height={$data['parameters']["window_height"]},toolbar={$data['parameters']["toolbar"]},status={$data['parameters']["status"]},menubar={$data['parameters']["menubar"]},scrollbars={$data['parameters']["scrollbars"]},location=no,resizable={$data['parameters']["resizable"]}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\twindow.open(page, "popupad", windowprops); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']["window_type"] == 'popunder') { $script = <<<EOD <script language="JavaScript"> var expDays = {$expday}; var page = "{$data['parameters']["page_url"]}"; var windowprops = "width={$data['parameters']["window_width"]},height={$data['parameters']["window_height"]},toolbar={$data['parameters']["toolbar"]},status={$data['parameters']["status"]},menubar={$data['parameters']["menubar"]},scrollbars={$data['parameters']["scrollbars"]},location=no,resizable={$data['parameters']["resizable"]}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\twindow.open(page, "popupad", windowprops).blur(); \t\twindow.focus(); alert("1"); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); alert("2"); \t} } {$showon} </script> EOD; } break; case 'image': $mosConfig_live_site = $livesite; $data['parameters']['preview_script'] = "var newPopup=window.open('','PopupWindow','width=" . $data['parameters']['window_width'] . ",height=" . $data['parameters']['window_height'] . ",toolbar=" . $data['parameters']['toolbar'] . ",status=" . $data['parameters']['status'] . ",menubar=" . $data['parameters']['menubar'] . ",scrollbars=" . $data['parameters']['scrollbars'] . ",location=no,resizable=" . $data['parameters']['resizable'] . "'); var popContent='';\n \n popContent+= '<a target=\\'_blank\\' href=\\'{$data["target_url"]}\\'><img src=\\'{$site_url}images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}\\' border=0></a>';\n\t\t\t\tnewPopup.document.write(popContent); newPopup.document.close(); newPopup.focus();"; if ($data['parameters']['window_type'] == 'popup') { $script = <<<EOD <script type="text/javascript" language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { var count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent=''; \t\tpopContent+= '<a target="_blank" href="{$link_label}"><img src="{$site_url}/images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}" border=0></a>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.focus(); \t} else{ \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']['window_type'] == 'popunder') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent=''; \t\tpopContent+= '<a target="_blank" href="{$link_label}"><img src="{$site_url}/images/stories/ad_agency/{$data["advertiser_id"]}/{$data["image_url"]}" border=0></a>'; \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.blur(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } break; case 'html': $crt = 1; $string = 'href="'; $fisier = $data['parameters']["html"]; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); if ($url != 'ad_url') { $data['parameters']['linktrack'][$crt] = $url; $pos1 = false; } elseif (isset($data['id'])) { $sql = "SELECT parameters FROM #__ad_agency_banners WHERE id = " . $data['id']; $database->setQuery($sql); $tmp_params = $database->loadResult(); $tmp_params = @unserialize($tmp_params); if (isset($tmp_params['linktrack'][1])) { $url = $tmp_params['linktrack'][1]; $data['parameters']['linktrack'][1] = $url; } $pos1 = false; } //$crt++; $pos1 = strpos($fisier, $string); } $html_content = ""; $data['parameters']["html"] = preg_replace("/href((\\s+)?)=((\\s+)?)\"\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?]+)\\b/i", "href=\"ad_url", $data['parameters']['html']); $LINES = explode("\n", $data['parameters']["html"]); foreach ($LINES as $i => $v) { $v = trim($v); $html_content .= "popContent+='" . $v . "\\r\\n';\r\n"; } $preview_content = ""; $LINES = explode("\n", addslashes($data['parameters']["html"])); foreach ($LINES as $i => $v) { $v = trim($v); $preview_content .= "popContent+='" . $v . "\\r\\n';\r\n"; } $data['parameters']['preview_script'] = "var newPopup=window.open('','PopupWindow','width=" . $data['parameters']['window_width'] . ",height=" . $data['parameters']['window_height'] . ",toolbar=" . $data['parameters']['toolbar'] . ",status=" . $data['parameters']['status'] . ",menubar=" . $data['parameters']['menubar'] . ",scrollbars=" . $data['parameters']['scrollbars'] . ",location=no,resizable=" . $data['parameters']['resizable'] . "');\n\t\t\t\t\tvar popContent=''; " . $preview_content . "\n\t\t\t\t\tnewPopup.document.write(popContent); newPopup.document.close(); newPopup.focus(); "; if ($data['parameters']['window_type'] == 'popup') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent=''; \t\t{$html_content} \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.focus(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } if ($data['parameters']['window_type'] == 'popunder') { $script = <<<EOD <script language="javascript"> var expDays = {$expday}; var windowprops = "width={$data['parameters']['window_width']},height={$data['parameters']['window_height']},toolbar={$data['parameters']['toolbar']},status={$data['parameters']['status']},menubar={$data['parameters']['menubar']},scrollbars={$data['parameters']['scrollbars']},location=no,resizable={$data['parameters']['resizable']}"; function GetCookie (name) { \tvar arg = name + "="; \tvar alen = arg.length; \tvar clen = document.cookie.length; \tvar i = 0; \twhile (i < clen) { \t\tvar j = i + alen; \t\tif (document.cookie.substring(i, j) == arg) return getCookieVal (j); \t\ti = document.cookie.indexOf(" ", i) + 1; \t\tif (i == 0) break; \t} \treturn null; } function SetCookie (name, value) { \tvar argv = SetCookie.arguments; \tvar argc = SetCookie.arguments.length; \tvar expires = (argc > 2) ? argv[2] : null; \tvar path = (argc > 3) ? argv[3] : null; \tvar domain = (argc > 4) ? argv[4] : null; \tvar secure = (argc > 5) ? argv[5] : false; \tdocument.cookie = name + "=" + escape (value) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + ((path == null) ? "" : ("; path=" + path)) + ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : ""); } function DeleteCookie (name) { \tvar exp = new Date(); \texp.setTime (exp.getTime() - 1); \tvar cval = GetCookie (name); \tdocument.cookie = name + "=" + cval + "; expires=" + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays)); function amt(){ \tvar count = GetCookie("{$cookie_name}"); \tif(count == null) { \t\tSetCookie("{$cookie_name}","1"); \t\treturn 1; \t} else { \t\tvar newcount = parseInt(count) + 1; \t\tDeleteCookie("{$cookie_name}"); \t\tSetCookie("{$cookie_name}",newcount,exp); \t\treturn count; \t} } function getCookieVal(offset) { \tvar endstr = document.cookie.indexOf (";", offset); \tif (endstr == -1) endstr = document.cookie.length; \treturn unescape(document.cookie.substring(offset, endstr)); } function checkCount() { \tvar count = GetCookie("{$cookie_name}"); \tif (count == null) { \t\tcount=1; \t\tSetCookie("{$cookie_name}", count, exp); \t\tvar newPopup=window.open("","PopupWindow",windowprops); \t\tvar popContent=''; \t\t{$html_content} \t\tnewPopup.document.write(popContent); \t\tnewPopup.document.close(); \t\tnewPopup.blur(); \t} else { \t\tcount++; \t\tSetCookie("{$cookie_name}", count, exp); \t} } {$showon} </script> EOD; } break; default: break; } $content = $script; if ($data['parameters']['popup_type'] != "image") { $data['width'] = $data['parameters']['window_width']; $data['height'] = $data['parameters']['window_height']; } $data['parameters'] = serialize($data['parameters']); //$data['location'] = json_encode($data['limitation']); if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($_POST['id']); $db = JFactory::getDBO(); if (isset($_POST['id']) && $_POST['id'] != 0) { $where = $_POST['id']; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (isset($where)) { $this->store_geo($where); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; $helper = new JomSocialTargeting(); $helper->save($where); } $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($where) . "'"; $db->setQuery($sql); $db->query(); $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($where) . "', '100', NULL, " . $data['czones'][$val] . ");"; $db->setQuery($query); $db->query(); } } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes(trim($content)) . "' WHERE `id`='" . intval($where) . "'"; $db->setQuery($sql); $db->query(); if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return $item->id; }
function store() { $random_number = rand(1, 100); JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = JModelLegacy::getInstance('adagencyAds', 'adagencyModel'); $database = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $_POST["parameters"]["ad_code"] = $_POST['transitioncode']; $data = JRequest::get('post'); $sendmail = $data['sendmail']; $data['key'] = ''; // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); } else { $current_banner = $this->getAdById($data['id']); } $data['parameters']["ad_code"] = $_POST['transitioncode']; /*saving floating ad*/ $crt = 1; $string = 'href="'; $fisier = $data['parameters']["ad_code"]; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']["linktrack"][$crt] = $url; $crt++; $pos1 = strpos($fisier, $string); } $bordercolor = $data['parameters']["border_color"]; $backcolor = $data['parameters']["bg_color"]; $html_content = preg_replace("/(href((\\s+)?)=((\\s+)?)\")\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?\\&\\,\\%\\=]+)\\b/i", "href=\"ad_url", $data['parameters']["ad_code"]); $closead = JText::_('ADAG_CLOSEAD'); $script = <<<EOD <SCRIPT language="JavaScript1.2"> var ie=document.all; var dom=document.getElementById; var ns4=document.layers; var bouncelimit=32; var direction="up"; function initbox(){ if (!document.all) { \tfafa = document.getElementById("floatit"); \tfafa.parentNode.removeChild(fafa); \tdocument.body.appendChild(fafa); } if (!dom&&!ie&&!ns4) return; crossobj=(dom)?document.getElementById("floatit").style : ie? document.all.floatit : document.floatit; scroll_top=(ie)? document.body.scrollTop : window.pageYOffset; crossobj.top=scroll_top-250; crossobj.visibility=(dom||ie)? "visible" : "show"; dropstart=setInterval("floatit()",50); } function floatit(){ scroll_top=(ie)? document.body.scrollTop : window.pageYOffset; if (parseInt(crossobj.top)<100+scroll_top) crossobj.top=parseInt(crossobj.top)+40; else{ clearInterval(dropstart); bouncestart=setInterval("bouncein()",50); } } function bouncein(){ crossobj.top=parseInt(crossobj.top)-bouncelimit; if (bouncelimit<0) bouncelimit+=8; bouncelimit=bouncelimit*-1; if (bouncelimit==0){ clearInterval(bouncestart); } } function HideVertFloating(number) { \tvar divs = document.getElementsByClassName('floatit'+number); \tfor(var i=0; i<divs.length; i++){ \t\tdivs[i].parentNode.removeChild(divs[i]); \t} } var screenWidth = window.innerWidth ? window.innerWidth*.92 : document.body.offsetWidth*.92; var screenHeight = window.innerHeight ? window.innerHeight : document.body.offsetHeight; </SCRIPT> <div id="floatit" class="floatit{$random_number} mod_ijoomlazone" style="height:{$data['height']}px; width:{$data['width']}px; position:absolute; xtopzz xbottzz xleftzz xrightzz z-index:500; background-color: #{$backcolor}; border:{$data['parameters']["border"]}px solid #{$bordercolor};" > <table cellpadding="5" cellspacing="0" width="100%" id="AutoNumber2"> \t<tr> \t\t<td width="100%" style="text-align:right;"> \t\t\t<a href="" onClick="HideVertFloating({$random_number}); return false;">{$closead}</a> \t\t</td> \t</tr> \t<tr> \t\t<td width="100%"> \t\t\t\t<!----start----> \t\t\t\t{$html_content} \t\t\t\t<!----End----> \t\t\t</td> \t\t</tr> \t</table> \t<script type="text/javascript"> \t\tinitbox(); \t\tvar xxx; </script> </div> EOD; //$adcodu = $script; //var_dump($data["parameters"]);die(); $adcodu = str_replace("xtopzz", "top: " . $data["parameters"]["toppos"] . "px;", $script); $adcodu = str_replace("xleftzz", "left: " . $data["parameters"]["leftpos"] . "px;", $adcodu); $adcodu = str_replace("xbottzz", "bottom: " . $data["parameters"]["bottpos"] . "px;", $adcodu); $adcodu = str_replace("xrightzz", "right: " . $data["parameters"]["rightpos"] . "px;", $adcodu); //var_dump($adcodu);die(); $data['parameters'] = serialize($data['parameters']); //$data['location'] = json_encode($data['limitation']); if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($_POST['id']); $db = JFactory::getDBO(); if (isset($_POST['id']) && $_POST['id'] != 0) { $where = $_POST['id']; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (isset($where)) { $this->store_geo($where); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; JomSocialTargeting::save($where); } $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($where) . "'"; $db->setQuery($sql); $db->query(); $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($where) . "', '100', NULL, " . $data['czones'][$val] . ");"; $db->setQuery($query); $db->query(); } } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes(trim($adcodu)) . "' WHERE `id`='" . intval($where) . "'"; $db->setQuery($sql); $db->query(); if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return true; }
function store() { JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = JModelLegacy::getInstance('AdagencyAds', 'AdagencyModel'); $item = $this->getTable('adagencyAds'); $database = JFactory::getDBO(); $data = JRequest::get('post'); $sendmail = $data['sendmail']; $data['key'] = ''; $isNew = false; if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $isNew = true; } else { $current_banner = $this->getAdById($data['id']); } // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } $data['parameters'] = @serialize($data['parameters']); if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($data['id']); $db = JFactory::getDBO(); if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; $helper = new JomSocialTargeting(); $helper->save($idi); } $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($idi) . "'"; $db->setQuery($sql); $db->query(); $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . $data['czones'][$val] . ");"; $db->setQuery($query); $db->query(); } } } } if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return true; }
function store() { $database = JFactory::getDBO(); $db = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $notify = JRequest::getInt('id'); $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $data = JRequest::get('post'); //echo "<pre>";var_dump($data);die(); if (!isset($data['parameters']["align"])) { $data['parameters["align"]'] = NULL; } if (!isset($data['parameters']["border"])) { $data['parameters["border"]'] = NULL; } if (!isset($data['parameters']["border_color"])) { $data['parameters["border_color"]'] = '000000;'; } if (!isset($data['parameters']["bg_color"])) { $data['parameters["bg_color"]'] = 'FFFFFF'; } $data['parameters']['toppos'] = "288"; $data['parameters']['leftpos'] = "459"; $data['parameters']['bottpos'] = ""; $data['parameters']['rightpos'] = ""; $selected_camps = array(); if (isset($data['adv_cmp']) && is_array($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $key => $val) { if ($val) { $selected_camps[] = $val; } } } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } $data['parameters']['ad_code'] = JRequest::getVar('transitioncode', '', 'POST', 'STRING', JREQUEST_ALLOWHTML); /*saving floating ad*/ $crt = 1; $string = 'href="'; $fisier = $data['parameters']['ad_code']; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']["linktrack"][$crt] = $url; $crt++; $pos1 = strpos($fisier, $string); } $html_content = preg_replace("/(href((\\s+)?)=((\\s+)?)\")\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?\\&\\,\\%\\=]+)\\b/i", "href=\"ad_url", $data['parameters']['ad_code']); $closead = JText::_('ADAG_CLOSEAD'); $script = <<<EOD <SCRIPT language="JavaScript1.2"> var ie=document.all; var dom=document.getElementById; var ns4=document.layers; var bouncelimit=32; var direction="up"; function initbox(){ if (!document.all) { \tfafa = document.getElementById("floatit"); \tfafa.parentNode.removeChild(fafa); \tdocument.body.appendChild(fafa); } if (!dom&&!ie&&!ns4) return; crossobj=(dom)?document.getElementById("floatit").style : ie? document.all.floatit : document.floatit; scroll_top=(ie)? document.body.scrollTop : window.pageYOffset; crossobj.top=scroll_top-250; crossobj.visibility=(dom||ie)? "visible" : "show"; dropstart=setInterval("floatit()",50); } function floatit(){ scroll_top=(ie)? document.body.scrollTop : window.pageYOffset; if (parseInt(crossobj.top)<100+scroll_top) crossobj.top=parseInt(crossobj.top)+40; else{ clearInterval(dropstart); bouncestart=setInterval("bouncein()",50); } } function bouncein(){ crossobj.top=parseInt(crossobj.top)-bouncelimit; if (bouncelimit<0) bouncelimit+=8; bouncelimit=bouncelimit*-1; if (bouncelimit==0){ clearInterval(bouncestart); } } function HideVert(){ if (window.bouncestart) clearInterval(bouncestart); crossobj.visibility="hidden"; document.getElementById("floatit").style.display = "none"; } var screenWidth = window.innerWidth ? window.innerWidth*.92 : document.body.offsetWidth*.92; var screenHeight = window.innerHeight ? window.innerHeight : document.body.offsetHeight; </SCRIPT> <div id="floatit" style="VISIBILITY: hidden; position:absolute; xtopzz xbottzz xleftzz xrightzz z-index:500; background-color:#{$data['parameters["bg_color"]']}; border-color: #{$data['parameters["border_color"]']};"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%" id="AutoNumber1" height="100%"> <tr> <td width="100%" align="{$data['parameters["align"]']}" height="100%" id="containing_td"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="{$data['width']}" id="AutoNumber2"> <tr> <td height="{$data['height']}" align="left" valign="top"> <table border="{$data['parameters["border"]']}" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="{$data['parameters["border_color"]']}" width="100%" id="AutoNumber2" bgcolor="{$data['parameters["bg_color"]']}"> <tr> <td width="100%" align="right"> <a href="" onClick="HideVert();return false;">{$closead}</a> \t</td> </tr> <tr> <td width="100%" height="{$data['height']}"> <!----start----> {$html_content} <!----End----> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <script type="text/javascript"> initbox(); var xxx; </script> </div> EOD; $adcodu = str_replace("xtopzz", "top: " . $data["parameters"]["toppos"] . "px;", $script); $adcodu = str_replace("xleftzz", "left: " . $data["parameters"]["leftpos"] . "px;", $adcodu); $adcodu = str_replace("xbottzz", "bottom: " . $data["parameters"]["bottpos"] . "px;", $adcodu); $adcodu = str_replace("xrightzz", "right: " . $data["parameters"]["rightpos"] . "px;", $adcodu); $the_code = $data['parameters']['ad_code']; $data['parameters'] = serialize($data['parameters']); // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); $ex_ad->parameters = @unserialize($ex_ad->parameters); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->parameters['ad_code'] == $the_code) { $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } // Check settings for auto-approve ads [end] $parameters = $data["parameters"]; $parameters = unserialize($parameters); if (!isset($parameters["target_window"])) { $parameters["target_window"] = "_blank"; $data["parameters"] = serialize($parameters); } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } if (isset($notify) && $notify != 0) { $where = $notify; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi); $db->setQuery($query); $db->query(); $campLimInfo = $adsModel->getCampLimInfo(); if (isset($selected_camps)) { foreach ($selected_camps as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { $query = "INSERT INTO `#__ad_agency_campaign_banner`\n (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`)\n VALUES\n ('" . $val . "', '" . $idi . "', '100', NULL, " . $data['czones'][$val] . ");"; //$query = "INSERT INTO #__ad_agency_campaign_banner VALUES ({$val},{$idi},100)"; $db->setQuery($query); $db->query(); } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes(trim($adcodu)) . "' WHERE `id`='" . intval($where) . "'"; $db->setQuery($sql); $db->query(); // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone as phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users as u on u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($where); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $where . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $where . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } // END - Send email to administrator $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $item_id = JRequest::getInt('Itemid', '0', 'post'); if ($item_id != 0) { $Itemid = "&Itemid=" . $item_id; } else { $Itemid = NULL; } $isWizzard = $this->isWizzard(); $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); global $mainframe; if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } return true; }
function store() { $database = JFactory::getDBO(); $db = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $notify = JRequest::getInt('id'); $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $data = JRequest::get('post'); if (isset($data['width']) && isset($data['height'])) { $data['width'] = NULL; $data['height'] = NULL; unset($data['width']); unset($data['height']); } //echo "<pre>";var_dump($data);die(); if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } //echo "<pre>";var_dump($data);die(); if (isset($data['adv_cmp'])) { $adv_cmp = $data['adv_cmp']; } $res = true; // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // Check settings for auto-approve ads [end] // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); $ex_ad->parameters = @unserialize($ex_ad->parameters); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->target_url == $data['target_url'] && $ex_ad->image_url == $data['image_url'] && stripslashes(@$ex_ad->parameters['alt_text_t']) == $data['linktitle'] && stripslashes(@$ex_ad->parameters['alt_text']) == $data['linktext'] && stripslashes(@$ex_ad->parameters['alt_text_a']) == $data['linkaction']) { //&&(stripslashes(@$ex_ad->parameters['img_alt']) == $data['parameters']['img_alt']) $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } if (isset($ex_ad->parameters)) { foreach ($data['parameters'] as $key => $value) { $ex_ad->parameters[$key] = $value; } $data['parameters'] = $ex_ad->parameters; } if (!isset($data['parameters']['img_alt']) || $data['parameters']['img_alt'] == '') { $data['parameters']['img_alt'] = $data['target_url']; } //echo "<pre>";var_dump($data);die(); $data['parameters'] = serialize($data['parameters']); $parameters = $data["parameters"]; $parameters = unserialize($parameters); if (!isset($parameters["target_window"])) { $parameters["target_window"] = "_blank"; $data["parameters"] = serialize($parameters); } $data["linktext"] = str_replace("\r\n", " ", $data["linktext"]); $data["parameters"]["alt_text"] = str_replace("\r\n", " ", $data["parameters"]["alt_text"]); if (!$item->bind($data)) { $res = false; } if (!$item->check()) { $res = false; } if (!$item->store()) { $res = false; } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi); $db->setQuery($query); $db->query(); if (isset($data['image_url']) && $data['image_url'] != NULL) { $img_url = JPATH_BASE . DS . 'images' . DS . 'stories' . DS . $configs->imgfolder . DS . $data['advertiser_id'] . DS . $data['image_url']; //echo $img_url."<br />"; @(list($width_orig, $height_orig, $type, $attr) = @getimagesize($img_url)); /*echo "Width original: ";var_dump($width_orig)."<br />"; echo "Height original: ".$height_orig."<br />"; echo "Type: ".$type."<br />"; echo "Attr: ".$attr."<br />"; echo "<pre>";var_dump($adv_cmp);echo "<hr />";//die(); //die();*/ } $fls = array(); $campLimInfo = $adsModel->getCampLimInfo(); //echo "<pre>";var_dump($campLimInfo);echo "<hr />";//die(); if (isset($adv_cmp)) { foreach ($adv_cmp as $val) { $zparams = NULL; $thumb = NULL; if (strstr($val, "|no|")) { $yes_no = 0; } else { $yes_no = 1; } $val = str_replace("|yes|", "", $val); $val = str_replace("|no|", "", $val); if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { if ($yes_no == 1) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`)\n\n VALUES ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . intval($data['czones'][$val]) . ");"; //$query = "INSERT INTO #__ad_agency_campaign_banner VALUES ({$val},{$idi},100)"; $db->setQuery($query); $db->query(); $query = "SELECT z.adparams,z.textadparams FROM #__ad_agency_zone AS z WHERE z.zoneid = " . intval($data['czones'][$val]); $db->setQuery($query); $res = $db->loadObject(); $zparams = @unserialize($res->adparams); $ex_ad->parameters = @unserialize($res->textadparams); if (isset($ex_ad->parameters['mxsize']) && intval($ex_ad->parameters['mxsize']) > 0 && isset($ex_ad->parameters['mxtype'])) { if ($ex_ad->parameters['mxtype'] == 'w' && $ex_ad->parameters['mxsize'] < $zparams['width'] || $zparams['width'] == '') { //$ratio = $zparams['width']/$zparams['height'];$zparams['height'] = $zparams['width']/$ratio; $zparams['width'] = $ex_ad->parameters['mxsize']; } elseif ($ex_ad->parameters['mxtype'] == 'h' && $ex_ad->parameters['mxsize'] < $ex_ad->parameters['height'] || $zparams['height'] == '') { //$ratio = $zparams['width']/$zparams['height'];$zparams['width'] = $ratio * $zparams['height']; $zparams['height'] = $ex_ad->parameters['mxsize']; } if (isset($zparams['width']) && isset($zparams['height']) && isset($width_orig) && $width_orig != NULL && isset($height_orig) && ($width_orig > $zparams['width'] || $height_orig > $zparams['height'])) { // make the thumb with the maximum size or the zone //echo "Campaign id: ".$val."<br />"; $thumb = $this->makeThumb($img_url, $zparams['width'], $zparams['height']); if ($thumb != NULL && $thumb != false) { $sql = "UPDATE `#__ad_agency_campaign_banner` SET `thumb` = '" . trim($thumb) . "' WHERE `campaign_id` =" . intval($val) . " AND `banner_id` =" . intval($idi) . ";"; } else { $sql = "UPDATE `#__ad_agency_campaign_banner` SET `thumb` = NULL WHERE `campaign_id` =" . intval($val) . " AND `banner_id` =" . intval($idi) . ";"; } $db->setQuery($sql); $db->query(); $fls[] = $thumb; } } } } } } //echo "<hr />"; //var_dump($fls); //die(); // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone AS phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users AS u ON u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($idi); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $idi . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $idi . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $idi . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $idi . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $idi . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $idi . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } // END - Send email to administrator $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $isWizzard = $this->isWizzard(); $item_id = JRequest::getInt('Itemid', '0'); if ($item_id != 0) { $Itemid = "&Itemid=" . intval($item_id); } else { $Itemid = NULL; } $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); global $mainframe; if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } return $res; }
function store() { JLoader::import('adagencyads', JPATH_SITE . DS . 'components' . DS . 'com_adagency' . DS . 'models'); $front_ads_model = JModelLegacy::getInstance('adagencyAds', 'adagencyModel'); $db = JFactory::getDBO(); $database = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $data = JRequest::get('post'); $sendmail = $data['sendmail']; $data['key'] = ''; // Prepare the keywords, trim them if (isset($data['keywords']) && $data['keywords'] != '') { $data['keywords'] = implode(',', array_map('trim', explode(',', $data['keywords']))); } if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); } else { $current_banner = $this->getAdById($data['id']); } if (trim($data['ad_start_date']) != "") { $data['ad_start_date'] = date("Y-m-d H:i:s", strtotime($data['ad_start_date'])); } else { $data['ad_start_date'] = date("Y-m-d H:i:s"); } if (trim($data['ad_end_date']) != "Never" && trim($data['ad_end_date']) != "") { $data['ad_end_date'] = date("Y-m-d H:i:s", strtotime($data['ad_end_date'])); } if (intval($data["id"]) == 0) { $sql = "select max(`ordering`) from #__ad_agency_banners"; $database->setQuery($sql); $database->query(); $max_ordering = $database->loadColumn(); $max_ordering = $max_ordering["0"]; $data["ordering"] = $max_ordering + 1; } $adcode = stripslashes($data['ad_code']); $adcodu = stripslashes($_POST["ad_code"]); /* remove break lines */ $adcodu = preg_replace("/\r|\n/", ' ', $adcodu); /*allow only one space */ $adcodu = preg_replace('/\\s+/', ' ', $adcodu); /* transfor HREF into href */ $adcodu = str_replace('HREF', 'href', $adcodu); /* cases of href */ $adcodu = str_replace('href = "', 'href="', $adcodu); $adcodu = str_replace('href ="', 'href="', $adcodu); $adcodu = str_replace('href= "', 'href="', $adcodu); //$adcodu = str_replace('<!--', '<!--'."\n", $adcodu); //$adcodu = str_replace('//-->', "\n".'//-->', $adcodu); $adcodu = str_replace('s-cript', 'script', $adcodu); $content = $adcodu; if (!strpos($adcodu, 'ad_url')) { $string = 'href="'; $fisier = $adcodu; $pos1 = strpos($fisier, $string); $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']['linktrack'] = $url; $adcodu = preg_replace('/href="(.*?)"/', 'href="ad_url"', $adcodu); $content = $adcodu; } else { $data['parameters']['linktrack'] = $data['linktrack']; } $data['parameters'] = serialize($data['parameters']); if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $db = JFactory::getDBO(); $this->setError($db->getErrorMsg()); return false; } $configs = $this->getInstance("adagencyConfig", "adagencyAdminModel"); $configs = $configs->getConfigs(); $cids = intval($_POST['id']); if (isset($_POST['id']) && $_POST['id'] != 0) { $where = $_POST['id']; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (isset($where)) { $this->store_geo($where); require_once JPATH_BASE . '/components/com_adagency/helpers/jomsocial.php'; $helper = new JomSocialTargeting(); $helper->save($where); } if (!$isNew) { $sql = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id = '" . intval($where) . "'"; $qz[] = $sql; $db->setQuery($sql); $db->query(); } $campLimInfo = $front_ads_model->getCampLimInfo($data['advertiser_id']); if (isset($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $val) { if ($val) { if (strpos(" " . $val, "no") > 0) { } elseif (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences']) { if (isset($data['czones'][$val])) { $query = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`) VALUES ('" . intval($val) . "', '" . intval($where) . "', '100', NULL, " . intval($data['czones'][$val]) . ");"; $qz[] = $query; $db->setQuery($query); $db->query(); } } } } } $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes($content) . "' WHERE `id`='" . intval($where) . "'"; $db = JFactory::getDBO(); $db->setQuery($sql); $db->query(); if ($sendmail && (isset($current_banner) && $current_banner->approved != $data['approved'] && $data['approved'] != 'P')) { $this->sendmail($current_banner->id, $data['approved']); } return true; }
function store() { $database = JFactory::getDBO(); $db = JFactory::getDBO(); $item = $this->getTable('adagencyAds'); $adsModel = $this->getInstance("adagencyAds", "adagencyModel"); $notify = JRequest::getInt('id'); $changed = "new"; $advid = $this->getCurrentAdvertiser(); if (isset($advid->aid)) { $advid = $advid->aid; } else { $advid = 0; } $configs = $this->getInstance("adagencyConfig", "adagencyModel"); $configs = $configs->getConfigs(); $data = JRequest::get('post'); $selected_camps = array(); if (isset($data['adv_cmp']) && is_array($data['adv_cmp'])) { foreach ($data['adv_cmp'] as $key => $val) { if ($val) { $selected_camps[] = $val; } } } $random_number = rand(1, 100); $data['parameters["bg_color"]'] = "FFFFFF"; $data['parameters["border_color"]'] = "000000"; if ($data['id'] == 0) { $data['created'] = date("Y-m-d"); $data['key'] = md5(rand(1000, 9999)); $data['ad_start_date'] = $data['created']; } else { $data['key'] = NULL; } $data['parameters']['ad_code'] = JRequest::getVar('transitioncode', '', 'POST', 'string', JREQUEST_ALLOWRAW); //JRequest::getVar('transitioncode'); $adv_cmp = $data['adv_cmp']; /*saving transition ad*/ $crt = 1; $string = 'href="'; $fisier = $data['parameters']['ad_code']; $pos1 = strpos($fisier, $string); while ($pos1) { $fisier = substr($fisier, $pos1 + strlen($string), strlen($fisier)); $pos2 = strpos($fisier, '"'); $url = substr($fisier, 0, $pos2); $data['parameters']['linktrack'][$crt] = $url; $crt++; $pos1 = strpos($fisier, $string); } $html_content = preg_replace("/(href((\\s+)?)=((\\s+)?)\")\\b((http(s?):\\/\\/)|(www\\.)|(ftp:\\/\\/))([\\w\\.]+)([-~\\/\\w+\\.-?\\&\\,\\%\\=]+)\\b/i", "href=\"ad_url", $data['parameters']['ad_code']); $closead = "Close Ad"; $script = <<<EOD <script type="text/javascript"> function getAbsoluteLeft(objectId) { \t// Get an object left position from the upper left viewport corner \t// Tested with relative and nested objects \to = document.getElementById(objectId); \toLeft = o.offsetLeft; // Get left position from the parent object \twhile(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element \t\toParent = o.offsetParent; // Get parent object reference \t\toLeft += oParent.offsetLeft; // Add parent left position \t\to = oParent; \t} \t// Return left postion \treturn oLeft; } function getAbsoluteTop(objectId) { \t// Get an object top position from the upper left viewport corner \t// Tested with relative and nested objects \to = document.getElementById(objectId); \toTop = o.offsetTop; // Get top position from the parent object \twhile(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element \t\toParent = o.offsetParent; // Get parent object reference \t\toTop += oParent.offsetTop; // Add parent top position \t\to = oParent; \t} \t// Return top position \treturn oTop; } function leftposition() { \tvar left=getAbsoluteLeft("floatvert"); \tdocument.getElementById("floatvert").style.left = (-1) * left + "px"; } function topposition() { \tvar top = getAbsoluteTop("floatvert"); \tdocument.getElementById("floatvert").style.top = (-1) * top + "px"; } function initbox(){ document.getElementById("floatvert").style.visibility="visible"; if (!document.all) { asd = document.getElementById("floatvert"); asd.parentNode.removeChild(asd); document.body.appendChild(asd); } leftposition(); topposition(); } function HideVert(number) { //document.getElementById("floatvert").style.visibility="hidden"; \t//document.getElementById("floatvert").parentNode.removeChild(document.getElementById("floatvert")); \t \tvar divs = document.getElementsByClassName('floatvert'+number); \tfor(var i=0; i<divs.length; i++){ \t\tdivs[i].parentNode.removeChild(divs[i]); \t} } var screenWidth = screen.width; var screenHeight = screen.height; </script> <div id="floatvert" class="floatvert{$random_number}" style="z-index:1000;position:absolute;top:1px;left:1px;visibility:hidden; background-color: #{$data['parameters["bg_color"]']}; border-color: #{$data['parameters["border_color"]']};"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="continut2"> <tr> \t<td bordercolor="{$data['parameters["border_color"]']}" bgcolor="{$data['parameters["bg_color"]']}" align="{$data['parameters["align"]']}" id="containing_td" valign="{$data['parameters["valign"]']}"> \t\t<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="continut3"> \t\t<tr> \t\t\t<td align="left" valign="top"> \t\t\t\t<table border="{$data['parameters["border"]']}" cellpadding="5" cellspacing="0" style="border-collapse: collapse" id="continut4" > \t\t\t\t<tr> \t\t\t\t\t<td align="left"> \t\t\t\t\t\t<a href="" onClick="HideVert({$random_number});return false;">{$closead}</a> \t\t\t\t\t</td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td id="continut" class="continut" valign="top" > \t\t\t\t\t{$html_content} \t\t\t\t </td> \t\t\t\t</tr> \t\t\t\t</table> \t\t\t</td> \t\t</tr> \t\t</table> \t</td> </tr> </table> <script type="text/javascript"> initbox(); var divs = document.getElementsByClassName('continut'); for(var i=0; i<divs.length; i++){ \tdivs[i].width = screen.width; \tdivs[i].height = screen.height; } /*document.getElementById("continut").width = screen.width; document.getElementById("continut").height = screen.height; document.getElementById("continut2").width = screen.width; document.getElementById("continut2").height = screen.height; document.getElementById("continut3").width = screen.width; document.getElementById("continut3").height = screen.height; document.getElementById("continut4").width = screen.width; document.getElementById("continut4").height = screen.height;*/ </script> </div> EOD; $adcodu = $script; $the_code = $data['parameters']['ad_code']; $data['parameters'] = serialize($data['parameters']); // Check settings for auto-approve ads [begin] $advertiser = $this->getCurrentAdvertiser(); if (isset($advertiser->apr_ads) && $advertiser->apr_ads != 'G') { $approved = $advertiser->apr_ads; } else { $sql = "SHOW COLUMNS FROM `#__ad_agency_banners` WHERE field = 'approved'"; $db->setQuery($sql); $res = $db->loadObject(); $approved = $res->Default; } if ($approved == 'N') { $approved = 'P'; } $data['approved'] = $approved; // if the ad is not new then -> if (isset($data['id']) && $data['id'] > 0) { $ex_ad = $this->getAdById($data['id']); $ex_ad->parameters = @unserialize($ex_ad->parameters); // if the ad was approved or declined and the new status would be 'pending', make sure changes occured to it! if ($ex_ad->approved != 'P' && $data['approved'] == 'P') { // if no change has been made, let the status be as it was if ($ex_ad->title == $data['title'] && $ex_ad->description == $data['description'] && $ex_ad->parameters['ad_code'] == $the_code) { $data['approved'] = $ex_ad->approved; } else { //it was changed, and sent email to administrator $notify = "0"; $changed = "changed"; } } } // Check settings for auto-approve ads [end] $parameters = $data["parameters"]; $parameters = unserialize($parameters); if (!isset($parameters["target_window"])) { $parameters["target_window"] = "_blank"; $data["parameters"] = serialize($parameters); } if (!$item->bind($data)) { $this->setError($item->getErrorMsg()); return false; } if (!$item->check()) { $this->setError($item->getErrorMsg()); return false; } if (!$item->store()) { $this->setError($item->getErrorMsg()); return false; } if (isset($notify) && $notify != 0) { $where = $notify; } else { $where = mysql_insert_id(); } if ($where == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $where = $db->loadResult(); } if (!isset($data['id']) || $data['id'] == 0) { $data['id'] = mysql_insert_id(); } $idi = $data['id']; if ($idi == 0) { $ask = "SELECT `id` FROM `#__ad_agency_banners` ORDER BY `id` DESC LIMIT 1 "; $db->setQuery($ask); $idi = $db->loadResult(); } if (isset($idi)) { $this->store_geo($idi); } require_once JPATH_BASE . "/administrator/components/com_adagency/helpers/jomsocial.php"; JomSocialTargeting::save($idi); $query = "DELETE FROM #__ad_agency_campaign_banner WHERE banner_id=" . intval($idi); $db->setQuery($query); $db->query(); $campLimInfo = $adsModel->getCampLimInfo(); // echo "<pre>";var_dump($campLimInfo);die(); if (isset($selected_camps)) { foreach ($selected_camps as $val) { if ($val && (!isset($campLimInfo[$val]) || $campLimInfo[$val]['adslim'] > $campLimInfo[$val]['occurences'])) { $query = "INSERT INTO `#__ad_agency_campaign_banner`\n (`campaign_id` ,`banner_id` ,`relative_weighting` ,`thumb`, `zone`)\n VALUES\n ('" . intval($val) . "', '" . intval($idi) . "', '100', NULL, " . intval($data['czones'][$val]) . ");"; //$query = "INSERT INTO #__ad_agency_campaign_banner VALUES ({$val},{$idi},100)"; $db->setQuery($query); $db->query(); } } } //die(); $sql = "UPDATE #__ad_agency_banners SET `ad_code` = '" . addslashes(trim($adcodu)) . "' WHERE `id`='" . intval($where) . "'"; $db->setQuery($sql); $db->query(); // Send email to administrator if ($notify == '0') { $sql = "SELECT a.user_id, a.company, a.telephone as phone, u.name, u.username, u.email FROM #__ad_agency_advertis AS a LEFT OUTER JOIN #__users as u on u.id=a.user_id\tWHERE a.aid=" . intval($advid) . " GROUP BY a.aid"; $db->setQuery($sql); $user = $db->loadObject(); if (isset($user) && $user != NULL) { $sql = "select `params` from #__ad_agency_settings"; $db->setQuery($sql); $db->query(); $email_params = $db->loadColumn(); $email_params = @$email_params["0"]; $email_params = unserialize($email_params); $ok_send_email = 0; $subject = ""; $message = ""; if ($changed == "new") { $subject = $configs->sbnewad; $message = $configs->bodynewad; $ok_send_email = $email_params["send_ban_added"]; } else { $subject = $configs->sbadchanged; $message = $configs->boadchanged; $ok_send_email = $email_params["send_ad_modified"]; } if (!isset($user->company) || $user->company == "") { $user->company = "N/A"; } if (!isset($user->phone) || $user->phone == "") { $user->phone = "N/A"; } $current_ad = $this->getAdById($where); if (isset($current_ad->approved) && $current_ad->approved == "Y") { $status = JText::_("NEWADAPPROVED"); } else { $status = JText::_("ADAG_PENDING"); } $epreview = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&no_html=1&adid=" . $where . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=preview&tmpl=component&adid=" . $where . "</a>"; $eapprove = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=approve&cid=" . $where . "&key=" . $data['key'] . "</a>"; $edecline = "<a href='" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "' target='_blank'>" . JURI::root() . "index.php?option=com_adagency&controller=adagencyAds&task=manage&action=decline&cid=" . $where . "&key=" . $data['key'] . "</a>"; $subject = str_replace('{name}', $user->name, $subject); $subject = str_replace('{login}', $user->username, $subject); $subject = str_replace('{email}', $user->email, $subject); $subject = str_replace('{banner}', $data['title'], $subject); $subject = str_replace('{company}', $user->company, $subject); $subject = str_replace('{phone}', $user->phone, $subject); $subject = str_replace('{approval_status}', $status, $subject); $subject = str_replace('{banner_preview_url}', $epreview, $subject); $subject = str_replace('{approve_banner_url}', $eapprove, $subject); $subject = str_replace('{decline_banner_url}', $edecline, $subject); $message = str_replace('{name}', $user->name, $message); $message = str_replace('{login}', $user->username, $message); $message = str_replace('{email}', $user->email, $message); $message = str_replace('{banner}', $data['title'], $message); $message = str_replace('{company}', $user->company, $message); $message = str_replace('{phone}', $user->phone, $message); $message = str_replace('{approval_status}', $status, $message); $message = str_replace('{banner_preview_url}', $epreview, $message); $message = str_replace('{approve_banner_url}', $eapprove, $message); $message = str_replace('{decline_banner_url}', $edecline, $message); if ($ok_send_email == 1) { JFactory::getMailer()->sendMail($configs->fromemail, $configs->fromname, $configs->adminemail, $subject, $message, 1); } } } // END - Send email to administrator $sql = "SELECT approved FROM #__ad_agency_banners WHERE id = " . intval($idi); $db->setQuery($sql); $approved = $db->loadResult(); $isWizzard = $this->isWizzard(); $item_id = JRequest::getInt('Itemid', '0', 'post'); if ($item_id != 0) { $Itemid = "&Itemid=" . intval($item_id); } else { $Itemid = NULL; } $link = "index.php?option=com_adagency&controller=adagencyAds&p=1" . $Itemid; $msg = JText::_('AD_BANNERSAVED'); global $mainframe; if ($isWizzard && $approved == 'P') { $mainframe->redirect($link, $msg); } return true; }