<?php
/**
* Duoxingyu Framework 部分函数库
* @author 多星宇
*/
if (!defined('SYSTEM_ROOT')) { die('Insufficient Permissions'); }
/**
* 获取用户ip地址
*/
function getIp() {
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
if (!ip2long($ip)) {
$ip = '';
}
return $ip;
}
/**
* 加密密码
*/
function EncodePwd($pwd) {
$p = new P();
return $p->pwd($pwd);
}
/**
* 验证email地址格式
*/
function checkMail($email) {
if (preg_match("/^[\w\.\-]+@\w+([\.\-]\w+)*\.\w+$/", $email) && strlen($email) <= 60) {
return true;
} else {
return false;
}
}
/**
* (弃用)生成一个随机的字符串
*
* @param int $length
* @param boolean $special_chars
* @return string
*/
function getRandStr($length = 12, $special_chars = false) {
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
if ($special_chars) {
$chars .= '!@#$%^&*()';
}
$randStr = '';
for ($e = 0; $e < $length; $e++) {
$randStr .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $randStr;
}
/**
* 获取两段文本之间的文本
*
* @param 完整的文本
* @param 左边文本
* @param 右边文本
* 返回“左边文本”与“右边文本”之间的文本
*/
function textMiddle($text, $left, $right) {
$loc1 = stripos($text, $left);
if (is_bool($loc1)) { return ""; }
$loc1 += strlen($left);
$loc2 = stripos($text, $right, $loc1);
if (is_bool($loc2)) { return ""; }
return substr($text, $loc1, $loc2 - $loc1);
}
/**
* 获取一个bduss对应的百度用户名
*
* @param bduss
* 返回百度用户名,失败返回空
*/
function getBaiduId($bduss){
global $m;
$header[] = 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8';
$header[] = 'Cookie: BDUSS='.$bduss;
$c = new wcurl('http://wapp.baidu.com/',$header);
$data = $c->get();
$c->close();
return urldecode(textMiddle($data,'i?un=','">'));
}
/**
* 获取Gravatar头像(或贴吧头像)
* http://en.gravatar.com/site/implement/images/
* @param $email
* @param $s size
* @param $d default avatar
* @param $g
*/
function getGravatar($s = 140, $d = 'mm', $g = 'g', $site = 'secure') {
if(option::uget('face_img') == 1) {
if(option::uget('face_url') != ''){
return option::uget('face_url');
} else {
return 'http://tb.himg.baidu.com/sys/portrait/item/';
}
} else {
$hash = md5(EMAIL);
$avatar = "https://{$site}.gravatar.com/avatar/$hash?s=$s&d=$d&r=$g";
return $avatar;
}
}
/**
* 解压zip
* @param type $zipfile 要解压的文件
* @param type $path 解压到该目录
* @param type $type
* @return int
*/
function UnZip($zipfile, $path) {
if (!class_exists('ZipArchive', FALSE)) {
return 3;//zip模块问题
}
$zip = new ZipArchive();
if (@$zip->open($zipfile) !== TRUE) {
return 2;//文件权限问题
}
if (true === @$zip->extractTo($path)) {
$zip->close();
return 0;
} else {
return 1;//文件权限问题
}
}
/**
* 清空缓冲区的内容
* @note 已修复无法清除缓冲区的bug
*/
function Clean() {
ob_clean();
}
/**
* [已搬走]MySQL 随机取记录
* 请查看S::rand()
* @param $t 表
* @param $c ID列,默认为id
* @param $n 取多少个
* @param $w 条件语句
* @param $f bool 是否强制以多维数组形式返回,默认false
* @param $p string 随机数据前缀,如果产生冲突,请修改本项
* @return array 取1个直接返回结果数组(除非$f为true),取>1个返回多维数组,用foreach取出
*/
function rand_row($t , $c = 'id' , $n = '1', $w = '' , $f = false , $p = 'tempval_') {
global $m;
return $m->rand($t , $c , $n, $w, $f, $p);
}
/**
* 从数组中随机取一个值
* @param array 数组
*/
function rand_array($a) {
$r = array_rand($a,1);
return $a[$r];
}
/**
* 随机生成一个指定长度的正整数
* @param int $l 长度
*/
function rand_int($l) {
$int = null;
for ($e=0; $e < $l; $e++) {
$int .= mt_rand(0,9);
}
return $int;
}
/**
* 获取空闲的贴吧记录表
*
*/
function getfreetable() {
global $m;
$x = $m->once_fetch_array("SELECT COUNT(*) AS fffff FROM `".DB_NAME."`.`".DB_PREFIX."tieba`");
$fbs = option::get('fb_tables');
$fbset = option::get('fb');
$f = unserialize($fbs);
if (!empty($fbset) && $x['fffff'] >= $fbset && !empty($f)) {
$c = sizeof($f);
foreach ($f as $key => $value) {
$x = $m->once_fetch_array("SELECT COUNT(*) AS fffff FROM `".DB_NAME."`.`".DB_PREFIX.$value."`");
if ($x['fffff'] < $fbset) {
break;
}
}
return $value;
} else {
return 'tieba';
}
}
/**
* 清除用户的所有贴吧
*
* @param 用户ID
*/
function CleanUser($id) {
global $m;
$x=$m->once_fetch_array("SELECT * FROM `".DB_NAME."`.`".DB_PREFIX."users` WHERE `id` = {$id} LIMIT 1");
$m->query('DELETE FROM `'.DB_NAME.'`.`'.DB_PREFIX.$x['t'].'` WHERE `'.DB_PREFIX.$x['t'].'`.`uid` = '.$id);
}
/**
* 删除用户
* 为节省数据库,捆绑清除贴吧数据
*
* @param 用户ID
*/
function DeleteUser($id) {
global $m;
CleanUser($id);
$m->query('DELETE FROM `'.DB_NAME.'`.`'.DB_PREFIX.'users` WHERE `'.DB_PREFIX.'users`.`id` = '.$id);
}
/**
* zip压缩
* @param $orig_fname 将在zip的文件路径
* @param $content 文件内容
* @param $tempzip zip存储路径
* @return bool
*/
function CreateZip($orig_fname, $content, $tempzip) {
if (!class_exists('ZipArchive', FALSE)) {
return false;
}
$zip = new ZipArchive();
$res = $zip->open($tempzip, ZipArchive::CREATE);
if ($res === TRUE) {
$zip->addFromString($orig_fname, $content);
$zip->close();
return true;
} else {
return false;
}
}
/**
* 删除文件或目录
*/
function DeleteFile($file) {
if (!file_exists($file))
return false;
if (empty($file))
return false;
if (@is_file($file))
return @unlink($file);
$ret = true;
if ($handle = @opendir($file)) {
while ($filename = @readdir($handle)) {
if ($filename == '.' || $filename == '..')
continue;
if (!DeleteFile($file . '/' . $filename))
$ret = false;
}
} else {
$ret = false;
}
@closedir($handle);
if (file_exists($file) && !rmdir($file)) {
$ret = false;
}
return $ret;
}
/**
* 批量复制
* @param $source 源目录名
* @param $destination 目的目录名
* @return 成功返回TRUE,失败返回原因
*/
function CopyAll($source,$destination){
if(!is_dir($source)) {
return '错误:'.$source.'并不是一个目录';
}
if(!is_dir($destination)) {
mkdir($destination,0777,true);
}
$handle = dir($source);
while($entry=$handle->read()) {
if(($entry!=='.')&&($entry!=='..')) {
if(is_dir($source.'/'.$entry)) {
CopyAll($source.'/'.$entry, $destination.'/'.$entry);
} else {
copy($source.'/'.$entry, $destination.'/'.$entry);
}
}
}
return true;
}
/**
* 备份指定表的数据结构和所有数据
*
* @param string $table 数据库表名
* @return string
*/
function dataBak($table) {
global $m;
$sql = "DROP TABLE IF EXISTS `$table`;\n";
$createtable = $m->query("SHOW CREATE TABLE $table");
$create = $m->fetch_row($createtable);
$sql .= $create[1].";\n\n";
$rows = $m->query("SELECT * FROM $table");
$numfields = $m->num_fields($rows);
$numrows = $m->num_rows($rows);
while ($row = $m->fetch_row($rows)) {
$comma = '';
$sql .= "INSERT INTO `$table` VALUES(";
for ($e = 0; $e < $numfields; $e++) {
$sql .= $comma."'" . $m->escape_string($row[$e]) . "'";
$comma = ',';
}
$sql .= ");\n";
}
$sql .= "\n";
return $sql;
}
/**
* 执行一个网络请求而不等待返回结果
* @param string $url URL
* @param string $post po
没有合适的资源?快使用搜索试试~ 我知道了~
PHP实例开发源码-多星宇贴吧签到助手 php版 v10.0.zip
共64个文件
php:44个
js:4个
css:3个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 193 浏览量
2022-10-17
04:26:09
上传
评论
收藏 322KB ZIP 举报
温馨提示
PHP实例开发源码—多星宇贴吧签到助手 php版 v10.0.zip PHP实例开发源码—多星宇贴吧签到助手 php版 v10.0.zip PHP实例开发源码—多星宇贴吧签到助手 php版 v10.0.zip
资源详情
资源评论
资源推荐
收起资源包目录
PHP实例开发源码—多星宇贴吧签到助手 php版 v10.0.zip (64个子文件)
132699456734022863
do.php 2KB
index.php 3KB
do.sh 59B
config.yaml 107B
config.php 848B
templates
admin-update.php 5KB
index.php 6KB
admin-cron.php 5KB
admin-users.php 3KB
reg.php 3KB
admin-plugins.php 6KB
showtb.php 5KB
login.php 2KB
admin-set.php 15KB
baiduid.php 11KB
set.php 2KB
navi.php 7KB
admin-stat.php 3KB
admin-tools.php 11KB
control.php 2KB
setting.php 25KB
install
check.php 6KB
index.html 2KB
install.template.sql 6KB
install.php 15KB
uninst.template.sql 306B
template.table.sql 572B
ajax.php 16KB
lib
class.E.php 3KB
msg.php 5KB
class.mysqli.php 5KB
class.wcurl.php 5KB
globals.php 7KB
ui.php 4KB
reg.php 4KB
class.mysql.php 5KB
class.option.php 9KB
class.cron.php 6KB
sfc.functions.php 27KB
plugins.php 9KB
class.smtp.php 10KB
cron_system_sign.php 479B
class.S.php 6KB
class.former.php 3KB
mysql_autoload.php 564B
class.P.php 2KB
class.zip.php 3KB
class.misc.php 17KB
cron_system_sign_retry.php 485B
source
css
bootstrap.min.css 114KB
my.css 26B
ui.css 744B
fonts
glyphicons-halflings-regular.woff 23KB
glyphicons-halflings-regular.ttf 44KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.svg 106KB
js
jquery.min.js 91KB
js.js 11KB
my.js 25B
bootstrap.min.js 35KB
doc
baiduid.png 34KB
get_bduss.exe 61KB
app.conf 853B
init.php 2KB
共 64 条
- 1
易小侠
- 粉丝: 6415
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0