Jump to content

toxicious

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by toxicious

  1. My website recently got suspended because it was causing high load on my shared hosts servers, and this is not the first time.Though they were kind and unsuspended it and told me to fix it. I am not sure what is causing the load so it would be awesome with some advice or a point in the right direction (maybe how I can test what script is the thief). A little about the website: It's built using PHP only, along with a MySQL DB. It relies heavily on the DB, a lot of queries are made to list stuff.There's basically only one file that is called directly by the user, index.php. That file then includes the right other files depending on the URL the user typed and so on (URL Rewriting is happening).So yeah, a lot of includes are made. The thing is, it didn't have a lot of visitors on it when it got suspended. I can't tell exactly how many were on the site at the moment they suspended it, but I can tell there were only 500 unique visitors that day (normally ~400) and a total of 800 visits. Not that much. I would love to improve the performance of my site, but as I said I have no idea where to start!Is there any program that could run through my site, checking which scripts causing high load so I then could analyze those files in particular?I have a local dev server I could do some testing on at least.
  2. You have an error in your css file. It is a good practice writing good-looking easy-readable files too: .photos {float:left;height:90px;width:110px;margin:30px;} h2 {color:green;text-weight:bold;font-family:times;} .sec {clear:both;margin-bottom:2px;} iframe {position:relative;padding:0px;top:10px;left:120px;border:5px groove orange;} h1 {position:relative;top:10px;left:220px;color:green;} .center {margin:auto;width:70%;background-color:#b0e0e6;} Your forgot the ending clam ( } ) on the h1 tag styles.
  3. I have written some rules in my .htaccess file but they don't work as I want them to. I have these: RewriteRule ^news/page/([0-9]+)/?$ news?page=$1 [NC,QSA]RewriteRule ^([0-9a-z-_]+)/?$ index.php?p=$1 [NC,QSA] Here are some scenarios: Url - Should go to - works? /news - /index.php?p=news - yes/news/page/2/ - /news?page=2 => /index.php?p=news&page=2 - no I have similar rules, with the exact same regex on my IIS server and there it works.If I change the first rule to be like this: RewriteRule ^news/page/([0-9]+)/?$ index.php?p=news&page=$1 [NC,QSA] It works. Which means that it succeeds in matching the first url, but the one that is created out of the first match isn't matched anymore...I don't have any logging possiblities since it is shared hosting.
  4. Do you want to find all of the invalid characters (and store them for example) or do you just want to validate if the string only contains numbers (returns true/false)? If you only want to validate, this regex would be fine:^[\d,]+$ It will also say that a string like this: "589,5523,523" is valid. If this is not what you are looking for, could you explain a little more
  5. I'm getting crazy about this. I've been trying for days and hours with different plugins to make AJAX navigation work like I want, or more like the plugins say that it should work. I'm gonna start to explain what I want: URLs without hash for browsers supporting history.pushState (example.com/news)Only fetch the part of the page that needs changing (for example I have a folder where I put files which contains content that can be fetched and inserted into a layout)If a user lands at example.com/news he should still see the whole layout including the content, not just the content of that "file" (which is just news...) Now please, can anyone tell me if this is possible?I stumbled upon this site: http://hypem.com/ Which seems to have acomplished that. If you inspect the site with Firebug you find this:When you click a link this happens: A short-version url is set in the browser with pushState (example.com/popular)An AJAX request is made to a longer version of that URL (example.com/popular?params=hereāˆ§=so&on)That response to that request is only the content of the page, not a "whole page".The new content is showed with JS. The most interesting thing here is probably the fetching part. How can the url popular show a complete page when you land at it, when they also can request it and only receive some content? It feels like all my spare time is going away into just getting this to work
  6. The settings will only be changed by me, so hardcoding them into a separate file is the easiest I think. Since I will use "include .../settings.php" or something like that I hardly doubt that it will affect the performance
  7. Hmm okay. Thanks a lot for a fast answer! I think having some variables in a file is enough for me then
  8. My website needs to do a lot of mysql connections to fetch and insert stuff into a db. In my last "version" of this website I have one file called dblogin.php in which I connect to the db. Then I just do an "include "dblogin.php" (kinda) and then I go on with the stuff. Is there any recommended way of doing this? I mean you want the address, username etc. in one file so you don't have to change it in multiple files if something changes.
  9. Thx a lot for the two examples! Interesting ways of doing it. Will go with example 1 since it was really simple
  10. This is the HTML: <div id="cellwrapper"><div id="leftcell"> </div><div id="midcell">Lots of content here</div><div id="rightcell"> </div></div> All of the columns should have a dynamic height. The midcell will contain different amounts of text, and the two side-columns should be the same height. With other words: I want the side columns (left & right) to be 100% height of their parent div (cellwrapper) without setting its height (cellwrappers height). Before I've used a table, but I've been told not to use it for designs so I want something with divs.Here is the CSS I have so far: #cellwrapper {background: yellow;display: table;}#leftcell {display: table-cell;width: 35px;float: left;background-image: url('img/col.gif');background-repeat: repeat-y;}#rightcell {display: table-cell;width: 35px;float: left;background-image: url('img/col.gif');background-repeat: repeat-y;}#midcell {display: table-cell;width: 470px;float: left;background: white;} As you can see, I've tried with the display: table thingy, but I didn't get it to work. The side columns are still only one image high (the col.gif is only 20px high). The display: table way seems like the easiest. Could someone please point out what is wrong?
  11. Yeah that would be a good idea. Did a quick calculation, for each tracked player there will be 24 hourly rows and 30 daily rows (aprox.). Which equals ~54 rows/player. If I split like you said it will pretty much be half of the data in each table.Also read a bit here: http://forums.mysql.com/read.php?24,240757,240757#msg-240757 He has 100 million rows plus and asks about performance. I beleive as long as I don't use wrong types for the columns, I can at least be safe until I reach 1 million rows or something like that. Though 1 million rows would equal about 40,000 tracked players, which I NEVER will reach anyway. Let's say it spreads and I get 100 players, that will only be tiny 2,500 rows/table (aprox.) So yeah, it probably won't matter. Anyway, it would be great if more people could give some input on what the pro's and con's are with JamesB's design VS my design (maybe it's just ineffective having lots of tables)
  12. @birbal, nicheI already know how to create a db and stuff, my problem is that I am not sure how to structure my new db (which I haven't created yet). @JamesBThat do sound like a solid design, how do you think the performance is with that one? Will it be slower because everything is stored in one table?
  13. I want to design a DB that should store stats for a game.A program will fetch stats from another website and put in the db every hour. It will also move/purge old stats into the correct place. The point is for the players to be able to see their stats the last hour, the last 5 hours, the last x hours etc. Also the last 3 days and so on.The DB will store hourly stats for the last 24 hours, and daily stats for the last 30 days. The design I came up with was this (beware, I'm no pro at designing DBs): Single DB, hourly_00 hourly_01 hourly_02 ... hourly_23 daily_01 daily_02 ... daily_30 players And when it comes to the design of the tables each table would contain a row with the players stats at that time (specified by the table name) and a player_id.The players table would contain ids and their playername. atm I do not track that many stats, just 3-4 integers. Also, it is worth noting that I won't go public with my little site. Only me, my friends and maybe if they tell their friends. Meaning that I won't buy a fancy domain name that attracts visitors, I won't advertise the site etc. I hardly think it would ever go over 20-100 players being tracked depending on how much work I put into it. If any SQL pro want to give me a tip or show me a completely different structure which is much more awesome, pleease do so
  14. Thanks for the script! I have studied it and now I understand things better :)Gonna play a little with it first, then I'll migrate my db using a script.
  15. Great article you linked me too!I would love to improve the design my db, especially now when it has grown a lot.I guess I could just rework my current design into separate tables and then set the foreign keys since I already have ids on both the files and the mirrors I'm gonna create a php script taking care of all the mirrors, putting them into the file_mirrors table together with the correct addon id. (the file_mirrors table will have as many rows as mirrors, right?) Then I just need to set the keys. Though I need some help where to set them so it works like this: When I delete a mirror, the corresponding row in file_mirrors should be deleted.When I delete a file, all the corresponding rows in file_mirrors should be deleted, and all the mirrors belonging to it should also get deleted (inside mirrors). Is this right?: ALTER TABLE filesADD CONSTRAINT files_conFOREIGN KEY (id) REFERENCES file_mirror(file_id)ON UPDATE CASCADEON DELETE CASCADE ALTER TABLE mirrorsADD CONSTRAINT mirrors_consFOREIGN KEY (id) REFERENCES file_mirror(mirror_id)ON UPDATE CASCADEON DELETE CASCADE ALTER TABLE file_mirrorsADD CONSTRAINT file_mirrors_consFOREIGN KEY (mirror_id) REFERENCES mirrors(id)ON UPDATE CASCADEON DELETE CASCADE ALTER TABLE file_mirrorsADD CONSTRAINT file_mirrors_cons2FOREIGN KEY (file_id) REFERENCES files(id)ON UPDATE CASCADEON DELETE CASCADE EDIT: thought about one thing, how does adding work with the new structure?I assume I do everything manually?
  16. I had a problem with my front-end that messed up my db a little, but it is somewhat easy to fix. Now I am wondering if I can fix it just by doing an mysql query, else I will need to create a php script which does multiple queries and some loops. This is basically what I want to do: SELECT id FROM mirrors then for each id In words (beware of bad description, code ftw): I want to delete all the mirrors, that aren't listed in the files table (un-indexed mirrors). Is it possible to create a nice MySQL query that does it?
  17. I think I'll go with the BrowserID system. No strain on my db and easier for the user
  18. Great post! So basically, if I were to write a login system with a remember me feature, every page would start something along the lines of this: <?phpif(!isset($_SESSION)){//Check if the user has a cookieif ($_COOKIE['login'] != ""){ //Extract and check to db //If match, set session[login] = true}}?> Edit: damn code feature...removing the indentation
  19. Well I am a little with you here, besides, I am using the jQuery from google which means it isn't my bandwidth. Though on my current site (which is small), I load it one time, at the index page. The rest of the site is pretty much loaded into divs (instead of iframes) via jquery so they also can use that jquery Meaning that, if we put aside the bandwidth question and the loading it multiple times thingy, I suppose it is okay?Though as you say, Ingolme, I should probably learn how to do it both with and without jQuery.
  20. Well that was simple, like a cookie stored on the webserver.But what if I want the user to be logged in for 24 hours or something? I have checked some big sites and all of them seems to use cookies when it comes to that. Edit: question: do I need to have that session start tag at every page since I don't know where the user will land?
  21. I recently started coding some javascript which is use at my site (no big complex functions) and I have also discovered jQuery.Quite often when I do different things, it all ends with me finding out how to do it in jQuery and going that way instead since in 100% of the cases it is simpler I think. I mean, it feels like a human designed jQuery and a robot designed javascript Is it bad to use jQuery all the time? Since I am not learning to use any of the native functions?
  22. I have started a little with writing a very simple log-in system to be used by the admins on my site. Currently I have a form, when the user submits it (ajax) it checks against a db (hashed passwords of course #sonyfail) and if it matches, it creates a cookie contaning the hash of the password and a cookie containing the username. But when the user enters a page which needs you to be logged in, what should I do there? Should I do a check against the db everytime and check if the credentials in the cookie match? That seems like an expensive operation every time the user like refreshes a page or visits a new one o.OBut I can't see any other solution that is secure?
  23. Yes I read the docs, but I have to admit I skipped the jqXHR part since I had no interest in using that object. But saw the example now. Weird that it can succeed multiple times... Anyway, thanks a lot for clarifying for me! Solved some other problems I had too
×
×
  • Create New...