session_start();
require("params/config.php");
function RandStringEDO($length = 64){
$chars = 'abdefhiknrstyzABDEFGHKNQRSTYZ23456789';
$numChars = strlen($chars);
$string = '';
for ($i = 0; $i < $length; $i++) {
$string .= substr($chars, rand(1, $numChars) - 1, 1);
}
return $string;
}
if (strlen($_SESSION["NAKS"]["SESSION"])!=64)
{
$_SESSION["NAKS"]["SESSION"]=RandStringEDO(64); // создаем рабочую сессию
}
if (count($_POST)):
$cache_id=time()."_".RandStringEDO(5);
$file=fopen($_SERVER["DOCUMENT_ROOT"]."/znaks/params/cache/".$cache_id,"w");
if ($file)
{
$array = array();
foreach($_POST as $key=>$value){
if(is_array($value)){
foreach($value as $key2=>$value2){
if(is_array($value2)){
foreach($value2 as $key3=>$value3){
$array[$key][key2][$key3] = mb_convert_encoding($value3, "CP1251", "UTF-8");
}
}else{
$array[$key][key2] = mb_convert_encoding($value2, "CP1251", "UTF-8");
}
}
}else{
$array[$key] = mb_convert_encoding($value, "CP1251", "UTF-8");
}
}
$string=serialize($array);
fwrite($file,$string);
fclose($file);
$path="http://ac.naks.ru/curl/form.php?session=".urlencode($_SESSION["NAKS"]["SESSION"])."&edo_login=".$EDO["login"]."&host=".$_SERVER["HTTP_HOST"]."&edo_password=".$EDO["password"]."&cache_id=".$cache_id;
$out=file_get_contents($path);
//print $out;
//require($path);
}
;
elseif ($_REQUEST["url"]):
if ($_REQUEST["id"]&&preg_match("/^order\_rtf\_/",$_REQUEST["url"]))
{
header('Content-Transfer-Encoding: binary');
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-type: application/msword;");
header('Content-disposition: attachment; filename="order.rtf";');
}
$path="http://ac.naks.ru/curl/href.php?session=".urlencode($_SESSION["NAKS"]["SESSION"])."&edo_login=".$EDO["login"]."&edo_password=".$EDO["password"]."&url=".$_REQUEST["url"];
if ($_REQUEST["id"])
$path.="&ID=".$_REQUEST["id"];
if ($_REQUEST["attID"])
$path.="&attID=".$_REQUEST["attID"];
if ($_REQUEST["spec"])
$path.="&spec=Y";
$out=file_get_contents($path);
endif;
$menu="";
$reg_edo='';
$out=mb_convert_encoding($out, "UTF-8", "CP1251");
$reg_edo='Зарегистрироваться';
$out=preg_replace("/\<\!\-\-show\_menu\_edo\-\-\>/","
",$out);
$out=preg_replace("/\<\!\-\-show\_reg\_edo\-\-\>/",$reg_edo,$out);
print $out; // вывод потока
//print $path;
if ($_REQUEST["url"]=="logout")
{
$_SESSION["NAKS"]["SESSION"]=RandStringEDO(64); // новая сессия
}
?>
.png)
