PHP - Need Help To Find What Keywords Got Me Traffic On Google.
Ok, first let me tell you what I want to do. Google sends me traffic from many keywords, but I want to track what keyword does best for me as sales and so. The Analytics is good but I can't send the data to outside sites. So I figured this out : from the $_SERVER['HTTP_REFERER'] I can get the "q" value from the _GET and pass it on to track it... now I'm kind of stuck and I know it's easy but can't seem to find the function.
This is what I have so far: /* Code to try and store the keyword that was used to find and land on my site. */ $exurl = 'http://www.google.ca/url?sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ'; //set a demo refferer url that would usually be $exurl = $_SERVER['HTTP_REFERER'] $refurl = parse_url($exurl, PHP_URL_QUERY); // remove all before and including the "?" echo $refurl; // echo "sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ" Ok, so I managed to get the important part out of the google URL, now how do I split this into an array that I can then use. For instance somefunction($refurl, $newarray); and then I could say | echo $newarray['q']; | and it would echo "mykeyword" Of course If there is a space in the keywords I should use the urldecode() function to avoid the % char... Let me know if you know of any way to get this done. Similar TutorialsHere's a neat little script that you simply use by calling yourscript.php?microsoft (where microsoft is any keyword you want) and it returns 100 related keywords. It's pretty raw in it's form. I didn't write it. Purely for learning, I'm trying to figure out how to 1) issue a line break between each item in the elements of the arry? 2) return only the keywords and not the associated array info. Currently, it returns results like: Array ( => microsoft [1] => microsoft security essentials [2] => microsoft office [3] => microsoft templates [4] => microsoft updates [5] => microsoft silverlight [6] => microsoft word [7] => microsoft money [8] => microsoft office 2010 [9] => microsoft clip art [10] => microsoft [11] => microsoft security essentials [12] => microsoft office [13] => microsoft templates [14] => microsoft updates [15] => microsoft silverlight [16] => microsoft word [17] => microsoft money [18] => microsoft office 2010 [19] => microsoft clip art [20] => microsoft security essentials [21] => microsoft security essentials review [22] => microsoft security essentials alert [23] => microsoft security essentials update [24] => microsoft security essentials 2.0 I'm wanting to know how to make it return results like... microsoft microsoft security essential microsoft office microsoft templates etc.... Code: [Select] <?php function text_between($start,$end,$string) { if ($start != '') {$temp = explode($start,$string,2);} else {$temp = array('',$string);} $temp = explode($end,$temp[1],2); return $temp[0]; } function gsscrape($keyword) { $keyword=str_replace(" ","+",$keyword); global $kw; $data=file_get_contents('http://clients1.google.com/complete/search?hl=en&q='.$keyword); $data=explode('[',$data,3); $data=explode('],[',$data[2]); foreach($data as $temp) { $kw[]= text_between('"','"',$temp); } } #simple to use, just use yourscriptname.php?keywords if ($_SERVER['QUERY_STRING']!='') { gsscrape($_SERVER['QUERY_STRING']); foreach ($kw as $keyword) { gsscrape($keyword); } #all results are in array $kw... print_r($kw); } ?> hi i need some help . i see some person use bot traffic or proxey taffic software or script like jiggling and hitleap . they give a url of any sites then this software proxey view this websites.. i want asked can it possible stop these bot traffic its any procedure in php or javascript to stop this traffic..
I would like to be able to detect, for instance, people who are using the TOR browser when they attempt to log in to one of my sites. my traffic report globals can already tell me if they are coming from a TOR node, but I would like to reject a login if an onion system or an anonymity browser is being used. I have only ran into one other site that has the capability of doing this, in terms of talking about forums only, and that is MrExcel: https://www.mrexcel.com/board/ if you try to register an account there with TOR, the page renders and says “we have detected you are trying to use automated queries to register an account”. there are of course, ways to get around that, if you click buttons in a timely manner, so they are not that good. but regardless, the pre-packaged software they bought does the job fairly well. can anyone offer any help in this regard? I know for a fact that most of the big banks in the USA have this covered, so I know that technology exists to block traffic coming from these sources, but I don’t know if it’s available to the little guy like me. Hi, Is it possible to make some kind of network/web traffic sniffer than can give you stats on how much p2p, mail etc etc traffic is going out your router? If so, does anyone know of any tutorials on the subject? Hi Guys I need a PHP function to which I pass two postcodes and it works out the road distance, I dont mind using google or any other API I have managed to fing JS ways and php functions using crow route but I really really need a traffic distance in PHP Please advice, Help Thank you How can I make my PHP script non accessible to users? I am wanting to cron the script and don't want anybody to spam the script as it would cause performance issues if it was constantly spammed by a user. Can I put the PHP file anywhere that only the server can run it?
Thanks any info would be awesome.
Hi;
I have succesfully managed to route all the traffic to the file controller.php using this command line of .htaccess :
RewriteEngine On RewriteRule (.*) /var/www/html/site/controller.php [L,QSA]Now how to tell the controller.php to process the url that was passed. For example i have tried that: controller.php : <?php include( $_SERVER["REQUEST_URI"] ); ?>but the controller.php didn't do anything i keep getting a blank page when i browse any webpage such as site/index.php so how to tell controller.php to echo the content of the request ? because the user shouldn't notice any change as if there is no controller.php. Thank you. I currently have three tables Domains Keywords Words In words I would have Sport Football Rugby And allocate them to the domain in keywords, but say I wanted Rugby League, would I have an entry in words as Rugby League or two seperate entries rugby and league? And how would i combine them in the keywords table? Keywords_id Keywords_domain Keywords_word Thanks Hi is it possible to take a list of keywords like (web design, oldham web design) and compare it to a large amount of text and output how many times the keywords appear? Hi, im new to the forum and also to php, ive had a look through the tutorials and various threads but cant seem to find what im after. im created a simply image gallery that auto creates my thumbnails and allows for editing the image with gdlibrary etc all very good here. I recently decided to start work on the image keyword tagging so i could carry out searches etc on my very large image collection. i created the usual 3 table setup as im going to have a many to many relationship, so i have my "images" table, "keywords" table and a "img_key" table to link them together. As i understand it this would seem like the best setup for what i want to achieve, if not would someone be able to advise what i should be doing to get better results. Ok so the main problem i have now is that i want to show a series of check boxes underneath each image that gets selected so i can start tagging the uploaded images, to do this i used "select * from keywords" which gave me all keywords available - which is what i want...... However, i now want to somehow add to this so that once the page loads it knows which keywords have already been selected and ticks the relevant boxes automatically, as I have an sql update statement linked to the tickboxes/submit button i want to ensure i dont forget to re-tick any boxes So in a nutshell i need help with displaying all keywords each as a tickbox and if they have already been linked in my 'img_key' link table then they will tick the related tick box automatically , depending on what i need to change im guessing i may need to revise my updating of mysql ? ive been struggling with this silly problem now for a few weeks so im desperate for some assistance Hello, I'm working on a file upload/download setup. I want the MySQL table to be arranged like so: id----int(11)----primary key Filename----varchar(30) Keyword1----varchar(30) Keyword2----varchar(30) Description----text DateAdded----timestampCURRENT_TIMESTAMP Type----varchar(30) Size----int(11) Content----mediumblob My question is; Is there a way to make the users select their keywords from a predetermined list (i.e. a dropdown menu) rather than letting them just punch in whatever keywords they want? Folks, I want to extract the keywords Only form the below Script's output: <?php $keywords = file_get_contents('http://suggestqueries.google.com/complete/search?hl=en&gl=us&ds=pr&client=products&hjson=t&jsonp=ac_hr&q=paintball&cp=2'); //$keywords = json_decode($keywords); print_r($keywords); ?> Output is: ac_hr(["paintball",[["paintballs","","0"],["paintball sniper","","1"],["paintball mask","","2"],["paintball vest","","3"],["paintball pants","","4"],["paintball bunkers","","5"],["paintball markers","","6"],["paintball chronograph","","7"],["paintball bow","","8"],["paintball helmets","","9"]],"","","","","",{}]) How to extract the keywords Only in an Array?? Cheers Natasha T Ok, so first, I'm a little more experienced than a newb, but far from an expert. And I'm fairly certain when yall help me through this I'm going to bang my head on the desk and chastize myself for not thinking of it. So here we go. I'm attempting to use some examples I found on php.net for the iptc embed & iptcparse functions. What I've done is taken a class file that was posted (just a collection of the snippets), corrected it for the most part to function how it should. It will read the IPTC data from a jpg just fine. It'll even write to the IPTC fields. The problem comes with the IPTC_KEYWORDS field. That field needs to be an array and I can't get it to write properly. Right now the only thing it's writing is the word "array". Also, I'm a bit confused as to what one of the functions is trying to do and I think it's the function that's causing the mess. Below are the classfile and then the test file making the call. Code: [Select] <? /* Examples taken from php.net */ DEFINE('IPTC_OBJECT_NAME', '005'); DEFINE('IPTC_EDIT_STATUS', '007'); DEFINE('IPTC_PRIORITY', '010'); DEFINE('IPTC_CATEGORY', '015'); DEFINE('IPTC_SUPPLEMENTAL_CATEGORY', '020'); DEFINE('IPTC_FIXTURE_IDENTIFIER', '022'); DEFINE('IPTC_KEYWORDS', '025'); DEFINE('IPTC_RELEASE_DATE', '030'); DEFINE('IPTC_RELEASE_TIME', '035'); DEFINE('IPTC_SPECIAL_INSTRUCTIONS', '040'); DEFINE('IPTC_REFERENCE_SERVICE', '045'); DEFINE('IPTC_REFERENCE_DATE', '047'); DEFINE('IPTC_REFERENCE_NUMBER', '050'); DEFINE('IPTC_CREATED_DATE', '055'); DEFINE('IPTC_CREATED_TIME', '060'); DEFINE('IPTC_ORIGINATING_PROGRAM', '065'); DEFINE('IPTC_PROGRAM_VERSION', '070'); DEFINE('IPTC_OBJECT_CYCLE', '075'); DEFINE('IPTC_BYLINE', '080'); DEFINE('IPTC_BYLINE_TITLE', '085'); DEFINE('IPTC_CITY', '090'); DEFINE('IPTC_PROVINCE_STATE', '095'); DEFINE('IPTC_COUNTRY_CODE', '100'); DEFINE('IPTC_COUNTRY', '101'); DEFINE('IPTC_ORIGINAL_TRANSMISSION_REFERENCE', '103'); DEFINE('IPTC_HEADLINE', '105'); DEFINE('IPTC_CREDIT', '110'); DEFINE('IPTC_SOURCE', '115'); DEFINE('IPTC_COPYRIGHT_STRING', '116'); DEFINE('IPTC_CAPTION', '120'); DEFINE('IPTC_LOCAL_CAPTION', '121'); class iptc { var $meta=Array(); var $hasmeta=false; var $file=false; function iptc($filename) { echo 'IPTC Loading for: '.$filename.'<br />'; $size = getimagesize($filename,$info); $this->hasmeta = isset($info["APP13"]); if($this->hasmeta) $this->meta = iptcparse($info["APP13"]); $this->file = $filename; } function set($tag, $data) { echo 'Updating IPTC Tag.<br />'; $this->meta ["2#$tag"]= Array( $data ); $this->hasmeta=true; } function get($tag) { echo 'Getting IPTC data.<br />'; return isset($this->meta["2#$tag"]) ? $this->meta["2#$tag"][0] : false; } function view() { echo 'Print IPTC Data.<br />'; foreach(array_keys($this->meta) as $s) { $c = count ($this->meta[$s]); for ($i=0; $i <$c; $i++) { echo $s.' = '.$this->meta[$s][$i].'<br />'; } } } function binary() { echo 'Setting new binary block for IPTC writing.<br />'; $iptc_new = ''; foreach (array_keys($this->meta) as $s) { $c = count ($this->meta[$s]); for ($i=0; $i <$c; $i++) { $tag = str_replace("2#", "", $s); $iptc_new .= $this->iptc_maketag(2, $tag, $this->meta[$s][$i]); } } return $iptc_new; } function iptc_maketag($rec,$dat,$val) { echo 'Making IPTC Tag<br />'; $len = strlen($val); if ($len < 0x8000) { return chr(0x1c).chr($rec).chr($dat). chr($len >> 8). chr($len & 0xff). $val; } else { return chr(0x1c).chr($rec).chr($dat). chr(0x80).chr(0x04). chr(($len >> 24) & 0xff). chr(($len >> 16) & 0xff). chr(($len >> 8 ) & 0xff). chr(($len ) & 0xff). $val; } } function write() { echo 'Writing file...<br />'; if(!function_exists('iptcembed')) return false; $mode = 0; $content = iptcembed($this->binary(), $this->file, $mode); $filename = $this->file; @unlink($filename); #delete if exists $fp = fopen($filename, "w"); fwrite($fp, $content); fclose($fp); } #requires GD library installed function removeAllTags() { 'Removing previous IPTC tags to re-write new data.<br />'; $this->hasmeta=false; $this->meta=Array(); $img = imagecreatefromstring(implode(file($this->file))); @unlink($this->file); #delete if exists imagejpeg($img,$this->file,100); } }; ?> And here's the test-call: Code: [Select] <?php require_once("iptceasy.php"); $i = new iptc("fortworden.jpg"); $keywords = array( "keywords" => "updatedkey1", "updatedkey2", "updatedkey3" , "updatedkey4" ); echo $i->set(IPTC_KEYWORDS, $keywords); $i->write(); echo 'Done.'; ?> If I try to set any of the other IPTC fields with a string, the functions work fine. I'm fairly certain the error is either in the set() function or the iptc_maketag() function. And the iptc_maketag() function is the one I'm stumped about. Is that binary that it's prepending to the data? Thanks for any light you can shed and help you can give on this in advance! -Mike Friends, Requirement: I want to Extract the Keywords from All the Search Engine Referer URLs and save all the keywords in an Array so i can Echo/show all the "popular Terms" which drive traffic to my Site from Search Engines. I already have the Code for Extracting the Keyword from URL, can someone tell me how can i save the $keyword in an array that whenever i visit my site, i can see that What all keywords brought visitors to my site from Search Engines? Code to Extract Keywords from URL: <? $referrer = $_SERVER['HTTP_REFERER']; $referrer ='http://www.google.co.id/search?hl=id&client=firefox-a&hs=IKn&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&q=pemahaman+pelajaran+ips+tentang+endogen+dan+eksogen&aq=f&aqi=&aql=&oq=&gs_rfai='; $referrer_query = parse_url($referrer); $referrer_host = $referrer_query['host']; $referrer_query = $referrer_query['query']; $q = "[q|p|qkw|key|query|searchfor|Keywords|searchterm]"; //Yahoo uses both query strings, I am using switch() for each search engine preg_match('/'.$q.'=(.*?)&/',$referrer,$keyword); $keyword = urldecode($keyword[1]); $potongnya = array('&q=','&p=','key=','query=','searchfor=','Keywords=','searchterm='); $referrer_query = str_replace($potongnya, "&|pencarian=", $referrer_query); $arr = explode("&", "$referrer_query"); for($k = 0, $l = count($arr); $k < $l; ++$k) { $ygdicari = "$arr[$k]"; $findmeyach = "|pencarian="; $posnyaaa = strpos($ygdicari, $findmeyach); if ($posnyaaa === false) {} else { $keyword = str_replace('|pencarian=', "", $ygdicari); $potongkeynya = array('+','%20'); $keyword = str_replace($potongkeynya, " ", $keyword); } } if ($keyword=="") { $potongnya = array('q=','p='); $referrer_query = str_replace($potongnya, "&|pencarian=", $referrer_query); $arr = explode("&", "$referrer_query"); for($k = 0, $l = count($arr); $k < $l; ++$k) { $ygdicari = "$arr[$k]"; $findmeyach = "|pencarian="; $posnyaaa = strpos($ygdicari, $findmeyach); if ($posnyaaa === false) {} else { $keyword = str_replace('|pencarian=', "", $ygdicari); $potongkeynya = array('+','%20'); $keyword = str_replace($potongkeynya, " ", $keyword); } } } $keyword = strtolower($keyword); $urikeyword = array('sex ','porn ','porno',', ','penis ','penis ','http://www.','http://','http','gamble','"',"'"); $keyword = str_replace($urikeyword, "", "$keyword"); echo "$keyword"; exit; ?> Many Thanks Natasha T hi there - first attempt at programming in PHP so please bear with my novice attempts (not much programming experience in any languege really) i am building a site which hosts mp3s. I have MySQL database with one of the fields contating descriptive keywords for the tracks (such as slow, chilled, intense etc) i have created an html page with search form that send data to php file which runs a query of the keywords field - and all works fine now i want that in addition to the search form (with an input text box for the search criteria and the submit button) i will have a 'cloud' of key words - clickable links - that will send the data to the PHP query file (clicking on slow will search for tracks described with 'slow' and so on) - any ideas how do send data by clicking on a link? my html form is: Code: [Select] <body bgcolor="white"> <form action="test3.php" target="main" method="post"> <input type="text" name="searchkeywords" size=100><br> <input type="submit" value="Search"> <input name="searchkeywords" value="slow" type="submit"> </form> <DIV align="center" style="left : 240px; position : absolute; top : 100px;"><iframe src ="test3.php" width="1000" height="800" name="main" frameborder="2" scrolling="no"> <p>Your browser does not support iframes.</p> </iframe></DIV> </body> my php query file is: Code: [Select] <?php $con = mysql_connect("localhost","root","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $result = mysql_query("SELECT * FROM music WHERE keywords LIKE '%$_POST[searchkeywords]%'"); $txt1='<A HREF="/audioplayer-standalone/'; $txt2='" ><IMG src="images/misc_23.png" width="32" height="32" align="left" border="0"></A>'; $txt3='<script language="JavaScript" src="/audioplayer-standalone/audio-player.js"></script><object type="application/x-shockwave-flash" data="/audioplayer-standalone/player.swf" id="audioplayer'; $txt4='" height="24" width="290"><param name="movie" value="/audioplayer-standalone/player.swf"><param name="FlashVars" value="playerID=audioplayer'; $txt5='&soundFile=/audioplayer-standalone/'; $txt6='"><param name="quality" value="high"><param name="menu" value="false"><param name="wmode" value="transparent"> </object>'; echo "<table border='1'> <tr> <th width='220' align='left'>Track Name</th> <th width='220' align='left'>Artist</th> <th width='220' align='left'>Description</th> <th></th> <th></th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['track'] . "</td>"; echo "<td>" . $row['artist'] . "</td>"; echo "<td>" . $row['description'] . "</td>"; echo "<td>" . $txt1.$row['filename'].$txt2 . "</td>"; echo "<td>" . $txt3.$row['id'].$txt4.$row['id'].$txt5.$row['filename'].$txt6 ."</td>"; echo "</tr>"; } echo "</table>"; // some code mysql_close($con); ?> I'm looking to know the best way to process a search query that has multiple words in the search: Code: [Select] elseif(isset($_GET['search'])){ $search=$_GET['search']; $keyword=explode(" ",$search); //database query } Should I do a while loop query the database for each keyword? Hello i am making a page that shows the description title etc of a page and shows some other info's.... I Came across the script from this page and i was wondering how well is it wroted Dos anyone know a shorter script that dos that functions? I have a php line like: echo "<p><b>Tags: </b>" . $row['tags'] . "</p>";
it looks like this on web page: how do i add hyperlink to each keyword like: Tags: <a href='category/keyword1'>keyword1</a>, <a href='category/keyword2'>keyword2</a>, <a href='category/keyword3'>keyword3</a>,...
I am trying to make a form search through user input, and link it up with existing data in the database. so if in the text field, the person puts " flowers, red roses, white roses, daisies, sunflowers, cars" then they press "submit" the code then runs sql to search the database with matching terms. So that if the terms in the database field row are things->DBentry1->flowers, trucks, cars, red roses, things->DBentry2->dogs, cats, flowers it will echo out " 2 entries have matches "entry 1 has flowers, cars and red roses" "entry 2 has flowers" I want the results to be in order of number of matches returned for that database entry. it will skip "trucks because trucks was not entered and so did not match., Basically I want the search form to let the user put the terms in separated by a comma and a space or without a space, and then php and mysql find the matching terms, then echo out the results in matching order from most to least. I know that is a lot to ask of you all, but I would appreciate any help. Thanks in advance. how should i approach this with preg_match? i have a text: "big red apple" now i want the script to create a href for each keyword apple and link to http://apple.com examples appreciated |