Jump to content

lynxus

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Everything posted by lynxus

  1. Hi Guys, I have two values. 1) Number of users connected. ( Ex: 3456 ) 2) Number of users configured. ( Ex: 4100 ) How can I show this as a percentage. Ie: there are X% users connected. ( A percentage of the total configured ) Now, my maths is normally good but i just dont trust my workings lol. Ive been doing : $percent = $connected / $configured * 100; Thanks L
  2. Hi Guys, I currently have a method of getting a users attention by injecting a flash file in an ajax response and placing it in a div. However, Newer security measures from browsers mean that the file doesnt play on certain versions of certain browsers.. Anyway. Is there another method of achieving this? I see that facebook play a sound when a new message comes in, so it must be possible? ( Html5? ) Essentially I need a website (javascript?) to query playsound.php If playsound.php responds with "1" ( ie it just replies with an output of 1 ) then id like it to play a sound. I would then use a JS timer to run the ajax query every so often to check if it needs to play a sound. Does anyone have any ideas on how I can do this? As it appears my original method of using ajax to fill a div with a flash element is fastly becoming outdated. Thanks in advance Graham
  3. Try putting some id's in the form.. <form action ="reply.php" id="myForm" method="post" > Name: <input type="text" name="name" id="name" size="25" maxlength="50" /> <br> </br> Description: <textarea name="editor1" id="editor1"> </textarea> <input type="submit" value="Submit" /> </form>
  4. Although, I personally didnt use message1 and message2.... The below should work anyway without the need to generate new strings.: $message = preg_replace("/(?<!href=\")((https?:\/\/)(www\.|ftp\.)?[\w\-]+\.[^\s\<]+)(?!\")/ism", "<a href=\"\\1\" target=\"_blank\">\\1</a>", $message); $message = preg_replace("/(?<!http:\/\/)(?<!https:\/\/)((www|ftp)\.[\w\-]+\.[^\s\<]+)(?!\")/ism", "<a href=\"http://\\1\" target=\"_blank\">\\1</a>", $message);
  5. Good times. Thanks muchly. Been trying to learn regex and my brain hurts lol.. Getting there though
  6. Hi, Thanks for taking a look again.. yeah google.com etc dont worry about ( as long as it starts with www. or http:// or ftp. ) is good enough for me. I only put that in the $message as a test to see what your regex did
  7. Thanks very much for your reply. It doesn't seem to do anything? ( it doesn't seem to replace anything and no errors in logs.. ) <html><body> <?php $message = "Why not visit www.google.com or google.com or http://www.google.com or http://google.com or www.google.co.uk or http://google.co.uk "; $message = preg_replace("/^(?<!href=\")(https?:\/\/)?((www|ftp)\.[\w\-]+\.[^\s\<]+)(?!\")/ism", "<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $message); echo $message; ?> </body> </html>
  8. Hi Guys, I have the following code that uses ereg however im useless when it comes to regex so I dont know how to move to preg .. Essentially, It takes a string and makes a URL "clickable" ie: if it finds a link like http://www.google.com it would change http://www.google.com to a proper html href Could someone help convert this to preg so my code is more compatible with newer version of PHP.. Thanks muchly in advance. Graham $message = "Have you seen google? http://www.google.com "; $message = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]"," :link: <a title=\"Click to open in a new window\" alt=\"Click to open in a new window\" target=\"blank\" href=\"\\0\">\\0</a>", $message);
  9. Hi Guys, I have the following code. I have a div named data that gets filled in by the data from data.php How can i get it so it ONLY updates that div when the data is different as currently it doesnt. It seems to update even though its the same ( If i have something selected in teh div, it will de-select when it updates ( although the html is the same )) Thanks in advance. <script language="javascript" type="text/javascript"> <!-- function getdata() { $(document).ready(function(){ $.get("data.php", function(result){ if(result != $("#data").html()) { $("#data").html(result); } }); }); } //--> var timer = null; timer = setInterval('getdata()', 2000); </script>
  10. Ah ha, perfect.. ( Couldn't find that page anywhere ) Thanks again. -G
  11. Is there a list of what can be put into this field: $myDateTime->setTimezone(new DateTimeZone('America/New_York')); I cant seem to find a definitive one
  12. As promised, I tried it and it works perfectly. Thanks very much. -Graham
  13. Cheers man, Ill give it a try in the morning and let yall know.
  14. None currently ( Im assuming the data is correct in the DB ) I get dates from the database ( thats saved as UTC ) Id like to convert some dates on the fly to other timezones ( so i can display datetimes in other peoples locales ) I hope that makes sense?
  15. I did think of " date_default_timezone_set('America/Los_Angeles');" However, Does this now change the timezone of the script? I dont want this. i want the script to stay in UTC however I want to be able to echo a date through a function that turns the inputted date into whateever datetime i ask for ? ( im not sure how strtotime will fix this issue? Can I punt a timezone to it?
  16. Hi Guys.. How can I change a date on the fly ? Everything is UTC on my server. How can I change a date to something else on the fly? Ie: $timezone = "cet"; $datetime = "2011-09-04 19:53:00"; echo $datetime($timezone); So I can give it a datetime and have it echo the datetime as if it were in the other timezone? Thanks Graham
  17. Hi Guys, I have a problem with one of my queries. It takes far to long to execute and uses too much CPU. Does anyone know how to make it cleaner? I have a table of IP addresses with some details in them like country, lat long etc. My query will simply get the last 30 hits based on IP address and Time for Xsiteid( last 30 IP's ) heres the DB structure.. +-----------+--------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+-------------------+----------------+ | id | int(15) | NO | PRI | NULL | auto_increment | | ip | varchar(26) | NO | | NULL | | | time | timestamp | NO | | CURRENT_TIMESTAMP | | | siteid | varchar(30) | NO | | NULL | | | country | varchar(2) | NO | | NULL | | | town | varchar(40) | NO | | Unknown | | | lat | varchar( | NO | | Unknown | | | lon | varchar( | NO | | Unknown | | | extra | varchar(100) | NO | | NULL | | | requested | int(1) | NO | | 0 | | | ref | tinytext | NO | | NULL | | | browser | varchar(100) | NO | | Unknown | | +-----------+--------------+------+-----+-------------------+----------------+ heres the query: SELECT DISTINCT * from visitorips where siteid LIKE '372010' order by id desc limit 30; Ive tried: SELECT DISTINCT * from visitorips where siteid = '372010' order by id desc limit 30; SELECT DISTINCT id,ip,ref,etc,etc,etc from visitorips where siteid LIKE '372010' order by id desc limit 30; But these take just as long ( if longer ) 5 rows in set (0.69 sec) Uses like 150% cpu. How can i get this down? Im sure theres a better way to query the table? It currently has 200k rows. ( last 62 days is all thats kept. ) I have a primary key on ID and nothing else. However i did try putting an index on other columns and didnt gain any performance increase. Thanks G
  18. Hi Guys, Need some help I have two dates: Now= 2011-02-08 Expires= 2011-06-15 How can I check if we are getting close to the expire date. For example. Lets say we were 5 days away from 2011-06-15 ( todays date was 2011-06-10 ) for example.. How can i tell this? / return 1 Ie: if date is 5 days or less away do ( this ) Its s essentially so i can email people when something is due to expire. Many thanks L
  19. Sweet, Thanks man. Been googling like mad and cant find anything that works correctly. This did it fine. Thanks very muchly! -G
  20. Hi Guys, I have a textarea on a html page with XXX amount of lines. How can I in php insert a separate mysqlrow for EACH line on the html textarea? Thanks G
  21. Typical, After HOURS!!!! of looking, Ive found the issue. In IE when using utf-8 and ajax you need: message = encodeURIComponent(message); This appears to fix it completely.
  22. Everything is set to utf 8 on ALL my documents. <?php header("Content-type: text/html; charset=utf-8");?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Database is utf-8unicode ci FF and Gchrome WORK FINE! Its just IE that wont send the data properly. Always get ????????? I noticed it ALSO cant send the damn £ character. What is wrong, all other browsers are fine, Typical IE buggering everything up. -G
  23. Im having a terrible issue saving the persian language into my DB and bringing it back into a PHP echo. All i get is: ���� Rather than the actual text that it should show. I have a form that submits the text to a UTF8-Unicode DB table. A then have a php doc that reads that table and echos to the document. However it just comes out as ���� The document is set to UTF-8 and PHP sends the UTF-8 header. Does anyone know what im doing wrong? This only seems to happen when using IE Meant to look like : ل لينوكس دلخواه قابل نصب بوده But instead just shows ?????????????? Thanks G
  24. This has been resolved from some fellows over at webmaster-talk.com $(document).ready(function() { $.ajax({ url: 'notify.php', success: function(data) { if (data == "1") { showNotification(); } } }); });
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.