Ejemplo n.º 1
0
 public function execute()
 {
     $mysql = new LTMySQL();
     if (!$mysql->connect(LTRODBConfig::HOST, LTRODBConfig::USER, LTRODBConfig::PASS)) {
         throw new Exception('Failed to connect to DB. Try later.');
     }
     $mysql->selectdb(LTRODBConfig::DB);
     $this->id = mysql_real_escape_string($this->id, $mysql->link());
     // Retrieve Message from DB
     $res = $mysql->query("select t1.id,t1.author,t1.added,t1.title,t2.body from ehead as t1 join entry as t2 where t1.id='{$this->id}' and t1.id=t2.id;");
     if (1 !== $mysql->numrows()) {
         throw new Exception('Message does not exist.');
     }
     $row = mysql_fetch_assoc($res);
     if (!$_row) {
         throw new RuntimeException('Failed to read message from DB. Try later.');
     }
     return json_encode(array('id' => $row['id'], 'author' => $row['author'], 'added' => $row['added'], 'title' => $row['title'], 'body' => $row['body']));
 }
Ejemplo n.º 2
0
 * Copyright 2009, Your Company All rights reserved.
 */
define("TLDIR_INDEX", $_SERVER['DOCUMENT_ROOT']);
@(include_once TLDIR_INDEX . '/php/LTConfig.php');
@(include_once TLDIR_INDEX . '/php/LTMySQL.php');
$pass = trim(strip_tags(urldecode(stripslashes($_GET['pass']))));
try {
    if (!preg_match('/[a-z0-9]{32}/', $pass)) {
        throw new RuntimeException('Invalid PASS.');
    }
    $mysql = new LTMySQL();
    if (!$mysql->connect(LTRWDBConfig::HOST, LTRWDBConfig::USER, LTRWDBConfig::PASS)) {
        throw new Exception('DB Connection Failed. Can not register user at the moment. Try later.');
    }
    $mysql->selectdb(LTRWDBConfig::DB);
    $pass = mysql_real_escape_string($pass, $mysql->link());
    $res = $mysql->query("select name,login,email from candidate where pass='******';");
    if (!$mysql->numrows()) {
        throw new RuntimeException('Link is not valid any more.');
    }
    $row = mysql_fetch_assoc($res);
    if (!$row) {
        throw new RuntimeException('Failed to find user in DB. Try to re-register.');
    }
    $mysql->query("delete from candidate where pass='******';");
    // Generate password for user.
    $pass = uniqid();
    $mysql->query("insert into user set login='******'login']}',pass='******'\';');
    $id = $mysql->insertid();
    $mysql->query("insert into uinfo set id='{$id}',name='{$row['name']}',email='{$row['email']}',added=unix_timestamp();");
    mail($row['email'], '[' . LTConfig::HOST . '] User registration.', $row['name'] . ",\n\nYou have successfuly registered. Your password is: {$pass}", 'From: ' . LTConfig::SUPPORT . "\r\n" . 'Reply-To: ' . LTConfig::SUPPORT);
Ejemplo n.º 3
0
 public function execute()
 {
     $mysql = new LTMySQL();
     if (!$mysql->connect(LTRODBConfig::HOST, LTRODBConfig::USER, LTRODBConfig::PASS)) {
         throw new Exception('DB Connection Failed. Can not read user at the moment. Try later.');
     }
     $mysql->selectdb(LTRODBConfig::DB);
     $this->uid = mysql_real_escape_string($this->uid, $mysql->link());
     $res = $mysql->query("select name,added from uinfo where id='{$this->uid}';");
     if (!$mysql->numrows()) {
         throw new Exception('User does not exist.');
     }
     $row = mysql_fetch_assoc($res);
     if (!$row) {
         throw new RuntimeException('Failed to read user from DB. Try later.');
     }
     return json_encode(array('name' => $_row['name'], 'added' => $_row['added']));
 }