コード例 #1
0
 public function addEntry($sender, $param)
 {
     if ($this->IsValid) {
         $name = strtr(trim($this->Name->Text), array("'" => "''"));
         $email = strtr(trim($this->Email->Text), array("'" => "''"));
         $phone = strtr(trim($this->Phone->Text), array("'" => "''"));
         $address = strtr(trim($this->Address->Text), array("'" => "''"));
         $memo = strtr($this->Memo->Text, array("'" => "''"));
         $db = new TAdodb();
         $db->DataSourceName = $this->Application->getUserParameter('DSN');
         $db->Execute("INSERT INTO tblEntry (name,email,phone,address,memo) VALUES ('{$name}','{$email}','{$phone}','{$address}','{$memo}')");
         $this->Application->transfer('HomePage', array(HomePage::FILTER => $name[0]));
     }
 }
コード例 #2
0
 public function login($name, $password = '')
 {
     $authenticated = false;
     $adodb = new TAdodb();
     //$adodb->setDataSourceName($this->Application->getUserParameter('DSN'));
     require "config.php";
     $adodb->setDataSourceName($dsn);
     $adodb->SetFetchMode("Associative");
     //Check if there are any admin users
     $result = $adodb->Execute("SELECT * FROM users WHERE admin=255");
     //Check with config.php password if there are no admin users
     if ($result->RecordCount() == 0) {
         if ($name == $admin_name && $password == $admin_temp_password) {
             $this->setEmail("*****@*****.**");
             $this->setId(0);
             $this->setAdmin(true);
             $this->setGroup(false);
             $this->setRepository(false);
             $this->setAuthenticated(true);
             $this->setConfigAdmin(true);
             $result->Close();
             return true;
         }
     }
     $result->Close();
     //Check for database user
     $md5_pw = md5($password);
     $s_name = makeSqlString($name);
     $result = $adodb->Execute("SELECT * FROM users WHERE name={$s_name} AND password='******'");
     //$result=$adodb->Execute("SELECT * FROM users WHERE name='$name' AND password = MD5('$password')");
     if ($result->RecordCount() > 0) {
         $authenticated = true;
         $fields = $result->fields;
         $userid = $fields['id'];
         $s_userid = makeSqlString($userid);
         $email = $fields['email'];
         $this->setEmail($email);
         $this->setId($userid);
         if ($fields['admin'] == 255) {
             //Level 255 is superadmin
             $this->setAdmin(true);
         } else {
             $this->setAdmin(false);
         }
         $groups = $adodb->Execute("SELECT * FROM groups WHERE adminid={$s_userid}");
         if ($groups->RecordCount() > 0) {
             $this->setGroup(true);
         } else {
             $this->setGroup(false);
         }
         $repos = $adodb->Execute("SELECT * FROM repositories WHERE ownerid={$s_userid}");
         if ($repos->RecordCount() > 0) {
             $this->setRepository(true);
         } else {
             $repos = $adodb->Execute("SELECT repositorygrants FROM users WHERE id={$s_userid}");
             if ($repos->fields['repositorygrants'] > 0) {
                 $this->setRepository(true);
             } else {
                 $this->setRepository(false);
             }
         }
     }
     $result->Close();
     $this->setAuthenticated($authenticated);
     return $authenticated;
 }