Browse Source

代码调整

tags/6.0.0
tianya 3 years ago
parent
commit
b0b73ae828
7 changed files with 322 additions and 376 deletions
  1. +2
    -0
      .gitignore
  2. +212
    -259
      src/include/dedemodule.class.php
  3. +1
    -1
      src/include/enums.func.php
  4. +0
    -20
      src/include/extend.func.php
  5. +84
    -94
      src/include/membermodel.cls.php
  6. +0
    -1
      src/index.php
  7. +23
    -1
      src/install/v57sp2_to_v58.txt

+ 2
- 0
.gitignore View File

@@ -26,3 +26,5 @@ src/uploads/litimg/*
src/special/
*.bat
src/data/backupdata/*
src/a/*.html
src/data/mkall_cache_*.php

+ 212
- 259
src/include/dedemodule.class.php View File

@@ -1,4 +1,4 @@
<?php if(!defined('DEDEINC')) exit("Request Error!");
<?php if (!defined('DEDEINC')) exit("Request Error!");
/**
* 织梦模块类
*
@@ -8,27 +8,27 @@
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once(DEDEINC.'/charset.func.php');
require_once(DEDEINC.'/dedeatt.class.php');
require_once(DEDEINC.'/dedehttpdown.class.php');
require_once(DEDEINC . '/charset.func.php');
require_once(DEDEINC . '/dedeatt.class.php');
require_once(DEDEINC . '/dedehttpdown.class.php');
class DedeModule
{
var $modulesPath;
var $modulesUrl;
var $modulesUrl;
var $modules;
var $fileListNames;
var $sysLang;
var $moduleLang;
function __construct($modulespath='',$modulesUrl='')
function __construct($modulespath = '', $modulesUrl = '')
{
global $cfg_soft_lang;
$this->sysLang = $this->moduleLang = $cfg_soft_lang;
$this->fileListNames = array();
$this->modulesPath = $modulespath;
$this->modulesUrl = $modulesUrl;
$this->modulesUrl = $modulesUrl;
}
function DedeModule($modulespath='')
function DedeModule($modulespath = '')
{
$this->__construct($modulespath);
}
@@ -40,73 +40,68 @@ class DedeModule
* @param string $moduletype 模块类型
* @return string
*/
function GetModuleList($moduletype='')
function GetModuleList($moduletype = '')
{
if(is_array($this->modules)) return $this->modules;
if (is_array($this->modules)) return $this->modules;
$dh = dir($this->modulesPath) or die("没找到模块目录:({$this->modulesPath})!");
$fp = @fopen($this->modulesPath.'/modulescache.php','w') or die('读取文件权限出错,目录文件'.$this->modulesPath.'/modulescache.php不可写!');
$fp = @fopen($this->modulesPath . '/modulescache.php', 'w') or die('读取文件权限出错,目录文件' . $this->modulesPath . '/modulescache.php不可写!');
fwrite($fp, "<"."?php\r\n");
fwrite($fp, "<" . "?php\r\n");
fwrite($fp, "global \$allmodules;\r\n");
while($filename = $dh->read())
{
if(preg_match("/\.xml$/i", $filename))
{
$minfos = $this->GetModuleInfo(str_replace('.xml','',$filename));
if(isset($minfos['moduletype']) && $moduletype!='' && $moduletype!=$minfos['moduletype'])
{
while ($filename = $dh->read()) {
if (preg_match("/\.xml$/i", $filename)) {
$minfos = $this->GetModuleInfo(str_replace('.xml', '', $filename));
if (isset($minfos['moduletype']) && $moduletype != '' && $moduletype != $minfos['moduletype']) {
continue;
}
if($minfos['hash']!='')
{
if ($minfos['hash'] != '') {
$this->modules[$minfos['hash']] = $minfos;
fwrite($fp, '$'."GLOBALS['allmodules']['{$minfos['hash']}']='{$filename}';\r\n");
fwrite($fp, '$' . "GLOBALS['allmodules']['{$minfos['hash']}']='{$filename}';\r\n");
}
}
}
fwrite($fp,'?'.'>');
fwrite($fp, '?' . '>');
fclose($fp);
$dh->Close();
return $this->modules;
}
/**
/**
* 从远程获取模块信息
*
* @access public
* @param string $moduletype 模块类型
* @return string
*/
function GetModuleUrlList($moduletype='',$url='')
function GetModuleUrlList($moduletype = '', $url = '')
{
$dh = dir($this->modulesPath) or die("没找到模块目录:({$this->modulesPath})!");
$fp = @fopen($this->modulesPath.'/modulescache.php','w') or die('读取文件权限出错,目录文件'.$this->modulesPath.'/modulescache.php不可写!');
$cachefile = DEDEDATA.'/module/moduleurllist.txt';
$remotelist = '';
if(file_exists($cachefile) && (filemtime($cachefile) + 60 * 30) > time())
{
// 30分钟本地缓存一次
$remotelist = file_get_contents($cachefile);
} else {
$del = new DedeHttpDown();
$del->OpenUrl($url);
$remotelist = $del->GetHtml();
PutFile($cachefile, $remotelist);
}
if(empty($remotelist)) return false;
$dh = dir($this->modulesPath) or die("没找到模块目录:({$this->modulesPath})!");
$fp = @fopen($this->modulesPath . '/modulescache.php', 'w') or die('读取文件权限出错,目录文件' . $this->modulesPath . '/modulescache.php不可写!');
$cachefile = DEDEDATA . '/module/moduleurllist.txt';
$remotelist = '';
if (file_exists($cachefile) && (filemtime($cachefile) + 60 * 30) > time()) {
// 30分钟本地缓存一次
$remotelist = file_get_contents($cachefile);
} else {
$del = new DedeHttpDown();
$del->OpenUrl($url);
$remotelist = $del->GetHtml();
PutFile($cachefile, $remotelist);
}
if (empty($remotelist)) return false;
$modules = unserialize($remotelist);
if(empty($moduletype)){
return $modules;
}
$return = array();
foreach($modules as $arrow=>$data) {
if($data['moduletype']==$moduletype)
$return[] = $data;
}
return $return;
if (empty($moduletype)) {
return $modules;
}
$return = array();
foreach ($modules as $arrow => $data) {
if ($data['moduletype'] == $moduletype)
$return[] = $data;
}
return $return;
}
/**
* 转换编码
@@ -117,29 +112,19 @@ class DedeModule
*/
function AppCode(&$str)
{
if($this->moduleLang==$this->sysLang)
{
if ($this->moduleLang == $this->sysLang) {
return $str;
}
else
{
if($this->sysLang=='utf-8')
{
if($this->moduleLang=='gbk') return gb2utf8($str);
if($this->moduleLang=='big5') return gb2utf8(big52gb($str));
}
else if($this->sysLang=='gbk')
{
if($this->moduleLang=='utf-8') return utf82gb($str);
if($this->moduleLang=='big5') return big52gb($str);
}
else if($this->sysLang=='big5')
{
if($this->moduleLang=='utf-8') return gb2big5(utf82gb($str));
if($this->moduleLang=='gbk') return gb2big5($str);
}
else
{
} else {
if ($this->sysLang == 'utf-8') {
if ($this->moduleLang == 'gbk') return gb2utf8($str);
if ($this->moduleLang == 'big5') return gb2utf8(big52gb($str));
} else if ($this->sysLang == 'gbk') {
if ($this->moduleLang == 'utf-8') return utf82gb($str);
if ($this->moduleLang == 'big5') return big52gb($str);
} else if ($this->sysLang == 'big5') {
if ($this->moduleLang == 'utf-8') return gb2big5(utf82gb($str));
if ($this->moduleLang == 'gbk') return gb2big5($str);
} else {
return $str;
}
}
@@ -154,9 +139,9 @@ class DedeModule
*/
function GetHashFile($hash)
{
include_once($this->modulesPath.'/modulescache.php');
if(isset($GLOBALS['allmodules'][$hash])) return $GLOBALS['allmodules'][$hash];
else return $hash.'.xml';
include_once($this->modulesPath . '/modulescache.php');
if (isset($GLOBALS['allmodules'][$hash])) return $GLOBALS['allmodules'][$hash];
else return $hash . '.xml';
}
/**
@@ -167,51 +152,48 @@ class DedeModule
* @param string $ftype 文件类型
* @return string
*/
function GetModuleInfo($hash, $ftype='hash')
function GetModuleInfo($hash, $ftype = 'hash')
{
if($ftype=='file') $filename = $hash;
else if(!empty($this->modulesUrl)) {
$filename = $this->modulesUrl.$hash.'.xml';
}else $filename = $this->modulesPath.'/'.$this->GetHashFile($hash);
if ($ftype == 'file') $filename = $hash;
else if (!empty($this->modulesUrl)) {
$filename = $this->modulesUrl . $hash . '.xml';
} else $filename = $this->modulesPath . '/' . $this->GetHashFile($hash);
$start = 0;
$minfos = array();
$minfos['name']=$minfos['team']=$minfos['time']=$minfos['email']=$minfos['url']='';
$minfos['hash']=$minfos['indexname']=$minfos['indexurl']='';
$minfos['ismember']=$minfos['autosetup']=$minfos['autodel']=0;
$minfos['name'] = $minfos['team'] = $minfos['time'] = $minfos['email'] = $minfos['url'] = '';
$minfos['hash'] = $minfos['indexname'] = $minfos['indexurl'] = '';
$minfos['ismember'] = $minfos['autosetup'] = $minfos['autodel'] = 0;
//$minfos['filename'] = $filename;
if(empty($this->modulesUrl)){
$minfos['filesize'] = filesize($filename)/1024;
$minfos['filesize'] = number_format($minfos['filesize'],2,'.','').' Kb';
}
$fp = fopen($filename,'r') or die("文件 {$filename} 不存在或不可读!");
if (empty($this->modulesUrl)) {
$minfos['filesize'] = filesize($filename) / 1024;
$minfos['filesize'] = number_format($minfos['filesize'], 2, '.', '') . ' Kb';
}
$fp = fopen($filename, 'r') or die("文件 {$filename} 不存在或不可读!");
$n = 0;
while(!feof($fp))
{
while (!feof($fp)) {
$n++;
if($n > 30) break;
$line = fgets($fp,256);
if($start==0)
{ if(preg_match("/<baseinfo/is",$line)) $start = 1; }
else
{
if(preg_match("/<\/baseinfo/is",$line)) break;
if ($n > 30) break;
$line = fgets($fp, 256);
if ($start == 0) {
if (preg_match("/<baseinfo/is", $line)) $start = 1;
} else {
if (preg_match("/<\/baseinfo/is", $line)) break;
$line = trim($line);
list($skey,$svalue) = explode('=',$line);
list($skey, $svalue) = explode('=', $line);
$skey = trim($skey);
$minfos[$skey] = $svalue;
}
}
fclose($fp);
if(isset($minfos['lang'])) $this->moduleLang = trim($minfos['lang']);
if (isset($minfos['lang'])) $this->moduleLang = trim($minfos['lang']);
else $this->moduleLang = 'gbk';
if($this->sysLang=='gb2312') $this->sysLang = 'gbk';
if($this->moduleLang=='gb2312') $this->moduleLang = 'gbk';
if ($this->sysLang == 'gb2312') $this->sysLang = 'gbk';
if ($this->moduleLang == 'gb2312') $this->moduleLang = 'gbk';
if($this->sysLang != $this->moduleLang)
{
foreach($minfos as $k=>$v) $minfos[$k] = $this->AppCode($v);
if ($this->sysLang != $this->moduleLang) {
foreach ($minfos as $k => $v) $minfos[$k] = $this->AppCode($v);
}
return $minfos;
@@ -225,27 +207,22 @@ class DedeModule
* @param string $ftype 文件类型
* @return string
*/
function GetFileXml($hash, $ftype='hash')
function GetFileXml($hash, $ftype = 'hash')
{
if($ftype=='file') $filename = $hash;
else $filename = $this->modulesPath.'/'.$this->GetHashFile($hash);
if ($ftype == 'file') $filename = $hash;
else $filename = $this->modulesPath . '/' . $this->GetHashFile($hash);
$filexml = '';
$fp = fopen($filename,'r') or die("文件 {$filename} 不存在或不可读!");
$fp = fopen($filename, 'r') or die("文件 {$filename} 不存在或不可读!");
$start = 0;
while(!feof($fp))
{
$line = fgets($fp,1024);
if($start==0)
{
if(preg_match("/<modulefiles/is",$line))
{
while (!feof($fp)) {
$line = fgets($fp, 1024);
if ($start == 0) {
if (preg_match("/<modulefiles/is", $line)) {
$filexml .= $line;
$start = 1;
}
continue;
}
else
{
} else {
$filexml .= $line;
}
}
@@ -263,31 +240,27 @@ class DedeModule
* @param string $enCode 是否加密
* @return string
*/
function GetSystemFile($hashcode, $ntype, $enCode=TRUE)
function GetSystemFile($hashcode, $ntype, $enCode = TRUE)
{
$this->GetModuleInfo($hashcode,$ntype);
$this->GetModuleInfo($hashcode, $ntype);
$start = FALSE;
$filename = $this->modulesPath.'/'.$this->GetHashFile($hashcode);
$fp = fopen($filename,'r') or die("文件 {$filename} 不存在或不可读!");
$filename = $this->modulesPath . '/' . $this->GetHashFile($hashcode);
$fp = fopen($filename, 'r') or die("文件 {$filename} 不存在或不可读!");
$okdata = '';
while(!feof($fp))
{
$line = fgets($fp,1024);
if(!$start)
{
while (!feof($fp)) {
$line = fgets($fp, 1024);
if (!$start) {
// 2011-6-7 修复模块打包程序中上传安装程序生成为空白文件(by:华强)
if(preg_match("#<{$ntype}>#i", $line)) $start = TRUE;
}
else
{
if(preg_match("#<\/{$ntype}#i", $line)) break;
if (preg_match("#<{$ntype}>#i", $line)) $start = TRUE;
} else {
if (preg_match("#<\/{$ntype}#i", $line)) break;
$okdata .= $line;
unset($line);
}
}
fclose($fp);
$okdata = trim($okdata);
if(!empty($okdata) && $enCode) $okdata = base64_decode($okdata);
if (!empty($okdata) && $enCode) $okdata = base64_decode($okdata);
$okdata = $this->AppCode($okdata);
return $okdata;
}
@@ -302,11 +275,11 @@ class DedeModule
*/
function WriteSystemFile($hashcode, $ntype)
{
$filename = $hashcode."-{$ntype}.php";
$fname = $this->modulesPath.'/'.$filename;
$filect = $this->GetSystemFile($hashcode,$ntype);
$fp = fopen($fname,'w') or die('生成 {$ntype} 文件失败!');
fwrite($fp,$filect);
$filename = $hashcode . "-{$ntype}.php";
$fname = $this->modulesPath . '/' . $filename;
$filect = $this->GetSystemFile($hashcode, $ntype);
$fp = fopen($fname, 'w') or die('生成 {$ntype} 文件失败!');
fwrite($fp, $filect);
fclose($fp);
return $filename;
}
@@ -319,9 +292,9 @@ class DedeModule
* @param string $ntype 文件类型
* @return void
*/
function DelSystemFile($hashcode,$ntype)
function DelSystemFile($hashcode, $ntype)
{
$filename = $this->modulesPath.'/'.$hashcode."-{$ntype}.php";
$filename = $this->modulesPath . '/' . $hashcode . "-{$ntype}.php";
unlink($filename);
}
@@ -334,8 +307,8 @@ class DedeModule
*/
function HasModule($hashcode)
{
$modulefile = $this->modulesPath.'/'.$this->GetHashFile($hashcode);
if(file_exists($modulefile) && !is_dir($modulefile)) return TRUE;
$modulefile = $this->modulesPath . '/' . $this->GetHashFile($hashcode);
if (file_exists($modulefile) && !is_dir($modulefile)) return TRUE;
else return FALSE;
}
@@ -347,13 +320,13 @@ class DedeModule
* @param string $isremove 是否删除
* @return string
*/
function GetEncodeFile($filename,$isremove=FALSE)
function GetEncodeFile($filename, $isremove = FALSE)
{
$fp = fopen($filename,'r') or die("文件 {$filename} 不存在或不可读!");
$str = @fread($fp,filesize($filename));
$fp = fopen($filename, 'r') or die("文件 {$filename} 不存在或不可读!");
$str = @fread($fp, filesize($filename));
fclose($fp);
if($isremove) @unlink($filename);
if(!empty($str)) return base64_encode($str);
if ($isremove) @unlink($filename);
if (!empty($str)) return base64_encode($str);
else return '';
}
@@ -368,16 +341,14 @@ class DedeModule
{
$dap = new DedeAttParse();
$filelists = array();
$modulefile = $this->modulesPath.'/'.$this->GetHashFile($hashcode);
$fp = fopen($modulefile,'r') or die("文件 {$modulefile} 不存在或不可读!");
$modulefile = $this->modulesPath . '/' . $this->GetHashFile($hashcode);
$fp = fopen($modulefile, 'r') or die("文件 {$modulefile} 不存在或不可读!");
$i = 0;
while(!feof($fp))
{
$line = fgets($fp,1024);
if(preg_match("/^[\s]{0,}<file/i",$line))
{
while (!feof($fp)) {
$line = fgets($fp, 1024);
if (preg_match("/^[\s]{0,}<file/i", $line)) {
$i++;
$line = trim(preg_replace("/[><]/","",$line));
$line = trim(preg_replace("/[><]/", "", $line));
$dap->SetSource($line);
$filelists[$i]['type'] = $dap->CAtt->GetAtt('type');
$filelists[$i]['name'] = $dap->CAtt->GetAtt('name');
@@ -395,35 +366,37 @@ class DedeModule
* @param string $isreplace 是否替换
* @return string
*/
function DeleteFiles($hashcode,$isreplace=0)
function DeleteFiles($hashcode, $isreplace = 0)
{
if($isreplace==0) return TRUE;
else
{
if ($isreplace == 0) return TRUE;
else {
$dap = new DedeAttParse();
$modulefile = $this->modulesPath.'/'.$this->GetHashFile($hashcode);
$fp = fopen($modulefile,'r') or die("文件 {$modulefile} 不存在或不可读!");
$modulefile = $this->modulesPath . '/' . $this->GetHashFile($hashcode);
$fp = fopen($modulefile, 'r') or die("文件 {$modulefile} 不存在或不可读!");
$i = 0;
$dirs = '';
while(!feof($fp))
{
$line = fgets($fp,1024);
if(preg_match("/^[\s]{0,}<file/i",$line))
{
while (!feof($fp)) {
$line = fgets($fp, 1024);
if (preg_match("/^[\s]{0,}<file/i", $line)) {
$i++;
$line = trim(preg_replace("/[><]/","",$line));
$line = trim(preg_replace("/[><]/", "", $line));
$dap->SetSource($line);
$filetype = $dap->CAtt->GetAtt('type');
$filename = $dap->CAtt->GetAtt('name');
$filename = str_replace("\\","/",$filename);
if($filetype=='dir'){ $dirs[] = $filename; }
else{ @unlink($filename); }
$filename = str_replace("\\", "/", $filename);
if ($filetype == 'dir') {
$dirs[] = $filename;
} else {
@unlink($filename);
}
}
}
$okdirs = array();
if(is_array($dirs)){
$st = count($dirs) -1;
for($i=$st;$i>=0;$i--){ @rmdir($dirs[$i]); }
if (is_array($dirs)) {
$st = count($dirs) - 1;
for ($i = $st; $i >= 0; $i--) {
@rmdir($dirs[$i]);
}
}
fclose($fp);
}
@@ -438,73 +411,62 @@ class DedeModule
* @param string $isreplace 是否替换
* @return string
*/
function WriteFiles($hashcode, $isreplace=3)
function WriteFiles($hashcode, $isreplace = 3)
{
global $AdminBaseDir;
$dap = new DedeAttParse();
$modulefile = $this->modulesPath.'/'.$this->GetHashFile($hashcode);
$fp = fopen($modulefile,'r') or die("文件 {$modulefile} 不存在或不可读!");
$modulefile = $this->modulesPath . '/' . $this->GetHashFile($hashcode);
$fp = fopen($modulefile, 'r') or die("文件 {$modulefile} 不存在或不可读!");
$i = 0;
while(!feof($fp))
{
$line = fgets($fp,1024);
if( preg_match("/^[\s]{0,}<file/i",$line) )
{
while (!feof($fp)) {
$line = fgets($fp, 1024);
if (preg_match("/^[\s]{0,}<file/i", $line)) {
$i++;
$line = trim(preg_replace("/[><]/","",$line));
$line = trim(preg_replace("/[><]/", "", $line));
$dap->SetSource($line);
$filetype = $dap->CAtt->GetAtt('type');
$filename = $dap->CAtt->GetAtt('name');
$filename = str_replace("\\","/",$filename);
if(!empty($AdminBaseDir)) $filename = $AdminBaseDir.$filename;
if($filetype=='dir')
{
if(!is_dir($filename))
{
@mkdir($filename,$GLOBALS['cfg_dir_purview']);
$filename = str_replace("\\", "/", $filename);
if (!empty($AdminBaseDir)) $filename = $AdminBaseDir . $filename;
if ($filetype == 'dir') {
if (!is_dir($filename)) {
@mkdir($filename, $GLOBALS['cfg_dir_purview']);
}
@chmod($filename,$GLOBALS['cfg_dir_purview']);
}
else
{
@chmod($filename, $GLOBALS['cfg_dir_purview']);
} else {
$this->TestDir($filename);
if($isreplace==0) continue;
if($isreplace==3)
{
if(is_file($filename))
{
$copyname = @preg_replace("/([^\/]{1,}$)/","bak-$1",$filename);
@copy($filename,$copyname);
if ($isreplace == 0) continue;
if ($isreplace == 3) {
if (is_file($filename)) {
$copyname = @preg_replace("/([^\/]{1,}$)/", "bak-$1", $filename);
@copy($filename, $copyname);
}
}
if(!empty($filename))
{
$fw = fopen($filename,'w') or die("写入文件 {$filename} 失败,请检查相关目录的权限!");
if (!empty($filename)) {
$fw = fopen($filename, 'w') or die("写入文件 {$filename} 失败,请检查相关目录的权限!");
$ct = '';
while(!feof($fp))
{
$l = fgets($fp,1024);
if(preg_match("/^[\s]{0,}<\/file/i",trim($l))){ break; }
while (!feof($fp)) {
$l = fgets($fp, 1024);
if (preg_match("/^[\s]{0,}<\/file/i", trim($l))) {
break;
}
$ct .= $l;
}
$ct = base64_decode($ct);
if($this->sysLang!=$this->moduleLang)
{
if ($this->sysLang != $this->moduleLang) {
//转换内码
if(preg_match('/\.(xml|php|inc|txt|htm|html|shtml|tpl|css)$/', $filename))
{
if (preg_match('/\.(xml|php|inc|txt|htm|html|shtml|tpl|css)$/', $filename)) {
$ct = $this->AppCode($ct);
}
//转换HTML编码标识
if(preg_match('/\.(php|htm|html|shtml|inc|tpl)$/i', $filename))
{
if($this->sysLang=='big5') $charset = 'charset=big5';
else if($this->sysLang=='utf-8') $charset = 'charset=gb2312';
if (preg_match('/\.(php|htm|html|shtml|inc|tpl)$/i', $filename)) {
if ($this->sysLang == 'big5') $charset = 'charset=big5';
else if ($this->sysLang == 'utf-8') $charset = 'charset=gb2312';
else $charset = 'charset=gb2312';
$ct = preg_match("/charset=([a-z0-9-]*)/i", $charset, $ct);
}
}
fwrite($fw,$ct);
fwrite($fw, $ct);
fclose($fw);
}
}
@@ -523,17 +485,16 @@ class DedeModule
*/
function TestDir($filename)
{
$fs = explode('/',$filename);
$fn = count($fs) - 1 ;
$fs = explode('/', $filename);
$fn = count($fs) - 1;
$ndir = '';
for($i=0;$i < $fn;$i++)
{
if($ndir!='') $ndir = $ndir.'/'.$fs[$i];
for ($i = 0; $i < $fn; $i++) {
if ($ndir != '') $ndir = $ndir . '/' . $fs[$i];
else $ndir = $fs[$i];
$rs = @is_dir($ndir);
if( !$rs ) {
@mkdir($ndir,$GLOBALS['cfg_dir_purview']);
@chmod($ndir,$GLOBALS['cfg_dir_purview']);
if (!$rs) {
@mkdir($ndir, $GLOBALS['cfg_dir_purview']);
@chmod($ndir, $GLOBALS['cfg_dir_purview']);
}
}
return TRUE;
@@ -548,10 +509,10 @@ class DedeModule
* @param string $fp 文件指针
* @return bool
*/
function MakeEncodeFile($basedir,$f,$fp)
function MakeEncodeFile($basedir, $f, $fp)
{
$this->fileListNames = array();
$this->MakeEncodeFileRun($basedir,$f,$fp);
$this->MakeEncodeFileRun($basedir, $f, $fp);
return TRUE;
}
@@ -563,10 +524,10 @@ class DedeModule
* @param string $f
* @return bool
*/
function MakeEncodeFileTest($basedir,$f)
function MakeEncodeFileTest($basedir, $f)
{
$this->fileListNames = array();
$this->MakeEncodeFileRunTest($basedir,$f);
$this->MakeEncodeFileRunTest($basedir, $f);
return TRUE;
}
@@ -578,26 +539,23 @@ class DedeModule
* @param string $f
* @return void
*/
function MakeEncodeFileRunTest($basedir,$f)
function MakeEncodeFileRunTest($basedir, $f)
{
$filename = $basedir.'/'.$f;
if(isset($this->fileListNames[$f])) return;
else if(preg_match("/Thumbs\.db/i",$f)) return;
$filename = $basedir . '/' . $f;
if (isset($this->fileListNames[$f])) return;
else if (preg_match("/Thumbs\.db/i", $f)) return;
else $this->fileListNames[$f] = 1;
$fileList = '';
if(!file_exists($filename))
{
ShowMsg("文件或文件夹: {$filename} 不存在,无法进行编译!","-1");
if (!file_exists($filename)) {
ShowMsg("文件或文件夹: {$filename} 不存在,无法进行编译!", "-1");
exit();
}
if(is_dir($filename))
{
if (is_dir($filename)) {
$dh = dir($filename);
while($filename = $dh->read())
{
if($filename[0]=='.' || strtolower($filename)=='cvs') continue;
$nfilename = $f.'/'.$filename;
$this->MakeEncodeFileRunTest($basedir,$nfilename);
while ($filename = $dh->read()) {
if ($filename[0] == '.' || strtolower($filename) == 'cvs') continue;
$nfilename = $f . '/' . $filename;
$this->MakeEncodeFileRunTest($basedir, $nfilename);
}
}
}
@@ -611,32 +569,28 @@ class DedeModule
* @param string $fp 文件指针
* @return string
*/
function MakeEncodeFileRun($basedir,$f,$fp)
function MakeEncodeFileRun($basedir, $f, $fp)
{
$filename = $basedir.'/'.$f;
if(isset($this->fileListNames[$f])) return;
else if(preg_match("#Thumbs\.db#i", $f)) return;
$filename = $basedir . '/' . $f;
if (isset($this->fileListNames[$f])) return;
else if (preg_match("#Thumbs\.db#i", $f)) return;
else $this->fileListNames[$f] = 1;
$fileList = '';
if(is_dir($filename))
{
if (is_dir($filename)) {
$fileList .= "<file type='dir' name='$f'>\r\n";
$fileList .= "</file>\r\n";
fwrite($fp,$fileList);
fwrite($fp, $fileList);
$dh = dir($filename);
while($filename = $dh->read())
{
if($filename[0]=='.' || strtolower($filename)=='cvs') continue;
$nfilename = $f.'/'.$filename;
$this->MakeEncodeFileRun($basedir,$nfilename,$fp);
while ($filename = $dh->read()) {
if ($filename[0] == '.' || strtolower($filename) == 'cvs') continue;
$nfilename = $f . '/' . $filename;
$this->MakeEncodeFileRun($basedir, $nfilename, $fp);
}
}
else
{
} else {
$fileList .= "<file type='file' name='$f'>\r\n";
$fileList .= $this->GetEncodeFile($filename);
$fileList .= "\r\n</file>\r\n";
fwrite($fp,$fileList);
fwrite($fp, $fileList);
}
}
@@ -652,5 +606,4 @@ class DedeModule
unset($this->fileList);
unset($this->fileListNames);
}
}//End Class

+ 1
- 1
src/include/enums.func.php View File

@@ -95,7 +95,7 @@ function GetEnumsForm($egroup, $evalue=0, $formid='', $seltitle='')
{
$formid = $egroup;
}
$forms = "<select name='$formid' id='$formid' class='enumselect'>\r\n";
$forms = "<select name='$formid' id='$formid' class='enumselect form-control'>\r\n";
$forms .= "\t<option value='0' selected='selected'>--请选择--{$seltitle}</option>\r\n";
foreach(${'em_'.$egroup.'s'} as $v=>$n)
{


+ 0
- 20
src/include/extend.func.php View File

@@ -1,21 +1 @@
<?php
function litimgurls($imgid=0)
{
global $lit_imglist,$dsql;
//获取附加表
$row = $dsql->GetOne("SELECT c.addtable FROM #@__archives AS a LEFT JOIN #@__channeltype AS c
ON a.channel=c.id where a.id='$imgid'");
$addtable = trim($row['addtable']);
//获取图片附加表imgurls字段内容进行处理
$row = $dsql->GetOne("Select imgurls From `$addtable` where aid='$imgid'");
//调用inc_channel_unit.php中ChannelUnit类
$ChannelUnit = new ChannelUnit(2,$imgid);
//调用ChannelUnit类中GetlitImgLinks方法处理缩略图
$lit_imglist = $ChannelUnit->GetlitImgLinks($row['imgurls']);
//返回结果
return $lit_imglist;
}

+ 84
- 94
src/include/membermodel.cls.php View File

@@ -1,4 +1,4 @@
<?php if(!defined('DEDEINC')) exit('forbidden');
<?php if (!defined('DEDEINC')) exit('forbidden');
/**
* 会员自定义模块
*
@@ -8,9 +8,9 @@
* @license http://help.dedecms.com/usersguide/license.html
* @link http://www.dedecms.com
*/
require_once DEDEINC.'/dedetag.class.php';
require_once DEDEINC.'/customfields.func.php';
require_once DEDEINC.'/enums.func.php';
require_once DEDEINC . '/dedetag.class.php';
require_once DEDEINC . '/customfields.func.php';
require_once DEDEINC . '/enums.func.php';
/**
* 会员自定义模块
@@ -33,71 +33,65 @@ class membermodel
var $postTemplate;
//兼容PHP4版本
function membermodel($modtype){
function membermodel($modtype)
{
$this->__construct($modtype);
}
//析构函数
function __construct($modtype){
function __construct($modtype)
{
$this->name = $modtype;
$this->db = $GLOBALS['dsql'];
$query = "SELECT * FROM #@__member_model WHERE name='{$modtype}'";
$diyinfo = $this->db->getone($query);
if(!is_array($diyinfo))
{
showMsg('参数不正确,该会员模型不存在','javascript:;');
if (!is_array($diyinfo)) {
showMsg('参数不正确,该会员模型不存在', 'javascript:;');
exit();
}
$etypes = array();
$egroups = array();
$this->db->Execute('me','SELECT * FROM `#@__stepselect` ORDER BY id desc');
while($arr = $this->db->GetArray())
{
$etypes[] = $arr;
$egroups[$arr['egroup']] = $arr['itemname'];
}
$this->egroups = $egroups;
$etypes = array();
$egroups = array();
$this->db->Execute('me', 'SELECT * FROM `#@__stepselect` ORDER BY id desc');
while ($arr = $this->db->GetArray()) {
$etypes[] = $arr;
$egroups[$arr['egroup']] = $arr['itemname'];
}
$this->egroups = $egroups;
$this->modid = $diyinfo['id'];
$this->table = $diyinfo['table'];
$this->description = $diyinfo['description'];
$this->state = $diyinfo['state'];
$this->issystem = $diyinfo['issystem'];
$this->info = $diyinfo['info'];
}//end func __construct()
} //end func __construct()
/**
* 获取用户数据表单
*
* @access public
* @param string $type 表单类型
* @param string $value 值
* @param string $admintype 模型类型
* @return string
*/
function getForm($type = 'post', $value = '', $admintype='membermodel2')
/**
* 获取用户数据表单
*
* @access public
* @param string $type 表单类型
* @param string $value 值
* @param string $admintype 模型类型
* @return string
*/
function getForm($type = 'post', $value = '', $admintype = 'membermodel2')
{
global $cfg_cookie_encode;
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->SetNameSpace("field", "<", ">");
$dtp->LoadSource($this->info);
$formstring = '';
$formfields = '';
$func = $type == 'post' ? 'GetFormItem' : 'GetFormItemValue';
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tagid=>$tag)
{
if($tag->GetAtt('autofield'))
{
if($tag->GetAtt('state') == 1)
{
if (is_array($dtp->CTags)) {
foreach ($dtp->CTags as $tagid => $tag) {
if ($tag->GetAtt('autofield')) {
if ($tag->GetAtt('state') == 1) {
//如果启用该字段
if($type == 'post')
{
if ($type == 'post') {
//对一些字段进行特殊处理
if($tag->GetName() == 'onlynet')
{
if ($tag->GetName() == 'onlynet') {
$formstring .= '<li><span>联系方式限制:</span><div class="lform">
<input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
不公开所有联系方式
@@ -105,68 +99,66 @@ class membermodel
不公开电话、详细地址
<input name="onlynet" type="radio" id="onlynet" value="0" />
公开所有联系方式</div></li>';
} else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace')
{
$formtitle = ($tag->GetName() == 'place')? '目前所在地' : '家乡所在地';
$formstring .='<li><div class="lform">' . GetEnumsForm('nativeplace',
0,$tag->GetName()).'</div><span>'.$formtitle.':</span></li>';
} else if (array_key_exists($tag->GetName(),$this->egroups))
{
} else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace') {
$formtitle = ($tag->GetName() == 'place') ? '目前所在地' : '家乡所在地';
$formstring .= '<li><div class="lform">' . GetEnumsForm(
'nativeplace',
0,
$tag->GetName()
) . '</div><span>' . $formtitle . ':</span></li>';
} else if (array_key_exists($tag->GetName(), $this->egroups)) {
//对联动模型进行特殊处理
$formstring .='<li><div class="lform">'. GetEnumsForm($tag->GetName(),
0,$tag->GetName()).'</div><span>'.$this->egroups[$tag->GetName()].':</span></li>';
} else if ($tag->GetAtt('type') == 'checkbox')
{
$formstring .= '<li><div class="lform">' . GetEnumsForm(
$tag->GetName(),
0,
$tag->GetName()
) . '</div><span>' . $this->egroups[$tag->GetName()] . ':</span></li>';
} else if ($tag->GetAtt('type') == 'checkbox') {
//对checkbox模型进行特殊处理
$formstring .=$func($tag,$admintype);
$formstring .= $func($tag, $admintype);
} else {
$formstring .= $func($tag,$admintype);
$formstring .= $func($tag, $admintype);
}
} else {
if($tag->GetName() == 'onlynet')
{
$formstring .= '<p style="display:none"><label>联系方式限制:</label>
if ($tag->GetName() == 'onlynet') {
$formstring .= '<p style="display:none"><label>联系方式限制:</label>
<input name="onlynet" type="radio" id="onlynet" value="2" checked="checked" />
不公开所有联系方式
<input name="onlynet" type="radio" id="onlynet" value="1" />
不公开电话、详细地址
<input name="onlynet" type="radio" id="onlynet" value="0" />
公开所有联系方式</p>';
} else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace'){
$formtitle = ($tag->GetName() == 'place')? '目前所在地' : '家乡所在地';
$formstring .='<p><label>'.$formtitle.':</label>' . GetEnumsForm('nativeplace',$value[$tag->GetName()],$tag->GetName()).'</p>';
} else if ($tag->GetName() == 'birthday'){
$formstring .='<p><label>'.$tag->GetAtt('itemname').':</label><input type="text" class="intxt" style="width: 100px;" id="birthday" value="'.$value[$tag->GetName()].'" name="birthday"></p>';
} else if (array_key_exists($tag->GetName(),$this->egroups)){
//对联动模型进行特殊处理
$formstring .='<p><label>'.$this->egroups[$tag->GetName()].':</label> '. GetEnumsForm($tag->GetName(),$value[$tag->GetName()],$tag->GetName()).'</p>';
} else if ($tag->GetAtt('type') == 'checkbox'){
//对checkbox模型进行特殊处理
$formstring .=$func($tag,dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
}
else if ($tag->GetAtt('type') == 'img')
{
$fieldname = $tag->GetName();
$labelname = $tag->GetAtt('itemname');
$fvalue = dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES);
$imgstrng = "<p><label>{$labelname}:</label><input type='text' name='$fieldname' value='$fvalue' id='$fieldname' style='width:300px' class='text' /> <input name='".$fieldname."_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('addcontent.$fieldname','big')\" />\r\n</p>";
$formstring .=$imgstrng;
}
else {
$formstring .= $func($tag,dede_htmlspecialchars($value[$tag->GetName()],ENT_QUOTES),$admintype);
//echo $formstring;
}
} else if ($tag->GetName() == 'place' || $tag->GetName() == 'oldplace') {
$formtitle = ($tag->GetName() == 'place') ? '目前所在地' : '家乡所在地';
$formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $formtitle . ':</label><div class="col-sm-10">' . GetEnumsForm('nativeplace', $value[$tag->GetName()], $tag->GetName()) . '</div></div>';
} else if ($tag->GetName() == 'birthday') {
$formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $tag->GetAtt('itemname') . ':</label><div class="col-sm-10"><input type="text" class="form-control" style="width: 100px;" id="birthday" value="' . $value[$tag->GetName()] . '" name="birthday"></div></div>';
} else if (array_key_exists($tag->GetName(), $this->egroups)) {
//对联动模型进行特殊处理
$formstring .= '<div class="form-group row"><label class="col-sm-2 col-form-label">' . $this->egroups[$tag->GetName()] . ':</label><div class="col-sm-10">' . GetEnumsForm($tag->GetName(), $value[$tag->GetName()], $tag->GetName()) . '</div></div>';
} else if ($tag->GetAtt('type') == 'checkbox') {
//对checkbox模型进行特殊处理
$formstring .= $func($tag, dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES), $admintype);
} else if ($tag->GetAtt('type') == 'img') {
$fieldname = $tag->GetName();
$labelname = $tag->GetAtt('itemname');
$fvalue = dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES);
$imgstrng = "<div class='form-group row'><label class='col-sm-2 col-form-label'>{$labelname}:</label><div class='col-sm-10'><input type='text' name='$fieldname' value='$fvalue' id='$fieldname' class='text' /> <input name='" . $fieldname . "_bt' class='inputbut' type='button' value='浏览...' onClick=\"SelectImage('addcontent.$fieldname','big')\" />\r\n</div></div>";
$formstring .= $imgstrng;
} else {
$formstring .= $func($tag, dede_htmlspecialchars($value[$tag->GetName()], ENT_QUOTES), $admintype);
//echo $formstring;
}
}
$formfields .= $formfields == '' ? $tag->GetName().','.$tag->GetAtt('type') : ';'.$tag->GetName().','.$tag->GetAtt('type');
$formfields .= $formfields == '' ? $tag->GetName() . ',' . $tag->GetAtt('type') : ';' . $tag->GetName() . ',' . $tag->GetAtt('type');
}
}
}
}
$formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"".$formfields."\" />\n";
$formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"".md5($formfields.$cfg_cookie_encode)."\" />";
$formstring .= "<input type=\"hidden\" name=\"dede_fields\" value=\"" . $formfields . "\" />\n";
$formstring .= "<input type=\"hidden\" name=\"dede_fieldshash\" value=\"" . md5($formfields . $cfg_cookie_encode) . "\" />";
return $formstring;
}//end func getForm
} //end func getForm
/**
* 获取字段列表
@@ -178,16 +170,14 @@ class membermodel
function getFieldList()
{
$dtp = new DedeTagParse();
$dtp->SetNameSpace("field","<",">");
$dtp->SetNameSpace("field", "<", ">");
$dtp->LoadSource($this->info);
$fields = array();
if(is_array($dtp->CTags))
{
foreach($dtp->CTags as $tagid=>$tag)
{
if (is_array($dtp->CTags)) {
foreach ($dtp->CTags as $tagid => $tag) {
$fields[$tag->GetName()] = array($tag->GetAtt('itemname'), $tag->GetAtt('type'));
}
}
return $fields;
}
}
}

+ 0
- 1
src/index.php View File

@@ -37,4 +37,3 @@ else
header('HTTP/1.1 301 Moved Permanently');
header('Location:index.html');
}
?>

+ 23
- 1
src/install/v57sp2_to_v58.txt View File

@@ -1,3 +1,25 @@
ALTER TABLE `#@__tagindex`
ADD COLUMN `uptime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `addtime`,
ADD COLUMN `mktime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `uptime`;
ADD COLUMN `mktime` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `uptime`;

ALTER TABLE `#@__feedback`
ADD COLUMN `fid` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `aid`;

ALTER TABLE `#@__feedback`
ADD COLUMN `replycount` INT(10) UNSIGNED NOT NULL DEFAULT '0' AFTER `dtime`;

INSERT INTO `#@__sysconfig` (`varname`, `info`, `groupid`, `type`, `value`) VALUES ( 'cfg_feedback_msglen', '评论内容字数限定', 5, 'number', '200');

CREATE TABLE `#@__feedback_goodbad` (
`fgid` INT(11) NOT NULL AUTO_INCREMENT,
`mid` INT(11) NOT NULL DEFAULT '0',
`fid` INT(11) NOT NULL DEFAULT '0',
`fgtype` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '0:good 1:bad',
PRIMARY KEY (`fgid`)
) TYPE=MyISAM;

CREATE TABLE `#@__search_limits` (
`ip` VARCHAR(200) NOT NULL,
`searchtime` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`ip`)
) TYPE=MyISAM;

Loading…
Cancel
Save