Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by sKunKbad

  1. Authentication for CodeIgniter can be handled by a few different libraries, depending on what version of CodeIgniter you are using. If you are using 3.X, then you might try Community Auth: https://community-auth.com It's probably way over your head, but it works great. Another popular choice is Ion Auth. I don't have experience with Ion Auth, so I can't tell you about it.
  2. I was thinking that being able to start and stop the ssh tunneling would be nice to do with php, but after investigation I'm just going to use autossh and keep the ssh tunnel open permanently. Since the server will be using the connection at all hours of the day and night, I don't think it could hurt to keep it open.
  3. I did figure it out. The user running shell_exec, in my case www-data, needed its own self-created rsa key. I guess when I initially created it I didn't create it as www-data, so it didn't work. All is well now.
  4. PC is just a development environment, but production server is also Ubuntu, so figured if it works on dev it should work on production. I'm supposed to create an application on that production machine that can do mysql queries on that "castrated" server. I cannot make a secure connection with MySQL because that castrated server is not set up for that. I think this might be my only option.
  5. I see all over the internet tutorials that are basically saying that setting up the ssh tunnel for mysql is easy, but I get an error, and no joy: Host key verification failed This error is in a log file that I created. I am attempting to use PHP's shell_exec on my Ubuntu desktop: shell_exec('ssh -p 2233 -f -L 3307: acct@remote-server.com sleep 60 >> ./ssh.logfile 2>&1'); So, pretty standard according to the internet, but it's not working for me. 1) The remote server is a hosted website. It's a "semi-dedicated" plan, and just a glorified shared hosting
  6. I have mail sending out of my Raspberry Pi using SSMTP, but going through my gmail account. It was super easy: root=$smail Debug=yes mailhub=smtp.gmail.com:587 hostname=irrigation AuthUser=example@gmail.com AuthPass=Pas$weRd123 UseTLS=yes useSTARTTLS=YES RewriteDomain=gmail.com I didn't do anything else, and it just works. So if you can set up a gmail account, your good. Well, I did have to tell google to trust my insecure app, but that's it.
  7. Figured it out. Just need to wrap $property in curly braces. unset( $this->{$property}[$key] );
  8. I'm having a problem unsetting an array element when in PHP 5.5, but only when it's a class property. See code: <?php /** * Works fine as procedural code */ $arr = [23213523, 3634634, 68486468]; $val = 3634634; if( ( $key = array_search( $val, $arr ) ) !== FALSE ) { unset( $arr[$key] ); } echo '<pre>'; print_r($arr); echo '</pre>'; /** * Works fine on PHP7, but not PHP5.5 */ class Foo { public $arr = [23213523, 3634634, 68486468]; public function bar() { $this->_unset_numeric_val('arr', 3634634 ); } private function _unset_numer
  9. I'm guilty, so shoot me.

  10. Unless I'm being asked for my opinion, I'm just doing what the customer wants. That's kind of besides the point though, as I'm just learning some more about regular expressions in general. I thought I'd come here to PHP freaks because the site members are usually pretty responsive and knowledgeable. I'm guilty, so shoot me.
  11. Forget about passwords. I told ya I'm just learning, and I'm just using passwords because it's Sunday and I'm too lazy to come up with something else on my day off. So, I found an answer, but while I understand the basics of what a positive lookahead is, I guess my next question would be if I'm not needing a capturing group, does it hurt performance or anything if it is capturing vs non-capturing? // This /^(?=(?:.*[\d].*){3,}).*$/ // Works the same as this /^(?=(.*[\d].*){3,}).*$/ In the end preg_match is going to give me a boolean and I'm not using the matches parameter at all. P
  12. I found this works: /^(?=(?:.*[\d].*){3,}).*$/ I can change the 3 to whatever number I want, and seems to match appropriately.
  13. Well, what I was trying to achieve is a config file that has a bunch of rules that are used to dynamically create regex for the validation of password strength, and turning this off completely would be an option. I only got this idea because I've been watching some videos on regex. Even though I've been tinkering with regex for years, it's just not something I'm good at. So, while looking at the existing regex I've been using for password strength, I wondered how I would force somebody to have more than one digit, say 2 or 3 or 50. It was just a thought.
  14. I'm playing around with some regex that is used for password strength, and right not it ensures that there is at least one digit: /^(?=.*\d).*$/ This works great, but I was thinking what if I wanted to say that more than 1 digit was required, so I tried this: /^(?=.*\d{2,}).*$/ This works only if the two digits are next to each other: exam22ple // match exam2pl2e // does not match So, what I'd like to know is how to match when the digits are not next to each other.
  15. Yeah, I don't think I'd want to dictate for code, but if I could just think it and it was typed, dang that would be awesome.
  16. I've been typing for way too long. Took my first typing class in 7th grade, so about 35 years ago. Maybe someday instead of keyboards we can just put on our typing helmets and get to work
  17. I was waiting to see if anyone else replied. What you guys said makes sense. Thanks for your input.
  18. So, it is here in this forum that I first found help with PHP back in 2006 when I started learning PHP. I worked on my own websites, and slowly learned more and more. In 2009 started using Kohana, and then switched to CodeIgniter because it felt easier and felt like it was faster. Now it seems like as a PHP dev I'm just expected to use Laravel. Being a CodeIgniter dev is like having leprosy. Laravel seems easy enough, and I've enjoyed learning the basics. I just feel like the ORM, which is a big part of its magic, is not for me. I like writing SQL, and I'm no expert but Laravel ORM (which
  19. Everything before "END DENY LIST --" ends up getting tossed out and dynamically rebuilt, so I just used explode: $arr = explode('END DENY LIST --', $string); $string = $new_deny_list . $arr[1]; I have a copy of Regex Buddy that's probably almost a decade old, and a book on regex, so I should probably go find them. In the interest of trying to understand what you're suggesting, I just found a site that does online regex analysis, https://regex101.com/ Do I understand correctly that the nongreedy quantifier would simply add a question mark after my asterisk, like this: (?<=# BEGIN DEN
  20. I ended up coming up with a solution that uses explode and str_replace, but it relies on the DENY LIST comments being at the top of the file. I thought about using exec and sed, but I took the easy way out for now. Still curious as to what is up with preg_replace. It doesn't seem like it's very reliable if it can't handle a big string.
  21. I'm on Ubuntu 16.04 with PHP7, and I have no encountered this problem in other environments. The following script fails (white screen of death) unless I subtract a character from $string. What is going on? <?php $string = "# MAKE SURE TO LEAVE THE NEXT TWO LINES HERE. # BEGIN DENY LIST -- # END DENY LIST -- asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd fsdfsdfsdfsdf asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdasd asdasdasdasdas
  22. I understand that it would be better to allow PHP to log it's own errors, and I could even specify the location of a custom error log, but I like having the extra info in the log, such as request URI, headers, post data, etc. You suggest to have error_reporting on in both environments, but interestingly the errors are getting logged even when it is set to 0 in production.
  23. So, I'd like to log my PHP errors on my production environment, and a cron will send them to me via email. I used to just send them instantly to myself with email, but had a bad experience where a loop sent me about 4000 emails. I can use set_error_handler() returning FALSE so that PHP stops execution when necessary, and I don't have to call die(). In the production environment display_errors is set to 0, and so is error_reporting(). This seems to work fine, but I'm wondering if there are any unseen side effects of what I'm doing. Please take a look: <?php class Tvsc_error_handler { pu
  24. Yep, this is what I ended up doing. I was just curious if there might have been a one liner way.
  25. I am changing the name of one of the fields in my table: ALTER TABLE `users` CHANGE `user_date` `created_at` DATETIME NOT NULL; The old field, "user_date" is int(10) and storing time in epoch format. The new field is just a datetime field. Is it possible to modify this query so that the time is converted to datetime? Thanks.
  • 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.