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; }
<?php //============================================================================ // (c) 2009-2010, Eolya - All Rights Reserved. // This source code is the property of Eolya. // The license applying to this source code is available at : // http://www.crawl-anywhere.com/licenses/ //============================================================================ if ($action == "stopsource" || $action == "pausesource" || $action == "resumesource") { $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_update($mg, "sources"); $query = array("id" => intval($_GET["id"])); $stmt->setQuery($query); if ($action == "stopsource") { $stmt->addColumnValue("crawl_process_status", "5"); } if ($action == "pausesource") { $stmt->addColumnValue("crawl_process_status", "2"); } if ($action == "resumesource") { $stmt->addColumnValue("crawl_process_status", "3"); $stmt->addColumnValue("crawl_priority", "1"); } $stmt->addColumnValueDate("crawl_nexttime"); $stmt->execute(); /* if (!$rs) { $res = "Error"; }
$res = "Success "; //$res .= $s; } print $res; exit; } if ($action == "saveaccount") { $id = $_POST["account_id"]; if ($id == "") { $res = "Error "; print $res; exit; } $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_update($mg, "accounts"); $query = array("id" => intval($id)); $stmt->setQuery($query); $stmt->addColumnValue("name", $_POST["account_name"]); $stmt->addColumnValue("id_engine", intval($_POST["id_engine"])); $stmt->addColumnValue("id_target", intval($_POST["id_target"])); $stmt->execute(); $res = "Success "; } print $res; exit; } if ($action == "deleteaccount") { $id = $_POST["account_id"]; if ($id == "") { $res = "Error ";
} $res = "Success "; } print $res; exit; } if ($action == "savetarget") { $id = $_POST["id"]; if ($id == "") { $res = "Error "; print $res; exit; } $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_update($mg, "targets"); $query = array("id" => intval($id)); $stmt->setQuery($query); $stmt->addColumnValue("name", $_POST["name"]); $stmt->addColumnValue("id_account", intval($_POST["id_account"])); $stmt->addColumnValue("target_type", $_POST["target_type"]); $stmt->addColumnValue("target_parameters", $_POST["target_parameters"]); $stmt->addColumnValue("queue_dir", $_POST["queue_dir"]); $stmt->execute(); $res = "Success "; } print $res; exit; } if ($action == "deletetarget") { $id = $_POST["id"];
} $res = "Success "; } print $res; exit; } if ($action == "saveuser") { $id = $_POST["user_id"]; if ($id == "") { $res = "Error "; print $res; exit; } $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_update($mg, "users"); $query = array("id" => intval($id)); $stmt->setQuery($query); if ($_POST["user_level"] == "2") { $stmt->addColumnValue("id_account", 0); } else { if (isset($_POST["id_account"])) { $stmt->addColumnValue("id_account", intval($_POST["id_account"])); } } if (isset($_POST["user_password"]) && trim($_POST["user_password"] != "")) { $stmt->addColumnValue("user_password", trim($_POST["user_password"])); } if (isset($_POST["user_level"])) { $stmt->addColumnValue("user_level", $_POST["user_level"]); }
continue; } if ($count == 1) { $mode = "update"; } } if ($mode == 'insert') { $stmt = new mg_stmt_insert($mg, "sources", $mg_source_defaults); $stmt->addColumnValue("id_account", intval($id_account_current)); $stmt->addColumnValueDate("createtime"); $enabled = $status; } else { if ($strategy == 'skip') { continue; } $stmt = new mg_stmt_update($mg, "sources"); $stmt->setQuery($query); $enabled = (string) $item->enabled; } $stmt->addColumnValue("deleted", "0"); $stmt->addColumnValue("enabled", $enabled); if ($reset == "1") { $stmt->addColumnValue("crawl_mode", "2"); } else { $stmt->addColumnValue("crawl_mode", "0"); } $stmt->addColumnValue("crawl_firstcompleted", "0"); $stmt->addColumnValue("crawl_priority", $priority); $stmt->addColumnValueDate("crawl_nexttime"); $stmt->addColumnValue("crawl_process_status", "0"); $query = array("id" => intval($id_account_current));
} $res = "Success "; } print $res; exit; } if ($action == "saveengine") { $id = $_POST["engine_id"]; if ($id == "") { $res = "Error "; print $res; exit; } $mg = mg_connect($config, "", "", ""); if ($mg) { $stmt = new mg_stmt_update($mg, "engines"); $query = array("id" => intval($id)); $stmt->setQuery($query); $stmt->addColumnValue("name", $_POST["engine_name"]); $stmt->execute(); $res = "Success "; } print $res; exit; } if ($action == "deleteengine") { $id = $_POST["engine_id"]; if ($id == "") { $res = "Error "; print $res; exit;
// $query = array ('$and' => array($query, array ("url_host" => (string) $item->url_host))); // $count = mg_row_count($mg, "sources", $query); // if ($count > 1) continue; // if ($count == 1) $mode = "update"; // } if ($mode == 'insert') { $stmt = new mg_stmt_insert($mg, "sources", $mg_source_defaults); $stmt->addColumnValue("id_account", intval($id_account_current)); $stmt->addColumnValueDate("createtime"); $enabled = $status; $import_update_fields = array(); } else { if ($strategy == 'skip') { continue; } $stmt = new mg_stmt_update($mg, "sources"); $stmt->setQuery($query); $enabled = (string) $item->enabled; $import_update_fields = array_map('trim', explode(',', $config->getDefault("sources.import_update_fields", ""))); } if (!empty($import_id_field) && strtolower($import_id_field) != 'name') { $stmt->addColumnValue("import_id", (string) $item->{$match}); } if (update_field("deleted", $import_update_fields)) { $stmt->addColumnValue("deleted", "0"); } if (update_field("enabled", $import_update_fields)) { $stmt->addColumnValue("enabled", $enabled); } if ($reset == "1") { $stmt->addColumnValue("crawl_mode", "2");