public function delNote($noteID) { $am = AccountManager::getInstance(); $vcsLogin = $am->vcsLogin; // A user can only delete his note. Not those of others users. $s = 'SELECT user FROM `userNotes` WHERE id = %d'; $params = array($noteID); $r = $this->conn->query($s, $params); $a = $r->fetch_object(); if ($a->user == $vcsLogin) { // We can delete it $s = 'DELETE FROM `userNotes` WHERE id = %d'; $params = array($noteID); $this->conn->query($s, $params); return true; } else { return false; } }
/** * Get all news for this LANG. * * @return An indexed array (id, title, description, link, pubDate) readable by ExtJs, or false if an error occurs */ function getLastNews() { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $result = array(); if ($this->lang == 'en') { $url = $appConf[$project]['news.url.en']; } else { $url = str_replace("{LANG}", strtolower(str_replace('_', '-', $this->lang)), $appConf[$project]['news.url.lang']); } $content = @file_get_contents($url); if (!$content) { return false; } $xml = new SimpleXMLElement($content); $channel = $xml->channel; $i = 0; foreach ($channel->item as $item) { $result[$i]['id'] = $i; $result[$i]['title'] = (string) $item->title; $result[$i]['description'] = preg_replace('/(<a href[^>]+">)([^>]+)(<\\/a>)/', "\$2", (string) $item->description); $result[$i]['link'] = (string) $item->link; $result[$i]['pubDate'] = @date('Y/m/d H:i:s', @strtotime((string) $item->pubDate)); $i++; } return $result; }
/** * Initialise the lock file * * @param string $id The lock identifier */ function __construct($id) { $am = AccountManager::getInstance(); $appConf = $am->appConf; // For security, we don't want to have IDs that can traverse directories. $id = basename($id); $this->id = $id; $this->path = $appConf['GLOBAL_CONFIGURATION']['data.path'] . '.' . $this->id; }
/** */ public function __construct($path) { $this->am = AccountManager::getInstance(); // Only available for PHP project if ($this->am->project != 'PHP') { return false; } $this->path = str_replace('..', '', $path); $this->checkPath(); $this->makePreview(); }
function errlog($mess) { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $mess = '[' . @date('d/m/Y H:i:s') . '] by ' . $am->vcsLogin . ' : ' . str_replace("\r\n", " ", $mess) . "\n"; $fp = fopen($appConf[$project]['vcs.path'] . '../.errlog', 'a+'); fwrite($fp, $mess); fclose($fp); // Send me all error for debug warning $am->email('*****@*****.**', '[PhDOE - Error] New error detected', "A new error was detected :\n\n====" . $mess . "\n\n====", '*****@*****.**', 'others'); }
public function setProject($project) { $project = strtoupper($project); // This project must be defined in $availableProject constant if (!isset($this->appConf[$project]) || $this->appConf[$project]['project.enable'] == false) { return false; } $this->project = $project; AccountManager::getInstance()->project = $project; $_SESSION['project'] = $project; return true; }
public static function buildUrl($appid, $memid) { if (empty($appid) || empty($memid)) { throw new MyException("appid或 memid 不能为空 appid={$appid} memid={$memid}"); } $memObj = AccountManager::getInstance()->getMemberByMemid($appid); if (AppConstants::$APP_TESTSITE[0] == $appid) { return self::testSite($memObj); } if (AppConstants::$APP_FANFOU[0] == $appid) { return self::fanfou($memObj); } throw new MyException("can not get the app, has the app registered? appid={$appid}"); }
/** * Get all open bugs for this LANG. * * @return An indexed array (id, title, description, link, pubDate) readable by ExtJs */ function getOpenBugs() { $appConf = AccountManager::getInstance()->appConf; $project = AccountManager::getInstance()->project; if ($this->lang == 'en') { $url = $appConf[$project]['bugs.url.en']; } else { $url = $appConf[$project]['bugs.url.lang']; } $r = @file_get_contents($url); if (!$r) { return false; } $xml = new SimpleXMLElement($r); $channel = $xml; $i = 0; $result = array(); foreach ($channel->item as $item) { $title = (string) $item->title; $description = $item->description; if (strstr($title, '[' . strtoupper($this->lang) . ']') || $this->lang == 'en') { $result[$i]['id'] = $i; $result[$i]['title'] = $title; $match = array(); if (strstr($description, "Reproduce code:")) { preg_match_all('/Description:\\s*?------------(.*?)Reproduce code:/s', $description, $match); } else { preg_match_all('/Description:\\s*?------------(.*)/s', $description, $match); } $result[$i]['description'] = isset($match[1][0]) ? highlight_string(trim($match[1][0]), true) : ''; $result[$i]['link'] = (string) $item->link; $match = array(); // Try to find the link to this documentation bug preg_match('/From manual page: (.*?)(#|\\s)/s', $description, $match); $result[$i]['xmlID'] = isset($match[1]) ? $match[1] : false; // We remove all caracters except xmlid (after and before) if ($result[$i]['xmlID']) { $match = array(); preg_match('/function\\.(.[^%]*)/es', $result[$i]['xmlID'], $match); if (isset($match[1])) { $result[$i]['xmlID'] = $match[1]; } } $i++; } } return $result; }
/** * Manage a word ; Add or update a word base on his wordId. * If wordId is "new", the word is added, else it was updated * @param $wordId : Database Id for the word or "new" if we want to add it * @param $valueEn : New English value * @param $valueLang : New lang value * */ public function manageDictionaryWord($wordId, $valueEn, $valueLang) { $am = AccountManager::getInstance(); $vcsLogin = $am->vcsLogin; $project = $am->project; $vcsLang = $am->vcsLang; $time = @date("Y-m-d H:i:s"); if ($wordId == 'new') { $s = 'INSERT INTO `dictionary` (`project`, `lang`, `valueEn`, `valueLang`, `lastUser`, `lastDate`) VALUES ("%s", "%s", "%s", "%s", "%s", "%s")'; $params = array($project, $vcsLang, $valueEn, $valueLang, $vcsLogin, $time); } else { $s = 'UPDATE `dictionary` SET `valueEn` = "%s", `valueLang`= "%s", `lastUser` = "%s", `lastDate` = "%s" WHERE `id` = %d'; $params = array($valueEn, $valueLang, $vcsLogin, $time, $wordId); } $this->conn->query($s, $params); return $time; }
/** * @static * @return CvsClient|SvnClient */ public static function getInstance() { $appConf = AccountManager::getInstance()->appConf; if (!isset(self::$instance)) { switch ($appConf['GLOBAL_CONFIGURATION']['vcs.type']) { case 'cvs': require_once dirname(__FILE__) . '/CvsClient.php'; self::$instance = CvsClient::getInstance(); break; case 'svn': require_once dirname(__FILE__) . '/SvnClient.php'; self::$instance = SvnClient::getInstance(); break; } } return self::$instance; }
/** <div class="itemHeader"> <div class="itemlogo"><img src="../styles/images/fanfou.gif" alt="fanfou"></div> <div class="itemlogo"><img src="../styles/images/person_image.gif" alt="person"></div> <a href="[__who_url]" title="浏览[__who]的共享">[__who]</a>在 <a href="[__where_url]" title="[__where]">[__where]</a> 共享了 <a href="[__title__link]" title="[__Title]">[__Title]</a> </div> */ private function buildItemHeader() { $memApp = AccountManager::getInstance()->getMemAppBySynid($this->rssItem->synid); $appObj = AppManager::getInstance()->getAppByAppid($memApp->appid); $html = ' <div class="itemHeader">'; // <div class="itemlogo"><img src="../styles/images/fanfou.gif" alt="fanfou"></div> $html .= '<div class="itemlogo"><img src="' . $appObj->getLogoUrl() . '" alt="' . $appObj->name . '"></div>'; // <div class="itemlogo"><img src="../styles/images/person_image.gif" alt="person"></div> $memberObj = AccountManager::getInstance()->getMemberByMemid($memApp->memid); $html .= '<div class="itemlogo"><img src="' . $memberObj->getPersonalImage() . '" alt="' . $memberObj->name . '"></div>'; //<a href="[__who_url]" title="浏览[__who]的共享">[__who]</a>在 $html .= '<a href="http://www.friendsharing.com/memid=' . $memberObj->memid . '" title="浏览' . $memberObj->name . '的共享">' . $memberObj->name . '</a>在'; // <a href="[__where_url]" title="[__where]">[__where]</a> 共享了 $html .= '<a href="' . $memApp->rssurl . '" title="' . $appObj->name . '">' . $appObj->name . '</a>共享了'; // <a href="[__title__link]" title="[__Title]">[__Title]</a> $html .= '<a href="' . $this->rssItem->link . '" title="' . $this->rssItem->title . '">' . $this->rssItem->title . '</a>'; $html .= '</div>'; return $html; }
public function checkForError($xmlContent) { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $this->xmlContent = $xmlContent; $this->saveInTmpFile(); $this->XmlFileResult = tempnam(sys_get_temp_dir(), 'PhDOE_' . mt_rand()); $cmd = new ExecStatement($appConf['GLOBAL_CONFIGURATION']['xmllint.bin'] . ' --noout %s > %s 2>&1', array($this->XmlFileName, $this->XmlFileResult)); $trial_threshold = 3; while ($trial_threshold-- > 0) { $output = array(); SaferExec::exec($cmd, $output); if (strlen(trim(implode('', $output))) != 0) { break; } } $this->rawErrors = file($this->XmlFileResult); $this->Errors = $this->parseResult(); return $this->Errors; }
/** * Initialise * */ function __construct() { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; // This entities will not be checked as there are always wrong. We use it into the manual like this : "&url.foo;bar" // Entries should not include the & and ; $this->EntitiesNotChecked = array("url.pecl.package.get", "url.pecl.package"); $this->urlConnectTimeout = 10; $this->userAgent = 'DocWeb Link Crawler (http://doc.php.net)'; $this->pathEntities = $appConf[$project]['entities.url']; $this->forkUrlAllow = function_exists('pcntl_fork') && isset($_ENV['NUMFORKS']); $this->forkNumAllowed = $this->forkUrlAllow ? $_ENV['NUMFORKS'] : 0; $this->supportedSchemes = array('http'); if (extension_loaded('openssl')) { $this->supportedSchemes[] = 'https'; } if (function_exists('ftp_connect')) { $this->supportedSchemes[] = 'ftp'; } $this->conn = DBConnection::getInstance(); }
private function parseEntities() { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $files = explode("|", $appConf[$project]['entities.usedbyeditor.location']); $this->entities = array(); $count = 0; while (list($k, $file) = each($files)) { if (empty($file) || !($content = file_get_contents($file))) { continue; } preg_match_all('/<!ENTITY\\s(.*?)\\s(\'|")(.*?)(\\2)>/s', $content, $match); $from = explode('/', $file); for ($i = 0; $i < count($match[1]); $i++) { $this->entities[$count]['id'] = $count; $this->entities[$count]['from'] = $from[count($from) - 1]; $this->entities[$count]['items'] = $match[1][$i]; $this->entities[$count]['value'] = htmlentities($match[3][$i]); $count++; } } }
/** * Get the list of failed build. */ public function getFailedBuild() { $project = AccountManager::getInstance()->project; $s = 'SELECT `id`, `lang`, `date` FROM `failedBuildLog` WHERE `project` = "%s"'; $params = array($project); $r = $this->conn->query($s, $params); $node = array(); while ($a = $r->fetch_assoc()) { $node[] = $a; } return array('nb' => $r->num_rows, 'node' => $node); }
/** * Test if the file is a modified file. * * @return Mixed FALSE if the file haven't been modified, otherwise, some information about the user how have modified it. */ public function isModified() { $am = AccountManager::getInstance(); $project = $am->project; $s = 'SELECT `id` as fidDB, `users`.`vcs_login` as `user`, `users`.`userID`, `users`.`authService`, `module` as fromModule, `type` as ftype, `work`.`userID` FROM `work`, `users` WHERE `work`.`userID` = `users`.`userID` AND `work`.`project` = "%s" AND `lang`="%s" AND `path`="%s" AND `name`="%s"'; $params = array($project, $this->lang, $this->path, $this->name); $r = $this->conn->query($s, $params); if ($r->num_rows == 0) { return false; } else { $a = $r->fetch_assoc(); if ($a['user'] == 'anonymous') { $a['user'] = $a['user'] . ' #' . $a['userID']; } $a['haveKarma'] = $a['authService'] == 'VCS' && $am->checkKarma($a['user'], $this->lang) === true; return json_encode($a); } }
echo "----------------end add memebers---------------------"; echo "<br>"; echo "<br>"; echo "----------------begin add app---------------------"; echo "<br>"; AppManager::getInstance()->loadAllApps(); $appbasic = AppManager::getInstance()->getAppByAppid(1); echo "----------------end add app---------------------"; echo "<br>"; echo "<br>"; echo "----------------begin member register app---------------------"; echo "<br>"; $memberObj = AccountManager::getInstance()->getMemberByEmail('*****@*****.**'); AccountManager::getInstance()->registerMemApp($memberObj->memid, AppConstants::$APP_TESTSITE[0]); $memberObj = AccountManager::getInstance()->getMemberByEmail('*****@*****.**'); AccountManager::getInstance()->registerMemApp($memberObj->memid, AppConstants::$APP_FANFOU[0]); echo "----------------end member register app---------------------"; echo "<br>"; echo "<br>"; echo "----------------begin add test rss items---------------------"; echo "<br>"; var_dump(RssManager::getInstance()->getLatestItems()); echo "----------------end add test rss items---------------------"; echo "<br>"; echo "<br>"; echo "----------------begin---------------------"; echo "<br>"; echo "----------------end---------------------"; echo "<br>"; echo "<br>"; echo "----------------begin---------------------";
/** * Save the error's stack into DB * */ function saveError() { $project = AccountManager::getInstance()->project; if (count($this->errorStack) > 0) { $sql = 'INSERT INTO errorfiles (`project`, `lang`, `path`, `name`, `maintainer`, `value_en`,`value_lang`,`type`) VALUES '; $errorSQL = array(); $params = array(); foreach ($this->errorStack as $error) { $errorSQL[] = '("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'; $params[] = $project; $params[] = $this->lang; $params[] = $this->filePath; $params[] = $this->fileName; $params[] = $this->maintainer; $params[] = $error['value_en']; $params[] = $error['value_lang']; $params[] = $error['type']; } $this->conn->query($sql . implode(', ', $errorSQL), $params); } }
private function updateKarmaList() { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $file = @file($appConf[$project]['vcs.karma.file']); $line_avail = array(); $user = array(); // We cleanUp the content of this file for ($i = 0; $i < count($file); $i++) { if (substr($file[$i], 0, 6) == 'avail|') { $line_avail[] = $file[$i]; $t = explode("|", $file[$i]); $users = trim($t[1]); $karmas = isset($t[2]) ? trim($t[2]) : 'ALL'; $users = explode(",", $users); $karmas = explode(",", $karmas); for ($j = 0; $j < count($users); $j++) { if (isset($user[$users[$j]])) { $user[$users[$j]]['karma'] = array_merge($karmas, $user[$users[$j]]['karma']); } else { $user[$users[$j]]['karma'] = $karmas; } } } } // We store this value into DB as json string to retrieve it later $to_store = array("update_time" => time(), "data" => $user); RepositoryManager::setStaticValue('karma_list', '', json_encode($to_store)); }
public function applyOnlyTools() { $am = AccountManager::getInstance(); // We start by cleaning up the database $this->conn->query("DELETE FROM `errorfiles` WHERE `project`='%s'", array($am->project)); // We start by all translation // We select files how have revision=en_revision for this lang $query = 'SELECT * FROM files WHERE `project`="%s" AND `lang`!="%s" AND `revision`=`en_revision`'; $params = array($am->project, 'en'); $r = $this->conn->query($query, $params); while ($a = $r->fetch_object()) { $error = new ToolsError(); $fileEN = new File('en', $a->path . $a->name); $ENContent = $fileEN->read(true); $fileLANG = new File($a->lang, $a->path . $a->name); $LANGContent = $fileLANG->read(true); $error->setParams($ENContent, $LANGContent, $a->lang, $a->path, $a->name, ''); $error->run(); $error->saveError(); } //.... and now, EN files $query = 'SELECT * FROM files WHERE `project`="%s" AND `lang`="%s"'; $params = array($am->project, 'en'); $r = $this->conn->query($query, $params); while ($a = $r->fetch_object()) { $error = new ToolsError(); $fileEN = new File('en', $a->path . $a->name); $ENContent = $fileEN->read(true); $error->setParams($ENContent, '', $a->lang, $a->path, $a->name, ''); $error->run(); $error->saveError(); } }
/** * Executes cvs commit * * @param $log Commit log * @param $create Array of files to be created * @param $update Array of files to be updated * @param $delete Array of files to be deleted * @return Array of stdout of cvs commit */ public function commit($log, $create = false, $update = false, $delete = false) { $am = AccountManager::getInstance(); $appConf = $am->appConf; $project = $am->project; $create_stack = array(); for ($i = 0; $create && $i < count($create); $i++) { $create_stack[] = $create[$i]->lang . '/' . $create[$i]->path . '/' . $create[$i]->name; } $update_stack = array(); for ($i = 0; $update && $i < count($update); $i++) { $p = $update[$i]->lang . '/' . $update[$i]->path . '/' . $update[$i]->name; $update_stack[] = $p; @copy($appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $p, $appConf[$project]['vcs.path'] . $p); @unlink($appConf['GLOBAL_CONFIGURATION']['data.path'] . $appConf[$project]['vcs.module'] . '-new/' . $p); } $delete_stack = array(); for ($i = 0; $delete && $i < count($delete); $i++) { $delete_stack[] = $delete[$i]->lang . '/' . $delete[$i]->path . '/' . $delete[$i]->name; } // Buil the command line $cvsLogin = AccountManager::getInstance()->vcsLogin; $cvsPasswd = AccountManager::getInstance()->vcsPasswd; $commands = array(new ExecStatement('export CVS_PASSFILE=%s', array(realpath($appConf['GLOBAL_CONFIGURATION']['data.path']) . '/.cvspass')), new ExecStatement('cd %s', array($appConf[$project]['vcs.path'])), new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository login')); if (!empty($delete_stack)) { $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f remove -f' . str_repeat(' %s', count($delete_stack)), array($delete_stack)); } if (!empty($create_stack)) { $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f add' . str_repeat(' %s', count($create_stack)), array($create_stack)); } $args = array_merge(array($log), $create_stack, $update_stack, $delete_stack); $commands[] = new ExecStatement('cvs -d :pserver:' . $cvsLogin . ':' . $cvsPasswd . '@cvs.php.net:/repository -f commit -l -m %s' . str_repeat(' %s', count($create_stack) + count($update_stack) + count($delete_stack)), $args); $output = array(); SaferExec::execMulti($commands, $output); return $output; }
case 'new': $libelMod = 'New file'; break; case 'delete': $libelMod = 'Deleted'; break; } $msg .= $libelMod . ": " . $data['PatchesForReview']['data'][$i]['fileFullPath'] . "\n"; $msg .= "By: " . $data['PatchesForReview']['data'][$i]['user'] . " on " . $data['PatchesForReview']['data'][$i]['date'] . "\n"; $msg .= "===================================================================\n"; // We get the diff $file = new File($data['PatchesForReview']['data'][$i]['fileLang'], $data['PatchesForReview']['data'][$i]['filePath'] . $data['PatchesForReview']['data'][$i]['fileName']); $r = $file->diff(); $msg .= implode("\n", $r); $msg .= "\n\n => Put this change into your patches : https://edit.php.net/?project=php&action=putIntoMyPatches&idDB=" . $data['PatchesForReview']['data'][$i]['idDB'] . "\n => Delete this change: https://edit.php.net/?project=php&action=deleteThisChange&idDB=" . $data['PatchesForReview']['data'][$i]['idDB'] . "\n "; $msg .= "\n"; $msg .= " ------------------------------------------------------------------\n\n"; } $msg .= "\n\n"; } $msg .= "\n-- \nhttps://edit.php.net/\nThis email is send automatically by the Php Docbook Online Editor.\n "; //Usefull for language like pt_BR for example, because doc-pt_br don't exist, it's doc-pt-br $emailLang = str_replace("_", "-", strtolower($lang)); $to = $lang === 'en' ? "*****@*****.**" : "doc-{$emailLang}@lists.php.net"; $subject = "Contributions are ready for review"; // We send an email for this failed build AccountManager::getInstance()->email($to, $subject, $msg, $to, 'list'); echo "email send !\n"; } } }
/** * */ public function setDirectAction() { $am = AccountManager::getInstance(); if (!$am->isLogged()) { return JsonResponseBuilder::failure(); } $action = $this->getRequestVariable('action'); $patchID = $this->getRequestVariable('patchID'); $idDB = $this->getRequestVariable('idDB'); if ($action == 'putIntoMyPatches') { $r = RepositoryManager::getInstance()->moveToPatch($patchID, $idDB); if ($r === true) { return JsonResponseBuilder::success(); } else { return JsonResponseBuilder::failure(array('err' => $r)); } } if ($action == 'deleteThisChange') { $r = RepositoryManager::getInstance()->clearLocalChangeByModifiedID($idDB); if (is_array($r)) { return JsonResponseBuilder::success(); } else { return JsonResponseBuilder::failure(array('err' => $r)); } } }
/** * Get statistic about files which need to be translated. * * @param $lang Can be either 'all' for all availables languages, or one specific language * @return An associated array */ public function getNoTransFileCount($lang = 'all') { $project = AccountManager::getInstance()->project; $result = $summary = array(); // We get EN files $s = 'SELECT * FROM files WHERE `lang`="en" AND `project`="%s"'; $params = array($project); $r = $this->conn->query($s, $params); while ($a = $r->fetch_object()) { $resultEN[$a->path . $a->name] = $a->size; } if ($lang == 'all') { $s = 'SELECT `path`, `name`, `lang` FROM `files` WHERE `lang` != "en" AND `revision` is NULL AND `status` is NULL AND `project` = "%s" '; $params = array($project); } else { $s = 'SELECT `path`, `name`, `lang` FROM `files` WHERE `lang` = "%s" AND `revision` is NULL AND `status` is NULL AND `project` = "%s" '; $params = array($lang, $project); } $r = $this->conn->query($s, $params); while ($a = $r->fetch_object()) { $result[$a->lang][$a->path . $a->name] = 'exist'; } while (list($a, $b) = each($result)) { $size[$a] = 0; while (list($k, $v) = each($result[$a])) { $size[$a] += $resultEN[$k]; } } // reset($result); while (list($a, $b) = each($result)) { $summary[$a]['total'] = count($result[$a]); $summary[$a]['total_size'] = $size[$a]; } return $summary; }
private function addModStat($type, $subType, $value, $yearMonth) { $am = AccountManager::getInstance(); $project = $am->project; $tmp = explode('-', $yearMonth); $year = $tmp[0]; $month = $tmp[1]; $s = ' SELECT id FROM `usageStatistics` WHERE `type` = "%s" AND `subType` = "%s" AND YEAR(`yearMonth`) = "%s" AND MONTH(`yearMonth`) = "%s" AND `project` = "%s" '; $params = array($type, $subType, $year, $month, $project); $r = $this->conn->query($s, $params); $nb = $r->num_rows; if ($nb == 0) { // It's the first time we compute stats for this Year-Month. We add them into DB $s = 'INSERT INTO `usageStatistics` ( `project`, `type`, `subType`, `value`, `yearMonth` ) VALUES ( "%s", "%s", "%s", "%s", "%s" )'; $params = array($project, $type, $subType, $value, $year . '-' . $month . '-01'); $r = $this->conn->query($s, $params); } else { $a = $r->fetch_object(); // It's not the first time, we update the record $s = 'UPDATE `usageStatistics` SET `value`="%s" WHERE `id`="%s" '; $params = array($value, $a->id); $r = $this->conn->query($s, $params); } }
/** * Get a static value from DB * * @param $type The type of this value * @param $field The name of the field for this value * @return The value. */ public static function getStaticValue($type, $field) { // Save in DB $s = 'SELECT id, value FROM staticValue WHERE `project` = "%s" AND `type` = "%s" AND `field`= "%s"'; $params = array(AccountManager::getInstance()->project, $type, $field); $r = DBConnection::getInstance()->query($s, $params); if ($r->num_rows == 0) { return false; } else { $a = $r->fetch_object(); return json_decode($a->value); } }
<?php session_start(); error_reporting(E_ALL); require_once "./php/AccountManager.php"; require_once "./php/ToolsError.php"; $am = AccountManager::getInstance(); $am->isLogged(); if (isset($_GET['dir']) && isset($_GET['file'])) { // We retrieve all this error from DB to display the value. $errorTools = new ToolsError(); $errorTools->setParams('', '', $am->vcsLang, $_GET['dir'], $_GET['file'], ''); $error_to_display = $errorTools->getInfo(); if (empty($error_to_display)) { // We fake an empty error $error_to_display['-No error-']['error'][0]['value_en'] = '-'; $error_to_display['-No error-']['error'][0]['value_lang'] = '-'; } $fileLibel = $_GET['dir'] . $_GET['file']; } else { $error_to_display = array(); $fileLibel = NULL; } ?> <style type="text/css"> .member-table { font-size: 13px; color: #222222; font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif; margin: 10px;
/** * Get number of old reviewed files per translators. * * @param $lang Can be either 'all' for all availables languages, or one specific language * @return An associated array */ public function getReviewedStaleFileCount($lang = 'all') { $project = AccountManager::getInstance()->project; if ($lang == 'all') { $s = 'SELECT COUNT(`name`) AS total, `reviewed_maintainer`, `lang` FROM `files` WHERE `en_revision` = `revision` AND `reviewed` != "yes" AND `size` is not NULL AND `project` = "%s" GROUP BY `reviewed_maintainer` ORDER BY `reviewed_maintainer` '; $params = array($project); } else { $s = 'SELECT COUNT(`name`) AS total, `reviewed_maintainer`, `lang` FROM `files` WHERE `lang` = "%s" AND `en_revision` = `revision` AND `reviewed` != "yes" AND `size` is not NULL AND `project` = "%s" GROUP BY `reviewed_maintainer` ORDER BY `reviewed_maintainer` '; $params = array($lang, $project); } $r = $this->conn->query($s, $params); $result = array(); while ($a = $r->fetch_object()) { $result[$a->lang][$a->reviewed_maintainer] = $a->total; } return $result; }
class_exists('AccountManager') or (require '../account/AccountManager.class.php'); if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['email']) && isset($_POST['password'])) { $email = $_POST['email']; $password = $_POST['password']; $loginFailMsg = NULL; $redirectLoginSuccess = "../view/myself.php"; try { $memberObj = AccountManager::getInstance()->login($email, $password); } catch (MyException $e) { $memberObj = null; } //if(empty($loginFailMsg) == false ) echo $loginFailMsg; if ($memberObj) { $_SESSION['memid'] = $memberObj->memid; $_SESSION['memname'] = $memberObj->name; if (isset($_SESSION['PrevUrl']) && true) { $redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $redirectLoginSuccess); } else { $loginFailMsg = "Email或密码错误"; } }