PHP - Detecting Www.
I need a regular expression that detects a web address in a string of text.
I need it to find any http://www or www. web address. Any domain (.co.uk, .com anything) All these would be picked up: http://domain.com http://www.domain.com www.domain.com http://domain.co.uk http://www.domain.co.uk www.domain.co.uk Also, it must pick up all folders and other url variables (www.site.com/page1?a=123 etc.) ** Also, most importantly:*** It must NOT pick up web addresses that are inside a <a href="">xxx</a> link already, only oes that are plain text and not embedded in this HTML. I have tried but it only does bits of the above. I can do the PHP code, just need to know the regular expression to drop into my preg_match_all code. Thanks in advance. Similar TutorialsI've made a small chicken names website, and I also have a chicken name list as a thread on a chicken related forum. People submit their names, and I manually add them to the list. With the names growing so much, I decided to make a small background system that lets me put in the current list names, then the new names submitted. It will then run the lists, compare them, and spit out/ignore any duplicates and generate the new list. But each time I use it, it doesn't get rid of the duplicates. Can anyone tell me why? if($_GET['list_updater'] || $_POST['list_updater']) { if(!$_POST['current_list'] || !$_POST['new_names']) { ?> <table> <form action="index.php" method="POST"> <input type="hidden" name="list_updater" value="1"> <tr> <td> <textarea name="current_list" cols="40" rows="20"></textarea> </td> </tr> <tr> <td> <textarea name="new_names" cols="40" rows="20"></textarea> </td> </tr> <tr> <td><input type="submit" value="Generate New List"></td> </tr> </form> </table> <?php } else { //start our counting numbers $x = 0; $s = 0; $a = 0; //make our arrays $check_to[0]; $new[0]; //get the values from our lists $old_list = explode("\n",$_POST['current_list']); $new_list = explode("\n",$_POST['new_names']); //get new list variables foreach($old_list as $value) { $check_to[$x] = $value; $x++; } //add all our new names foreach($new_list as $value) { for($s = 0; $s < count($new_list); $s++) { } } ?> <textarea cols="45" rows="20"> <?php for($t = 0; $t < count($new); $t++) { echo $new[$t]; } ?> </textarea> <?php } } I have a scenario where users are downloading files from a legacy system and uploading the files into a new system that I am supporting. Many of the files do not have an extension (most are tiffs).
The issue we have is that the new system doesn't know how to open these files (we have them open in a preview window in the new system). I have tried numerous solutions, including finfo_file() and the depreciated mime_content_type() funcitons), but all they seem to return is "application/octet-stream".
Thanks.
I need to detect when a fatal error occurs in a shutdown function to ensure database records do no get hung up by a particular user when a coding modification goes south. error_get_last() is not on the menu with my PHP version 5.1.6. Can anyone suggest an alternative? Thanks How can i detect someone who is using proxy and has 2 or more accounts on my website?Or anyway, the important thing for me it is that they dont cheat because i have a competition and its forbidden to have 2 or more accounts.
I have a php script that detects the user's mobile phone and browser and some other stuff. To display this info, I use: <?php echo htmlentities($_SERVER['HTTP_USER_AGENT']); ?> But this outputs a lot more than I need. It outputs the handset, the browser, the version etc... like this: Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11B554a Safari/9537.53 Does anyone know what I need to change in the script just so I can have it display the handset name? All I want it to do is say something like "You have a Samsung Galaxy Note II" I have attached the mobile_detect script but I dont know what to edit because I don't really know php. Appreciate the help, JH Attached Files Mobile_Detect.php.zip 22.37KB 1 downloads Hey guy, I really need your help with this. I have Input from a text area, in this format: a b c d e f g 12 34 435 124 What I need do to is to output only a certain line from every block of text, every block is divided by one or more empty lines. I have done this: $input = $_POST["input"]; $lines = explode("\r",$input); $num = count($lines); $line_to_extract = $_POST['line_to_extract']; for($i=0;$i<$num;$i++) { if($i == $line_to_extract) { echo 'Line '.$i.': '.$lines[$i].'<br />'; } } What I need to do is to detect the empty line so I can keep track of the line to extract. PLEASE HELP!!! Hi,
I`m currently generating spam via my own mailserver, its not much, but some of my clients receive messages that the messages they send could not be delivered. ( They are probably not snding them, but some script on one of the many websites is).
Problem is that i`m currently unable to figure out which one of the websites is generating this spam. There are about 150 websites on this server.
Some have old wordpress versions on them because the clients don`t ever update them.
I`ve looked into adding a line in php.ini which should log all mails.
mail.add_x_header = On mail.log="E:\logs\phpmail\php-mail-errors.log" However this file keeps on being 0 bytes . Also if i generate a mail via a contact form which i made but the log is not showing it. The mail gets picked up by the mail servers, so the script does work. I`ve also checked that the php version is 5.0 or higher because otherwise the lines i added to the php.in would not be accepted by a earlier version then 5.0. The last I`ve done is changed the rights to the log file to writetable for the iis user, perhaps thats whats needed for the lines inh php to work. Has anyone any experiende with this issue ? I inherrited a site that has PHP code that decides to either serve the dedicated mobile site or desktop site to the user. I would prefer that tablets get served the mobile site. Currently Android tablet users get served the desktop site. I'd like to figure out how I can implement User Agent to detect an android tablet (with distinction from an Android phone) This is the code I'm working with to determine which site to serve (mobile or desktop) Thanks if ((strpos($user_agent, 'Mobile') === false && // Generic mobile browser string, most browsers have it. strpos($user_agent, 'SymbianOS') === false && // Nokia device running Symbian OS. strpos($user_agent, 'Opera M') === false && // Opera Mini or Opera Mobile. strpos($user_agent, 'Android') === false && // Android devices that don't have 'Mobile' in UA string. stripos($user_agent, 'HTC_') === false && // HTC devices that don't have 'Mobile' nor 'Android' in UA string. Case insensitive. strpos($user_agent, 'Fennec/') === false && // Firefox mobile strpos($user_agent, 'Kindle') === false && // Kindle Fire tablet strpos($user_agent, 'BlackBerry') === false) || // BlackBerry strpos($user_agent, 'iPad') === false) // iPad { // Serve Desktop Site return false; } I have a string of mixed Japanese or Chinese and Western characters and I would really like to leave the western characters and remove the others. Is there any way to detect which UTF-8 characters are Japanese/Chinese and to remove them? I have tried to use this which I found on another thread but my version of PHP (5.3) will not allow the /u in the following Code: [Select] echo "<BR>".preg_replace('/[^\u4E00-\u9FFF]+/', '', $string); I have tried using various combinations of /p (these, plus others) Code: [Select] echo "<BR>".preg_replace('/\p{Bopomofo}+/u', '', $string); echo "<BR>".preg_replace('/\p{Hiragana}+/u', '', $string); and the /x{} option tells me the numbers are to large Code: [Select] echo "<BR>".preg_replace('/[^\x{4E00}-\x{9FFF}]+/', '', $string); My string for this example is this but any combination of western and Japanese/Chinese characters are possible in the title. 2011.12.06 19:00-20:00 / ふくいちライブカメラ (Live Fukushima Nuclear Plant Cam) | Uploaded: 06 Dec 2011 Thanks for any help. Im trying to figure out, for my website, how to determine that page that a visitor is on so I can set the page title. I created an array (thinking that is what would be needed, not sure) Code: [Select] $pagetitle[0] = "Home"; $pagetitle[1] = "Links"; and so on for the different pages. My hope was to use an echo statement to create a title with a page name Code: [Select] <?php echo "$sitename - $pagetitle"; ?> Where my severe inexperience is getting me is how to code the php so that it knows what page it is on and then go through the array to get the appropriate page name. I may be doing this completely wrong from the start as far as method is concerned, so Im open to any ideas. i'm running code on what i only want to be the HOME page, but the current site it built using GET variables with index.php needless to say, the home page is accessed either as domain.com/ or domain.com/index.php - i'm hoping someone can show me how to check for this condition, that it is only index.php without anything further I'm only slightly familiar with $_SERVER['uri'], etc... So i don't know just what to ask. thanks for anyone's help. Glenn |