更新 v1.8.0版本

This commit is contained in:
LyLme 2023-12-17 23:45:03 +08:00
parent 43d649d9ec
commit 844998c3e0
3 changed files with 266 additions and 176 deletions

View File

@ -14,6 +14,7 @@ if(!defined('SQLITE') && (!$dbconfig['user'] || !$dbconfig['pwd'] || !$dbconfig[
} }
require SYSTEM_ROOT . "db.class.php"; require SYSTEM_ROOT . "db.class.php";
$DB = new DB($dbconfig['host'], $dbconfig['user'], $dbconfig['pwd'], $dbconfig['dbname'], $dbconfig['port']); $DB = new DB($dbconfig['host'], $dbconfig['user'], $dbconfig['pwd'], $dbconfig['dbname'], $dbconfig['port']);
$web_config = $DB->query("SELECT * FROM `lylme_config`"); $web_config = $DB->query("SELECT * FROM `lylme_config`");
while($row = $DB->fetch($web_config)) { while($row = $DB->fetch($web_config)) {
$conf[$row['k']] = $row['v']; $conf[$row['k']] = $row['v'];
@ -25,7 +26,6 @@ require SYSTEM_ROOT . "tj.php";
require SYSTEM_ROOT . "version.php"; require SYSTEM_ROOT . "version.php";
require SYSTEM_ROOT . "updbase.php"; require SYSTEM_ROOT . "updbase.php";
require SYSTEM_ROOT . "site.php"; require SYSTEM_ROOT . "site.php";
$cdnpublic = cdnpublic($conf['cdnpublic']); $cdnpublic = cdnpublic($conf['cdnpublic']);
$templatepath = './template/' . $conf["template"]; $templatepath = './template/' . $conf["template"];
$template = $templatepath . '/index.php'; $template = $templatepath . '/index.php';

View File

@ -1,191 +1,238 @@
<?php <?php
//MySQL、MySQLi、SQLite 三合一数据库操作类 //MySQL、MySQLi、SQLite 三合一数据库操作类
if(!defined('IN_CRONLITE'))exit(); if(!defined('IN_CRONLITE')) {
exit();
}
$nomysqli=false; $nomysqli = false;
if(defined('SQLITE')==true){ if(defined('SQLITE') == true) {
class DB { class DB
var $link = null; {
public $link = null;
function __construct($db_file){ public $result = null;
global $siteurl; public function __construct($db_file)
$this->link = new PDO('sqlite:'.ROOT.'includes/sqlite/'.$db_file.'.db'); {
if (!$this->link) die('Connection Sqlite failed.\n'); global $siteurl;
return true; $this->link = new PDO('sqlite:' . ROOT . 'includes/sqlite/' . $db_file . '.db');
if (!$this->link) {
die('Connection Sqlite failed.\n');
}
return true;
} }
function fetch($q){ public function fetch($q)
return $q->fetch(); {
} return $q->fetch();
function get_row($q){ }
$sth = $this->link->query($q); public function get_row($q)
return $sth->fetch(); {
} $sth = $this->link->query($q);
function count($q){ return $sth->fetch();
$sth = $this->link->query($q); }
return $sth->fetchColumn(); public function count($q)
} {
function query($q){ $sth = $this->link->query($q);
return $this->result=$this->link->query($q); return $sth->fetchColumn();
} }
function affected(){ public function query($q)
return $this->result->rowCount(); {
} return $this->result = $this->link->query($q);
function error(){ }
$error = $this->link->errorInfo(); public function affected()
return '['.$error[1].'] '.$error[2]; {
} return $this->result->rowCount();
} }
} public function error()
elseif(extension_loaded('mysqli') && $nomysqli==false) { {
class DB { $error = $this->link->errorInfo();
var $link = null; return '[' . $error[1] . '] ' . $error[2];
}
}
} elseif(extension_loaded('mysqli') && $nomysqli == false) {
class DB
{
public $link = null;
public function __construct($db_host, $db_user, $db_pass, $db_name, $db_port)
{
function __construct($db_host,$db_user,$db_pass,$db_name,$db_port){
$this->link = mysqli_connect($db_host, $db_user, $db_pass, $db_name, $db_port); $this->link = mysqli_connect($db_host, $db_user, $db_pass, $db_name, $db_port);
if (!$this->link) die('Connect Error (' . mysqli_connect_errno() . ') '.mysqli_connect_error()); if (!$this->link) {
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
//mysqli_select_db($this->link, $db_name) or die(mysqli_error($this->link)); //mysqli_select_db($this->link, $db_name) or die(mysqli_error($this->link));
mysqli_query($this->link,"set sql_mode = ''"); mysqli_query($this->link, "set sql_mode = ''");
//字符转换,读库 //字符转换,读库
mysqli_query($this->link,"set character set 'utf8'"); mysqli_query($this->link, "set character set 'utf8'");
//写库 //写库
mysqli_query($this->link,"set names 'utf8'"); mysqli_query($this->link, "set names 'utf8'");
return true; return true;
} }
function fetch($q){ public function fetch($q)
return mysqli_fetch_assoc($q); {
} return mysqli_fetch_assoc($q);
function num_rows($result){ }
return mysqli_num_rows($result); public function num_rows($result)
} {
function get_row($q){ return mysqli_num_rows($result);
$result = mysqli_query($this->link,$q); }
return mysqli_fetch_assoc($result); public function get_row($q)
} {
function get_column($q){ $result = mysqli_query($this->link, $q);
$result = mysqli_query($this->link,$q); return mysqli_fetch_assoc($result);
$row = mysqli_fetch_array($result); }
return $row[0]; public function get_column($q)
} {
function count($q){ $result = mysqli_query($this->link, $q);
$result = mysqli_query($this->link,$q); $row = mysqli_fetch_array($result);
$count = mysqli_fetch_array($result); return $row[0];
return $count[0]; }
} public function count($q)
function query($q){ {
return mysqli_query($this->link,$q); $result = mysqli_query($this->link, $q);
} $count = mysqli_fetch_array($result);
function escape($str){ return $count[0];
return mysqli_real_escape_string($this->link,$str); }
} public function query($q)
function insert($q){ {
if(mysqli_query($this->link,$q)) return mysqli_query($this->link, $q);
return mysqli_insert_id($this->link); }
return false; public function escape($str)
} {
function affected(){ return mysqli_real_escape_string($this->link, $str);
return mysqli_affected_rows($this->link); }
} public function insert($q)
function insert_array($table,$array){ {
$q = "INSERT INTO `$table`"; if(mysqli_query($this->link, $q)) {
$q .=" (`".implode("`,`",array_keys($array))."`) "; return mysqli_insert_id($this->link);
$q .=" VALUES ('".implode("','",array_values($array))."') "; }
return false;
if(mysqli_query($this->link,$q)) }
return mysqli_insert_id($this->link); public function affected()
return false; {
} return mysqli_affected_rows($this->link);
function error(){ }
$error = mysqli_error($this->link); public function insert_array($table, $array)
$errno = mysqli_errno($this->link); {
return '['.$errno.'] '.$error; $q = "INSERT INTO `$table`";
} $q .= " (`" . implode("`,`", array_keys($array)) . "`) ";
function close(){ $q .= " VALUES ('" . implode("','", array_values($array)) . "') ";
$q = mysqli_close($this->link);
return $q; if(mysqli_query($this->link, $q)) {
} return mysqli_insert_id($this->link);
} }
return false;
}
public function error()
{
$error = mysqli_error($this->link);
$errno = mysqli_errno($this->link);
return '[' . $errno . '] ' . $error;
}
public function close()
{
$q = mysqli_close($this->link);
return $q;
}
}
} else { // we use the old mysql } else { // we use the old mysql
class DB { class DB
var $link = null; {
public $link = null;
function __construct($db_host,$db_user,$db_pass,$db_name,$db_port){ public function __construct($db_host, $db_user, $db_pass, $db_name, $db_port)
{
$this->link = @mysql_connect($db_host.':'.$db_port, $db_user, $db_pass); $this->link = @mysql_connect($db_host . ':' . $db_port, $db_user, $db_pass);
if (!$this->link) die('Connect Error (' . mysql_errno() . ') '.mysql_error());
mysql_select_db($db_name, $this->link) or die(mysql_error($this->link));
mysql_query("set sql_mode = ''"); if (!$this->link) {
//字符转换,读库 die('Connect Error (' . mysql_errno() . ') ' . mysql_error());
mysql_query("set character set 'utf8'"); }
//写库
mysql_query("set names 'utf8'");
return true; mysql_select_db($db_name, $this->link) or die(mysql_error($this->link));
}
function fetch($q){
return mysql_fetch_assoc($q);
}
function num_rows($result){
return mysql_num_rows($result);
}
function get_row($q){
$result = mysql_query($q, $this->link);
return mysql_fetch_assoc($result);
}
function get_column($q){
$result = mysql_query($q, $this->link);
$row = mysql_fetch_array($result);
return $row[0];
}
function count($q){
$result = mysql_query($q, $this->link);
$count = mysql_fetch_array($result);
return $count[0];
}
function query($q){
return mysql_query($q, $this->link);
}
function escape($str){
return mysql_real_escape_string($str, $this->link);
}
function affected(){
return mysql_affected_rows($this->link);
}
function insert($q){
if(mysql_query($q, $this->link))
return mysql_insert_id($this->link);
return false;
}
function insert_array($table,$array){
$q = "INSERT INTO `$table`";
$q .=" (`".implode("`,`",array_keys($array))."`) ";
$q .=" VALUES ('".implode("','",array_values($array))."') ";
if(mysql_query($q, $this->link)) mysql_query("set sql_mode = ''");
return mysql_insert_id($this->link); //字符转换,读库
return false; mysql_query("set character set 'utf8'");
} //写库
function error(){ mysql_query("set names 'utf8'");
$error = mysql_error($this->link);
$errno = mysql_errno($this->link);
return '['.$errno.'] '.$error; return true;
} }
function close(){ public function fetch($q)
$q = mysql_close($this->link); {
return $q; return mysql_fetch_assoc($q);
} }
} public function num_rows($result)
{
return mysql_num_rows($result);
}
public function get_row($q)
{
$result = mysql_query($q, $this->link);
return mysql_fetch_assoc($result);
}
public function get_column($q)
{
$result = mysql_query($q, $this->link);
$row = mysql_fetch_array($result);
return $row[0];
}
public function count($q)
{
$result = mysql_query($q, $this->link);
$count = mysql_fetch_array($result);
return $count[0];
}
public function query($q)
{
return mysql_query($q, $this->link);
}
public function escape($str)
{
return mysql_real_escape_string($str, $this->link);
}
public function affected()
{
return mysql_affected_rows($this->link);
}
public function insert($q)
{
if(mysql_query($q, $this->link)) {
return mysql_insert_id($this->link);
}
return false;
}
public function insert_array($table, $array)
{
$q = "INSERT INTO `$table`";
$q .= " (`" . implode("`,`", array_keys($array)) . "`) ";
$q .= " VALUES ('" . implode("','", array_values($array)) . "') ";
if(mysql_query($q, $this->link)) {
return mysql_insert_id($this->link);
}
return false;
}
public function error()
{
$error = mysql_error($this->link);
$errno = mysql_errno($this->link);
return '[' . $errno . '] ' . $error;
}
public function close()
{
$q = mysql_close($this->link);
return $q;
}
}
} }
?>

View File

@ -1,3 +1,46 @@
<?php <?php
class site {} $site = new SITE($dbconfig['host'], $dbconfig['user'], $dbconfig['pwd'], $dbconfig['dbname'], $dbconfig['port']);
class SITE extends DB
{
public function __construct($db_host, $db_user, $db_pass, $db_name, $db_port)
{
parent::__construct($db_host, $db_user, $db_pass, $db_name, $db_port);
}
/**
* @Description 获取分组信息
* @return object
*/
public function getGroups()
{
return $this->query("SELECT * FROM `lylme_groups` WHERE `group_pwd` = 0 ORDER BY `group_order` ASC");
}/**
* 获取分组列表
* @Description
* @return object
*/
public function getCategorys()
{
//获取分组信息
return $this->query("SELECT * FROM `lylme_groups` WHERE `group_pwd` = 0 ORDER BY `group_order` ASC");
}
/**
* 获取标签菜单
* @Author: LyLme
* @return object
*/
public function getTags()
{
return $this->query("SELECT * FROM `lylme_tags` ORDER BY `lylme_tags`.`sort` ASC");
}
/**
* 获取搜索引擎
* @Author: LyLme
* @return object
*/
public function getSou()
{
return $this->query("SELECT * FROM `lylme_sou` WHERE `sou_st` = 1 ORDER BY `lylme_sou`.`sou_order` ASC");
}
}