Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by dkub

  1. Why do you have quotes around $url in your file_get_contents call? Any quotes are unnecessary here, and single quotes prevent string interpolation, meaning you're passing the literal string "$url" as your parameter.
  2. Use the i (case insensitive) modifier. http://php.net/manual/en/function.preg-replace.php http://php.net/manual/en/reference.pcre.pattern.modifiers.php http://www.phpliveregex.com/p/k1P
  3. What's the purpose of your dbConnection class? It simply wraps PDO, offering no new functionality, but having the disadvantage of hard-coded connection parameters with public visibility. You're likely better off simply using PDO directly. You're also better off inserting the dependency into ManageUsers rather than leaving it as a hidden dependency inside the constructor. $query = $this->link->prepare("INSERT INTO `users` (`username`,`password`,`ip_address`,`reg_time`,`reg_date`) VALUES('$username','$password','$ip_address','$time','$date')"); That's not how prepared statements work. http://php.net/manual/en/pdo.prepare.php A few additional things: function registerUsers($username,$password,$ip_address, $time, $date){ echo $users->registerusers('bob','bob','127.494.439.39.340','12:00','29:02:2017'); registerUsers !== registerusers Don't store passwords as plain text. Use password_hash. That's not how IP addresses are formatted. Why are you storing date and time separately? Why are you storing dates in a weird format?
  4. Sounds like your cron job is just executing some SQL query based on what little information you provided in your original post. If that's an incorrect assumption, can you flesh out what it is you're actually doing? If I'm right, then you could either use last login date/time as a constraint in your update, or use it to select the correct set of users and then perform whatever actions you need to individually.
  5. Don't do this. Don't display connection errors to the user; they shouldn't need to care and you don't want to be exposing internal errors to the outside world. Log errors, throw exceptions, handle them gracefully. Don't ever trust user input. You're leaving yourself wide open to SQL injection here. Use prepared statements. While you're at it, look at PDO instead of mysqli. It's far more pleasant to use. More SQL injection and you're using GET requests for what should be a POST. Aside from the $row["Num_of_downtime"] not existing, you don't need PHP to increment this. SQL can do it just fine. $sqlupdate = "UPDATE `Test_downtime`.`Downtime` SET `Num_of_downtime` = `Num_of_downtime` + 1, `Last_downtime` = NOW() WHERE `Server_Name` = ?";
  6. Where are these values coming from? You're not selecting them. Honestly, though, there's so much wrong with that code I don't even know where to start.
  7. I assume you're storing logins somewhere. You could use that information to retrieve a list of "eligible" users on whom to perform whatever action your cron job is meant to perform.
  8. Oh wait. Composite keys. /api/bin/1/2 points to a single object. Disregard my earlier suggestion, then. I suspect resourceful controllers will fall short and you will need to be more declarative in your routing.
  9. You have two fields called fileWrite...
  10. Looks like using dot notation will get you part of the way there. Route::resource('bin/foo.bar', 'RestBinController'); ❯ ./artisan route:list +--------+-----------+------------------------------+-----------------+------------------------------------------------+--------------+ | Domain | Method | URI | Name | Action | Middleware | +--------+-----------+------------------------------+-----------------+------------------------------------------------+--------------+ | | GET|HEAD | / | | Closure | web | | | GET|HEAD | api/user | | Closure | api,auth:api | | | GET|HEAD | bin/foo/{foo}/bar | foo.bar.index | App\Http\Controllers\RestBinController@index | web | | | POST | bin/foo/{foo}/bar | foo.bar.store | App\Http\Controllers\RestBinController@store | web | | | GET|HEAD | bin/foo/{foo}/bar/create | foo.bar.create | App\Http\Controllers\RestBinController@create | web | | | GET|HEAD | bin/foo/{foo}/bar/{bar} | foo.bar.show | App\Http\Controllers\RestBinController@show | web | | | PUT|PATCH | bin/foo/{foo}/bar/{bar} | foo.bar.update | App\Http\Controllers\RestBinController@update | web | | | DELETE | bin/foo/{foo}/bar/{bar} | foo.bar.destroy | App\Http\Controllers\RestBinController@destroy | web | | | GET|HEAD | bin/foo/{foo}/bar/{bar}/edit | foo.bar.edit | App\Http\Controllers\RestBinController@edit | web | +--------+-----------+------------------------------+-----------------+------------------------------------------------+--------------+ Not exactly the /api/bin/1/2 you were describing but close, and perhaps a little more descriptive.
  11. An image of some random JavaScript error in some random WordPress plugin and absolutely no description of what's going on. What exactly would you like us to do? Have you considered asking the creator of this plugin? If you want anyone here to help, you will certainly need to provide more details. Bumping a thread without offering any additional details seems unlikely to get you anywhere.
  12. Should you leave what blank? It's not clear what you're even trying to accomplish here. You create a file resource but don't use it, you delete files and then do nothing. And, of course, you leave yourself open to directory traversal attacks.
  13. Are $_GET['new'] and $_GET['del'] both going to be set at the same time? If $_GET['new'] is null, you exit, never getting to evaluate other conditions...
  14. What is $_POST['item_id']? I don't see that included in the form snippet above. What I do see, however, is an ID passed to use_item. $_POST['use_item'][3] would therefore be used to update the item with an ID of 3, no? See where I'm going with this?
  15. The mysql extension has been deprecated since approximately forever and was removed in PHP 7. Perhaps even more importantly is that mysqli is a separate extension. You can't mix and match functions. Read the links I provided earlier (well, read the ones I've provided here also) and you pretty much have a step by step guide to get your code working.
  16. mysqli::query returns a mysqi_result object. You need to fetch results before you can output them.
  17. I don't know that this code contains a 'culprit' or that there necessarily even is one. Hard to see when only seeing a single class without context. This class appears to be responsible for creating thumbnails, that's it. It seems unlikely that the original image would be entirely discarded, so that's where you'd want to start looking.
  18. Seriously? Have you looked at the suggestions offered? Have you tried using absolute paths? What error message(s) are you receiving? "It's not working" doesn't actually provide anyone any information.
  19. Your front controller and assets files (images, JS, CSS) belong in your public directory. That's about it. Just shoving everything into the public directory doesn't seem like a good fit for anything. You could certainly attempt to integrate your existing app into Laravel, though that depends largely on how large the app is, how far along it is, and how it is written. The more your concerns are tangled, the harder it's going to be. If the app is relatively small or is in the early stages of development, and if it's reasonably written, integration shouldn't be too large a hurdle.
  20. You haven't marked any of the select options as 'selected'. When you submit the form, its data is being stored somewhere, probably in a superglobal ($_GET or $_POST). When you're building up your select list, you'll want to compare the current item in the list against the value from the last time the form was submitted. As an aside, you probably want to break this out into a function and separate the reading of the files from the creation of the select list as those are two different concerns.
  • 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.