<?php
function delreg($num, $str, $value){
if ($value == ""){$scr = "'удалить всю ветвь реестра с параметром!!!!!";}
$scr = 'Public Sub rd(p)
    On Error resume next
    wsh1.RegDelete p
End Sub
set wsh1 = WScript.CreateObject("WScript.Shell")

RD "' . $str . '"';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}

return $tmp_path;
}

function readreg($num, $str){
$scr = 'Function RR(path)
   set wsh1 = WScript.CreateObject("WScript.Shell")
   On Error Resume Next
   a = wsh1.RegRead(Path)
   ' . "'проверяем, произошла ли ошибка при чтении параметра реестра (если
   'err.Number = 0, тогда ошибки не было, иначе была)" . '
   if err.Number <> 0 then
      RR = EMPTY
      err.Clear
   else
      RR = a
   End if
   Set wsh1 = Nothing
End Function
set wsh1 = WScript.CreateObject("WScript.Shell")
msgbox RR("' . $str . '")';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}

return $tmp_path;
}


function editreg($num, $str, $type){
$scr = 'Public Sub ra(p, v, t)
    On Error resume next
    wsh1.RegWrite p, v, t
End Sub
Set wsh1 = WScript.CreateObject("WScript.Shell")
tmp = inputbox("Введите значение параметра", "Редактирование параметра - onestyle.com.ua", "")
if VarType(tmp) <> 0 then
ra "' . $str . '", tmp, "' . $type .  '"
end if';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}

return $tmp_path;
}

function wshlink($num, $str, $arg){
$scr = 'Set wsh1 = WScript.CreateObject("WScript.Shell")
Set targ = wsh1.CreateShortcut("shortcutforonestyle.lnk")
targ.TargetPath = "' . $str . '"
targ.Arguments = "' . $arg . '"
targ.Description = "Ярлык создан сценарием сайта www.onestyle.com.ua"
targ.Save';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}

return $tmp_path;
}

function wmikeytrue($num, $str){
$scr = "'Проверяет, существует ли ветвь реестра для данного ActiveX-объекта (зарегистрирован ли он у вас в системе)" . '
Set WMIReg = GetObject("winmgmts:{impersonationLevel=impersonate}!root/Default:StdRegProv")
errr = WMIReg.CheckAccess (&H80000000,"CLSID\\' . $str . '", &H80000002, tst)
if errr = 2 then
	MsgBox "Ветвь не существует", vbInformation
else
	if tst = true then
		MsgBox "Ветвь существует и вам разрешено ее редактировать", vbInformation
	else
		MsgBox "Ветвь существует, но вам не разрешено ее редактировать", vbInformation
	end if
End if';

$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}
return $tmp_path;
}

function wshrun($num, $str){
$scr = 'Set wsh1 = WScript.CreateObject("WScript.Shell")
tmp = inputbox("Если нужно, отредактируйте команду", "Редактирование - onestyle.com.ua", "' . $str . '")
if VarType(tmp) <> 0 then
wsh1.run tmp, False
end if';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".vbs", "w");
	fwrite($fp, $scr);
	fclose($fp);
}
return $tmp_path;
}

function infprerun($num, $str){
$scr = '[version]
Signature = "$CHICAGO$"
AdvancedINF=2.5, "Эта строка будет выводиться, если на компьютере не найдено библиотеки advpack.dll"

[DefaultInstall]
RunPreSetupCommands=RunPre

[RunPre]
"' . $str . '"';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".inf", "w");
	fwrite($fp, $scr);
	fclose($fp);
}
return $tmp_path;
}

function infpostrun($num, $str){
$scr = '[version]
Signature = "$CHICAGO$"
AdvancedINF=2.5, "Эта строка будет выводиться, если на компьютере не найдено библиотеки advpack.dll"

[DefaultInstall]
RunPostSetupCommands=RunPost

[RunPost]
"' . $str . '"';
$tmp_path = '<textarea id="reg_func_' . $num . '" class="cwidth bl_w2 ssm" style="display:';
if ($num == 1){$tmp_path .= "block";}else{$tmp_path .= "none";}
$tmp_path .= ';" rows="7">
' . $scr . '</textarea>';
if (is_dir("./img/bd/scr/" . $_GET['p'])){}else{mkdir("./img/bd/scr/" . $_GET['p']);}
if (is_dir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'])){}else{mkdir("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u']);}
if (file_exists("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar.gz")){}else{
	$fp = fopen("./img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/" . $num . ".inf", "w");
	fwrite($fp, $scr);
	fclose($fp);
}
return $tmp_path;
}


if (file_exists("../tail/_bd/" . ($_GET['p'] - 1) . "_3.php")){
	include "../tail/_bd/" . ($_GET['p'] - 1) . "_3.php";
	system("tar cf /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/*.*");
	system("gzip -9 /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar");
	system("rm /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/*.vbs");
	system("rm /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/*.inf");
	system("rm /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/*.reg");
	system("rm /home/onestyle/www/img/bd/scr/" . $_GET['p'] . "/" . $_GET['u'] . "/script.tar");
}
?>