Файл: test.masteram.us/adm_panel/import_messages.php
Строк: 162
<?
include '../Core.php';include_once '../sys/inc/adm_check.php';
user_access('adm_mysql',null,'index.php?'.SID);
adm_check();
if (isset($_GET['action']))
{
$action = $_GET['action'];
if ($action == 'install')
{
$mail = mysql_fetch_assoc(mysql_query("select * from `mail` limit 1"));
if (!isset($mail['import']))mysql_query("alter table `mail` add `import` set('0', '1') not null default '0'");
if (isset($_GET['go']))
{
$k_mail = mysql_result(mysql_query("select count(*) from `mail` where `import` = '0'"),0);
if ($k_mail!=0)
{
$q = mysql_query("select * from `mail` where `import` = '0' order by time desc limit 50");
while ($mails = mysql_fetch_assoc($q))
{
if ($mails['id_user'] == '0')
{
mysql_query("insert into `ls_mails` (`nameSystem`, `uidRecipient`, `time`, `time_read`, `read`, `boxInbox`, `boxOutbox`, `boxSystem`, `title`, `msg`) values ('Система', '$mails[id_kont]', '$mails[time]', '$mails[time]', '$mails[read]', '0', '0', '1', '".utf8_substr($mails['msg'], 10, 1)."', '$mails[msg]')");
}
else
{
mysql_query("insert into `ls_mails` (`uidSender`, `uidRecipient`, `time`, `time_read`, `read`, `boxInbox`, `boxOutbox`, `boxSystem`, `title`, `msg`) values ('$mails[id_user]', '$mails[id_kont]', '$mails[time]', '$mails[time]', '$mails[read]', '1', '1', '0', '".substr($mails['msg'], 0, 10)."', '$mails[msg]')");
}
mysql_query("update `mail` set `import` = '1' where `id` = '$mails[id]' limit 1");
}
}
}
$msg_total = mysql_result(mysql_query("select count(*) from `mail`"),0);
$msg_importing = mysql_result(mysql_query("select count(*) from `mail` where `import` = '1'"),0);
$msg_remaining = mysql_result(mysql_query("select count(*) from `mail` where `import` = '0'"),0);
$msg_done = $msg_importing/$msg_total;
$msg_done = intval($msg_done);
$set['title']='Импорт сообщений из стандартной почты';
include_once '../sys/inc/thead.php';
title();
err();
aut();
echo '<span class="ank_n">Всего сообщений в почте:</span> <span class="ank_d">'.$msg_total.'</span><br/>';
echo '<span class="ank_n">Импортировано:</span> <span class="ank_d">'.$msg_importing.'</span><br/>';
echo '<span class="ank_n">Осталось:</span> <span class="ank_d">'.$msg_remaining.'</span><br/>';
echo '<span class="ank_n">Выполнено:</span> <span class="ank_d">'.$msg_done.'</span><br/>';
if ($msg_remaining!=0)
{
echo '<form method="post" action="import_messages.php?action=install&go">';
if (!isset($_GET['go']))echo '<input type="submit" value="Начать импорт"/><br/>';
else echo '<input type="submit" value="Далее"/><br/>';
echo '</form>';
}
else
{
msg('Сообщения успешно импортированы');
}
}
elseif ($action == 'upgrade')
{
$mail = mysql_fetch_assoc(mysql_query("select * from `ls_messages` order by `id` asc limit 1"));
if (!isset($mail['import']))mysql_query("alter table `ls_messages` add `import` set('0', '1') not null default '0'");
$k_mail = mysql_result("select count(*) from `ls_messages` where `import` = '0'");
if ($k_mail!=0)
{
$q = mysql_query("select * from `ls_messages` where `import` = '1' order by `id` desc limit 25");
while($mails = mysql_fetch_assoc($q))
{
if (mysql_result(mysql_query("select count(*) from `ls_inbox` where `msgId` = '$mails[id]'"),0)!=0)
{
$boxInbox = '1';
}
else
{
$boxInbox = '0';
}
if (mysql_result(mysql_query("select count(*) from `ls_outbox` where `msgId` = '$mails[id]'"),0)!=0)
{
$boxOutbox = '1';
}
else
{
$boxOutbox = '0';
}
if (mysql_result(mysql_query("select count(*) from `ls_system` where `msgId` = '$mails[id]'"),0)!=0)
{
$boxSystem = '1';
}
else
{
$boxSystem = '0';
}
if ($boxSystem == '1')
{
$mail1 = mysql_fetch_assoc(mysql_query("select * from `ls_system` where `msgId` = '$mails[id]' limit 1"));
mysql_query("insert into `ls_mails` (`uidRecipient`, `nameSystem`, `time`, `time_read`, `read`, `boxInbox`, `boxOutbox`, `boxSystem`, `title`, `msg`) values ('$mail1[uidArrive]', '$mail1[nameSend]', '$mail1[time]', '$mail1[time_read]', '$mail1[read]', '$boxInbox', '$boxOutbox', '$boxSystem', '$mail1[title]', '$mails[msg]')");
}
if ($boxInbox == '1')
{
$mail1 = mysql_fetch_assoc(mysql_query("select * from `ls_inbox` where `msgId` = '$mails[id]' limit 1"));
mysql_query("insert into `ls_mails` (`uidRecipient`, `uidSender`, `time`, `time_read`, `read`, `boxInbox`, `boxOutbox`, `boxSystem`, `title`, `msg`) values ('$mail1[uidArrive]', '$mail1[uidSend]', '$mail1[time]', '$mail1[time_read]', '$mail1[read]', '$boxInbox', '$boxOutbox', '$boxSystem', '$mail1[title]', '$mails[msg]')");
}
elseif ($boxOutbox == '1')
{
$mail1 = mysql_fetch_assoc(mysql_query("select * from `ls_outbox` where `msgId` = '$mails[id]' limit 1"));
mysql_query("insert into `ls_mails` (`uidRecipient`, `uidSender`, `time`, `time_read`, `read`, `boxInbox`, `boxOutbox`, `boxSystem`, `title`, `msg`) values ('$mail1[uidArrive]', '$mail1[uidSend]', '$mail1[time]', '$mail1[time_read]', '$mail1[read]', '$boxInbox', '$boxOutbox', '$boxSystem', '$mail1[title]', '$mails[msg]')");
}
}
}
$msg_total = mysql_result(mysql_query("select count(*) from `ls_messages`"),0);
$msg_importing = mysql_result(mysql_query("select count(*) from `ls_messages` where `import` = '1'"),0);
$msg_remaining = mysql_result(mysql_query("select count(*) from `ls_messages` where `import` = '0'"),0);
$msg_done = $msg_importing/$msg_total;
$set['title']='Импорт сообщений из v.1.0';
include_once '../sys/inc/thead.php';
title();
err();
aut();
$smarty = new Smarty_conf();
$posts=array();
$posts[]=array('Всего сообщений в почте', $msg_total);
$posts[]=array('Импортировано', $msg_importing);
$posts[]=array('Осталось', $msg_remaining);
$posts[]=array('Выполнено', $msg_done);
$smarty->assign('post', $posts);
$smarty->display('body.key-value.tpl');
if ($msg_remaining!=0)
{
$smarty = new Smarty_conf();
$smarty->assign('method', 'POST');
$smarty->assign('action', 'import_messages.php?action=upgrade&go');
$elements=array();
if (!isset($_GET['go']))$elements[]=array('type'=>'submit', 'br'=>1, 'info'=>array('value'=>'Начать обновление'));
else $elements[]=array('type'=>'submit', 'br'=>1, 'info'=>array('value'=>'Далее'));
$smarty->assign('el', $elements);
$smarty->display('input.form.tpl');
}
else
{
msg('Сообщения успешно импортированы');
}
}
else
{
header("Location: import_messages.php?".SID);
exit;
}
}
else
{
$set['title']='Импорт сообщений';
include_once '../sys/inc/thead.php';
title();
err();
aut();
echo '<div class="main_menu">';
echo 'Уважаемый '.$user['nick'].', вы успешно установили модуль личной почты версии 2.0 от кодера Dimazzz. Поездавияем вас с этим замечательным событием. С помощью этого мастера вы можете импортировать сообщения из стандартной почты двига <a href="http://dcms.su">Dcms.Su</a>, а также апгрейдить уже установленную ранее версию 1.0 модуля.<br/>Выберите действие:<br/>';
echo '<a href="import_messages.php?action=install">Импортировать из стандартной почты</a><br/>';
//$menu[]=array('import_messages.php?action=upgrade', 'Апгрейд с v.1.0 до v.2.0');
echo '</div>';
}
include_once '../sys/inc/tfoot.php';
?>