<?php
session_start();

include('includes/ajax_check_login.php');

require_once('includes/common.php');

if( !isset($_POST) )
	exit(json_encode(array('ErrCode'=>-1, 'ErrMessage'=>'輸入資料不足', 'RedirectURL'=>'')));

require_once('includes/admin.php');
$obj_class_admin = new class_admin();

$arr_macthes = array();
foreach( $_POST as $str_key=>$str_value )
{
	if( preg_match('/^order_(\d+)$/i', $str_key, $arr_matches) )
	{
		if( ( $uint_order = (int)$str_value ) < 0 || $uint_order > 255 )
			continue;

		if( !$obj_class_admin->update_news_cate_order((int)$arr_matches[1], $uint_order) )
			exit(json_encode(array('ErrCode'=>0, 'ErrMessage'=>'更新類別優先順序失敗！', 'RedirectURL'=>'')));
	}
}

exit(json_encode(array('ErrCode'=>1, 'ErrMessage'=>'更新類別優先順序成功', 'RedirectURL'=>'')));
?>