Пример #1
0
 public function add(array $data)
 {
     if (!isset($data['CreatorID']) || !isset($data['RegionUUID'])) {
         return false;
     }
     $data['CreationDate'] = time();
     if (count($this->db->fetchOne("SELECT UUID FROM auth WHERE UUID='{$data['CreatorID']}'")) != 1) {
         return false;
     }
     $data['OwnerID'] = isset($data['OwnerID']) ? $data['OwnerID'] : $data['CreatorID'];
     $data['LastOwnerID'] = isset($data['LastOwnerID']) ? $data['LastOwnerID'] : $data['CreatorID'];
     if (count($this->db->fetchOne("SELECT uuid FROM regions WHERE uuid='{$data['RegionUUID']}'")) != 1) {
         return false;
     }
     $data['UUID'] = $data['SceneGroupID'] = Model_OpenSim::getRandomId();
     $primsData = array();
     $primsFields = $this->db->fetchAll('SHOW COLUMNS FROM prims');
     foreach ($primsFields as $p) {
         $f = $p['Field'];
         if (array_key_exists($f, $data)) {
             $primsData[$f] = $data[$f];
         }
     }
     $shapeData = array();
     $shapeFields = $this->db->fetchAll('SHOW COLUMNS FROM primshapes');
     foreach ($shapeFields as $p) {
         $f = $p['Field'];
         if (array_key_exists($f, $data)) {
             $shapeData[$f] = $data[$f];
         }
     }
     $this->db->insert('prims', $primsData);
     $this->db->insert('primshapes', $shapeData);
     return $data['UUID'];
 }
Пример #2
0
 public function editPassword($id, $password)
 {
     $passwordSalt = $this->db->fetchOne("SELECT passwordSalt FROM auth WHERE UUID=\"{$id}\"");
     if (!$passwordSalt) {
         return false;
     }
     $this->db->update('auth', array('passwordHash' => md5(md5($password) . ':' . $passwordSalt)), "UUID=\"{$id}\"");
 }