-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
If you want the detection code look at http://detectmobilebrowsers.mobi/
-
You would have something along the lines of the following run in a common include of all pages of your site. The function would have to be completed by yourself aswell as the setting cookies, etc, that is fairly straightforward <?php function isMobileDevice($agent) { // detect a mobile device if() { // is a mobile device return true; } // isnt a mobile device return false; } if(isMobileDevice($_SERVER['HTTP_USER_AGENT'])) { if(!strlen($_COOKIE['agentpref'])) { // redirect user to make a choice of which site to view header("Location:site-choice.php"); exit(); } else { // redirect to mobile site if($_COOKIE['agentpref'] == 'mobile') { header("Location:http://mobile.xyz.com"); exit(); } } } ?>
-
Using mod rewrite for redirection is fine. It doesn't matter where you place the lines in your htaccess file! I would post them on the mod rewrite forum board if they are not working correctly. The main disadvantage of using a rewrite rule is that a mobile user will always be redirected whether they wish to or not. If I was using an iPhone I may still want to view your main website rather than a cutdown mobile version. Using a php script to handle the redirection you would be able to offer users the choice of which site to view. i.e 1. Detect user agent 2. If mobile device and no preference cookie is set redirect user to choice screen 3. If user wants to be on mobile site or main site set a cookie for this option 4. Redirect user 5. If cookie is set to mobile and user lands on main website then redirect
-
When using php functions you must check what the return value of the fuction is! You have added the str_replace function but not stored its return value str_replace('\"',"", strip_tags($str)); should be // remove any " from $str also strip any HTML tags $str = str_replace('"',"", strip_tags($str));
-
Got one http://www.webidsupport.com/ Anyone used this?
-
Prior to any insert strip them out! $name = 'Joe "idiot" Bloggs"; $name = str_replace('"',"", strip_tags($name)); I would run a replace command on your database to get rid of them. If you cannot then convert them into their html entity before displaying in a text field. <input type="text" name="name" value="<?php print htmlentities($res['StudentName']); ?>" />
-
LOL! Like I said I could build the whole thing from scratch, but why? I won't be learning anything new, just spending more time on mundane parts when I could rip the logic out of another and fit it into my own code structure. Don't want to re-invent the wheel as such. Just thought people may have downloaded an ebay clone that has worked successfully for them. Currently I can only find crap. Dont mind paying a small amount i.e $100 or whatever as long as the source code is not encrypted. CMS crap. Not getting involved with that.
-
no. i do not understand. affiliate ad code is fixed into your template. if you wanted to randomise between different ads then simply store the javascript code in different include files. i.e ad1.js ad2.js ad3.js To make it pick a random ad: <script language="javascript" src="ad<?php print rand(1,3); ?>.js"></script>
-
Probably because the name contains a " and is causing a textfield to cut short in its value param. Remove quotes from a person's name. Nobody should have a quote in their name!
-
There are no tutorials. The code should be provided by whoever your ads are generated by!
-
<?php $res['StudentName'] = 'Testy "Mc" Testerson'; $nameParts = explode(" ", $res['StudentName']); // you can view the parts of the name using print_r // print_r($nameParts); for($x = 0; $x < count($nameParts)-1; $x++) { $firstname .= clean($nameParts[$x]); } $lastname = clean($nameParts[count($nameParts)-1]); print $firstname." ".$lastname; ?>
-
If the ads are served from a 3rd party server then they will have to be requested on each page load. Pages serving lots of ads will generally be slow. I don't know why your would request ads using php. They are usually javascript. If so you can include the ad code to be loaded after the HTML is sent to the browser. The server where the ads are requested from maybe busy therefore slowing your page load also. Other things that can slow down a page are heavy database queries or poor code.
-
In what case can I increment value of i without using loops ?
JonnoTheDev replied to linux1880's topic in PHP Coding Help
eh? <?php $i = 0; $i++; // will print 1 print $i; ?> -
substr(clean($res['StudentName']),0,strrpos($res['StudentName'],' ')); Nothing as it is not assigned to a variable! However your function will return a string that is safe to use in a database query <?php $res['StudentName'] = "Joe Bloggs"; // Will store 'Joe' in $firstname $firstname = substr(clean($res['StudentName']),0,strrpos($res['StudentName'],' ')); // insert into database $result = mysql_query("INSERT INTO students SET firstname='".$firstname."'"); ?> Also using the substr() function is not the best way to split the students name into parts
-
Anyone got any links for a decent FREE ebay style auction script that they have used successfully? The ones i've found are crap. Can't be arsed building from scratch myself so need to tear an existing one to pieces.
-
CentOS. Mostly familiar with Redhat type distros.
-
No. It is basic SEO. Links drive traffic.
-
How best to store dates for future calculations?
JonnoTheDev replied to dmccabe's topic in MySQL Help
Store them using a DATE field. If you also require the time use a DATETIME. These field types make it much easier to write SQL to produce your reports allowing you to group by dates, etc. If you were to use a unix timestamp then querying is more difficult as you have to convert the timestamp back to date with FROM_TIMESTAMP. Dates will be formatted YYYY-MM-DD however it is so easy to convert them to UK format using your application code. -
To have something iterate x number of times you use a loop construct i.e <?php $numberOfTimes = 3; for($x = 1; $x <= $numberOfTimes; $x++) { print "loop number ".$x."<br />"; } ?>
-
Here is a start. You can change the values in the variables accordingly. What you should do is convert into a function so you can make multiple calls i.e first call is login page. If login is successful second call is calendar page, etc.. You should have a param so you can switch between HTTP methods such as POST & GET. If you are completing a form then the usual method is POST. To request a page the usual method is GET. <?php $ch = curl_init(); # where the key is the field name $postData = array('username' => 'foo', 'password' => 'bar'); # Convert data array into a query string (ie animal=dog&sport=baseball) foreach($dataArray as $key => $value) { if(strlen(trim($value)) > 0) { $value = is_array($value) ? $value : urlencode($value); $tempString[] = $key . "=" . $value; } else { $tempString[] = $key; } } $queryString = join('&', $tempString); curl_setopt($ch, CURLOPT_POSTFIELDS, $queryString); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_NOBODY, FALSE); $cookiePath = '/tmp/cookies.txt'; curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath); curl_setopt($ch, CURLOPT_TIMEOUT, 60); # add browser user agent $userAgent = 'CURL BOT'; curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); # target url & referer $target = 'http://www.xyz.com/login'; $referer = 'http://www.xyz.com'; curl_setopt($ch, CURLOPT_URL, $target); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); # Create return array $returnArray['FILE'] = curl_exec($ch); $returnArray['STATUS'] = curl_getinfo($ch); $returnArray['ERROR'] = curl_error($ch); curl_close($ch); if(!strlen($returnArray['ERROR'])) { // move onto the next page } ?>
-
You need to include mail headers. Look at the examples on http://uk.php.net/manual/en/function.mail.php
-
track website search engine placement by keyword?
JonnoTheDev replied to michaellunsford's topic in Miscellaneous
Oh lordy, how I wish there was. Google stopped the use of their API. Google Analytics will not do what you require. Join the club and suffer the pain of scraping Google rankings. This is going to take some work by the way. Google has many template layouts and is always adding new features to its SERPS. Also look at datacenter addresses as opposed to the standard google.com/.co.uk etc. Do not attempt without proxies, you will get banned! Suggest registering with one of the blackhat forums to get some ideas. Wish I could offer more help but people will be reluctant as tools that do this job effectively are worth their weight in gold. The filtered results are not a true representation of rankings. -
You can also create a google xml sitemap and submit it within the webmaster tools.