Jump to content

corbin

Staff Alumni
  • Posts

    8,102
  • Joined

  • Last visited

Everything posted by corbin

  1. Don't know a premade script, but it sounds like it could be done fairly easily with some AJAX.
  2. You'll need to do that with PHP (which is why I've moved this to the PHP forum. If it's the MySQL parts you're having issues with, I'll move it back). There are two main approaches you can take, and each one has it's issues: --Pass the file through a PHP page. The theory would be that the PHP page would increment the download counter, then spit out the actual content to the client. -That leaves an instance of PHP running until the end of the download --Process the access logs every x minutes. -This could be strenuous on the server if the logs grow rapidly. --Increment the download count on a PHP page and then forward the user to the address of the actual download. -You would have to make sure the user came through the PHP page. I would probably go with the first or third method. If you go with the third method, you'll have to be careful about making sure the client came through the page that counts the downloads (setting a session variable would be the easiest way to do that). Anyway, method and practice are often different, but that should at least help you start ;p. If you already have code, and you're having issues with it, post the area that you're having issues with.
  3. Eh, you could have said something about it without being rude. People usually don't get offended by a simple "Errr... why don't you just try it?" It's annoying how often questions like that pop up though. It seems like there are a lot of people out there just afraid (or too lazy) to try things. It's weird.
  4. Well, what if the DLL has to retain state or something? I don't know why it would need to as long as it's just functions and not classes, but who knows.
  5. Errr.... Any file on Windows is at least 4KB? Do you mean due to file system over head? Because I don't think filesystem overhead for 1 file would be 4KB.
  6. As long as your communication skills are good, you'll be fine. In fact, I don't think I would even think about the ethnicity of a programmer I were going to hire. Pug, have you actually tried living on minimum wage? I've never done it myself, but I've worked a few minimum wage jobs with people who worked at minimum wage full time. Their lives essentially suck. I'm sure it varies by parts of the country, but minimum wage in my state is no where near high enough to live comfortably off of. And like CV said, by comfortable I don't mean with luxuries, I mean like, without wondering where you're going to come up with a dollar for the dollar menu at McDonalds so you can eat.
  7. Eh, I think a reference is more useful than a tutorial. I guess for people starting out though it would be a lot easier.
  8. Typically the use of @ is bad. It's slower than without it, and it suppresses errors. Isn't it better to fix them than suppress them? Typically I just silently log errors (in other words, display_errors = 0) but don't suppress them. But, sometimes while doing quick testing, or as MadTechie said, personal code, it can be fine.
  9. Unless you can somehow get a COM object to work as MrAdam suggested, you're probably out of luck. DLLs are basically just files full of executable information stored in chunks like functions with a table that points to where each executable chunk is (it's not quite as simple as that sounds). But still, as far as I know PHP has no way to interact with random DLLs. You could write a PHP extension that interfaces with your own DLL, but that could quickly become difficult.
  10. The first thing I notice is: RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d Two things: -That only applies to one rewrite rule. RewriteConds only apply to the closest following RewriteRule. (Maybe that's on purpose though.) -The OR will always make it true, since something can't be both a file and a directory. If file does not exists or directory does not exist. So that RewriteCond is basically useless. Perhaps you meant it without the OR? Oddly enough the only rule that would apply to /directory/ would be: RewriteRule ^([a-z0-9]+)/$ $1.php [NC] And then no rules after that would apply any more as far as I can tell. The weird part is that that should still give an error if whatever.php does not exist. What version of PHP is it? And if you remove just that 1 line does it work? Also, your RewriteRules could be optimized a bit.
  11. I hope you don't take this the wrong way, but that's utter crap. If you were my employee, if I heard you say "Doing lots of things quickly with minimal effort gives you a greater return" I would begin inspecting your work quite closely wondering if I should fire you or not. If I draw a sketch, is it going to look better if I put 30 seconds into it, or 30 minutes? "You do a little bit of lots of things and you get the bigger picture." That should be amended to say: "You do a little bit of lots of things and you get a vague view of the bigger picture." Yes, a view of the bigger picture is valued in numerous ways, but that's like saying I could be good mechanic, or I could be a decent mechanic and a decent something else. When it comes down to it, each person only has so much time in his/her life to learn things, and we can't all have a perfect knowledge of everything. Blerh I feel guilty for contributing to the jacking of this thread, so on a more ontopic note: Eh, what exactly do you mean by engineer? Do you mean an engineer by education, or an engineer by experience/skills in coding? Either way I believe that statement is a bit off. I would assume that a "Senior PHP Developer"'s duties would include designing the basic layout of the program, assigning parts to people and then coordinating it (which is basically what you said). However, depending on how lightly staffed a company is, the Senior Dev might (and in most cases I would assume will) be expected to actually do some coding himself, along with some quality checks and basic bug-testing of code. As for the interview, if I were the interviewer, I would ask both technical and abstract questions. Since the jobs will all presumably relate to PHP, I would ask questions that signify that you have a good grasp of PHP as a language, but I would also ask questions that show that you're not just a mindless drone who knows the syntax. As for what those questions would be, not really sure.
  12. <continuing the offtopic trend> Well that depends. Sometimes your message does not get across. And sometimes you look silly. I'm not even saying all spelling has to be 100% correct for it to be decent. But in my opinion any body of text without proper grammar/capitalization looks juvenile. But maybe that's not important to you, and if it's not then I guess oh well. </offtopic>
  13. I don't know if I could actually name 20 even... lol.
  14. True.... I didn't think about forking. (Forking would only be an option if the server is linux, but I would guess that it is.) Not sure why I entirely forgot about forking lol (probably because I develop on Windows 99% of the time ;p). Dang now I'm curious how the performance of an application using forking would compare to something that uses threads. Might have to test that later lol.
  15. Without limit, it's not possible unless you don't mind pulling all of the results. Why can't you use limit?
  16. I'm not sure if it applies to this situation or not as I'm not entirely sure what you're trying to do, but you can always do something like this: UPDATE table SET field = field+1 WHERE someField = 'someValue';
  17. Because when you're stealing from a store, you're doing bad to the store. So, following that metaphor, you would be harming the ISP. But that's not the case. People doing harm using the internet are not (directly, since indirectly they could lose customers) harming their ISPs; they're harming the people against whom they're doing harm (which was maybe the most redundant thing I've said in a week). Aside from getting blacklisted and losing customers, ISPs are not harmed by malicious things people do using their services (unless those malicious things involve disrupting the ISP's business model). So, I feel that the gun-shop example would be more accurate. The gun store owner is not harmed by the use of the gun. In fact, no one has to be harmed by the gun. It could lie dormant indefinitely or it could be used for hunting. But, even that analogy is flawed since the gun shop owner doesn't lose sales if someone buys a gun from him and shoots someone. A more valid analogy would have to involve something like magical doors that lead to different areas, and those areas blocking doors based on people who have come through them in the past. Basically what it comes down to is whether it's worth the ISP's time to monitor their users and follow abuse reports. If they lose x future customers because they fear being blocked on websites, it's only worth avoiding being blocked if those customers would make up the money lost when following y reports. I think it's stupid for a website to block an entire ISP based on a few rogue users. Now, if the website were getting DDoS'd by a net from the same ISP, that I would understand, but otherwise, I think that's stupid. I guess I'm biased in this since I don't think an ISP's responsibilities include monitoring their users. I think if a law enforcement agency gets involved, the ISP should turn over all related information and stuff, but without that, I don't think it's the ISP's job. Then again, if the ISP doesn't do it, I'm not sure who would since it's not like the local cops job should include that either. Blerh, now that I think about that, I have no idea whose job it should really be. I feel like the ISP shouldn't do that, but that no existing enforcement agency would be right for it.
  18. Errr.... We'll need more code to know for sure, and EXPLAIN results on any queries involved. Can the two queries be combined using a JOIN?
  19. When ever you're not sure that an array will contain what you think it will, you should do: if(is_array($var)) { foreach... } To avoid that. Anyway, yeah, your regexp is a bit off. The first thing that I noticed is that you don't have any capturing parenthesis anywhere. Trying putting () around what ever you're trying to extract.
  20. http://dev.mysql.com/doc/refman/5.1/en/create-database.html http://dev.mysql.com/doc/refman/5.1/en/create-user.html http://dev.mysql.com/doc/refman/5.1/en/set-password.html http://dev.mysql.com/doc/refman/5.1/en/grant.html
  21. Yes, an insert failing would definitely be an error that would throw an exception. By the way, if you did want your application to error on an update statement that doesn't affect any rows, you could always just throw an exception your self, or catch it in an if clause and do something.
  22. (In the following post, I basically ignore C# since I know very little about it. Also, I realize C and C++ are not the same, but they are the same base, and they are very comparable in speed [assuming the coding style is the same... {in particular if OOP is used or not}].) This day in age when computers do billions of operations per second, the speed of language is really quite negligible. It's worth noting, by the way, that most of the slow down of PHP is actually the interpretation of it which only happens once (so for a script that would run indefinitely it wouldn't matter much). The core of PHP is written in C which gets transfered down to byte code (everything of course goes to byte code in the end). But, although C and PHP both end up in byte code (ignore interpretation time), PHP is still very, very slightly slower. (Basically because things can't be optimized as much as they could be if written in C because the variables used behind PHP have to be flexible and whatnot.) Anyway, when it comes down to it, unless it's something that .001% run time (probably even less) whether it's written in PHP or C will not make much of a difference. But, I advise against PHP in this particular case because of 1 important thing... Socket queuing. PHP is single threaded, which means that you can only have 1 thing going on at a time in the program. In other words, let's say you have 2 connections (assume the connection speed of your server is something high enough to handle both connections). Connection A is 10KB/s up and down, and Connection B is a 10MB/s up/down conn. Client A has to send your program 1MB, and client B has to send 1MB also. Only one socket can be read at a time in PHP (due to only having 1 thread), so client B will not be able to send his/her content until client A's is done sending (unless client B's socket gets read first). Anyway, that was a horribly worded example, but what I mean is each socket has to wait on the one in front of it, so the waiting time can add up VERY quickly (especially if a super slow connection is thrown into the mix). Also, more than 1 task can't be processed at a time. So, my tl;dr for you is as follows: Use a language that has threading. Yes, threading brings up entirely new issues of locking and queue management, but the gained efficiency is well worth the added complexity. As for answering your abstract question instead of the specific example: "I'm wondering what's a bigger factor in determining how many connections a server can handle: The Speed of the language (Interpreted vs. Compiled) or the processing power of the computer and the ability of the internet connection of the server." Think of it like bottlenecks. Of course which ever one is the bigger (metaphorically bigger, smaller in the sense of liquid passing through ;p) bottleneck will be the one that matters the most. The important of the speed of the language really depends on how much efficiency is needed, and how fast the computer is. The internet connection speed can vary in how much it matters. For 10 clients, 1MB/s and 100MB/s won't make much of a difference depending on what's going on, but with 1000 users, that can make HUGE difference even if throughput is fairly small. tl;dr: It entirely depends on the situation: how much data is going through, how slow the language is, so on.
  23. As long as I pay my bill, my ISP doesn't care one bit what I do. Now, if the FBI or some other law enforcement agency made them care, then suddenly they would have a very strong interest in what I was doing. I would imagine the same goes in Canada. I would imagine even the same goes in Poland and all those other countries, just maybe as much pressure isn't put on ISPs. When it comes down to it, ISPs are there to make money. "If you steal from store you can get banned from that store." I think you're looking at it the wrong way. Think about it with this metaphor: If I sell a gun to someone, is it my responsibility to make sure he doesn't shoot anyone with that gun?
  24. If an UPDATE statement doesn't affect any rows, that's not an error. It may not happen how you expect it, but as far as the MySQL engine goes (and PDO), that is not considered an error.
  25. Yeah, I remember someone talking about the badness of that post before. *Searches* http://www.phpfreaks.com/forums/index.php/topic,258236.0.html
×
×
  • 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.