echo "<loc>" . html($p->url()) . "</loc>"; echo "<lastmod>" . $p->modified('c') . "</lastmod>"; echo "<priority>" . ($p->isHomePage() ? 1 : number_format(0.5 / $p->depth(), 1)) . "</priority>"; echo "</url>"; } echo '</urlset>'; }), array('method' => 'GET', 'pattern' => 'appreciate', 'action' => function () { return go(kirby()->request()->referer()); }), array('method' => 'POST', 'pattern' => 'appreciate', 'action' => function () { // Return if no ID was sent if (get('page_id') == '') { return go(kirby()->request()->referer()); } // Create the appreciation $a = new Appreciation(site()); $entry = $a->appreciate(get('page_id')); // Send an email $email = new Email(array('to' => c::get('site_email'), 'from' => 'Aurer emailer <*****@*****.**>', 'subject' => 'Someone appreciates your work', 'body' => 'Page: ' . $entry['page'] . "\nTime: " . date('D, jS M, Y, G:i', $entry['timestamp']) . "\nIP: " . $entry['ip'], 'service' => 'mailgun', 'options' => array('key' => c::get('mailgun_key'), 'domain' => c::get('mailgun_domain')))); // Log email failures if (!$email->send()) { error_log($email->error()); } // Return JSON result return response::json($entry); }), array('method' => 'POST', 'pattern' => 'appreciate/comment', 'action' => function () { if (!get('id')) { return go(kirby()->request()->referer()); } $a = new Appreciation(site()); $data = (object) array('comments' => get('comments'), 'name' => get('name')); $entry = $a->add_comment(get('id'), $data);