<?php

if(!Session::get('uid')){
	Redirect::index();
}
$pub = new Model('pubs');
$pub->find(array('uid'=>Session::get('uid')));
$user = new Model('user');
$data = $user->field('pagetype')->find(Session::get('uid'));
if($data->pagetype==0){
	$to='/admin/main';
}else if($data->pagetype==1){
	$to='/admin/main';
}else if($data->pagetype==2){
	$to='/admin/main';
}
if(!$pub->has_id()){
	$pub->uid = Session::get('uid');
	$pub->isval = '0';
	$pub->save();
	Session::set('wid',$pub->id);
	Redirect::to($to);
}else if($pub->isval !='1'){
	Session::set('wid',$pub->id);
	Redirect::to($to);
}else{	
	Session::set('wid',$pub->id);
	Redirect::to($to);
}
