Jump to content

corbin

Staff Alumni
  • Posts

    8,102
  • Joined

  • Last visited

Everything posted by corbin

  1. Hi... mSQL != MSSQL, so using the mSQL extension makes no sense. Additionally, unless your code has some existing dependency on the MSSQL extension (mssql_* functions), you should be using MS's extension http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx If you do have code depedent on mssql_*, I suggest recoding it, but if it's a big project that might not be possible. Anyway, php_mssql.dll depends on a dll originally in MSSQL 2000 (I don't think the DLL exists in SQL Serv 2005/2008). I don't remember what the DLL is called, unfortunately, and I have no idea where to get it these days. Anyway, you'll likely want to run PHP from the command line or check the Apache error log to see exactly why the extension's not loading. (Also, on a semi related note: I usually use PDO for MSSQL related stuff [actually all DB related stuff, really]. That way it's easier to switch between mssql extensions if need be.)
  2. It's worth noting that PDO::quote does not work for the ODBC driver. And yes, I should have mentioned that encoding issues and what not can make ' quite dangerous to simple str_replace escape. When working with MSSQL, I always use prepared statements because of the ODBC PDO driver not implementing quote (and I just prefer prepared statements over PDO::quote'ing).
  3. Loading a page into a div is about as simple as AJAX gets, so I would find an AJAX tutorial. Or is there something specific that you're having issues with?
  4. urlencode? Or, instead you could use a library with bound parameters (better option). Or, you could just replace ' with ''. (note that that is two ')
  5. The easiest solution is to just use number_format() on in the application code instead of doing it at a database level.
  6. There probably still is (I know there was like 3 years ago), but I can't imagine any free hosting would be decent. I suggest just getting a like $5 package from some web host. (Also, the domain name will run you $10-15.) You can probably find a free host, but don't expect it to be good. Then again, I'm a pessimist.
  7. Might just be an oddity of Firefox. Got to hate the browser compatibility world. Have you tried using something like Live Http Headers to see exactly what Firefox is passing? Maybe it's passing something else you could use.
  8. Hmm, albeit it a weak one, I do think it might be an attack of some kind. It's either that or a very aggressive search crawler (google bot for example). Is the page particularly resource intensive? Because if I were going to attack a website and had little resources, my approach would be to find a very DB/memory heavy page and slam it. If a page is rather resource intensive, a fairly modest computer/internet connection can flood a server. Anyway, is it the exact URL or variations of it? For example store.php over and over again, or store.php?page=1 then store.php?page=2... Also, have you tried googling the IP address? If it's a search bot, that will likely bring something up about it.
  9. Hmmm.... If that were the case, I would just make a custom extension so you could do like page.code or page.c or something. That way if they did find it, no big deal. Another option would be as you said, to just deny direct access to any file (and by "deny" I mean a 404 page). You could probably accomplish that with a clever RewriteCond and a RewriteRule (with the Cond checking if the file exists). Note that you'll need to order your rewrites correctly and mark the one rewriting /registration to /registration.php as final (with [F]). I'm actually kind of curious on this now, so if I decide to mess with it I'll post whatever I use.
  10. corbin

    Idiots.

    I would pretend I went somewhere without internet access.
  11. Yes, locking in MySQL is handled automatically. http://dev.mysql.com/doc/refman/5.0/en/internal-locking.html
  12. Ooo Twisted looks pretty cool. Almost makes me want to learn Python. TLG, with your approach right now, the easiest way to do it is this (although I would probably go the Twisted route): Have the main thread listening for new client connections. Every time a new client connection is received, spawn a new thread. That thread's entire purpose of existence will be to handle one client connection. Basically it will be like: main thread: while(new client) { new thread for client } client threads: while(connection open) { read socket and process } The hardest part of that approach will be the synchronization so that you can act on more than 1 socket if needed. (For example, to send a message from a to b, you'd have to use a's input stream and b's output stream, meaning you will need a way to manage connections outside of threads. Basically a locking system.) I could show you some Java code if you wanted, but I don't know Python well enough to accomplish anything. thorpe's suggestion looks pretty cool too. You'd probably be better off using it than trying to reinvent it. Then again, it might be better to start low down then move to Twisted so you know what's going on better.
  13. The socket accept is accepting a new client every time the loop goes. You need: while True: client, details = mySocket.accept() try: while True: info = client.recv(100) client.send(info) except: client.close() Note that to support more than 1 client at a time, that code will have to be changed.
  14. Well you would have to know what signals Windows sends the program. I more I think about it though, the more I'm not entirely sure if it is 100% signal based. Haven't gotten around to trying it myself yet though. Ahh, just googled, and it looks like Windows does not have signals in the sense that Unix does.... http://stackoverflow.com/questions/140111/sending-an-arbitrary-signal-in-windows I think what I'll do is look into the Apache source to see how it handles services as I don't even know how to get started with service stuff without using managed code.
  15. I suggest not having the Database class implement the singleton pattern. What if you want two database objects to live simultaneously? Instead, in this case, I would use a registry. Also, I would pass a Database object into an Article object. like $a = new Article($db); Or, a better design (in my opinion) would be to have an middle-man of sorts between the Article and Database class. $am = new ArticleMapper($db); $articles = $am->recentArticles(10); //could return the most recent 10 Article objects That way the database stuff is a bit more abstracted away. You could even have ArticleMapper extend a DbMapper class or something and have the ability to set a default Database object. $db = new Database(...); DbMapper::setDefaultDb($db); $am = new ArticleMapper; $newArticles = $am->getRecent(10); Then again, it probably would be better to just pass a DB object to Article objects. Otherwise, you might end up essentially creating a ORM package. (A mix of Doctrine/Zend_Db_Table is essentially what I was describing in that post after all ;p.)
  16. How large is the database? I used to manage a decent sized database on MSSQL (about 100k users each with 1000 or so random entries in stuff) that would take about 15 seconds to export to a file. Did you request a certain format of the data? Because formatting the data can be a pain, but if you just want the equivalent of a mysqldump, that should definitely not take 8 hours unless it's just a huge database.
  17. Ahhh, I did misunderstand. I thought you were trying to code a server for an existing client.
  18. To be honest, I'm not sure what signals I'm suggesting be implemented either. I'm quite curious on this now, so I might try to make a PHP-script as a service later. I didn't know that script-level PHP could accept signals. I guess I should have expected that . (To think, I doubted PHP!) Now, I'm not sure as to what the signals exactly are, since in C++ using managed code in Visual Studio, the code of a service extends System::ServiceProcess::ServiceBase and implements OnStart and OnStop (there's also OnPause I think, but that's optional). So it could actually be based on exports or something, but I would say 99.99999% chance it's based on signals, and that somewhere in the ServiceBase code it handles all that (except of course, that code isn't accessible, just the headers ;p). If I get anything working later, I'll post it.
  19. The problem is that you're trying to convert an object to a string, likely doing so implicitly by trying to echo or print it. Objects that do not have a __toString method do not have any defined mechanism for being converted to a string and as such throw an exception like that one. I need to see more code before I can help you with actual code though. That function you posted does not return an object.
  20. Technically the problem is that the parent constructor is not being set: class a { public function __construct() { echo 'a'; } } class b extends a { public function __construct() { echo 'b'; } } new b(); will echo out 'b'. You need to call parent::__construct(); to actually call the parent constructor. On a design note though, you're going about it the wrong way. You're coupling the database and the article objects quite tightly. The article object might should have a Database object inside of it, but it should not be a database object if that makes sense. Or, you could go a different route with it and have a mapper or some other intermediary between the Database object and the Article object (which is what I personally prefer, but it can be a bit painful to do by hand if not using a package of some kind). Also wrong with your design right now is that every Article object created will have it's own Database object and this Database connection inside of it which is pointless. Also, this is just me being picky, but it makes me cringe when I see a declaration for "Articles" and a creation of "articles". I just wish PHP was case sensitive with everything though, so I'm picky .
  21. If you're on PHP >= 5.3, I suggest http://us3.php.net/manual/en/datetime.diff.php as it can take months into account accurately I believe. (Otherwise, I would just assume a month is 30 days) lets s = the number of seconds since the user was last active years = floor(s/31536000) s -= years*31536000; months = floor(s/2592000) s -= months*2592000; days = floor(s/86400) You get the idea hopefully.
  22. <a style="margin:10px;" href="#" onclick="jQuery.facebox('<img src="/image.php/imagename.png?width=130&height=130&cropratio=1:1&image=/userimages/company_images/imagename.png"/>');"> Would be "correct" I think. (Although I'm not sure about the href="#" or onclick.) & is technically supposed to always be escaped to &, and the same applies for other entities as well.
  23. I would be willing to pay a small extra tax. IE6 is evil when it comes to doing anything slightly complicated with CSS.
  24. No, it is likely that the game traffic would be encrypted. Side note, if you're going down the path of hosting an unlicensed server for a popular game, you might want to consider the legal ramifications of that. But... on a more curious note: what game did you check? You might be able to find details on decrypting the traffic.
×
×
  • 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.