public function executeConfirmNewAccount() { $this->newAccountGetData(); $check = new CheckRequest(); $check->checkError($this->requestObj, $this->conf["account"]["field"]); if (strlen($this->requestObj->user_name) != 0) { if (CheckUser::userExist($this->requestObj->user_name) !== false) { $check->setError("user_name", "isUserExist"); } } $this->error = $check->getError(); if ($this->error !== false) { $this->tpl = "account_new.tpl"; } else { $this->tpl = "account_confirm.tpl"; } }
private function checkLogin() { if (CheckConnection::checkConnectTCP() === false) { $this->error["error_field"]["E018"] = 1; return false; } if (strlen($this->requestObj->user_name) > 0 && strlen($this->requestObj->password) > 0) { $password = sha1($this->requestObj->password); $data = array("user_name" => $this->requestObj->user_name, "password" => $password); // ユーザ名存在チェック if (($user = CheckUser::userExist($data)) === false) { Logger::error("Login Error : user or password not found!!! " . Logger::getArrayMessage($data)); $this->error["error_field"]["E017"] = 1; } else { $_SESSION["USER_DATA"] = $user; } } else { Logger::error("Login Error : user or password not found!!!"); $this->error["error_field"]["E017"] = 1; } }
public function execute() { global $wgCheckUserForceSummary; $db = $this->getDB(DB_SLAVE); $params = $this->extractRequestParams(); list($request, $target, $reason, $timecond, $limit, $xff) = array($params['request'], $params['target'], $params['reason'], $params['timecond'], $params['limit'], $params['xff']); if (!$this->getUser()->isAllowed('checkuser')) { $this->dieUsage('You need the checkuser right', 'permissionerror'); } if ($wgCheckUserForceSummary && is_null($reason)) { $this->dieUsage('You must define reason for check', 'missingdata'); } $reason = $this->msg('checkuser-reason-api', $reason)->inContentLanguage()->text(); $timeCutoff = strtotime($timecond); // absolute time if (!$timeCutoff) { $this->dieUsage('You need use correct time limit (like "2 weeks")', 'invalidtime'); } $this->addTables('cu_changes'); $this->addOption('LIMIT', $limit + 1); $this->addOption('ORDER BY', 'cuc_timestamp DESC'); $this->addWhere("cuc_timestamp > " . $db->addQuotes($db->timestamp($timeCutoff))); switch ($request) { case 'userips': $user_id = User::idFromName($target); if (!$user_id) { $this->dieUsage('Target user does not exist', 'nosuchuser'); } $this->addFields(array('cuc_timestamp', 'cuc_ip', 'cuc_xff')); $this->addWhereFld('cuc_user_text', $target); $res = $this->select(__METHOD__); $result = $this->getResult(); $ips = array(); foreach ($res as $row) { $timestamp = wfTimestamp(TS_ISO_8601, $row->cuc_timestamp); $ip = strval($row->cuc_ip); if (!isset($ips[$ip])) { $ips[$ip]['end'] = $timestamp; $ips[$ip]['editcount'] = 1; } else { $ips[$ip]['start'] = $timestamp; $ips[$ip]['editcount']++; } } $resultIPs = array(); foreach ($ips as $ip => $data) { $data['address'] = $ip; $resultIPs[] = $data; } CheckUser::addLogEntry('userips', 'user', $target, $reason, $user_id); $result->addValue(array('query', $this->getModuleName()), 'userips', $resultIPs); $result->setIndexedTagName_internal(array('query', $this->getModuleName(), 'userips'), 'ip'); break; case 'edits': if (IP::isIPAddress($target)) { $cond = CheckUser::getIpConds($db, $target, isset($xff)); if (!$cond) { $this->dieUsage('IP or range is invalid', 'invalidip'); } $this->addWhere($cond); $log_type = array(); if (isset($xff)) { $log_type[] = 'ipedits-xff'; } else { $log_type[] = 'ipedits'; } $log_type[] = 'ip'; } else { $user_id = User::idFromName($target); if (!$user_id) { $this->dieUsage('Target user does not exist', 'nosuchuser'); } $this->addWhereFld('cuc_user_text', $target); $log_type = array('useredits', 'user'); } $this->addFields(array('cuc_namespace', 'cuc_title', 'cuc_user_text', 'cuc_actiontext', 'cuc_comment', 'cuc_minor', 'cuc_timestamp', 'cuc_ip', 'cuc_xff', 'cuc_agent')); $res = $this->select(__METHOD__); $result = $this->getResult(); $edits = array(); foreach ($res as $row) { $edit = array('timestamp' => wfTimestamp(TS_ISO_8601, $row->cuc_timestamp), 'ns' => intval($row->cuc_namespace), 'title' => $row->cuc_title, 'user' => $row->cuc_user_text, 'ip' => $row->cuc_ip, 'agent' => $row->cuc_agent); if ($row->cuc_actiontext) { $edit['summary'] = $row->cuc_actiontext; } elseif ($row->cuc_comment) { $edit['summary'] = $row->cuc_comment; } if ($row->cuc_minor) { $edit['minor'] = 'm'; } if ($row->cuc_xff) { $edit['xff'] = $row->cuc_xff; } $edits[] = $edit; } CheckUser::addLogEntry($log_type[0], $log_type[1], $target, $reason, isset($user_id) ? $user_id : '0'); $result->addValue(array('query', $this->getModuleName()), 'edits', $edits); $result->setIndexedTagName_internal(array('query', $this->getModuleName(), 'edits'), 'action'); break; case 'ipusers': if (IP::isIPAddress($target)) { $cond = CheckUser::getIpConds($db, $target, isset($xff)); $this->addWhere($cond); $log_type = 'ipusers'; if (isset($xff)) { $log_type .= '-xff'; } } else { $this->dieUsage('IP or range is invalid', 'invalidip'); } $this->addFields(array('cuc_user_text', 'cuc_timestamp', 'cuc_ip', 'cuc_agent')); $res = $this->select(__METHOD__); $result = $this->getResult(); $users = array(); foreach ($res as $row) { $user = $row->cuc_user_text; $ip = $row->cuc_ip; $agent = $row->cuc_agent; if (!isset($users[$user])) { $users[$user]['end'] = wfTimestamp(TS_ISO_8601, $row->cuc_timestamp); $users[$user]['editcount'] = 1; $users[$user]['ips'][] = $ip; $users[$user]['agents'][] = $agent; } else { $users[$user]['start'] = wfTimestamp(TS_ISO_8601, $row->cuc_timestamp); $users[$user]['editcount']++; if (!in_array($ip, $users[$user]['ips'])) { $users[$user]['ips'][] = $ip; } if (!in_array($agent, $users[$user]['agents'])) { $users[$user]['agents'][] = $agent; } } } $resultUsers = array(); foreach ($users as $userName => $userData) { $userData['name'] = $userName; $result->setIndexedTagName($userData['ips'], 'ip'); $result->setIndexedTagName($userData['agents'], 'agent'); $resultUsers[] = $userData; } CheckUser::addLogEntry($log_type, 'ip', $target, $reason); $result->addValue(array('query', $this->getModuleName()), 'ipusers', $resultUsers); $result->setIndexedTagName_internal(array('query', $this->getModuleName(), 'ipusers'), 'user'); break; default: $this->dieUsage('Invalid request mode', 'invalidmode'); } }