Esempio n. 1
0
 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;
 }
            $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;
        }
        $cursor = $stmt->getCursor();
Esempio n. 3
0
<?php

require_once "../init_gpc.inc.php";
require_once "../init.inc.php";
$id = $_GET['id'];
$row = $_GET['row'];
if ($id == '') {
    exit;
}
//TODO: V4 - Tester
$mg = mg_connect($config, "", "", "");
if ($mg) {
    $stmt = new mg_stmt_select($mg, "sources_log");
    $query = array("id_source" => intval($id));
    $stmt->setQuery($query);
    $stmt->setSort(array("createtime" => -1));
    $count = $stmt->execute();
    header('Content-type: text/html; charset=UTF-8');
    if ($count == 0) {
        print "No log available !";
        exit;
    }
    $cursor = $stmt->getCursor();
    if ($row == "") {
        $row = 0;
        while ($cursor->hasNext()) {
            $rs = $cursor->getNext();
            $t = $rs["createtime"] / 1000;
            $created = date('Y-m-d H:i:s', $t);
            //1.37271406957E+12
            print "<a href='log.php?id=" . $id . "&row=" . $row . "'>" . $created . "</a><br>";
Esempio n. 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;
}
        }
    }
    $res .= "<br /><br /><br /><br /><br /><br />Add new account<a href='#' onClick='displayAddAccount(); return false;'><img src='images/edit_add_32.png'></a>&nbsp;&nbsp;";
    print $res;
    exit;
}
if ($action == "displayaccount") {
    $res = "<br /><br /><br />";
    $id = $_GET["id"];
    if ($id == "") {
        print "";
        exit;
    }
    $mg = mg_connect($config, "", "", "");
    if ($mg) {
        $stmt = new mg_stmt_select($mg, "accounts");
        $query = array("id" => intval($id));
        $stmt->setQuery($query);
        $count = $stmt->execute();
        if ($count == 0) {
            print $s;
            exit;
        }
        $cursor = $stmt->getCursor();
        $rs = $cursor->getNext();
        $res .= "<form name='account_edit' id='account_edit' action=''><center><table border='0' cellspacing='0' cellpadding='0'>";
        $res .= "<tbody>";
        $res .= "<tr>";
        $res .= "<td class='head'>Id</td>";
        $res .= "<td>" . $rs["id"] . "</td>";
        $res .= "</tr>";
 $mode = "";
 $ids = "";
 if (isset($_POST["mode"])) {
     $mode = $_POST["mode"];
 }
 if (isset($_POST["ids"])) {
     $ids = array_map('intval', $_POST["ids"]);
 }
 $mg = mg_connect($config, "", "", "");
 if ($mg) {
     $query = array("name" => "version");
     mg_get_value($mg, "infos", "value", $query, $version);
     $xml = new SimpleXMLElement('<crawlanywhere/>');
     $version = $xml->addChild('version', $version);
     $sources = $xml->addChild('sources');
     $stmt = new mg_stmt_select($mg, "sources");
     $query = array("id_account" => intval($id_account_current));
     if ($mode == 'selection') {
         $query2 = array("id" => array('$in' => $ids));
     } else {
         $query2 = array('$or' => array(array("deleted" => "0"), array("deleted" => NULL)));
     }
     $query = array('$and' => array($query, $query2));
     $stmt->setQuery($query);
     $stmt->setSort(array("name" => 1));
     $count = $stmt->execute();
     if ($count == 0) {
         $arr = array('status' => 'error');
         echo json_encode($arr);
         exit;
     }