function modlog__find($cond = array(), $orderby = array(), $page = 1, $pagesize = 20) { $cond = cond_to_sqladd($cond); $orderby = orderby_to_sqladd($orderby); $offset = ($page - 1) * $pagesize; return db_find("SELECT * FROM `bbs_modlog` {$cond}{$orderby} LIMIT {$offset},{$pagesize}"); }
function group__find($cond = array(), $orderby = array(), $page = 1, $pagesize = 1000) { $cond = cond_to_sqladd($cond); $orderby = orderby_to_sqladd($orderby); $offset = ($page - 1) * $pagesize; $grouplist = db_find("SELECT * FROM `bbs_group` {$cond}{$orderby} LIMIT {$offset},{$pagesize}", 'gid'); return $grouplist; }
function thread_top_find($fid = 0) { if ($fid == 0) { $threadlist = db_find("SELECT * FROM `bbs_thread_top` WHERE top=3 ORDER BY tid DESC LIMIT 100", 'tid'); } else { $threadlist = db_find("SELECT * FROM `bbs_thread_top` WHERE fid='{$fid}' AND top=1 ORDER BY tid DESC LIMIT 100", 'tid'); } $tids = arrlist_values($threadlist, 'tid'); $threadlist = thread_find_by_tids($tids, 1, 100); return $threadlist; }
function forum_delete($fid) { // 把板块下所有的帖子都查找出来,此处数据量大可能会超时,所以不要删除帖子特别多的板块 $threadlist = db_find("SELECT tid, uid FROM `bbs_thread` WHERE fid='{$fid}'"); foreach ($threadlist as $thread) { thread_delete($thread['tid']); } $r = forum__delete($fid); forum_list_cache_delete(); return $r; }
function friendlink_find($cond = array(), $orderby = array(), $page = 1, $pagesize = 1000) { $cond = cond_to_sqladd($cond); $orderby = orderby_to_sqladd($orderby); $offset = ($page - 1) * $pagesize; $friendlinklist = db_find("SELECT * FROM `bbs_friendlink` {$cond}{$orderby} LIMIT {$offset},{$pagesize}", 'linkid'); if ($friendlinklist) { foreach ($friendlinklist as &$friendlink) { friendlink_format($friendlink); } } return $friendlinklist; }
function thread_new_find() { $threadlist = db_find("SELECT * FROM `bbs_thread_new` ORDER BY tid DESC LIMIT 100"); if (empty($threadlist)) { $threadlist = thread_find(array(), array('tid' => -1), 1, 100); foreach ($threadlist as $thread) { thread_new_create($thread['tid']); } } else { $tids = arrlist_values($threadlist, 'tid'); $threadlist = thread_find_by_tids($tids, 1, 100, 'tid'); } return $threadlist; }
function thread_lastpid_find() { $threadlist = db_find("SELECT * FROM `bbs_thread_lastpid` ORDER BY lastpid DESC LIMIT 100"); if (empty($threadlist)) { // 此处特殊情况,一般不会执行到此处,无须索引 $threadlist = thread_find(array(), array('lastpid' => -1), 1, 100); foreach ($threadlist as $thread) { thread_lastpid_create($thread['tid'], $thread['lastpid']); } } else { $tids = arrlist_values($threadlist, 'tid'); $threadlist = thread_find_by_tids($tids, 1, 100, 'lastpid'); } return $threadlist; }
function forum_access_find_by_fid($fid) { $accesslist = db_find("SELECT * FROM `bbs_forum_access` WHERE fid='{$fid}' ORDER BY gid ASC LIMIT 100", 'gid'); return $accesslist; }
function attach_gc() { global $time, $conf; $attachlist = db_find("SELECT * FROM bbs_attach WHERE pid='0'"); if (empty($attachlist)) { return; } foreach ($attachlist as $attach) { // 如果是 1 天内的附件,则不处理,可能正在发帖 if ($time - $attach['create_date'] < 86400) { continue; } $filepath = $conf['upload_path'] . $attach['filename']; is_file($filepath) and unlink($filepath); } }
function post_find_by_pids($pids) { if (empty($pids)) { return array(); } $sqladd = implode(',', $pids); return db_find("SELECT * FROM bbs_post WHERE pid IN({$sqladd})"); }
<?php require_once "../../phplib/util.php"; ini_set('memory_limit', '512000000'); $lexems = db_find(new Lexem(), 'restriction like "%S%" or restriction like "%P%"'); $count = count($lexems); foreach ($lexems as $lexem) { print "Regenerez {$lexem->form} {$lexem->modelType}{$lexem->modelNumber}{$lexem->restriction} ({$count} rămase)\n"; $lexem->regenerateParadigm(); $count--; }
<?php require_once '../phplib/util.php'; require_once '../phplib/ads/adsModule.php'; require_once '../phplib/ads/diverta/divertaAdsModule.php'; $opts = getopt('s:'); if (count($opts) != 1) { print "Usage: fixDivertaBooks -s <start-id>\n"; exit; } // Resolve some ambiguities automatically. List the form that is alphabetically first and specify what to return $PREFERRED_FORMS = array('a' => 'a', 'al' => 'al', 'carte' => 'carte', 'cartea' => 'cartea', 'clasa' => 'clasa', 'fara' => 'fără', 'i' => 'i', 'ii' => 'ii', 'in' => 'în', 'la' => 'la', 'mai' => 'mai', 'mare' => 'mare', 'marea' => 'marea', 'povesti' => 'povești', 'print' => 'prinț', 'printul' => 'prințul', 's' => 's', 'sa' => 'să', 'si' => 'și', 'teste' => 'teste', 'ti' => 'ți', 'timp' => 'timp', 'top' => 'top'); $books = db_find(new DivertaBook(), "id >= {$opts['s']} order by id"); foreach ($books as $book) { print "Loaded: {$book->id} [{$book->title}] [{$book->url}]\n"; $origTitle = $book->title; // Preliminary stuff $book->title = trim($book->title); if (text_endsWith($book->title, ', ***')) { $book->title = substr($book->title, 0, -5); } switch ($book->sku) { case 'YDA00965': $book->title = 'Dicționar vizual spaniol-român'; break; case 'YHG00310': $book->title = '77 de rețete celebre și poveștile lor'; break; case 'YHU02030': $book->title = 'Zen aici și acum'; break;
if (count($lexems) != 1) { print "I {$longInfForm} are " . count($lexems) . " lexeme corespunzătoare\n"; } foreach ($lexems as $longInf) { if (!$longInf->isLoc) { print "I {$longInf->formNoAccent} nu este în LOC {$LEXEM_EDIT_URL}{$longInf->id}\n"; $longInf->isLoc = 1; $longInf->save(); } } } if ($verb->modelType == 'VT') { $ifs = db_find(new InflectedForm(), "lexemId = {$verb->id} and inflectionId = {$INFL_PART}"); $pm = ParticipleModel::loadByVerbModel($verb->modelNumber); assert($pm); foreach ($ifs as $if) { $partForm = $if->formNoAccent; $lexems = db_find(new Lexem(), "formNoAccent = '{$partForm}' and modelType = 'A' and modelNumber = '{$pm->adjectiveModel}'"); if (count($lexems) != 1) { print "P {$partForm} are " . count($lexems) . " lexeme corespunzătoare\n"; } foreach ($lexems as $part) { if (!$part->isLoc) { print "P {$part->formNoAccent} nu este în LOC {$LEXEM_EDIT_URL}{$part->id}\n"; $part->isLoc = 1; $part->save(); } } } } }
function lookup($sourceId, $cuv, $fd) { if (!source_exists($sourceId)) { socket_write($fd, "550 invalid database, use SHOW DB for a list\r\n"); return; } if ($sourceId == '*' || $sourceId == '!') { $sourceId = 0; } $cuv = StringUtil::cleanupQuery($cuv); $arr = StringUtil::analyzeQuery($cuv); $field = $arr[0] ? 'formNoAccent' : 'formUtf8General'; $lexems = db_find(new Lexem(), "{$field} = '{$cuv}' order by formNoAccent"); $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv); $searchResults = SearchResult::mapDefinitionArray($definitions); if (!count($definitions)) { socket_write($fd, "552 no match\r\n"); return; } socket_write($fd, "150 " . count($definitions) . " definition(s) found\r\n"); foreach ($searchResults as $sr) { $def = pretty_print($sr->definition->internalRep); socket_write($fd, "151 \"" . $cuv . "\" " . $sr->source->id . " \"" . $sr->source->name . "\"\r\n"); socket_write($fd, "{$cuv}\r\n{$def}"); socket_write($fd, ".\r\n"); } socket_write($fd, "250 ok\r\n"); }
*/ chdir('../../../'); // 请修改配置文件,设置正确的 mysql 账号密码 $conf = (include './simple/4/conf.php'); include './xiunophp/xiunophp.php'; // 创建表 $r = db_exec("DROP TABLE IF EXISTS `test_user`"); $r = db_exec("CREATE TABLE `test_user` (\n uid int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户编号',\n username char(32) NOT NULL DEFAULT '' COMMENT '用户名',\n password char(32) NOT NULL DEFAULT '' COMMENT '密码',\n PRIMARY KEY (uid)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8"); // 插入数据 $r = db_exec("INSERT INTO `test_user` SET username='******'"); $r = db_exec("INSERT INTO `test_user` SET username='******'"); // 查找一条数据 $arr = db_find_one("SELECT * FROM `test_user` WHERE username='******'"); print_r($arr); // 查找多条数据 $arrlist = db_find("SELECT * FROM `test_user` WHERE uid>0"); print_r($arrlist); /* 结果输出: Array ( [uid] => 1 [username] => Jack ) Array ( [0] => Array ( [uid] => 1 [username] => Jack )
function GetInfo($uid) { return db_find("user", $uid); }
<?php include_once "/var/www/web_classes/DUser.php"; include_once "/var/www/php/sql_connect.php"; $user = new DUser($_COOKIE["token"]); error_log($user->Email()); if ($user->Perms() == 1) { $string = $_POST["query"]; if (isset($_POST["query"])) { $query = $_POST["query"]; $string = db_find($query); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta name="theme-color" content="#FF8800"> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="The Official Oregon Tech Gaming Community Website. The place to find event times, locations, and announcements."> <meta name="author" content="Ian Murphy"> <link rel="icon" href="/assets/media/cog128.png"> <title>Administration - oitgaming.com</title> <!-- Bootstrap core CSS --> <link href="/assets/stylesheets/bootstrap.min.css" rel="stylesheet"> <link href="/assets/stylesheets/add.css" rel="stylesheet">
$modelStrings = ''; foreach ($models as $m) { if ($m) { if ($modelStrings) { $modelStrings .= ','; } $modelStrings .= "\"{$m}\""; } } if (!$modelStrings) { $modelStrings = "\"I1\""; } // print "$modelStrings\n"; $lexems = db_find(new Lexem(), "formNoAccent = '{$formNoAccent}' and concat(modelType, modelNumber, restriction) in ({$modelStrings})"); if (!count($lexems)) { $lexems = db_find(new Lexem(), "formNoAccent = '{$formNoAccent}'"); if (count($lexems)) { $newModels = ""; foreach ($lexems as $l) { $newModels .= "{$l->modelType}{$l->modelNumber}{$l->restriction} "; } print "Lexem: {$formNoAccent} Model(e) Dan: {$fields[2]}, Model(e) DEX online {$newModels}\n"; } else { // print "Lexem negăsit: $formNoAccent {$fields[2]}\n"; } } foreach ($lexems as $l) { $lexemDlrmMap[$l->id] = true; } } fclose($f);
function thread_find_by_tids($tids, $page = 1, $pagesize = 20, $order = 'tid') { $start = ($page - 1) * $pagesize; $tids = array_slice($tids, $start, $pagesize); if (!$tids) { return array(); } $in = implode(',', $tids); $threadlist = db_find("SELECT * FROM `bbs_thread` WHERE tid IN ({$in}) ORDER BY {$order} DESC", 'tid'); if ($threadlist) { foreach ($threadlist as &$thread) { thread_format($thread); } } return $threadlist; }
<?php $PREFIX = "http://www.dol.ro/magazin/"; $PREFIX_PREG = "http:\\/\\/www.dol.ro\\/magazin\\/"; require_once '../phplib/util.php'; require_once '../phplib/ads/adsModule.php'; require_once '../phplib/ads/diverta/divertaAdsModule.php'; $books = db_find(new DivertaBook(), "1 order by id"); foreach ($books as $book) { print "Loaded: {$book->id} [{$book->url}]\n"; $matches = array(); $result = preg_match("/^{$PREFIX_PREG}([^\\/]+)\\/(.*)/", $book->url, $matches); $category = strtolower($matches[1]); $book->url = "{$PREFIX}{$category}/{$matches[2]}"; $book->save(); print "Edited: {$book->id} [{$book->url}]\n"; }