virt2/api/code/export_mod.php

33 lines
1.9 KiB
PHP
Raw Normal View History

<?php
if ($_SESSION['dostup']!=='a' && $_SESSION['dostup']!=='e')header( 'Location: /403/' );
$db->change_db($set['bd_code']);
$html=MYDIR . '/api/mod/' . ID . '.html';
require MYDIR . '/api/save_files.php';
$fp = fopen ( $html, 'a+' ) or die ('Нет прав на запись файла ' . $html . '! Дайте доступ на запись или обратитесь к системному администратору ');
$size = filesize ( $html );
$htm = open_text (base64_encode(gzencode (fread ( $fp, $size ))));
fclose ( $fp );
$result = mysql_query( "SELECT * FROM `mod` WHERE `mod` = '" . ID . "' LIMIT 1" );
while ( $postrow[] = mysql_fetch_array($result));
$xml='<?xml version="1.0" encoding="UTF-8" ?>' . "\r\n";
$xml='<mod_name>' . ID . '</mod_name>' . "\r\n";
$xml.='<html>' . $htm . '</html>' . "\r\n";
$xml.='<js>' . $postrow[0]['js'] . '</js>' . "\r\n";
$xml.='<php>' . $postrow[0]['php'] . '</php>' . "\r\n";
$xml.='<install>' . $postrow[0]['install'] . '</install>' . "\r\n";
$xml.='<news>' . $postrow[0]['news'] . '</news>' . "\r\n";
$xml.='<act>' . $postrow[0]['act'] . '</act>' . "\r\n";
$xml.='<ver>' . $postrow[0]['ver'] . '</ver>' . "\r\n";
$xml.='<sql>' . base64_encode(gzencode ($postrow[0]['sql'])) . '</sql>' . "\r\n";
$xml.='<set>' . base64_encode(gzencode ($postrow[0]['set'])) . '</set>' . "\r\n";
$xml.='<set_form>' . base64_encode(gzencode ($postrow[0]['set_form'])) . '</set_form>' . "\r\n";
$xml.='<md5>' . md5($htm . $postrow[0]['js'] . $postrow[0]['php'] . $postrow[0]['act']) . $postrow[0]['ver'] . $postrow[0]['install'] . '</md5>' . "\r\n";
@mkdir(MYDIR . '/tmp', 0777);
@unlink (MYDIR . '/tmp/' . ID . '.xml');
@unlink (MYDIR . '/tmp/' . ID . '.zip');
@$fp = fopen ( MYDIR . '/tmp/' . ID . '.xml', 'w+' );
fwrite($fp, $xml);
fclose ( $fp );
chdir (MYDIR . '/tmp');
exec('zip -9 ' . ID . '.zip ' . ID . '.xml -m5');
?>