Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

Commit

Permalink
适配 PHP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
kagurazakayashi committed Mar 4, 2017
1 parent 793747c commit a1ebde3
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 58 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 云颜文字·源商店

云颜文字源商店的后台管理脚本,适用于 PHP7 。

## 功能说明

- emostore_admin_add_do.php:添加数据
- emostore_admin_alldata.php:数据库内容管理
- emostore_admin_cache.php:创建APP接口缓存
- emostore_admin_delete_do.php:删除数据
- emostore_admin_edit_do.php:修改数据
- emostore_admin_login_do.php:用户登录信息
- emostore_admin_login_ui.php:用户登录页面
- emostore_admin_loginstatus.php:检查登录状态
- emostore_admin_logout.php:登出用户
- emostore_admin_md5test.php:(测试用)MD5测试
- emostore_admin_sqlsetting.php:数据库连接设定
- emostore_user_regcheck.php:注册新用户
- index.php:自动登录和跳转
- login.html:登录页
- pagenumber.php:页码分割
- signup.html:注册新用户
- sqlnote.sql:数据库命令笔记
- validate_code.class.php、validate_image.php:验证码库

## 操作步骤

- 前往后台管理服务器中的 admin.php 页。
- 登录并在各模块中进行源条目的 增、删、改、查 。
- 点击刷新缓存,emostore.xml、emostore.json、emostore.ylt、updatetime.txt、phparray.txt、index.html 将被创建。
- 点击分发,这些内容将被复制到生产服务器。

备注:后台管理页面目前没有头像上传功能,目前请用FTP手动传图代替。
12 changes: 5 additions & 7 deletions emostore_admin_add_do.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
echo "没有登录任何用户,请先<a href='emostore_admin_login_ui.php?backurl=".$_SERVER['PHP_SELF']."'>登录</a>。";
die("<hr><p><b>访问受限:</b>必须使用管理员账户登录才可以继续哦。</p>");
}
@mysql_connect($db_host,$db_user,$db_password)
or die("<hr><p><b>数据库连接失败</p>");
@mysql_select_db($db_name)
or die("<hr><p><b>选择数据库失败</p>");
$linkID = db_connect();
$isok = true;
echo "<hr><table border=0 align=\"center\" width=800><tbody>";
$sqlkey = "`";
$sqlval = "'";
for ($i = 1; $i < count($keys); $i++) {
$nowkey = mysql_real_escape_string($keys[$i]);
$nowkey = mysqli_real_escape_string($linkID,$keys[$i]);
if (isset($_POST[$nowkey])) {
$nowval = mysql_real_escape_string($_POST[$nowkey]);
$nowval = mysqli_real_escape_string($linkID,$_POST[$nowkey]);
echo "<tr><td>".$nowkey."</td><td>".$nowval."</td></tr>";
$sqlkey = $sqlkey.$nowkey."`,`";
$sqlval = $sqlval.$nowval."','";
Expand All @@ -44,8 +41,9 @@
die("<hr><p><b>参数不正确,提交添加中止。</b></p>");
}
// echo $sql."<hr>";
$query = @mysql_query($sql)
$query = mysqli_query($linkID,$sql)
or die("<p><b>SQL语句执行失败。</b></p>");
mysqli_close($linkID);
echo "<p><b>条目添加成功。</b></p>";
?><p><a href="emostore_admin_alldata.php">返回源列表</a>
<meta http-equiv="Refresh" content="3;URL=emostore_admin_alldata.php">
Expand Down
16 changes: 7 additions & 9 deletions emostore_admin_alldata.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
echo "没有登录任何用户,请先<a href='emostore_admin_login_ui.php?backurl=".$_SERVER['PHP_SELF']."'>登录</a>。";
die("<hr><p><b>访问受限:</b>必须使用管理员账户登录才可以继续哦。</p>");
}
@mysql_connect($db_host,$db_user,$db_password)
or die("<hr><p><b>数据库连接失败</b></p>");
@mysql_select_db($db_name)
or die("<hr><p><b>选择数据库失败</b></p>");
$query = @mysql_query("select count(*) from `emoticonstore`.`emostore`")
$linkID = db_connect();
$query = mysqli_query($linkID,"select count(*) from `emoticonstore`.`emostore`")
or die("<hr><p><b>SQL语句执行失败,数据量检测失败。</b></p>");
$datacount = 0;
if($arr = mysql_fetch_array($query)) {
if($arr = mysqli_fetch_array($query)) {
echo "<hr>SQL数据库中共存储有 ".$arr[0]." 个颜文字源。</br></center>";
$datacount = $arr[0];
}
Expand All @@ -41,7 +38,7 @@
$maxpage = 1;
}
if (isset($_GET["pagenumber"])) {
$nowPageNumber = mysql_real_escape_string($_GET["pagenumber"]);
$nowPageNumber = mysqli_real_escape_string($linkID,$_GET["pagenumber"]);
if ($nowPageNumber < 1) {
$nowPageNumber = 1;
} else if ($nowPageNumber > $maxpage) {
Expand All @@ -58,10 +55,11 @@
$sql2 = "select * from `emoticonstore`.`emostore` order by id desc limit ".$formid.",".$yu.";";
}
// echo "<hr>".$sql2;
$query = @mysql_query($sql2)
$query = mysqli_query($linkID,$sql2)
or die("<hr><p><b>SQL语句执行失败,查询数据失败。</b></p>");
mysqli_close($linkID);
$arr = array();
while ($row=mysql_fetch_array($query)) {
while ($row=mysqli_fetch_array($query)) {
$arr[] = $row;
}
echo "<hr>";
Expand Down
10 changes: 4 additions & 6 deletions emostore_admin_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
die("<hr><p><b>访问受限:</b>必须使用管理员账户登录才可以继续哦。</p>");
}
include 'emostore_admin_sqlsetting.php';
@mysql_connect($db_host,$db_user,$db_password)
or die("<hr><p><b>数据库连接失败</b></p>");
@mysql_select_db($db_name)
or die("<hr><p><b>选择数据库失败</b></p>");
$linkID = db_connect();
$sql = "select * from `emoticonstore`.`emostore`";
$query = @mysql_query($sql)
$query = mysqli_query($linkID,$sql)
or die("<hr><p><b>SQL语句执行失败,查询数据失败。</b></p>");
while ($row=mysql_fetch_array($query)) {
while ($row=mysqli_fetch_array($query)) {
$arr[] = $row;
}
mysqli_close($linkID);
// $keyerr = count($arr[0]) - count($keys);
// if ($keyerr != 0) {
// die("<hr><p><b>配置键值对不匹配,差异".$keyerr."。</b></p>");
Expand Down
12 changes: 5 additions & 7 deletions emostore_admin_delete_do.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@
die("<hr><p><b>访问受限:</b>必须使用管理员账户登录才可以继续哦。</p>");
}
include 'emostore_admin_sqlsetting.php';
@mysql_connect($db_host,$db_user,$db_password)
or die("<hr><p><b>数据库连接失败</p>");
@mysql_select_db($db_name)
or die("<hr><p><b>选择数据库失败</p>");
$linkID = db_connect();
$id = "0";
if (isset($_GET["id"])) {
$id = mysql_real_escape_string($_GET["id"]);
$id = mysqli_real_escape_string($linkID,$_GET["id"]);
} else if (isset($_POST["id"])) {
$id = mysql_real_escape_string($_POST["id"]);
$id = mysqli_real_escape_string($linkID,$_POST["id"]);
} else {
die("<hr><p><b>请求参数错误。</p>");
}
$sql = "delete from `emostore` where `id`=".$id.";";
$query = @mysql_query($sql)
$query = mysqli_query($linkID,$sql)
or die("<p><b>SQL语句执行失败。</b></p>");
mysqli_close($linkID);
echo "<p><b>条目删除成功。</b></p>";
?><p><a href="emostore_admin_alldata.php">返回源列表</a>
<meta http-equiv="Refresh" content="3;URL=emostore_admin_alldata.php">
Expand Down
14 changes: 6 additions & 8 deletions emostore_admin_edit_do.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@
die("<hr><p><b>访问受限:</b>必须使用管理员账户登录才可以继续哦。</p>");
}
include 'emostore_admin_sqlsetting.php';
@mysql_connect($db_host,$db_user,$db_password)
or die("<hr><p><b>数据库连接失败</p>");
@mysql_select_db($db_name)
or die("<hr><p><b>选择数据库失败</p>");
$linkID = db_connect();
$isok = true;
echo "<hr><table border=0 align=\"center\" width=800><tbody>";
$sql = "update `emostore` set ";
for ($i = 0; $i < count($keys); $i++) {
$nowkey = mysql_real_escape_string($keys[$i]);
$nowkey = mysqli_real_escape_string($linkID,$keys[$i]);
if (isset($_POST[$nowkey])) {
$nowval = mysql_real_escape_string($_POST[$nowkey]);
$nowval = mysqli_real_escape_string($linkID,$_POST[$nowkey]);
echo "<tr><td>".$nowkey."</td><td>".$nowval."</td></tr>";
$sql = $sql."`".$nowkey."`='".$nowval."',";
} else {
Expand All @@ -36,13 +33,14 @@
}
$sql = substr($sql, 0,strlen($sql)-1);
echo "</tbody></table><hr>";
$sql = $sql." where `id`=".mysql_real_escape_string($_POST["id"]).";";
$sql = $sql." where `id`=".mysqli_real_escape_string($linkID,$_POST["id"]).";";
if ($isok == false) {
die("<hr><p><b>参数不正确,提交修改中止。</b></p>");
}
//echo $sql."<hr>";
$query = @mysql_query($sql)
$query = mysqli_query($linkID,$sql)
or die("<p><b>SQL语句执行失败。</b></p>");
mysqli_close($linkID);
echo "<p><b>条目修改成功。</b></p>";
// $query = @mysql_query("select count(*) from `emoticonstore`.`emostore`")
// or die("<hr><p><b>SQL语句执行失败1</p>");
Expand Down
15 changes: 7 additions & 8 deletions emostore_admin_login_do.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,18 @@
die("<p>参数不正确</p>");
}

@mysql_connect($db_host,$db_user,$db_password)
or die("<p>数据库连接失败</p>");
@mysql_select_db($db_name)
or die("<p>选择数据库失败</p>");
$con = db_connect();
//获取输入的信息
$username = $_POST['username'];
$passcode = $_POST['passcode'];
$backurl = "";
//获取session的值
$passwd = md5(md5($passcode));
$query = @mysql_query("select username,userflag from $user_table where username = '$username' and passcode = '$passwd'")
or die("<p>SQL语句执行失败</p>");
$sql = "select username,userflag from $user_table where username = '$username' and passcode = '$passwd'";
// $query = mysqli_query($con,$sql);
$query = mysqli_query($con,$sql);
//判断用户以及密码
if($row = mysql_fetch_array($query))
if($row = mysqli_fetch_array($query))
{
//判断权限
echo "<p>登录成功~!</p>";
Expand All @@ -52,6 +50,7 @@
}
if (isset($_POST['backurl'])) {
echo "<p><a href='".$_POST['backurl']."'>返回登录前页面</a></p>";
echo "<meta http-equiv=\"Refresh\" content=\"3;URL=".$_POST['backurl']."\">";
// echo "<meta http-equiv=\"Refresh\" content=\"3;URL=".$_POST['backurl']."\">";
}
mysqli_close($con);
?></center><?php echo $footer; ?></body></html>
39 changes: 34 additions & 5 deletions emostore_admin_sqlsetting.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
<?php
$db_host="uuumoedb.mysql.rds.aliyuncs.com:3838";
$db_user="emoticonuser";
$db_password="t7_PBTWzTbnUG0pEHUFcmEbN8zPhM_TS";
$db_name="emoticonstore";
$user_table="emostoreadmin";
$data_table="emostore";
$query="set names 'utf-8'";
$keys = ["id","name","iconurl","postedon","introduction","creator","creatorurl","server","serverurl","dataformat","installurl","codeurl","usergroup"];
$keynames = ["内部ID(只读)","颜文字源名称","图标网址","登记日期","简介","维护者","维护者网站","服务器","服务器提供网址","云颜文字数据格式","软件调用网址","源代码网址","呈现给用户组"];
//<?php echo $footer; ? >
$footer="<hr><center>源商店管理员后台 © 云颜文字团队 2015.<br>源商店 by 神楽坂雅詩,0wew0,神楽坂紫,KT.<br><a href=\"http://www.miitbeian.gov.cn/\" target=\"_blank\" title=\"此处为域名拥有者资料,并非内容提供者信息,请勿使用这些信息干扰他的生活,谢谢理解。如有问题请联系[email protected]\">京ICP备15023313号</a></center>";
$footer="<hr><center>源商店管理员后台 © 云颜文字团队 2015.<br>源商店 by 神楽坂雅詩,0wew0,神楽坂紫,KT</center>";

function db_connect() {
$db_host="_____";
$db_port=3000;
$db_user="_____";
$db_password="_____";
$db_name="_____";

/* $con=mysql_connect($db_host,$db_user,$db_password,$db_name,$db_port);
$sqlerrno = mysqli_connect_errno($con);
if ($sqlerrno) {
die('数据库操作失败。');
}
return $con; */

/* $con = mysqli_init();
mysqli_real_connect($con,$db_host,$db_user,$db_password,false,$db_port);
mysqli_errno($con)!=0 && die('数据库连接失败。'.$mysqli->error);
if (!$con) {
die('数据库操作失败。'.$mysqli->error);
}
if (!@mysqli_select_db($con,$db_name)) {
die('无法使用数据库。'.$mysqli->error);
}
return $con; */

$con = mysqli_connect($db_host.":".$db_port,$db_user,$db_password,$db_name);
if (mysqli_connect_errno($con))
{
echo "连接数据库失败: ".mysqli_connect_error();
}
return $con;
}
?>
12 changes: 5 additions & 7 deletions emostore_user_regcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
echo "<script>alert('请确认信息完整性!'); history.go(-1);</script>";
}else{
if($_POST["password"] == $_POST["confirm"]){
@mysql_connect($db_host,$db_user,$db_password)
or die("数据库连接失败");
@mysql_select_db($db_name)
or die("选择数据库失败");
$linkID = db_connect();
// mysql_query($query); //设定字符集
$sql = "select username from user where username = '$_POST[username]'"; //SQL语句
$result = mysql_query($sql); //执行SQL语句
$num = mysql_num_rows($result); //统计执行结果影响的行数
$result = mysqli_query($linkID,$sql); //执行SQL语句
$num = mysqli_num_rows($result); //统计执行结果影响的行数
if($num) //如果已经存在该用户
{
echo "<script>alert('用户名已存在'); history.go(-1);</script>";
Expand All @@ -21,7 +18,7 @@
{
$pw = md5(md5($_POST[password]));
$sql_insert = "insert into emostoreadmin (username,passcode,userflag) values('$_POST[username]','$pw','0')";
$res_insert = mysql_query($sql_insert);
$res_insert = mysqli_query($linkID,$sql_insert);
//$num_insert = mysql_num_rows($res_insert);
if($res_insert)
{
Expand All @@ -32,6 +29,7 @@
echo "<script>alert('系统繁忙,请稍候!'); history.go(-1);</script>";
}
}
mysqli_close($linkID);
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion pagenumber.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php
$pagenumber = 2;//一页内有多少条数据

$pageAll = @mysql_query("select count(*) from `emoticonstore`.`emostore`")
$pageAll = mysqli_query("select count(*) from `emoticonstore`.`emostore`")
or die("SQL语句执行失败");
// mysqli_close($linkID);
$page = $pageAll / $pagenumber;
if ($pageAll % $pagenumber != 0) {
$page++;
Expand Down

0 comments on commit a1ebde3

Please sign in to comment.