private function login_internal($config, $name, $password)
 {
     $mg = mg_connect($config, "", "", "");
     if ($mg) {
         $stmt = new mg_stmt_select($mg, "users");
         $query_username = array('user_name' => $name);
         if (isset($password) && !empty($password)) {
             $query_password = array('$or' => array(array('user_password' => md5($password)), array('user_password' => $password)));
             $query = array('$and' => array($query_username, $query_password));
         } else {
             $query = $query_username;
         }
         $stmt->setQuery($query);
         $count = $stmt->execute();
         if ($count == 1) {
             $cursor = $stmt->getCursor();
             $rs = $cursor->getNext();
             $this->id = $rs["id"];
             $this->name = $rs["user_name"];
             $this->level = intval($rs["user_level"]);
             $this->id_account = $rs["id_account"];
             $this->change_password = $rs["change_password_next_logon"] == "1";
             // mise a jour login_lasttime
             $stmt = new mg_stmt_update($mg, "users");
             $stmt->addColumnValueDate("login_lasttime");
             $stmt->setQuery(array('id' => $this->id));
             $stmt->execute();
             return true;
         }
     }
     return false;
 }
Example #2
0
function dbinit($config, $collection, $ar)
{
    $mg = mg_connect($config, "", "", "");
    if ($mg) {
        $coll = $mg->selectCollection($collection);
        foreach ($ar as $line) {
            $line = trim($line);
            if (!empty($line)) {
                $data = json_decode($line);
                $ret = $coll->insert($data);
            }
        }
    }
}
            $res .= "</td>";
            $res .= "<td class='count'>";
            $res .= $rs["running_crawl_item_processed"];
            $res .= "</td>";
            $res .= "<td class='count'>";
            $res .= $rs["running_crawl_item_to_process"];
            $res .= "</td>";
            $res .= "</tr>";
        }
        $res .= "</tbody></table></center>";
        print $res;
        exit;
    }
}
if ($action == "showenqueued") {
    $mg = mg_connect($config, "", "", "");
    if ($mg) {
        $stmt = new mg_stmt_select($mg, "sources");
        //$stmt->setWhereClause("enabled = 1 and deleted = 0 and (crawl_process_status='' or crawl_process_status='0') and id_account = " . $id_account_current);
        $query = array('$and' => array(array(enabled => "1"), array(deleted => "0"), array(id_account => intval($id_account_current)), array('$or' => array(array(crawl_process_status => null), array(crawl_process_status => "0")))));
        //$query = array('$and' => array(array(enabled => "1"), array(deleted => "0")));
        $stmt->setQuery($query);
        $stmt->setSort(array("crawl_priority" => -1, "crawl_nexttime" => 1));
        //$stmt->setSort(array( "crawl_nexttime" => 1 ));
        if ($limit != "0") {
            $stmt->setLimit($limit);
        }
        $count = $stmt->execute();
        if ($count == 0) {
            print "";
            exit;
Example #4
0
function getAvailableEngines($config)
{
    $aEnginesFinal = null;
    $mg = mg_connect($config, "", "", "");
    if ($mg) {
        $stmt = new mg_stmt_select($mg, "accounts");
        $stmt->setFields(array("id" => "true", "name" => "true"));
        $stmt->setSort(array("name" => 1));
        $count = $stmt->execute();
        if ($count > 0) {
            $aAccountsFinal = array();
            $cursor = $stmt->getCursor();
            while ($cursor->hasNext()) {
                $rs = $cursor->getNext();
                $id = strtolower(trim($rs['id']));
                $name = trim($rs['name']);
                $aEnginesFinal[$id] = $name;
            }
        }
    }
    return $aEnginesFinal;
}