Skip to content

Commit

Permalink
SAE
Browse files Browse the repository at this point in the history
  • Loading branch information
TedaLIEz committed Feb 24, 2015
1 parent 5d949c1 commit 6435729
Show file tree
Hide file tree
Showing 9 changed files with 716 additions and 252 deletions.
389 changes: 155 additions & 234 deletions .idea/workspace.xml

Large diffs are not rendered by default.

96 changes: 96 additions & 0 deletions App/Admin/Controller/NewsController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function trash(){
$this->news=D('NewsRelation')->where(array('del'=>1))->order('time desc')->limit($Page->firstRow.','.$Page->listRows)->select();
// $this->news=D('NewsRelation')->getNews(1);
$this->page=$Page->show();
$this->count=$count;
$this->display('news_index');
}

Expand All @@ -158,6 +159,25 @@ public function delete(){
D('NewsRelation')->relation('attr')->where(array('id'=>$id))->delete();

$this->redirect('news_index');

//In Sae :
/*
* $src=explode(" ",substr($data,1));
$st=new \SaeStorage();
foreach($src as $v=>$k){
$filename=substr($k,strpos($k,"com")+3);
if($st->fileExists('upload',$filename)){
if($st->delete('upload',$filename)&&D('NewsRelation')->relation('attr')->where(array('id'=>$id))->delete()){
$this->redirect('news_index');
}else{
$this->error('删除失败');
}
}else{
$this->error('删除失败');
}
}*/
}

public function deleteAll(){
Expand All @@ -171,6 +191,31 @@ public function deleteAll(){
}
D('NewsRelation')->relation('attr')->where($del)->delete();
$this->redirect('news_index');

//In Sae:


/*$src=explode(" ",substr($data,1));
$st=new \SaeStorage();
foreach($src as $v=>$k){
$filename=substr($k,strpos($k,"com")+3);
if($st->fileExists('upload',$filename)){
if(D('NewsRelation')->relation('attr')->where($del)->delete()&&$st->delete('upload',$filename)){
$this->redirect('news_index');
}else{
break;
}
}else{
break;
}
}
$this->error('删除失败');
*
*/


}


Expand Down Expand Up @@ -220,4 +265,55 @@ public function clearCache(){

}

//@Override

//Change in Sae


/*public function clearCache(){
$st=new \SaeStorage();
$images=$st->getList('upload','news/image');
// $images=get_filetree("./Upload/news/image"); //图片文件遍历
$pics=M('news')->field('src')->select();
foreach($pics as $s=>$p){
foreach($p as $k=>$v){
$pic[]=explode(" ",substr($v,1));
}
}
foreach($pic as $s=>$p){
foreach($p as $k=>$v){
if($v!=''){
$res[]=substr($v,strpos($v,"com")+4);
}
}
}
$result=array_diff($images,$res);
if($result!=null){
foreach($result as $k=>$v){
if($st->fileExists('upload',$v)){
if($st->delete('upload',$v)){
$this->success('清除成功','news_index');
break;
}else{
break;
}
}else{
break;
}
}
$this->success('没有缓存','news_index');
}else{
$this->success('没有缓存','news_index');
}
}*/


}
32 changes: 25 additions & 7 deletions App/Admin/Controller/UploadController.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/

namespace Admin\Controller;


use Think\Upload;

class UploadController extends CommonController{
Expand All @@ -23,6 +21,10 @@ public function upload(){
$upload->exts=array('txt','doc','docx');
$upload->rootPath='./Upload/UploadsDoc/';
$upload->subName=$_SESSION['username'];
// For Sae Add:
// $upload->driverConfig=array();
// $upload->driver='Sae';

$path=$upload->rootPath.$upload->subName.'/';
if(!file_exists($path)){
mkdir($path);
Expand All @@ -32,7 +34,8 @@ public function upload(){
$this->error($upload->getError());
}else{
foreach($info as $v){
$data[]=array('filename'=>$path.$v['savename'],
$data[]=array('filename'=>$path.$v['savename'], //$path.$v['savename'] to $v['url'] in Sae
//add 'url'=>$v['url'] in Sae
'remark'=>$v['name'],
'user'=>$_SESSION['username'],
'time'=>time());
Expand All @@ -54,12 +57,27 @@ public function doc_list(){

//删除上传附件
public function remove(){


$id=I('id',0,'intval');
$doc=M('doc')->where(array('id'=>$id))->select();
$doc=M('doc')->where(array('id'=>$id))->find();
// dump($doc);die;
foreach($doc as $v){
$filename=$v['filename'];
}
$filename=$doc['filename']; //$doc['filename'] to substr($doc['filename'],9) in Sae

/*
Function remove in Sae
$st=new \SaeStorage();
if($st->fileExists('upload',$filename)){
if($st->delete('upload',$filename)&&M('doc')->delete($id)){
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}else{
$this->error('删除失败');
}*/


// die;
if(M('doc')->delete($id)&&unlink($filename)){
$this->success('删除成功');
Expand Down
4 changes: 2 additions & 2 deletions App/Common/Common/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ function downloadFileById($id=0){
return false;
}else{
$Doc=M('doc');
$filename=$Doc->where(array('id'=>$id))->getField('filename');
$filename=$Doc->where(array('id'=>$id))->getField('filename'); //getField('filename') to getField('url') in Sae
$showname=$Doc->where(array('id'=>$id))->getField('remark');
if(file_exists($filename)){
if(file_exists($filename)){ //file_exists不生效 in Sae
$length = filesize($filename);
header('Content-Description: File Transfer');
header('Content-Type: application/msword');
Expand Down
2 changes: 1 addition & 1 deletion App/Common/Conf/config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
return array(
'DEFAULT_MODULE'=>'Admin',

'URL_MODEL' =>2,
'DB_TYPE' => 'mysql', // 数据库类型
'DB_HOST' => 'localhost', // 服务器地址
'DB_NAME' => 'aunet', // 数据库名
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#AUNET
#基于ThinkPHP框架的社团网快速开发
#完成SAE平台移植

##社团网后台管理系统入口http://serverName/AUNET/

Expand All @@ -14,12 +15,19 @@

##html及css文件放在对应入口路径/View下 例:/App/Home/View/(参照Admin/View中结构)

##aunet.sql 本地mysql文件
##app_authinkphp.sql SAE平台mysql文件

##已完成:
###1.权限管理(包括用户管理)
###2.新闻动态全部功能
###3.资料管理全部功能
###4.社团地带---活动预告全部功能
###5.伪静态

##待完成:
###1.FAQ管理
###2.其他部分的文字录入



2 changes: 1 addition & 1 deletion ThinkPHP/Library/Org/Util/Ueditor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Ueditor{

private $st;

private $rootpath = "./Upload/";
private $rootpath = "./Upload/"; //SAE Change into Upload

public function __construct($uid = ''){
// uid 为空则导入当前会话uid
Expand Down
Loading

0 comments on commit 6435729

Please sign in to comment.