Nestle Posted February 23, 2014 at 03:59 PM Report #546375 Posted February 23, 2014 at 03:59 PM Olá, Preciso de uma ajudinha urgente antes de abrir o meu site que adiei devido a uma alteração em mente. Tenho um script, generador de links, do tipo adf.ly, mas quero transforma-lo num script PTP. No script que tenho, quando geramos um novo link, quando entramos nele, teremos que esperar 5 segundos e ainda temos que clicar no "Skip Ads". Mas... eu quero que ele redireccione directamente para o site gerado. Para aqueles que não perceberam, (não sei explicar bem), é isto que basicamente quero fazer: Os links gerados no meu website acontece isto: http://adf.ly/PDaTo Eu quero que faça isto : http://tvlnk.com/ptp/LJsF Percebo mesmo muito minimamente de PHP, portanto não sei como fazer. Tenho aqui os 2 ficheiros PHP que acho que são só esses que fazem essas tais funções. Index.php : <?php ini_set('display_errors', 0); require_once '../global.php'; require_once ROOT_PATH . '/inc/analyzer.class.php'; function kill() { System::redirect(SITE_LOCATION); exit; }; if (isset($_GET['uid']) && isset($_GET['url'])) { $G_UID = intval($_GET['uid']); $G_URL_R = $G_UID . '/' . ($_GET['adt'] != 1 ? 'banner/' : ''); $G_URL = $_SERVER['REQUEST_URI']; $G_URL = substr($G_URL, strpos($G_URL, $G_URL_R) + strlen($G_URL_R)); $G_ADT = $_GET['adt'] != 1 ? 'Top Banner' : 'Interstitial'; $urlsb = substr($G_URL, 0, strpos($G_URL, '://')); if (!$urlsb) { $G_URL = 'http://' . $G_URL; } if (!is_numeric($G_UID) || !Utilities::validateURL($G_URL)) { kill(); } } else if(!preg_match('|^[0-9a-zA-Z]{1,6}$|', $_GET['to'])) { kill(); } $G_SHORT = false; if ($G_UID && $G_URL && $G_ADT) { $surl = SITE_LOCATION; $db = System::getDB(); $user = $G_UID; if ($tmp = $db->getField($_GLOBAL['TABLES']['LINKS'], 'short_url', "`long_url`='{$G_URL}' AND `adtype`='{$G_ADT}' AND `user`='{$user}'")) { $short = $tmp; $data = System::getDB()->getRows($_GLOBAL['TABLES']['LINKS'], "`short_url`='{$short}'", '', '1'); } else { $data = array('long_url' => $G_URL, 'adtype' => $G_ADT, 'user' => $user); $db->query('LOCK TABLES ' . $_GLOBAL['TABLES']['LINKS'] . ' WRITE;'); $lid = $db->insert($_GLOBAL['TABLES']['LINKS'], $data); $db->query('UNLOCK TABLES'); $short = $surl . System::shortenID($lid); $db->update($_GLOBAL['TABLES']['LINKS'], array('short_url' => $short), "`id`='{$lid}'"); $data = System::getDB()->getRows($_GLOBAL['TABLES']['LINKS'], "`id`='{$lid}'", '', '1'); } $G_SHORT = $short; } else { $surl = Utilities::removeURLQueries(Utilities::getCurrentURL()); $data = System::getDB()->getRows($_GLOBAL['TABLES']['LINKS'], "`short_url`='{$surl}'", '', '1'); } $lid = $data['id']; $oid = $data['user']; $url = $data['long_url']; $title = $data['title']; $adtyp = $data['adtype'] == 'Interstitial' ? 1 : 2; if (!$url) kill(); $HTTP_REFERER = !$_SERVER["HTTP_REFERER"] ? getenv('HTTP_REFERER') : $_SERVER["HTTP_REFERER"]; if ($data['adtype'] == 'None') { $analyzer = new Analyzer($lid, $oid, 0, $HTTP_REFERER); $analyzer->_record($adtype); System::redirect($url); } function get_ad() { global $_GLOBAL, $data, $HTTP_REFERER; $a = new Analyzer(0, 0, 0); if ($a->_isCrawler()) die('Crawlers are not allowed here'); $db = System::getDB(); $t = $data['adtype'] != 'Interstitial' ? 'Banner' : 'Interstitial'; $cc = $a->country($a->ip()); $ci = $db->getField($_GLOBAL['TABLES']['PACKAGES'], 'id', "`code`='{$cc}' AND `advert_type`='{$t}'"); $c = $db->getRows($_GLOBAL['TABLES']['CAMPAIGNS'], "`status`='2' AND `advert_type`='{$t}'"); $valid = array(); $date = date('j'); for ($i = 0; $i < count($c); $i++) { if (Utilities::float_cmp($c[$i]['spent_day'], $date) !== 0) { $db->update($_GLOBAL['TABLES']['CAMPAIGNS'], array('spent_today' => '0', 'spent_day' => date('d')), "`id`='{$c[$i]['id']}'"); } if (Utilities::float_cmp($c[$i]['daily_budget'], 0) == 1 && Utilities::float_cmp($c[$i]['spent_today'], $c[$i]['daily_budget']) == -1) continue; $pkg = explode(';', $c[$i]['packages']); foreach ($pkg as $p) { $t = explode(',', $p); if ($t[0] == $ci || $t[0] == '1' || $t[0] == '242') $valid[] = $c[$i]; } } return $valid[rand(0, count($valid) - 1)]; } $AD = get_ad(); $aid = $AD['id'] | 0; if ($adtyp == 2) { $analyzer = new Analyzer($lid, $oid, $aid, $HTTP_REFERER); $analyzer->_record('top_banner', 3); } $_user = new User($_GLOBAL['TABLES']['USERS'], $oid, System::getDB()); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title ? $title : SITE_PAGE_TITLE; ?></title> <meta http-equiv="X-UA-Compatible" content="IE=8; IE=9" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="<?php echo SITE_LOCATION; ?>css/style.css.php?fly" /> <script type="text/javascript" src="<?php echo SITE_LOCATION; ?>js/jquery.min.js"></script> <script type="text/javascript" src="<?php echo SITE_LOCATION; ?>js/jquery.libs.js"></script> </head> <body style="background:#FFFFFF;"> <noscript> <div style="padding: 5px; background-color: red; color: #ffffff; text-align:center; margin-top: 10px; margin-bottom: 10px;"> Your browser currently does not support javascript or you have javascript turned off. This site will have very limited functionality without javascript. Please use a modern browser with javascript or enable the javascript option. </div> </noscript> <div class="fly_head" style="max-height:115px;"> <?php if ($adtyp == 2) { ?> <div class="logo" style="display:inline-block;font-weight:bold;margin:0;max-height:100px;"></div> <div class="fly_banner" style="margin:0 20px;display:inline-block;" align="center"> <a href="#"> <img src="<?php echo $AD['website_banner']; ?>" width="720px" height="90px" border="0" /> </a> </div> <div style="float:right;display:inline-block;margin:5px 0;width:100px;text-align:right;font-size:11px;"> <a href="#" class="close"><img src="<?php echo SITE_LOCATION; ?>images/close.png" border="0" /></a> <a href="#" style="font-weight:600;position:absolute;color:white;text-decoration:none;top:90px;right:20px;"> ADVERTISEMENT </a> </div> <?php } else { ?> <div class="logo" style="display:inline-block;font-weight:bold;margin:5px 0;max-height:115px;"></div> <div style="float:right;display:inline-block;margin:20px 0;"> Please wait...<span id="redirectin">1</span> </div> <?php } ?> <div style="clear:both;"></div> </div> <div class="fly_head_bottom"> <?php if ($adtyp != 2) { ?> <div style="display:inline-block;"> <a href="<?php echo SITE_LOCATION; ?>?r=<?php echo $oid; ?>" class="uc" target="_blank"><?php echo SITE_NAME; ?></a> shorten urls and earn money </div> <div style="float:right;display:inline-block;"> <a href="<?php echo SITE_LOCATION; ?>advertising.php" class="uc" target="_blank"> </a> </div> <?php } ?> <div style="clear:both;"></div> </div> <?php $src = $adtyp == 1 ? $AD['website_url'] : $url; echo "<iframe class='fly_frame' src='{$src}' scrolling='auto' frameborder='0' style='width:100%;'></iframe>"; ?> <script type="text/javascript"> <?php function get_js_03() { global $AD, $aid, $lid, $oid, $adtyp, $url, $HTTP_REFERER; ob_start(); ?> $(document).ready(function() { $('iframe.fly_frame').height($(document).height()-$('div.fly_head').height()-($('div.fly_head_bottom').height()*2)); }); $('iframe.fly_frame').ready(function() { <?php if ($adtyp == 1) { ?> var a0x1 = -2; var rr = function() { if (a0x1 < 0) { $.post('<?php echo SITE_LOCATION; ?>links/ajax.fly.php',{opt:'check_log',args:{lid:<?php echo $lid; ?>,oid:<?php echo $oid; ?>}}, function(r) { var j = eval('(' + r + ')'); if (j.message && a0x1 != -2) { clearInterval(si); var skip_ad = $('<div class="skip_btn"><a href="#">SKIP AD >></a></div>'); $('div.fly_head span#redirectin').parent().css('margin', '6px').html(skip_ad); skip_ad.click(function() { $.post('<?php echo SITE_LOCATION; ?>links/ajax.fly.php', {opt:'make_log',args:{aid:<?php echo $aid; ?>,lid:<?php echo $lid; ?>,oid:<?php echo $oid; ?>,ref: <?php echo "'{$HTTP_REFERER}'"; ?>}}, function(rr) { var jj = eval('(' + rr + ')'); if (jj.message && a0x1 != -2) { top.location.href = jj.message.url; } } ); skip_ad.html('Loading Page...'); }); } else { a0x1 = 0; } } ); } else { $('span#redirectin').text(a0x1--); } }; rr(); var si = setInterval(rr, 0); <?php } else { ?> $('div.fly_banner a').click(function() { $.post('<?php echo SITE_LOCATION; ?>links/ajax.fly.php',{opt:'click_log',args:{aid:<?php echo $aid; ?>,lid:<?php echo $lid; ?>,oid:<?php echo $oid; ?>,ref: <?php echo "'{$HTTP_REFERER}'"; ?>}}, function() { top.location.href = '<?php echo $AD['website_url']; ?>'; } ); }); $('div.fly_head a.close').click(function() { $('div.fly_head').remove(); $('div.fly_head_bottom').remove(); top.location.href = '<?php echo $url; ?>'; }); <?php } ?> }); <?php $c = ob_get_contents(); ob_end_clean(); return $c; } echo Utilities::JSPack(get_js_03()); ?> </script> <?php if ($ga = $_user->get('ga_code')) { ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '<?php echo $ga; ?>']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })(); </script> <?php } ?> </body> </html> ajax.fly.php <?php define('AJAX_FLY_PHP_INCLUDED', true); require_once '../global.php'; $OPT = $_GET['opt']; $POPT = $_POST['opt']; $RET = array('error' => false, 'message' => false); if ($POPT == 'check_log') { $lid = intval($_POST['args']['lid']); $oid = intval($_POST['args']['oid']); $vlo = SITE_SESSION_PREPEND . "view_{$lid}_{$oid}"; if ($lid > 0 && $oid >= 0) { $view_time = 0; $cookie = $_COOKIE[$vlo] | false; if ($cookie && $cookie > 0) { $view_time = gettimeofday(true) - $cookie; } else { setcookie($vlo, gettimeofday(true)); } if ($view_time > 0) $RET['message'] = array('url' => '#'); } } else if ($POPT == 'make_log') { $aid = intval($_POST['args']['aid']); $lid = intval($_POST['args']['lid']); $oid = intval($_POST['args']['oid']); $ref = mysql_escape_string(trim($_POST['args']['ref'])); $vlo = SITE_SESSION_PREPEND . "view_{$lid}_{$oid}"; $cookie = $_COOKIE[$vlo] | false; $view_time = $cookie && $cookie > 0 ? gettimeofday(true) - $cookie : 0; if ($view_time > 0) { require_once ROOT_PATH . '/inc/analyzer.class.php'; $analyzer = new Analyzer($lid, $oid, $aid, $ref); $adtype = System::getDB()->getField($_GLOBAL['TABLES']['LINKS'], 'adtype', "`id`='{$lid}'"); $analyzer->_record($adtype, $view_time - 0); setcookie($vlo, 0); $RET['message'] = array('url'=>System::getDB()->getField($_GLOBAL['TABLES']['LINKS'], 'long_url', "`id`='{$lid}'") ); } } else if ($POPT == 'click_log') { $aid = intval($_POST['args']['aid']); $lid = intval($_POST['args']['lid']); $oid = intval($_POST['args']['oid']); $ref = mysql_escape_string(trim($_POST['args']['ref'])); require_once ROOT_PATH . '/inc/analyzer.class.php'; $analyzer = new Analyzer($lid, $oid, $aid, $ref); $RET['message'] = $analyzer->_recordClick(); } die(json_encode($RET)); Se for mais fácil para quem me ajudar, falar por skype, aqui tem: elcardoso98 Precisava isto urgentemente para abrir o meu website. Obrigado por toda a ajuda.
Devexz Posted February 23, 2014 at 04:31 PM Report #546379 Posted February 23, 2014 at 04:31 PM o que tu pretendes fazer é de um género de url shortner. Se for isso é bastante simples de fazer: Terias a url Teusite.com/asdfasdf Depois ias buscar a parte asdfasdf que estaria relacionada com o verdadeiro url que estaria guardado na base de dados. A seguir era só fazer um header location com o php. Contador de calorias: caloriaspordia.com
Nestle Posted February 23, 2014 at 04:36 PM Author Report #546380 Posted February 23, 2014 at 04:36 PM o que tu pretendes fazer é de um género de url shortner. Se for isso é bastante simples de fazer: Terias a url Teusite.com/asdfasdf Depois ias buscar a parte asdfasdf que estaria relacionada com o verdadeiro url que estaria guardado na base de dados. A seguir era só fazer um header location com o php. Eu já tenho o URL Shortener feito. Quero é passa-lo para Paid to Promote.... Quero retirar o esperar 5 segundos e ser logo redirecionado, sem ser preciso de ir aquela tal página com ads.
Devexz Posted February 23, 2014 at 09:52 PM Report #546416 Posted February 23, 2014 at 09:52 PM então tens que dar mais detalhes sobre como é que estás a pensar fazer a parte dos ganhos. Contador de calorias: caloriaspordia.com
Nestle Posted February 24, 2014 at 07:56 PM Author Report #546521 Posted February 24, 2014 at 07:56 PM Resolvido. Agora só me falta por a ser obrigatório gerar links a partir só de um website.
I-NOZex Posted February 25, 2014 at 12:20 AM Report #546550 Posted February 25, 2014 at 12:20 AM sabes, a tua questão, outros a podem ter, por isso, posta a solução para se evitar futuros rePosts... B2R » Beat2Revolution v3.0b | Regista e divulga-nos beat2revolution.net
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now