Beispiel #1
0
function cacheclear($handle=false)
{
	if(true === $handle) {
		static $sCacheIoHandler = null;
		if(is_null($sCacheIoHandler)) {
			include_once(LIB_PATH . 'io.han.php');
			$sCacheIoHandler = new IoHandler();
		}
		return @$sCacheIoHandler->ClearDir(CACHE_PATH);
	}
	return true;
}
Beispiel #2
0
	function clearAll()
	{
		$this->CheckAdminPrivs('cache');
		include(LIB_PATH.'io.han.php');
		$IO=new IoHandler();
		@$IO->ClearDir(CACHE_PATH);
		@$IO->ClearDir(ROOT_PATH . '/uc_client/data/cache/');
		
		$this->DatabaseHandler->Query("DELETE FROM ".TABLE_PREFIX.'system_failedlogins', 'UNBUFFERED');
		
		$this->Messager("缓存已清空",null);
	}
Beispiel #3
0
function ajherrorlog($type='',$log='',$halt=1) {
	$logfile = ROOT_PATH . 'errorlog/'.$type . '-' . date('Y-m').'.php';
	if (!is_file($logfile)) {
		$log ="<? exit; ?>\r\n" . $log;
	}
	$log = "[".my_date_format(time(),"Y-m-d H:i:s")."]" . $log . "\r\n";

	global $IoHandler;
	if(is_null($IoHandler)) {
		$load = new Load();
		$load->lib('io');
		$IoHandler = new IoHandler();
		$log = " \r\n ------------------------------------------------------ \r\n " . $log;
	}
	if (!is_dir(dirname($logfile))) {
		$IoHandler->MakeDir(dirname($logfile));
	}

	$IoHandler->WriteFile($logfile,$log,'a');

	if($halt) {
		exit();
	}
}
Beispiel #4
0
 function DeleteImage($imageId = '', $type = '', $imageUrl = '', $interal = false)
 {
     $this->GotoLogin();
     //$buildingId=$this->Post['buildingId']?$this->Post['buildingId']:$this->Get['buildingId'];
     if ($imageId == '') {
         $imageId = $this->Post['imageid'] ? $this->Post['imageid'] : $this->Get['imageid'];
     }
     if ($imageUrl == '') {
         $imageUrl = $this->Post['imageurl'] ? $this->Post['imageurl'] : $this->Get['imageurl'];
     }
     if ($type == '') {
         $type = $this->Post['type'] ? $this->Post['type'] : $this->Get['type'];
     }
     $IoHandler = new IoHandler();
     if ($imageUrl == "") {
         echo "没有找到可删除的图片";
         exit;
     }
     $urls = Getimageurls($imageUrl);
     if (is_array($urls) && count($urls) > 0) {
         foreach ($urls as $u) {
             $ret = $IoHandler->DeleteFile($u);
         }
     }
     if (!$interal) {
         echo "done";
     } else {
         return;
     }
 }
Beispiel #5
0
	function Disallow()
	{
		$this->CheckAdminPrivs('robot');
		$name = trim($this->Get['name']);
		$disallow = 'disallow1' == $this->Code ? 1 : 0;

		$sql = "update `".TABLE_PREFIX."system_robot` set `disallow`='{$disallow}' where `name`='{$name}'";
		$this->DatabaseHandler->Query($sql);

		$sql = "select `name`,`disallow` from `".TABLE_PREFIX."system_robot` where `disallow`=1";
		$query = $this->DatabaseHandler->Query($sql);
		$robot_config = ConfigHandler::get('robot');
		$robot_config['list'] = array();
		while ($row = $query->GetRow())
		{
			$robot_config['list'][$row['name']]['disallow'] = $row['disallow'];
		}
		$configHandler = new ConfigHandler();
		$configHandler->set('robot',$robot_config);


		$disallow_string = "User-agent: {$name}
Disallow: /

";

		$load = new Load();
		$load->lib('io');
		$IoHandler = new IoHandler();
		$robots_path = ROOT_PATH . 'robots.txt';

		$robots_string_new = $robots_string = $IoHandler->ReadFile($robots_path);
		$disallow_string_strpos = strpos($robots_string,$disallow_string);
		if ($disallow && false===$disallow_string_strpos) {
			$robots_string_new = $disallow_string . $robots_string_new;
		} elseif (!$disallow && false!==$disallow_string_strpos) {
			$robots_string_new = str_replace($disallow_string,"",$robots_string_new);
		}

		if ($robots_string_new!=$robots_string) {
			$return = $IoHandler->WriteFile($robots_path,$robots_string_new);

			if (!$return) {
				$this->Messager("写入 <b>{$robots_path}</b> 文件失败,请检查是否有可读写的权限",null);
			}
		}

		$this->Messager("修改成功");
	}
Beispiel #6
0
	function ImageThumbRebuild()
	{
				$load = new Load();
		$load->lib('io');
		$o_dirs = IoHandler::ReadDir(IMAGE_PATH.'product/');
		$dirs = array();
		foreach ($o_dirs as $i => $dir)
		{
			if (preg_match('/product\/\d{4}-\d{2}-\d{2}/', $dir))
			{
				$dirs[] = $dir;
			}
		}
		$thumbwidth = $this->Config['thumbwidth'];
		$thumbheight = $this->Config['thumbheight'];
				$op = $_GET['op'];
		if ($op == 'run')
		{
			$od = $_GET['od'];
			$dir = $dirs[$od];
			$files = IoHandler::ReadDir($dir);
			foreach ($files as $i => $src_file)
			{
				$dst_file = str_replace('/product/', '/product/s-', $src_file);
				resize_image($src_file, $dst_file, $thumbwidth, $thumbheight);
			}
			echo '更新了目录[ '.$dir.' ],有[ <b>'.count($files).'</b> ]张缩略图被生成!';
			return;
		}
		$cronLength = count($dirs);
		include(handler('template')->file('@admin/tttuangou_imagethumb_rebuild'));
	}
Beispiel #7
0
 function initPath($path)
 {
     $ret = $path;
     $path = substr($path, -1) == '/' ? $path : dirname($path);
     if (!is_dir($path)) {
         IoHandler::MakeDir($path);
     }
     return $ret;
 }
Beispiel #8
0
function upload_image($image_path = '',$filed='face',$small_width=80,$small_height=80)
{
	if($image_path == '') {
		$image_path = IMAGE_PATH.'/'.$filed.'/';
	}
	$date=date("Y-m-d");
	if(empty($_FILES) or empty($filed))	{
		return array('error'=>__('上传图片出错!请检查您的服务器环境!'));
	}
	if ($_FILES[$filed]['name']=='') {
		return array('error'=>__('您没有选择需要上传的图片!'));
	}
	$default_type=array('jpg','pic','png','jpeg','bmp','gif');	$imgary=explode('.',$_FILES[$filed]['name']);
	if(!in_array(strtolower($imgary[count($imgary)-1]),$default_type)){
		return array('error'=>'不支持的图片格式 ['.$imgary[count($imgary)-1].'] !');
	}

	require_once LIB_PATH . 'upload.han.php';
	$upload_handler = new UploadHandler($_FILES, $image_path, $filed , true);

	if(is_dir($image_path.$date)==false or is_dir($image_path.SMALL_PIC_PREFIX.$date)==false)
	{
		require_once LIB_PATH. 'io.han.php';
		IoHandler::MakeDir($image_path.$date);
		IoHandler::MakeDir($image_path.SMALL_PIC_PREFIX.$date);
	}

	$upload_handler->setMaxSize(1024);	$name = $date.'/'.substr(md5(microtime()).'.'.strtolower(end(explode('.', $_FILES[$filed]['name']))),-15);

	$size = $_FILES[$field]['size'];

	$photo['name']=$name;
	$photo['size']=$size;

	$upload_handler->setNewName($name);

	$result = $upload_handler->doUpload();

		if (false == $result)
	{
		return array('error'=>$upload_handler->getError());
	}

	$result = resize_image($image_path.$name,
	$image_path.SMALL_PIC_PREFIX.$name,
	$small_width,
	$small_height,
	false);
	return $name;
}
Beispiel #9
0
	function DoExport()
	{
		$this->CheckAdminPrivs('dbexport');
		global $sizelimit, $startrow, $extendins, $sqlcompat, $sqlcharset, $dumpcharset, $usehex, $complete, $excepttables;
		extract($this->Post);extract($this->Get);

		$excepttables=array(TABLE_PREFIX."sessions",);

		$time=$timestamp=time();
		$tablepre=TABLE_PREFIX;

		$this->DatabaseHandler->Query('SET SQL_QUOTE_SHOW_CREATE=1', 'SKIP_ERROR');
		if(!$filename || preg_match("/(\.)(exe|jsp|asp|aspx|cgi|fcgi|pl)(\.|$)/i", $filename))
		{
			$this->Messager("备份文件名无效");
		}

				if($type == 'all_tables') {
			$tables = $this->_array_keys2($this->_fetch_table_list($tablepre), 'Name');
		}
		elseif($type == 'custom')
		{
			$tables = array();
			if(empty($setup))
			{
				$tables=cache("tables",-1,true);
			}
			else
			{
				cache('tables',-1);
				cache($customtables);
				$tables = & $customtables;
			}
			if( !is_array($tables) || empty($tables))
			{
				$this->Messager("没有要导出的数据表");
			}
		}


		$volume = intval($volume) + 1;
		$idstring = '# Identify: '.base64_encode("$timestamp,".SYS_VERSION.",$type,$method,$volume")."\n";


		$dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $this->Config['charset']);
		$setnames = ($sqlcharset && $this->DatabaseHandler->GetVersion() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41')) ? "SET NAMES '$dumpcharset';\n\n" : '';
		if($this->DatabaseHandler->GetVersion() > '4.1') {
			if($sqlcharset) {
				$this->DatabaseHandler->Query("SET NAMES '".$sqlcharset."';\n\n");
			}
			if($sqlcompat == 'MYSQL40') {
				$this->DatabaseHandler->Query("SET SQL_MODE='MYSQL40'");
			} elseif($sqlcompat == 'MYSQL41') {
				$this->DatabaseHandler->Query("SET SQL_MODE=''");
			}
		}

		
		$backupdir = 'db/' . ($f = str_replace(array('/', '\\', '.'), '', $filename));
		$backupfilename = './backup/'.$backupdir.'/'.$f;
		if (!is_dir(($d = dirname($backupfilename)))) {
			$load = new Load();
			$load->lib('io');
			$IoHandler = new IoHandler();
			$IoHandler->MakeDir($d);
		}
		

		if($usezip) {
			require_once FUNCTION_PATH.'zip.func.php';
		}

		if($method == 'multivol') {
			$sqldump = '';
			$tableid = intval($tableid);
			$startfrom = intval($startfrom);
			
			$complete = TRUE;

			for(; $complete && $tableid < count($tables) && strlen($sqldump) + 500 < $sizelimit * 1000; $tableid++) {
				$sqldump .= $this->_sql_dump_table($tables[$tableid], $startfrom, strlen($sqldump));
				if($complete) {
					$startfrom = 0;
				}
			}
			
			$dumpfile = $backupfilename."-%s".'.sql';
			!$complete && $tableid--;
			if(trim($sqldump)) {
				$sqldump = "$idstring".
				"# <?exit();?>\n".
				"# TTTuangou Multi-Volume Data Dump Vol.$volume\n".
				"# Version: TTTuangou ".SYS_VERSION."\n".
				"# Time: $time\n".
				"# Type: $type\n".
				"# Table Prefix: $tablepre\n".
				"#\n".
				"# TTTuangou Home: http:\/\/www.tttuangou.net\n".
				"# Please visit our website for newest infomation about TTTuangou\n".
				"# --------------------------------------------------------\n\n\n".
				"$setnames".
				$sqldump;
				$dumpfilename = sprintf($dumpfile, $volume);
				@$fp = fopen($dumpfilename, 'wb');
				@flock($fp, 2);
				if(@!fwrite($fp, $sqldump)) {
					@fclose($fp);
					$this->Messager("备份文件名有问题");
				} else {
					fclose($fp);
					if($usezip == 2) {
						$fp = fopen($dumpfilename, "r");
						$content = @fread($fp, filesize($dumpfilename));
						fclose($fp);
						$zip = new zipfile();
						$zip->addFile($content, basename($dumpfilename));
						$fp = fopen(sprintf($backupfilename."-%s".'.zip', $volume), 'w');
						if(@fwrite($fp, $zip->file()) !== FALSE) {
							@unlink($dumpfilename);
						}
						fclose($fp);
					}
					unset($sqldump, $zip, $content);
					$this->Messager("分卷备份: 数据文件 #{$volume} 成功创建,程序将自动继续。
", "admin.php?mod=db&code=doexport&type=".rawurlencode($type)."&saveto=server&filename=".rawurlencode($filename)."&method=multivol&sizelimit=".rawurlencode($sizelimit)."&volume=".rawurlencode($volume)."&tableid=".rawurlencode($tableid)."&startfrom=".rawurlencode($startrow)."&extendins=".rawurlencode($extendins)."&sqlcharset=".rawurlencode($sqlcharset)."&sqlcompat=".rawurlencode($sqlcompat)."&exportsubmit=yes&usehex=$usehex&usezip=$usezip");

				}
			} else {
				$volume--;
				$filelist = '<ul>';

				if($usezip == 1) {
					$zip = new zipfile();
					$zipfilename = $backupfilename.'.zip';
					$unlinks = '';
					for($i = 1; $i <= $volume; $i++) {
						$filename = sprintf($dumpfile, $i);
						$fp = fopen($filename, "r");
						$content = @fread($fp, filesize($filename));
						fclose($fp);
						$zip->addFile($content, basename($filename));
						$unlinks .= "@unlink('$filename');";
						$filelist .= "<li><a href=\"$filename\">$filename\n";
					}
					$fp = fopen($zipfilename, 'w');
					if(@fwrite($fp, $zip->file()) !== FALSE) {
						eval($unlinks);
					} else {
						$this->Messager('database_export_multivol_succeed');
					}
					unset($sqldump, $zip, $content);
					fclose($fp);
					@touch('./backup/'.$backupdir.'/index.htm');
					$filename = $zipfilename;
					$this->Messager("数据成功备份并压缩至服务器 <a href=\"$filename\">$filename</a> 中。",null);
				} else {
					@touch('./backup/'.$backupdir.'/index.htm');
					for($i = 1; $i <= $volume; $i++) {
						$filename = sprintf($usezip == 2 ? $backupfilename."-%s".'.zip' : $dumpfile, $i);
						$filelist .= "<li><a href=\"$filename\">$filename\n";
					}
					$this->Messager("恭喜您,全部 $volume 个备份文件成功创建,备份完成。
".$filelist ,null);
				}
			}

		} else {

			$tablesstr = '';
			foreach($tables as $table) {
				$tablesstr .= '"'.$table.'" ';
			}

			require './config.inc.php';
			list($dbhost, $dbport) = explode(':', $dbhost);

			$query = $this->DatabaseHandler->Query("SHOW VARIABLES LIKE 'basedir'");
			list(, $mysql_base) = $db->fetch_array($query, MYSQL_NUM);

			$dumpfile = addslashes(dirname(dirname(__FILE__))).'/'.$backupfilename.'.sql';
			@unlink($dumpfile);

			$mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base).'bin/';
			@shell_exec($mysqlbin.'mysqldump --force --quick '.($this->DatabaseHandler->GetVersion() > '4.1' ? '--skip-opt --create-options' : '-all').' --add-drop-table'.($extendins == 1 ? ' --extended-insert' : '').''.($this->DatabaseHandler->GetVersion() > '4.1' && $sqlcompat == 'MYSQL40' ? ' --compatible=mysql40' : '').' --host="'.$dbhost.($dbport ? (is_numeric($dbport) ? ' --port='.$dbport : ' --socket="'.$dbport.'"') : '').'" --user="******" --password="******" "'.$dbname.'" '.$tablesstr.' > '.$dumpfile);

			if(@is_file($dumpfile)) {

				if($usezip) {
					require_once FUNCTION_PATH.'zip.func.php';
					$zip = new zipfile();
					$zipfilename = $backupfilename.'.zip';
					$fp = fopen($dumpfile, "r");
					$content = @fread($fp, filesize($dumpfile));
					fclose($fp);
					$zip->addFile($idstring."# <?exit();?>\n ".$setnames."\n #".$content, basename($dumpfile));
					$fp = fopen($zipfilename, 'w');
					@fwrite($fp, $zip->file());
					fclose($fp);
					@unlink($dumpfile);
					@touch('./backup/'.$backupdir.'/index.htm');
					$filename = $backupfilename.'.zip';
					unset($sqldump, $zip, $content);
					$this->Messager('database_export_zip_succeed');
				} else {
					if(@is_writeable($dumpfile)) {
						$fp = fopen($dumpfile, 'rb+');
						@fwrite($fp, $idstring."# <?exit();?>\n ".$setnames."\n #");
						fclose($fp);
					}
					@touch('./backup/'.$backupdir.'/index.htm');
					$filename = $backupfilename.'.sql';
					$this->Messager('database_export_succeed');
				}

			} else {

				$this->Messager('database_shell_fail');

			}

		}
	}
Beispiel #10
0
	function home()
	{
		$program_name = "天天团购";

		$item_list = array(
			'system_members' => array(
				'name' => '用户数',
				'url' => 'admin.php?mod=member&code=dosearch',
			),
			'tttuangou_city' => array(
				'name' => '城市数',
				'url' => 'admin.php?mod=tttuangou&code=city',
			),
			'tttuangou_seller' => array(
				'name' => '商家数',
				'url' => 'admin.php?mod=tttuangou&code=mainseller',
			),
			'tttuangou_product' => array(
				'name' => '产品数',
				'url' => 'admin.php?mod=product',
			),
			'tttuangou_order' => array(
				'name' => '订单数',
				'url' => 'admin.php?mod=order',
			),
			'tttuangou_ticket' => array(
				'name' => TUANGOU_STR . '券数',
				'url' => 'admin.php?mod=coupon',
			),
			'tttuangou_subscribe' => array(
				'name' => '订阅数',
				'url' => 'admin.php?mod=subscribe',
			),
			'tttuangou_question' => array(
				'name' => '问答数',
				'url' => 'admin.php?mod=tttuangou&code=mainquestion',
			),
			'tttuangou_usermsg' => array(
				'name' => '反馈信息数',
				'url' => 'admin.php?mod=tttuangou&code=usermsg',
			),
		);

				$sys_env = array();
		if(false === ($statistic = cache("misc/admin_statistic", 60)))
		{
			$statistic=array();
			foreach ($item_list as $item=>$items) {
				$table = TABLE_PREFIX . $item;
				$sql = " select count(*) as `total` from {$table} ";
				if ($item == 'tttuangou_subscribe')
				{
				    $sql .= "where validated='true'";
				}
                elseif ($item == 'tttuangou_product')
                {
                    $sql .= "where saveHandler = 'normal'";
                }
				$query = $this->DatabaseHandler->Query($sql);
				$row = $query->GetRow();
				$items['total'] = $row['total'];
				$sys_env[("sys_" . ("s"==substr(($_tmp = str_replace(array('tttuangou_','system_'),'',$item)),-1) ? $_tmp : $_tmp . "s"))] = $items['total'];

				$statistic[$item] = $items;
			}
			cache($statistic);
		} elseif (isset($statistic['sessions'])) {
			$sql="SELECT count(1) total FROM `" . TABLE_PREFIX . "system_sessions`";
			$query = $this->DatabaseHandler->Query($sql);
			$row=$query->GetRow();

			$statistic['sessions'] = $row['total'];
		}

				if (false === ($data_length = cache("misc/data_length", 3600)))
		{
			$sql="show table status from `{$this->Config['db_name']}` like '".TABLE_PREFIX."%'";
			$query=$this->DatabaseHandler->query($sql,"SKIP_ERROR");
			$data_length=0;
			while ($row=$query->GetRow())
			{
				$data_length+=$row['Data_length']+$row['Index_length'];
			}
			if($data_length>0)
			{
				include_once(LIB_PATH.'io.han.php');
				$data_length=IoHandler::SizeConvert($data_length);
			}
			$sys_env['sys_data_length'] = $data_length;

			cache($data_length);
		}
					$sql = " select count(*) as `total` from ".TABLE_PREFIX."tttuangou_push_queue WHERE rund='false'";
			$query = $this->DatabaseHandler->Query($sql);
			$row = $query->GetRow();
		$statistic['cron_length'] = array('name'=>'邮件队列长度','url'=>'admin.php?mod=push&code=queue','total'=>$row['total']);
				$statistic['data_length'] = array('name'=>'数据库尺寸','url'=>'admin.php?mod=db&code=optimize','total'=>$data_length);
				$statistic['express_wait_count'] = array('name'=>'等待发货',
			'url'=>'admin.php?mod=delivery&code=vlist&alsend=no','total'=>logic('order')->Count('status='.ORD_STA_Normal.' AND process="WAIT_SELLER_SEND_GOODS"'));

		$dateYmd = date('Y-m-d',time());
		$today_start = strtotime($dateYmd.' 00:00:00');
		$today_end   = strtotime($dateYmd.'23:59:59');
		$addwhere = '';
		if(MEMBER_ROLE_TYPE == 'seller'){
			$pids = logic('product')->GetUserSellerProduct(MEMBER_ID);
			$asql = 0;
			if($pids){
				$asql = implode(',',$pids);
			}
			$addwhere =  ' AND productid IN('.$asql.')';
		}
		$order_nums  = dbc(DBCMax)->select('order')->
			in('count(*) as NUM')->where("buytime between {$today_start} and {$today_end}".$addwhere)->limit(1)->done();
		$pay_ordes   = dbc(DBCMax)->select('order')->
			in('count(*) as NUM,sum(paymoney) as money')->where("paytime between {$today_start} and {$today_end} and paytime > 0 and pay > 0".$addwhere)->limit(1)->done();
		$notpay_ordes   = dbc(DBCMax)->select('order')->
			in('count(*) as NUM')->where("buytime between {$today_start} and {$today_end} and paytime = 0 and pay = 0".$addwhere)->limit(1)->done();
		$statistic['today_orders'] = $order_nums['NUM'];
		$statistic['today_pay_orders'] = $pay_ordes['NUM'];
		$statistic['today_unpay_orders'] = $notpay_ordes['NUM'];
		$statistic['today_income_orders'] = (float)$pay_ordes['money'];
		include(handler('template')->file('@admin/home'));
		exit;
	}
Beispiel #11
0
	function OpenTable() {
		$this->unicode_table = array();
		if($this->config['SourceLang'] == 'GBK' || $this->config['TargetLang'] == 'GBK') {
			$this->table = CODETABLE_DIR.$this->config['GBtoUnicode_table'];
		} elseif($this->config['SourceLang'] == 'BIG5' || $this->config['TargetLang'] == 'BIG5') {
			$this->table = CODETABLE_DIR.$this->config['BIG5toUnicode_table'];
		}
		$table_cache_file=CACHE_PATH.$this->config['SourceLang'].'-'.$this->config['TargetLang'].".cache.php";
		if(@include($table_cache_file))
		{
			$this->unicode_table=$unicode_table;
			unset($unicode_table);
			return null;
		}
		@$fp = fopen($this->table, 'rb');
		$tabletmp = fread($fp, filesize($this->table));
		for($i = 0; $i < strlen($tabletmp); $i += 4) {
			$tmp = unpack('nkey/nvalue', substr($tabletmp, $i, 4));
			if($this->config['TargetLang'] == 'UTF-8') {
				$this->unicode_table[$tmp['key']] = '0x'.dechex($tmp['value']);
			} elseif($this->config['SourceLang'] == 'UTF-8') {
				$this->unicode_table[$tmp['value']] = '0x'.dechex($tmp['key']);
			} elseif($this->config['TargetLang'] == 'UNICODE') {
				$this->unicode_table[$tmp['key']] = dechex($tmp['value']);
			}
		}
		if(!is_dir(CODETABLE_DIR)) {
			$load = new Load();
			$load->lib('io');
			$IoHandler = new IoHandler();
			$IoHandler->MakeDir(CODETABLE_DIR);
		}
		is_writeable(CODETABLE_DIR) || die("编码缓存目录不可写。请检查:".CODETABLE_DIR);
		if(!is_dir(dirname($table_cache_file))) {
			$load = new Load();
			$load->lib('io');
			$IoHandler = new IoHandler();
			$IoHandler->MakeDir(dirname($table_cache_file));
		}
		@$fp=fopen($table_cache_file,'wb');
		@fwrite($fp,"<?php\r\n\$unicode_table=".var_export($this->unicode_table,true).";?>");
		@fclose($fp);
	}
Beispiel #12
0
	function install()
	{
		$this->CheckAdminPrivs('upgrade');
		@set_time_limit(120);
		$version=$this->Post['version']?$this->Post['version']:$this->Get['version'];
		$step=$this->Get['step'];
		$status=(int)$this->Get['status'];		if(empty($version))$this->Messager("参数错误");
		$odver = get('odver') ? get('odver') : SYS_VERSION;
		$url="admin.php?mod=upgrade&code=install&version=$version&odver=$odver";
				$upgrade_data_dir = DATA_PATH.'upgrade/';
		$upcName = $odver.'~'.$version;
		$upgrade_file = $upgrade_data_dir.$upcName.".zip";
		if (is_file($upgrade_file)==false)
		{
			$this->Messager("升级包已经不存在,请重新下载", null);
		}
		$upgrade_tmp_dir = $upgrade_data_dir.$odver.'~'.$version.'/';
		is_dir($upgrade_tmp_dir) || @tmkdir($upgrade_tmp_dir);

		include_once(LIB_PATH.'io.han.php');

				if($step=='check')
		{
			$quick = $this->Get['quick'];
			$check_url=$url."&step=check&quick={$quick}";
			if($status===0) $this->Messager("正在释放临时文件...",$check_url.'&status=1',0);
			$files = logic('upgrade')->zip2web($upgrade_file, $upgrade_tmp_dir);
			isset($files['__extract_error__']) && $this->Messager($files['__error_string__'], null);
			$backup_url=$url."&step=backup";
			if ($quick == 'yes')
			{
				$this->Messager('正在开始升级...', $backup_url, 0);
			}
			include handler('template')->file('@admin/upgrade_change_list');
			exit;
		}

				if ($step=='backup')
		{
			logic('upgrade')->upgrade2start();

			$original_path=ROOT_PATH;			$backup_path=ROOT_PATH.'backup/'.SYS_VERSION.'-'.SYS_BUILD.'/';			if(!is_dir($backup_path)) {
				IoHandler::MakeDir($backup_path,0777);
			}
			clearstatcache();

			$error_found = logic('upgrade')->web2backup($upgrade_tmp_dir, $backup_path);
			if ($error_found == 'ok')
			{
				$error_found = logic('upgrade')->web2upgrade($upgrade_tmp_dir, $original_path);
			}
			if ($error_found != 'ok')
			{
				$msg = '<div style="width:700px;text-align:left;">备份或者升级网站文件时出错,程序无法继续执行!<hr/>';
				$msg .= $error_found;
				$msg .= '<hr/>请您检查相应文件权限后,<a href="'.$url.'&step=backup">点击此处</a> 重新升级';
				$msg .= '</div>';
				$this->Messager($msg, null);
			}
			$this->Messager("正在升级中,请勿关闭窗口...", $url, 0);
		}
				logic('upgrade')->upgrade2data($upgrade_tmp_dir);
				logic('upgrade')->upgrade2update($upgrade_tmp_dir, $original_path);
				logic('upgrade')->upgrade2clear($upcName);
				logic('upgrade')->upgrade2finish();
				$msg="升级已经完成! <br/><br/><a href='admin.php?mod=index&code=home'>返回后台首页</a>";
		$this->Messager($msg, null);
	}
Beispiel #13
0
 function DoEventSave($event)
 {
     $title = $this->QueryString('event_title');
     $type = $this->QueryString('event_class');
     $start = $this->QueryString('event_start');
     $start_hour = $this->QueryString('event_start_hour');
     $start_minute = $this->QueryString('event_start_minute');
     if (!$start_minute || $start_minute == '') {
         $start_minute = 0;
     }
     $end = $this->QueryString('event_end');
     $end_hour = $this->QueryString('event_end_hour');
     $end_minute = $this->QueryString('event_end_minute');
     if (!$end_minute || $end_minute == '') {
         $end_minute = 0;
     }
     $province = $this->QueryString('user_province');
     $city = $this->QueryString('user_city');
     $district = $this->QueryString('user_district');
     $street = $this->QueryString('user_street');
     $address = $this->QueryString('event_address');
     $note = $this->QueryString('event_note_h');
     $fee = $this->QueryString('event_fee');
     if (!$fee || $fee == '') {
         $fee = 0;
     }
     $need_info = $this->QueryString('event_needinfo_h');
     $event_img_id = $this->QueryString('event_img_id');
     $event_img_url = $this->QueryString('event_img_url');
     $eventEntity = new EventEntity();
     $eventEntity->title = $title;
     $eventEntity->type_id = $type;
     $eventEntity->content = safe_str($note);
     $eventEntity->province_id = $province;
     if ($city != '') {
         $eventEntity->city_id = $city;
     } else {
         $eventEntity->city_id = $province;
     }
     $eventEntity->image = $event_img_url;
     $fdate = explode('-', $start);
     $edate = explode('-', $end);
     $eventEntity->type_id = $type;
     $eventEntity->from_time = mktime($start_hour, $start_minute, 0, $fdate[1], $fdate[2], $fdate[0]);
     $eventEntity->end_time = mktime($end_hour, $end_minute, 0, $edate[1], $edate[2], $edate[0]);
     $eventEntity->area_id = $district;
     $eventEntity->money = $fee;
     if ($event && $event['id'] && $event['id'] != '' && $event['id'] > 0) {
         $eventEntity->id = $event['id'];
         $eventEntity->post_time = $event['post_time'];
         $eventEntity->postip = $event['postip'];
     } else {
         $eventEntity->id = 0;
         $eventEntity->post_time = time();
         $eventEntity->postip = getIP();
     }
     $eventEntity->post_uid = $this->User['uid'];
     $eventEntity->item = '';
     $eventEntity->item_id = 0;
     $eventEntity->last_time = time();
     $eventEntity->address = $address;
     $eventEntity->need_app_info = $need_info;
     if ($event && $event['id'] && $event['id'] != '' && $event['id'] > 0) {
         $redirectUrl = "index.php?mod=event&action=profile&id=" . $event['id'];
         $ret = $this->EventLogic->Update($eventEntity, $event['type_id']);
         if ($event_img_url != '' && $event['image'] != '' && $event['image'] != $event_img_url) {
             $IoHandler = new IoHandler();
             $urls = Getimageurls($event['image']);
             if (is_array($urls) && count($urls) > 0) {
                 foreach ($urls as $u) {
                     $d = $IoHandler->DeleteFile($u);
                 }
             }
             $this->ImageLogic->DeleteImage('', $event['image']);
             $this->ImageLogic->SetImgToItem('event', $event['id'], $event_img_id);
         }
     } else {
         $ret = $this->EventLogic->AddNewEvent($eventEntity);
         $redirectUrl = "index.php?mod=event&action=profile&id={$ret}";
         $this->ImageLogic->SetImgToItem('event', $ret, $event_img_id);
     }
     header("Location:{$redirectUrl}");
 }
Beispiel #14
0
 function DeleteImage($imgId = 0, $imageUrl = '')
 {
     $this->GotoLogin();
     $imgId = $this->Post['imgId'] ? $this->Post['imgId'] : $this->Get['imgId'];
     $imageUrl = $this->Post['imgUrl'] ? $this->Post['imgUrl'] : $this->Get['imgUrl'];
     $item = $this->Post['item'] ? $this->Post['item'] : $this->Get['item'];
     $imgtype = $this->Post['imgtype'] ? $this->Post['imgtype'] : $this->Get['imgtype'];
     $IoHandler = new IoHandler();
     if ($imageUrl == "") {
         echo "没有找到可删除的图片";
         return;
     }
     $urls = Getimageurls($imageUrl);
     if (is_array($urls) && count($urls) > 0) {
         foreach ($urls as $u) {
             $ret = $IoHandler->DeleteFile($u);
         }
     }
     $row = $this->ImgLogic->DeleteImage($imgId);
     if ($row && $row == 1) {
         $result = array();
         $result['status'] = "succeed";
     }
     echo json_encode($result);
     return;
 }
Beispiel #15
0
	function ReadDiskSpace($drive)
	{
		$disk_space['size']['total'] = disk_total_space($drive);
		$disk_space['size']['free'] = disk_free_space($drive);
		$disk_space['size']['used'] = $disk_space['size']['total'] - $disk_space['size']['free'];
		$disk_space['size_converted']['used'] = IoHandler::SizeConvert($disk_space['size']['total'] - $disk_space['size']['free']);
		$disk_space['size_converted']['total'] = IoHandler::SizeConvert($disk_space['size']['total']);
		$disk_space['size_converted']['free'] = IoHandler::SizeConvert($disk_space['size']['free']);
		Return $disk_space;
	}
Beispiel #16
0
 function UploadAvatorFromApp()
 {
     $this->NoLoginAjaxReturn();
     $rpath = './images/temp';
     $IoHandler = new IoHandler();
     $Images = new ImagesHandler('Filedata');
     $Images->saveDir = $rpath;
     $path = $Images->move_uploaded();
     if (!file_exists($path)) {
         $result['status'] = "failed";
         $result['message'] = urlencode('头像裁剪失败,图片传输过程中丢失');
         echo urldecode(json_encode($result));
         exit;
     }
     $userInfo = $this->UserLogic->GetUser($this->User['uid']);
     $old_facePath = $userInfo["face_url"];
     $imgId = $this->ImgLogic->AddNewImage();
     $path1 = 'images/user/' . face_path($imgId);
     if (!file_exists($path1)) {
         $IoHandler->MakeDir($path1);
     }
     $prefix = $path1 . $imgId;
     resizeimage($path, $prefix . '_p.jpg', 180, 180, true);
     resizeimage($path, $prefix . '_s.jpg', 50, 50, true);
     //$IoHandler->CopyFile($path, $prefix.'_t.jpg');
     if (file_exists($prefix . '_s.jpg')) {
         $userdata = array();
         $userdata['face_url'] = $prefix . '_s.jpg';
         $ret = $this->UserLogic->UpdateUser2($userdata, $this->User['uid']);
         if ($old_facePath && $old_facePath != "" && file_exists($old_facePath)) {
             $IoHandler->DeleteFile($old_facePath);
             $ps = explode("_", $old_facePath);
             $old2 = $ps[0] . "_p.jpg";
             if (file_exists($old2)) {
                 $IoHandler->DeleteFile($old2);
             }
         }
     } else {
         $result['status'] = "failed";
         $result['message'] = urlencode('头像缩放出错');
         $result['item'] = $prefix . '_s.jpg';
         echo urldecode(json_encode($result));
         exit;
     }
     $this->ImgLogic->DeleteImage($imgId, "");
     $IoHandler->DeleteFile($path);
     $result['status'] = "ok";
     $result['face_url'] = $prefix . '_s.jpg';
     $result['message'] = urlencode('头像保存成功');
     echo urldecode(json_encode($result));
 }