Пример #1
0
 public function testAll()
 {
     $database_confirm = Database_Confirm::getInstance();
     // New ID generation test.
     $id = $database_confirm->getNewID();
     $this->assertGreaterThan(10000, $id);
     // Store data for the ID.
     $database_confirm->store($id, "SELECT x, y, z FROM a;", "email", "subject", "body");
     // Search for this ID based on subject.
     $id2 = $database_confirm->searchID("Subject line CID{$id} Re:");
     $this->assertEquals($id, $id2);
     // Retrieve data for the ID.
     $query = $database_confirm->getQuery($id);
     $this->assertEquals("SELECT x, y, z FROM a;", $query);
     $to = $database_confirm->getMailTo($id);
     $this->assertEquals("email", $to);
     $subject = $database_confirm->getSubject($id);
     $this->assertEquals("subject", $subject);
     $body = $database_confirm->getBody($id);
     $this->assertEquals("body", $body);
     // Delete this ID.
     $database_confirm->delete($id);
     $query = $database_confirm->getQuery($id);
     $this->assertEquals("", $query);
 }
Пример #2
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Database_Confirm();
     }
     return self::$instance;
 }
Пример #3
0
 /**
  * handleEmail - handles a confirmation email received from $from with subject $subject and body $body.
  * Returns true if the mail was handled, else false.
  */
 public function handleEmail($from, $subject, $body)
 {
     // Find out in the confirmation database whether the $subject line contains an active ID.
     // If not, bail out.
     $database_confirm = Database_Confirm::getInstance();
     $id = $database_confirm->searchID($subject);
     if ($id == 0) {
         return false;
     }
     // An active ID was found: Execute the associated database query.
     $query = $database_confirm->getQuery($id);
     $database_users = Database_Users::getInstance();
     Database_SQLite::exec($database_users->db, $query);
     // Send confirmation mail.
     $mailto = $database_confirm->getMailTo($id);
     $subject = $database_confirm->getSubject($id);
     $body = $database_confirm->getBody($id);
     $database_mail = Database_Mail::getInstance();
     $database_mail->send($mailto, $subject, $body);
     // Delete the confirmation record.
     $database_confirm->delete($id);
     // Job done.
     return true;
 }
Пример #4
0
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
include "utils.php";
ob_start();
require_once "../database/sqlite.php";
require_once "../database/confirm.php";
$database_confirm = Database_Confirm::getInstance();
$database_confirm->create();
$okay = !ob_get_flush();
display_header($okay);
if ($okay) {
    display_okay();
    display_paragraph("Confirmation database okay.");
} else {
    display_paragraph("Errors creating or upgrading the confirmation database");
    open_paragraph();
    display_link("confirm1.php", "Retry");
    close_paragraph();
}
display_footer();