<?php
defined('PHP168_PATH') or die();
if(REQUEST_METHOD == 'GET'){
	GetGP(array('job','id'));
	load_language($this_plugin, 'global');	//加载语言包
	
	$config = $this_plugin->get_config(false);
	if(!$job){
		$listdb=$this_plugin->get();
		$config=$this_plugin->get_config();
		include $this_plugin->template('config');
		exit;
	}else if($job=='add'){
		include $this_plugin->template('edit');
		exit;
	}
	else if($job=='edit'){

		$data=$this_plugin->get($id);
		$data=$data[0];
		include $this_plugin->template('edit');
		exit;
	}
	else if($job=='show'){
		
		$this_plugin->show($id,1);
	}
	else if($job=='unshow'){
		
		$this_plugin->show($id,0);
	}
	else if($job=='delete'){
		$this_plugin->delete($id);
	}
	else if($job=='cache'){
		$this_plugin->_cache();
	}
	message('done',$this_url.'?plugin=ad_flash');
}elseif(REQUEST_METHOD == 'POST'){
$do=isset($_POST['do'])? $_POST['do']:'';
load_language($this_plugin, 'global');	//加载语言包
	if($do=='config'){
		$config = isset($_POST['config']) && is_array($_POST['config']) ? $_POST['config'] : array();
		
		$config['width'] = empty($config['width'])? 960:$config['width'];
		$config['height'] = empty($config['height'])? 290:$config['height'];
		$config['rolltimes'] = empty($config['rolltimes'])? 5:$config['rolltimes'];
		$config['textfonts'] = empty($config['textfonts'])? '宋体':$config['textfonts'];
		$config['textsizes'] = empty($config['textsizes'])? 12:$config['textsizes'];
		$config['textbolds'] = empty($config['textbolds'])? 0:$config['textbolds'];
		$this_plugin->set_config($config);
		$this_plugin->_cache();
		message('done',$this_url.'?plugin=ad_flash',2);
	}else if($do=='add'){
		$_POST['bigpic'] = attachment_url($_POST['bigpic'],true);
		$_POST['smallpic'] = attachment_url($_POST['smallpic'],true);
		$this_plugin->add($_POST);
		$this_plugin->_cache();
		message('done',$this_url.'?plugin=ad_flash',2);
	}else if($do=='edit'){
		$_POST['bigpic'] = attachment_url($_POST['bigpic'],true);
		$_POST['smallpic'] = attachment_url($_POST['smallpic'],ture);
		$this_plugin->edit($_POST);
		$this_plugin->_cache();
		message('done',$this_url.'?plugin=ad_flash',2);
	}
}