1<?php 2/* 3 * vim:set softtabstop=4 shiftwidth=4 expandtab: 4 * 5 * LICENSE: GNU Affero General Public License, version 3 (AGPL-3.0-or-later) 6 * Copyright 2001 - 2020 Ampache.org 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU Affero General Public License as published by 10 * the Free Software Foundation, either version 3 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU Affero General Public License for more details. 17 * 18 * You should have received a copy of the GNU Affero General Public License 19 * along with this program. If not, see <https://www.gnu.org/licenses/>. 20 * 21 */ 22 23declare(strict_types=0); 24 25namespace Ampache\Module\User; 26 27use Ampache\Module\Util\Mailer; 28use Ampache\Config\AmpConfig; 29 30/** 31 * Registration Class 32 * 33 * This class handles all the doodlys for the registration 34 * stuff in Ampache 35 */ 36class Registration 37{ 38 /** 39 * send_confirmation 40 * This sends the confirmation e-mail for the specified user 41 * 42 * @SuppressWarnings(PHPMD.UnusedFormalParameter) 43 * @param string $username 44 * @param string $fullname 45 * @param string $email 46 * @param string $website 47 * @param string $validation 48 * @return boolean 49 */ 50 public static function send_confirmation($username, $fullname, $email, $website, $validation) 51 { 52 if (!Mailer::is_mail_enabled()) { 53 return false; 54 } 55 56 $mailer = new Mailer(); 57 58 // We are the system 59 $mailer->set_default_sender(); 60 61 /* HINT: Ampache site_title */ 62 $mailer->subject = sprintf(T_("New User Registration at %s"), AmpConfig::get('site_title')); 63 64 $mailer->message = T_('Thank you for registering') . "\n"; 65 $mailer->message .= T_('Please keep this e-mail for your records. Your account information is as follows:') . "\n"; 66 $mailer->message .= "----------------------\n"; 67 $mailer->message .= T_('Username') . ": $username" . "\n"; 68 $mailer->message .= "----------------------\n"; 69 $mailer->message .= T_('To begin using your account, you must verify your e-mail address by vising the following link:') . "\n\n"; 70 $mailer->message .= AmpConfig::get('web_path') . "/register.php?action=validate&username=$username&auth=$validation"; 71 $mailer->recipient = $email; 72 $mailer->recipient_name = $fullname; 73 74 if (!AmpConfig::get('admin_enable_required')) { 75 $mailer->send(); 76 } 77 78 // Check to see if the admin should be notified 79 if (AmpConfig::get('admin_notify_reg')) { 80 $mailer->message = T_("A new user has registered, the following values were entered:") . "\n\n"; 81 $mailer->message .= T_("Username") . ": $username\n"; 82 $mailer->message .= T_("Fullname") . ": $fullname\n"; 83 $mailer->message .= T_("E-mail") . ": $email\n"; 84 $mailer->message .= T_("Website") . ": $website\n"; 85 $mailer->send_to_group('admins'); 86 } 87 88 return true; 89 } // send_confirmation 90 91 /** 92 * show_agreement 93 * This shows the registration agreement, /config/registration_agreement.php 94 * @return boolean 95 */ 96 public static function show_agreement() 97 { 98 $filename = __DIR__ . '/../../../config/registration_agreement.php'; 99 100 if (!file_exists($filename)) { 101 return false; 102 } 103 104 /* Check for existence */ 105 $filepointer = fopen($filename, 'r'); 106 107 if (!$filepointer) { 108 return false; 109 } 110 111 $data = fread($filepointer, filesize($filename)); 112 113 /* Scrub and show */ 114 echo $data; 115 116 return true; 117 } // show_agreement 118} // end registration.class 119