$urlcs = "./?".$_SERVER['QUERY_STRING'];
preg_match("#(/&|/?)p/=/d+/&?#i",$urlcs,$out);
if($out[0]){
$urlcsdn = preg_replace("#(/&|/?)p/=(/d+)/&?#i","&p=".($p+1),$urlcs);
$urlcsup = preg_replace("#(/&|/?)p/=(/d+)/&?#i","&p=".($p-1),$urlcs);
}
else {
$urlcsdn = $urlcs."&p=".($p+1);
$urlcsup = $urlcs."&p=".($p-1);
}