Jump to content

maxudaskin

Members
  • Posts

    628
  • Joined

  • Last visited

About maxudaskin

  • Birthday 05/13/1992

Profile Information

  • Gender
    Male
  • Location
    Toronto, Ontario

maxudaskin's Achievements

Advanced Member

Advanced Member (4/5)

0

Reputation

  1. Hello all and happy holidays! I am having a brain fart with my regex and cannot seem to wrap my head around what I am doing wrong. $regex = '/(?:<thead><tr>)(<th>(.*)<\/th>)+(?:<\/tr><\/thead>)/'; $subject = '<thead><tr><th>Day</th><th>Date</th><th>Duty</th><th>From</th><th>Report</th><th>To</th><th>Release</th><th>Flight Time</th><th>Duty Time</th><th>TAFB Time</th><th>Rest Time</th><th>Sector(s)/Event(s)</th></tr></thead><tbody>...more string'; What I am hoping to get out of this is ['Day', 'Duty', 'From', 'Report',] // ... and so on But I'm getting this instead Array( '<thead><tr><th>Day</th><th>Date</th><th>Duty</th><th>From</th><th>Report</th><th>To</th><th>Release</th><th>Flight Time</th><th>Duty Time</th><th>TAFB Time</th><th>Rest Time</th><th>Sector(s)/Event(s)</th></tr></thead>', '<th>Day</th><th>Date</th><th>Duty</th><th>From</th><th>Report</th><th>To</th><th>Release</th><th>Flight Time</th><th>Duty Time</th><th>TAFB Time</th><th>Rest Time</th><th>Sector(s)/Event(s)</th>', 'Day</th><th>Date</th><th>Duty</th><th>From</th><th>Report</th><th>To</th><th>Release</th><th>Flight Time</th><th>Duty Time</th><th>TAFB Time</th><th>Rest Time</th><th>Sector(s)/Event(s)', )
  2. <?php // FlightEntryController.php ... class FlightEntryController extends Controller { public function __construct() { $this->authorizeResource(FlightEntry::class); } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show(FlightEntry $flight) { dd($flight); } ... } // FlightEntryPolicy.php class FlightEntryPolicy { use HandlesAuthorization; ... /** * Determine whether the user can view the model. * * @param \App\Models\User $user * @param \App\Models\FlightEntry $flightEntry * @return \Illuminate\Auth\Access\Response|bool */ public function view(User $user, FlightEntry $flightEntry) { dd($user); if($user->hasPermissionTo('view flights not owned')) { // Spatie return Response::allow(); } if($user->id === $flightEntry->user_id) { return Response::allow(); } return Response::deny(null, 404); } ... } // AuthServiceProvider.php class AuthServiceProvider extends ServiceProvider { /** * The policy mappings for the application. * * @var array */ protected $policies = [ App\Models\FlightEntry::class => App\Policies\FlightEntryPolicy::class, ]; ... } // routes/web.php Route::resource('/flights', FlightEntryController::class)->middleware('auth'); With the policy not attached, everything works fine. When I attach the policy, index (viewAny) works, but show (view) does not. It throws a 403 and does not run the dd inside. I'm going crazy. Any suggestions?
  3. Turns out OpenCart has been modifying the source and adding an additional } that is creating a syntax error. Off to find the root of this issue.
  4. Hi guys, I'm customizing an OpenCart template that is riddled with programming bugs. It is MVC and I am having a really odd issue with a controller file. The template that I want to use is not loading. I have edited the one in the selected template and also the default, but no avail. I was troubleshooting why it wasn't working and I came to the conclusion that either I am completely blind or stupid, or PHP is all of a sudden a troll. Please let me know if you need more context, but here is a snippet of the code and the result. I am really at a loss right now. Result: 14 Code: echo "1"; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/product/category.tpl')) { echo "2";die(); $this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/product/category.tpl', $data)); } else { echo "3";die(); $this->response->setOutput($this->load->view('default/template/product/category.tpl', $data)); } echo "4";die();
  5. My suggestion is to seperate the active users data from the users themselves. Have a second table that is queried to find the last page load activity. This way you can, if you want, log all of the user's actions, login's, or none of them at all.
  6. You have to link to the image relative to the file that the user first loaded. If they loaded http : //www . example . com/dir/abcd/efg/index.php, and the image was in /dir/upload, you would have to either call the image relatively, ../../upload/image.jpg or absolutely, http : //www . example . com/dir/upload/image.jpg.
  7. I would create a cron job running once a day, calling a php script. The php script would get the rows from the table from x days ago and would loop through and send a follow up email. Have each email template in it's own file. Let's say, initial_email.php and followup_email.php. <?php /** * initial_email.php */ $message = <<<EOD Hi {$name}, Thank you for submitting your information. You will receive an email in about seven days. --- This is an automated email. Replies will not be received. EOD; <?php /** * followup_email.php */ $message = <<<EOD Hi {$name}, About a week ago, you entered your information into our system. This is the follow up email. --- This is an automated email. Replies will not be received. EOD;
  8. The best way to prevent header errors is to, instead of putting php in the middle of html code, separate your code into three main catagories Models Views Controllers Models are the liaisons between your code and databases, xml files, ect. Use functions such as get_posts, save_post, remove_post. Views are the files containing the HTML code. The only php on the page should be to output data. <h1>Posts</h1> <?php foreach($posts as $post): ?> <div> <?=$post?> </div> <?php endforeach; ?> Controllers control the data that is being sent to the views. Let's say that a user wants to view a post. Controller is activated. Controller gets the id of the post from the URI, $_GET['id'] Controller asks the Model for the post from the database. $model->get_post($id); Model runs get_post. Queries the database for a post with a 'post_id' of $id Model either returns the post data, or false if it didn't find anything Controller gets the post data. Checks if false. If false, returns a 'Post Not Found' error. Controller sends the post data to the View file. View echoes the post data. User reads the article and goes about the rest of their day, none the wiser. Here's some reading material. It is a bit lengthy.
  9. http://www.php.net/manual/en/function.array-multisort.php#example-4608
  10. Very ineffective salting method. Try this: function enc_salt($password) { $salt = 'somerandomecharacters1646#s@0-2 da2e/5ad+'; return md5($password . $salt); }
  11. Change if(file_put_contents($logfile, $data, FILE_APPEND)) { } else { echo "logfile could not be accessed"; } to if(!file_put_contents($logfile, $data, FILE_APPEND)) { echo "logfile could not be accessed"; }
  12. That's purely an HTML and CSS question... erm... statement.
  13. Real quick, I'm going to show you something to save your butt, then I'll try to explain how to do this. What is it exactly is it that you need help with? If you're looking to get code written for you, then you'll have to go to the Freelance Section. If you're looking for assistance with code that you're writing, you'll have to let us know what you need help with.
  14. I would highly suggest checking out PHPMailer.
×
×
  • 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.