Jump to content

Search the Community

Showing results for tags 'lessen bandwidth load'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I been working on a chat for a website got most of it done and happy with it, until I monitored it on chrome through the network in task manager and saw that the more text is shown, the of a load it takes. Here is what I have. submitchat.php <? print "<BODY SCROLL='NO' bgcolor='#404040' text='black'>"; print "<body style='overflow: hidden'>"; print "<form action='chatbox.php' method='post' id='banana'>"; print " <input type='text' name='message' id='message' size='100'></textarea>"; print "<input type='submit' name='submit' value='Send'></form>"; ?> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#banana").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('chatcode.php', $("#banana").serialize(), function(data) { $('#log').load('chatlog.php'); $('#message').val(''); }); } }); }); </script> chatlog.php <? include ("connect.php"); ?> <head> <body bgcolor="black"> </head> <? $delete = "DELETE FROM `messages` WHERE `timestamp` < (NOW() - INTERVAL 2 HOUR)"; $deletenow = $db->exec($delete); $getmsg = "SELECT * from messages ORDER BY TIMESTAMP DESC"; $getmsg2 = $db->query($getmsg); while ($getmsg3 = $getmsg2->fetch(PDO::FETCH_ASSOC)) { { $find = "/me"; if ($getmsg3['function'] == $find) { $string1 = "<font color='tan'><i><b>$getmsg3[user] </b><font color='tan'>$getmsg3[message]</font></i>"; } else { $string1 = "<font color='$getmsg3[chatcolor]'><b>$getmsg3[user]: </b></font><font color='white'>$getmsg3[message]</font>"; } echo "$string1<br>"; } } ?> main.php <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <head> <div id="main"> </head> <script type="text/javascript"> var auto_refresh; function start() { auto_refresh = setInterval(fresh, 10000); } function end() { auto_refresh = clearInterval(auto_refresh); } function fresh() { $('#log').load('chatlog.php'); } </script> <script type="text/javascript"> idleTimer = null; idleState = true; idleWait = 1200000; (function ($) { $(document).ready(function () { $('*').bind('mousemove keydown scroll', function () { clearTimeout(idleTimer); if (idleState == true) { $("#log").load('chatlog.php'); start(); } idleState = false; idleTimer = setTimeout(function () { // Idle Event $("#log").load('chatstop.php'); end(); idleState = true; }, idleWait); }); $("body").trigger("mousemove"); }); }) (jQuery) </script> <style> #topframe { width: 100%; position: absolute; left: 50%; top: 0%; ; color: #DDDAD7; height: 60%; overflow:auto; } #bottomframe { width: 100%; position: absolute; left: 50%; top: 60%; ; color: #DDDAD7; height: 40%; overflow:auto; } iframe {width: 100%; border: none; overflow-y: auto; overflow-x: hidden;} </style> <div id="topframe"> <iframe id="top" name="top" src="/home.php" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%" scrolling="auto"></iframe> </div> <div id="bottomframe"> <style> body { background-color: #404040; background-image:url('rockblack.jpg'); } #log { color: white; position: absolute; width: 95%; height: 80%; left: 50%; ; top: 15%; padding:5px 5px; background: black; border-radius: 20px; overflow:auto; -moz-border-radius: 20px; /* Firefox 3.6 and earlier */ } </style> <? print "<body text='white' scrolling='1'>"; ?> <div id="chatbox"> <? include ("submitchat.php"); ?> </div> <div id="log"> <? include ("chatlog.php"); ?> </div> </div> </div> Basically, main has submitchat.php and chatlog.php and refreshes #log div with chatlog.php every 10 seconds. Works as it is shown. As I said, as the messages in the database get bigger, so does the chatlog.php file. Is there a way to lessen that load without having to do the whole chat in a different approach?
×
×
  • 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.