<?php
class rewritehelperPlugin extends Plugin
{
	static function index()
	{
		$plugin = new Plugin();
		global $cfg_rewrite;
		$plugin->assign('cfg_rewrite',$cfg_rewrite);
		$plugin->assign('rewritefile',is_file('.htaccess'));
		return $plugin->display('admin.html');
	}
	
	static function remotedownload()
	{
		import('ORG.File');
		import('ORG.PclZip');
		$url = "http://oss.aliyuncs.com/waikucms/htaccess.zip";
		File::write_file('htaccess.zip',fopen_url($url));
		$zip =  new PclZip('htaccess.zip');
		$zip->extract(PCLZIP_OPT_PATH,'./'); 
		@unlink('htaccess.zip');
		return 1;
	}
	
	static function openrewrite()
	{
		$id = $_GET['id'];
		$model = M('config');
		if($id==0)
		{
			$model->where('id=33')->setField('value',1);
		}
		else
		{
			$model->where('id=33')->setField('value',0);
		}
		return;
	}
}