Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


kicken last won the day on December 12 2018

kicken had the most liked content!

Community Reputation

473 Excellent

1 Follower

About kicken

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    Bonita, FL
  • Age

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. kicken

    Reading between two lines in text file

    So you want to start reading data at the 0 @F*@ FAM line, then stop when you either hit the next FAM line or hit the end of file right? <?php $fp = fopen('valkrider.txt', 'r'); $record = []; while (!feof($fp)){ $line = trim(fgets($fp)); if (isHeaderLine($line)){ if (!empty($record)){ doSomethingWithRecord($record); $record = []; } } $record[] = $line; } if (!empty($record)){ doSomethingWithRecord($record); } function isHeaderLine($line){ return strncmp($line, '0 @F',4) === 0; } function doSomethingWithRecord($record){ var_dump($record); } This code works by just gathering every line read into a record array until it encounters one of those header lines. When it finds a header line it processes the previous record (if any) then starts a new record array. At the end of the loop it will process the final record if one exists. I made the assumption that the header lines all begin with "0 @F". If that's not accurate you'll have to expand on that condition. I'm also assuming there are not lines you need to ignore at the start/end of the file. Again, if that's not true you'll need to make adjustments.
  2. kicken

    Reading between two lines in text file

    It would help if you included an example of the file you are reading and which lines are your start and stop lines.
  3. Create a function that looks for inputs with a specific attribute and then apply your date picker code to those. For example: jQuery(function($){ var defaultSettings = { format: 'yyyy/mm/dd', calendarWeeks: true, weekStart: 1, todayHighlight: true }; $('[data-datepicker]').each(function(){ var $input = $(this); var settings = $.extend($input.data('datepicker')||{}, defaultSettings); $input.datepicker(settings); }); }); Then in your HTML you just give your inputs the appropriate attribute. If you want to change the default settings, put the new settings as the attributes value. <input type="text" name="start" data-datepicker> <input type="text" name="end" data-datepicker> <input type="text" name="birthday" data-datepicker='{"format":"mm/dd/yyyy"}'>
  4. I'd guess that what you'd want to do is just create a temporary directory somewhere when you need to build an app for a user and create/modify your cordova project there. Make the temporary directory. Create your cordova project Apply whatever settings/customizations the user specified Execute the cordova command to build the apk Copy the apk off somewhere when done Delete the directory.
  5. Program Execution There are several options for running a program. exec() is most common in my experience.
  6. kicken

    Prevent Brute Force on a Token

    The answer to this is two-fold. 1) Make sure your tokens are random and long. This makes the likelyhood of guessing a token so small it may as well be considered impossible. 2) Have a monitoring system in place that can detect a potential brute-force attempt and ban the source IP address. I suspect, like many do, you're under-estimated just how long such a brute-force attempt would take. Lets take your example and assume a fixed 32-character hex value with the attacker starting at 00000000000000000000000000000000 and working toward ffffffffffffffffffffffffffffffff. Assuming they have a great connection and your server has a great response time permitting a guess every 1ms, by the time they got to the value cb1d797808ad9cd9a67e6657398b9191 they would already have been guessing for 8,561,210,154,550,000,000,000,000,000 years (if my math is correct, no guarantee there). Sure, there's a chance they happen to guess one just after it was created along the way, but that chance is tiny. Hopefully before that happens you've realized what is going on and blocked them via your monitoring system.
  7. kicken

    free license key for jwplayer ?

    After googling around for a bit, it seems if you want a free version you have to grab the source from github and build it yourself. It's says it's not the same as the commercial version, but I'm not sure what exactly the differences are.
  8. kicken

    Implications of passing by reference

    Asking for a reference is considered a writing context. If the variable doesn't exist, it is created with a NULL value. Since you're overwriting $tmp each time, you don't notice any issues. If you were not overwriting it you'd notice those keys being created as the loop progresses. I use this when trying to group results from a query easily. For example, say I had a query that returned students and their enrolled courses and wanted to end up with an array with the list of students, and their enrollments by session. I'd do something like: $result = []; foreach ($stmt as $row){ $studentId = $row['studentId']; $sessionId = $row['sessionId']; $courseId = $row['courseId']; $student = &$result[$studentId]; if (!$student){ //Haven't seen student yet $student = [ 'fistName' => $row['studentFirstname'] , 'lastName' => $row['studentLastname'] , 'id' => $studentId , 'sessionList' => [] ]; } $session = &$student['sessionList'][$sessionId]; if (!$session){ //Haven't seen session yet $session = [ 'name' => $row['sessionName'] , 'id' => $sessionId , 'courseList' => [] ]; } //Assume no course duplicates. $course = &$session['courseList'][$courseId]; $course = [ 'name' => $row['courseName'] , 'id' => $courseId ]; } The code is simpler due to not having to check if keys exist or not by using isset() in each step. Using the reference will create the key and I can do a simple if to see if it was newly created or already existed. It also make a nice alias so at the end I can just do $session['courseList'][$courseId] instead of having to do $result[$studentId]['sessionList'][$sessionId']['courseList'][$courseId].
  9. kicken

    How to clear bookmarks In PhpStorm 2017.2.4

    Just hit your Delete key while you have them highlighted in the bookmarks window.
  10. var editor = $('#' + ed.editor + '.atjs'); That line means it is going to try and find an element with id=ed.editor and class="atjs". So you'd need to write your textarea such as: <textarea id="yourEditor" class="atjs"></textarea> then initialize tinymce on that textarea.
  11. Did you give your editor the atjs class? Did you initialize tinymce on the editor?
  12. kicken

    UNDEFINED INDEX with += Assignment Operator

    Because += involves reading the current value first, and you haven't yet defined any value for that index. $animal['count'] += $value is the same as $animal['count'] = $animal['count'] + $value If you know what keys you are using, then you can just initialize them to zero before your loop. $animal = ['count' => 0];
  13. kicken

    Looping through an array

    You can use explode to split your IP, array_map to do the conversion, and implode to join them back together again. $ipComponents = explode('.', $ip); $ipComponents = array_map('decbin', $ipComponents); $ip = implode('.', $ipComponents); The above would only work for IPv4 addresses. If you need to support IPv6 you'll need to adjust the code accordingly.
  14. kicken

    Sending SMTP email

    PHPMailer is still popular as far as I know, and is probably fine. I prefer SwiftMailer personally. As for why there is no native solution...probably just because there are already excellent third-party solutions and creating a well/full featured internal SMTP client would be more hassle than it's worth. The password functions were added because it's a very common task and one that many people end up doing incorrectly which can have major consequences. It's also something that would have been relatively easy to implement as native functions so the benefit of adding them was well worth the effort required to do so.
  15. When it comes to query parameters, I like to create a parameterize function which generates a placeholder name and adds the value + name to an array then returns the new parameter name. This allows concatenation like one might be used to but uses parameters. function Parameterize($value, &$binds){ static $counter = 0; if (!is_array($binds)){ $binds = []; } if (is_array($value)){ if (count($value) == 0){ return 'null'; } else { $allParams = []; foreach ($value as $v){ $allParams[] = Parameterize($v, $binds); } return implode(',', $allParams); } } else { if (is_bool($value)){ $value = (int)$value; } else if ($value instanceof \Datetime){ $value = $value->format('Y-m-d H:i:s'); } $param = ':param' . (++$counter); $binds[$param] = $value; return $param; } } With that, the query above would look like: // database specific code $sql = "SELECT id, state FROM loc WHERE state LIKE " . Parameterize($_GET['term'] . '%', $binds); $stmt = $pdo->prepare($sql); $stmt->execute($binds); If you want to do multiple queries in a row you need to clear out the variable holding the parameters ($binds above) before each query or you'll get an error due to mismatching parameters. I tend to isolate my queries into their own function which is another way to avoid this problem as each function has it's own scope.

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.