示例#1
0
 public static function authenticate($username = "", $password = "")
 {
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         $sql = "SELECT *  ";
         $sql .= "FROM  `user`  ";
         $sql .= "WHERE (";
         $sql .= "`username` =  :username ";
         $sql .= "OR  `email` =  :username";
         $sql .= ") ";
         $sql .= "AND  `password` =  :password ";
         $sql .= "AND  `valid` =  '1';";
         $params = array(':password' => $password, ':username' => $username);
         array_unshift($params, '');
         unset($params[0]);
         $results_array = $database->QueryForObject($sql, $params);
         return !empty($results_array) ? array_shift($results_array) : false;
     }
 }
示例#2
0
 public function deactivate($user)
 {
     $database = cbSQLConnect::connect('object');
     if (isset($database) && $user && ($user->rights === 'super' || $user->rights === 'admin')) {
         $fields = self::$db_fields;
         // $this->submitter = (int)$user->id;
         $this->status = 'I';
         foreach ($fields as $key) {
             $flag = $database->SQLUpdate("person", $key, $this->{$key}, "id", $this->id);
             if ($flag == "fail") {
                 break;
             }
         }
         if ($flag == "fail") {
             return false;
         } else {
             return $this->id;
         }
     }
 }
示例#3
0
 protected function update()
 {
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         $fields = self::$db_fields;
         foreach ($fields as $key) {
             $flag = $database->SQLUpdate("connections", $key, $this->{$key}, "id", $this->id);
             if ($flag == "fail") {
                 break;
             }
         }
         if ($flag == "fail") {
             return false;
         } else {
             return $this->id;
         }
     }
 }
示例#4
0
function savePlaces($place, $table, $id, $group)
{
    $database = cbSQLConnect::connect('object');
    if (isset($database)) {
        $fields = array();
        $fields['name'] = $place;
        $fields['ftable'] = $table;
        $fields['fid'] = $id;
        $fields['category'] = $group;
        // return data
        $insert = $database->SQLInsert($fields, "places");
        // return true if sucess or false
        if ($insert) {
            return $insert;
        } else {
            return "Insert didn't compute";
        }
    }
}
示例#5
0
        //    else
        //    {
        //       echo "STDCLASS OBJ";
        //    }
        // }
        //    echo "\n";
        // print_r($search_result);
        // echo "</pre>";
        // echo count($search_result);
    }
    exit;
}
if ($action = 'getFilteredData') {
    //    error_reporting(E_ALL);
    // ini_set('display_errors', '1');
    $database = cbSQLConnect::connect('array');
    $search_query = getRequest("key");
    $search_result_data = array();
    $search_result_tags = array();
    $results = array();
    if (isset($database) && !empty($search_query)) {
        $data = $database->QuerySingle("SELECT *, MATCH(title, author, comments) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) AS score FROM `file` WHERE MATCH(title, author, comments) AGAINST('" . $search_query . "*' IN BOOLEAN MODE) ORDER BY score DESC");
        //$results[] = $data;
        if (count($data) == 0) {
            //echo "Search found nothing in File\n";
        } else {
            foreach ($data as $instance) {
                $temp = recast("File", arrayToObject($instance));
                if ($temp->comments !== null) {
                    $results[] = $temp->comments;
                }
示例#6
0
     exit;
     exit;
 }
 // this will get us the list of individuals
 if ($action == 'getIndividuals') {
     $people = Person::getIndividuals();
     if ($people) {
         echo json_encode($people);
     } else {
         echo "failed";
     }
     exit;
 }
 // this will get us the list of individuals
 if ($action == 'getPlaces') {
     $database = cbSQLConnect::connect('object');
     $result = array();
     if (isset($database)) {
         $places = $database->QuerySingle("SELECT DISTINCT `id`, `name`, `ftable`, `fid`, `category` FROM `places`  GROUP BY `name`");
         if ($places) {
             foreach ($places as $aplace) {
                 $temp = array();
                 $temp[] = $aplace->id;
                 $temp[] = $aplace->name;
                 $temp[] = $aplace->ftable;
                 $temp[] = $aplace->fid;
                 $temp[] = $aplace->category;
                 $result[] = $temp;
             }
         } else {
             return "none";
示例#7
0
文件: user.php 项目: Jonathan-Law/fhd
 public function delete()
 {
     $database = cbSQLConnect::connect('object');
     if (isset($database)) {
         return $database->SQLDelete(self::$table_name, 'id', $this->id);
     }
 }