Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Everything posted by EchoFool

  1. Good question i just been googling and taking snippets here and there till it worked... is it sloppy design ? Im no JS pro i just look on the net and copy what does till i get it to work. Where did i go wrong ?
  2. Hey, I have an ajax script for a chat room but wanted some one who knows ajax to tell me if there is a way i can increase its efficientcy if at all...as it calls a php script all the time to check for new messages - was wondering if my method of calls can be improved? Here is my script: function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); function sndReq() { http.open('get', 'chatcheck.php'); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; var update = new Array(); if(response == '1') { updateShouts(); } } } function sendMessage() { $.ajax({ type: "POST", url: "chatpost.php", async: false, data: "message="+$("#myMessage").val(), }); $("#myMessage").val(""); return false; } function updateShouts(){ $('#chatArea').load('chat.php'); } setInterval( "sndReq()", 1000 );
  3. The global variables change quite regularly (multiple times a day) but some remain the same forever + 1. How secure is it when in a session - as some of the variables cannot be altered or may result in cheating my game. Also i have been looking into cache but have no idea where to learn, thanks for the link i will start there
  4. Hey, Quick question on how i should improve my efficientcy.... Currently my site loads all the main variables with a query at the top of the page then the rest of the page does what it needs with the vars. But lets say when you page refresh - no data has altered from the main variables have been changed - but currently it still queries and assigns all the variables - but i find this inefficient if the data has not changed to keep on loading them every page load with a query. Is there more efficent way to make php only query and update teh already set variables when "something" has changed... although that also leads to the problem of variables not being set if no chance has happened when the page reloads....any thoughts?
  5. No because then these: "&" => "&", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>" Won't be included ...
  6. Yeh but that i cannot include in my BBCode function can i cos its different functions...?
  7. woah that looks confusing, is my BBCode function not the best approach then
  8. Hey, I am trying to use my function replace urls into <A href=""> in the array but do not know how i would do it with the current function i am using for my BBCode.... Say a user types www.google.com i want it to be clickable in the post. My BBCode function is: <?php //bb code fucntion function BBCodechat($BB){ $BBCode = array("&" => "&", "[b]" => "<b>", "[/b]" => "</b>", "[i]" => "<i>", "[/i]" => "</i>", "[u]" => "<u>", "[/u]" => "</u>" ); $Message = str_ireplace(array_keys($BBCode), array_values($BBCode), $BB); return $Message; } ?> Hope you can help.
  9. Yeh thats the thing i dont want it to strip all html
  10. Hey, How would you do a replacement on a string which changes ? For example: <a href="users.php?id=3">Username</a> How would you use str_replace to take out <a href="users.php?id=3"> AND </a> Note - the id=3 could be any random number so i can't use exact strings to replace cos the value could be different. Thanks hope you can help.
  11. Hey, How would you apply a function to replace words which meet these conditions: Not in the middle of a word for example... "IGH" changes to "TEST" but "HIGH" would not change. Secondly the capital letters and non capital letters are not taken into account. Currently i use: <?php $Message = str_replace('/rules', 'Please read the rules here <a href="rules.php">Game Rules</a>', $Message); ?> How ever thers a number of problems here, if i want many things to be changed i would have to keep using lots of str_replace and updating $Message so wondering if theres an array method. Secondly if '/rules' is typed like '/RULES' then it wont execute str_replace.
  12. never mind i found the mistake i did not close a table so it bled into the next div.
  13. Hey, I have a form at the footer of my page, and some times on certain pages this footer form doesn't seem to acknowledge hitting the enter button. Instead of it making the form submit it makes the page refresh which is very odd. It only happens on 2 specific pages which happen to have forms also. Was wondering how can i prevent this odd issue? Though i barely know what could cause it.
  14. By saying : extremely difficult Means the possibility can occur?
  15. no im just checking such a problem could not happen for example.... when a user registers or logs in $_SESSION['Current_User'] = 4; lets say ID 4. Then i use that ID for everything. But if some one can edit their SESSION via their browser with a cookie editor, then they could set their ID as one of the Admins and thus have staff permissions and appear to be logged in as one of the staff members. So wanted to make sure that could not happen. And if it could how is it preventable.
  16. Can users edit their cookie/session and thus change who they are logged in as on a website? If they changed the data from say user 1 to user 2 would it work if so how is it done? And how is it prevent on the server side ? thanks
  17. hey I have a case statement that returns the wrong answer when its checking a value which is 0. Which makes no sense as all other values work fine. This is my case statement: $Var = 0; switch($Var) { case ($Var < 100): $Answer = 'step 1'; break; case ($Var > 99 && $Var < 200): $Answer = 'step 2'; break; case ($Var > 199 && $Var < 300): $Answer = 'step 3'; break; case ($Var > 299 && $Var < 400): $Answer = 'step 4'; break; case ($Var > 399): $Answer = 'step 5'; break; default: $Answer = 'step default'; } For input value 0 i get "Step 2" as a reply when it should "Step 1". I got no idea why this is the case, given it should not be showing step 2.. can some one explain please. Thanks.
  18. Hey, I have a PHP script which is called very frequently, and would like to make it as efficient as possible - so was wondering if you can give me some points on this script on how i can make it more efficient for my server. <?php If(!isset($_SESSION['ID'])){ echo '1'; $SELECT = mysql_query("SELECT id from logs WHERE id > '{$_SESSION['ID']}' ORDER BY id DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_assoc($SELECT); If($row){ $_SESSION['ID'] = $row['id']; } }Else{ $SELECT = mysql_query("SELECT id from logs WHERE id > '{$_SESSION['ID']}' ORDER BY id DESC LIMIT 1") or die(mysql_error()); $row = mysql_fetch_assoc($SELECT); If($row && $row['id'] > 0){ echo '1'; $_SESSION['ID'] = $row['id']; }else{ echo $_SESSION['ID']; } } ?> The idea behind it is simply to set the last id of the table to the session. Was hoping some one could see if this is the best way to do it. Thanks
  19. Oh i did not know jquery did it also... which is easiest/server efficient (if the script in question is calling a php script every half a second) To give idea of what im doing im trying to build a live chat with ajax (which is already working) as it calls a script which loads out the logs but currently it does not do any checks if there are new messages, as i only want it now to call if there are new messages which will add to server efficientcy. EDIT: fixed typos.
  20. Hey, I have been trying to find a simple demo script for passing variables with ajax but to no avail any has really made any sense to me. I was wondering if some one could simple show a crude example of how to send a variable from a php script to a different php script and return it. For example: PHP1 script:Send $Var to PHP2PHP2 script: Assign to $Var2 do some processingSend $Var2 back to PHP1 Can some one please show me a simple example so i can fiddle with and learn from it. Thanks
  21. Hey, Does any one know if there is a PHP function that can get the URL like PHP_SELF does but also bring the GET part of the url with it. Like index.php?get=hello ?
×
×
  • 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.