game/html/library.php

355 lines
16 KiB
PHP

<?
if( !isset($url[2]) || $url[2] == '' ) {
$url[2] = 'home';
}
if( $url[2] == 'upload' && $u->info['admin'] > 0 ) {
$html = '';
if( $u->info['molch1'] > time() ) {
$html = 'Ïåðñîíàæè ñ ìîë÷àíêîé íå ìîãóò ïóáëèêîâàòü èçîáðàæåíèÿ.';
}elseif( $u->info['banned'] > 0 ) {
$html = 'Çàáëîêèðîâàííûå ïåðñîíàæè íå ìîãóò ïóáëèêîâàòü èçîáðàæåíèÿ.';
}elseif( $u->info['align'] == 2 ) {
$html = 'Õàîñíèêè íå ìîãóò ïóáëèêîâàòü èçîáðàæåíèÿ.';
}elseif( !isset($u->info['id']) ) {
$html = '<center><br>Çàãðóæàòü èçîáðàæåíèÿ ìîãóò òîëüêî çàðåãèñòðèðîâàííûå ïîëüçîâàòåëè</center>';
}elseif( ($url[3] == 'me' || ($url[3] == 'all' && $u->info['admin'] > 0)) ) {
if( $url[3] == 'me' ) {
$sp = mysql_query('SELECT * FROM `upload_images` WHERE `uid` = "'.$u->info['id'].'" ORDER BY `id` DESC LIMIT 1000');
}elseif( $url[3] == 'all' ) {
$sp = mysql_query('SELECT * FROM `upload_images` ORDER BY `id` DESC LIMIT 1000');
}
$html .= '<b>Ëåâàÿ Êíîïêà Ìûøè</b> - Îòêðûòü èçîáðàæåíèå â íîâîì îêíå<br>
<b>Ïðàâàÿ Êíîïêà Ìàøè</b> - Óäàëèòü èçîáðàæåíèå ñ ñåðâåðà<hr>';
$i = 0;
$usrs = array();
while($pl = mysql_fetch_array($sp)) {
if( $url[4] == 'delete' && $url[5] == $pl['id'] ) {
unlink('ui/'.$pl['img'].'.'.$pl['type'].'');
mysql_query('DELETE FROM `upload_images` WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}else{
if( !isset($usrs[$pl['uid']]) ) {
$usrs[$pl['uid']] = mysql_fetch_array(mysql_query('SELECT `id`,`login` FROM `users` WHERE `id` = "'.$pl['uid'].'" LIMIT 1'));
if(!isset($usrs[$pl['uid']]['id'])) {
$usrs[$pl['uid']]['login'] = '!ÍÅÒ ÀÂÒÎÐÀ!';
}
$usrs[$pl['uid']] = $usrs[$pl['uid']]['login'];
}
$html .= '<a title="'.$usrs[$pl['uid']]."\n".date('d.m.Y H:i',$pl['time']).'" oncontextmenu="if(confirm(\'Âû óâåðåíû?\')){ top.location=\'https://new-combats.com/library/upload/'.htmlspecialchars($url[3],NULL,'cp1251').'/delete/'.$pl['id'].'/\'; }return false;" target="_blank" href="https://new-combats.com/ui/'.$pl['img'].'.'.$pl['type'].'"><img src="https://new-combats.com/ui/'.$pl['img'].'.'.$pl['type'].'" class="imgo"></a>';
}
$i++;
}
if( $i == 0 ) {
$html .= 'Íåò çàãðóæåííûõ èçîáðàæåíèé íà ñåðâåðå';
}
}else{
if( isset($_FILES['filename']) && $u->info['admin'] > 0 ) {
require_once('class.upload.php');
$handle = new upload($_FILES['filename']);
$count = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `users` WHERE `uid` = "'.$u->info['id'].'" AND `time` > '.(time()-60).' LIMIT 1'));
if( $count > 3 && $u->info['admin'] == 0 ) {
$html = 'Âû íå ìîæåòå òàê ÷àñòî çàëèâàòü èçîáðàæåíèÿ íà ñåðâåð';
}elseif ($handle->uploaded) {
if( $handle->file_src_name_ext == 'png' || $handle->file_src_name_ext == 'jpg' || $handle->file_src_name_ext == 'gif' ) {
$fname = 'u'.$u->info['id'].'_'.time();
$handle->file_new_name_body = $fname;
$handle->image_convert = $handle->file_src_name_ext;
/*
$handle->image_unsharp = true;
$handle->image_border = '0 0 0 0';
$handle->image_border_color = '#000000';
$handle->image_text = "";
$handle->image_text_font = 2;
$handle->image_text_position = 'B';
$handle->image_text_padding_y = 2;
*/
if( $u->info['admin'] == 0 ) {
$handle->image_max_width = 800;
$handle->image_max_height = 800;
$handle->src_size_mb = 1;
}
$handle->process('ui/');
if ($handle->processed)
{
mysql_query('INSERT INTO `upload_images` (`uid`,`time`,`img`,`type`) VALUES (
"'.$u->info['id'].'","'.time().'","'.mysql_real_escape_string($fname).'","'.mysql_real_escape_string($handle->file_src_name_ext).'"
) ');
$html .= 'Ôàéë <a href="https://new-combats.com/ui/'.$fname.'.'.$handle->file_src_name_ext.'" target="_blank">https://new-combats.com/ui/'.$fname.'.'.$handle->file_src_name_ext.'</a> áûë óñïåøíî çàãðóæåí.';
$handle->clean();
} else {
$html .= 'Âîçíèêëà îøèáêà ïðè äîáàâëåíèè ôàéëà.';
}
}else{
$html .= 'Âîçíèêëà îøèáêà ïðè äîáàâëåíèè ôàéëà!';
}
}
}else{
$html .= '
<br>
<b>Ïðàâèëà ïóáëèêàöèè èçîáðàæåíèé:</b><br>
&bull; Èçîáðàæåíèå íå äîëæíî íàðóøàòü ïðàâèëà ïðîåêòà<br>
&bull; Èçîáðàæåíèå äîëæíî âåñèòü íå áîëåå 1000 Êá<br>
&bull; Èçîáðàæåíèå íå äîëæíî áûòü áîëåå 800px õ 800px<br>
&bull; Ôîðìàòû èçîáðàæåíèÿ: JPEG , GIF , PNG<hr>
<center>
<form action="https://new-combats.com/library/upload/" method="post" enctype="multipart/form-data">
<input type="file" name="filename">
<input class="btn2" type="submit" value="Çàãðóçèòü"><hr>';
if( $u->info['admin'] > 0 ) {
$html .= '<a href="https://new-combats.com/library/upload/all/">[ Âñå èçîáðàæåíèÿ ]</a> ';
}
$html .= '<a href="https://new-combats.com/library/upload/me/">[ Ìîè èçîáðàæåíèÿ ]</a>';
$html .= '</form>
</center>';
}
}
echo '<div style="padding-left:20px;padding-top:20px;"><h3>Çàãðóçêà èçîáðàæåíèé</h3>'.$html.'</div>';
}elseif( $url[2] == 'list' ) {
$sp = mysql_query('SELECT * FROM `library_content` WHERE `delete` = 0 AND `moder` = 0 AND `uid` > 0 ORDER BY `id` ASC');
$html = '';
$i = 1;
while($pl = mysql_fetch_array($sp)) {
$html .= '<a target="_blank" href="https://new-combats.com/library/'.$pl['url_name'].'/">&gt;&gt; '.$pl['title'].'</a><br>Àâòîð: '.$u->microLogin($pl['uid'],1).' / Äàòà ïóáëèêàöèè: '.date('d.m.Y',$pl['time']).'<hr>';
$i++;
}
if( $html == '' ) {
$html = 'Â íàñòîÿùèé ìîìåíò íåïðîâåðåííûõ ñòàòåé íåò.<br>
<br>Åñëè Âû õîòèòå íàïèñàòü ñâîþ ñòàòüþ - <a target="_blank" href="https://new-combats.com/library/new/">https://new-combats.com/library/new/</a><br>
<br>Áîëåå ïîäðîáíàÿ èíôîðìàöèÿ - <a href="https://new-combats.com/library/public/">https://new-combats.com/library/public/</a>';
}
echo '<div style="padding-left:20px;padding-top:20px;"><h3>Ñïèñîê íåïðîâåðåííûõ ñòàòåé:</h3>'.$html.'</div>';
}elseif( $url[2] == 'new' && !isset($u->info['id']) ) {
echo '<div style="padding:50px;">Äëÿ ïóáëèêàöèè ñòàòüè Âû äîëæíû àâòîðèçèðîâàòüñÿ ñâîèì ïåðñîíàæåì.<br><b>Ãîñòÿì</b> äàííûé ðàçäåë íåäîñòóïåí.</div>';
}elseif( $url[2] == 'new' && isset($u->info['id']) ) {
?>
<!-- -->
<script src="https://new.new-combats.com/static/ckeditor/ckeditor.js"></script>
<!-- -->
<div class="lib-txt-title">Ïóáëèêàöèÿ ñòàòüè</div>
<div class="lib-txt">
<?
if(isset($_POST['save']) && isset($u->info['id'])) {
$_POST['lib_title'] = htmlspecialchars($_POST['lib_title'],NULL,'cp1251');
$mbpage_last = mysql_fetch_array(mysql_query('SELECT `time` FROM `library_content` WHERE `uid` = "'.$u->info['id'].'" ORDER BY `id` DESC LIMIT 1'));
if( $u->info['molch1'] > time() ) {
echo 'Ïåðñîíàæè ñ ìîë÷àíêîé íå ìîãóò ïóáëèêîâàòü ñòàòüè.';
}elseif( $u->info['banned'] > 0 ) {
echo 'Çàáëîêèðîâàííûå ïåðñîíàæè íå ìîãóò ïóáëèêîâàòü ñòàòüè.';
}elseif( $u->info['align'] == 2 ) {
echo 'Õàîñíèêè íå ìîãóò ïóáëèêîâàòü ñòàòüè.';
}elseif( isset($mbpage_last['time']) && $mbpage_last['time'] > time() - 3600 && $u->info['admin'] == 0 ) {
echo 'Íåëüçÿ ïóáëèêîâàòü ñòàòüè ÷àùå îäíîãî ðàçà â ÷àñ.<br>Âû ìîæåòå îïóáëèêîâàòü ñòàòüþ ÷åðåç <b>'.$u->timeOut(($mbpage_last['time']+3600-time())).'</b>.';
}elseif( isset($_POST['hide_id']) ) {
$mbpage = mysql_fetch_array(mysql_query('SELECT * FROM `library_content` WHERE `url_name` = "'.mysql_real_escape_string($_POST['hide_id']).'" AND `delete` = "0" ORDER BY `id` DESC LIMIT 1'));
if(isset($mbpage['id'])) {
if(isset($mbpage['id']) && ($mbpage['uid'] == $u->info['id'] || $u->info['admin'] > 0) && ($mbpage['moder'] == 0 || $u->info['admin'] > 0) ) {
mysql_query('UPDATE `library_content` SET `time` = "'.time().'",`title` = "'.mysql_real_escape_string($_POST['lib_title']).'",`text` = "'.mysql_real_escape_string($_POST['con_text']).'" WHERE `id` = "'.$mbpage['id'].'" LIMIT 1');
$sid = $mbpage['id'];
if( $sid > 0 ) {
?>
<b>Óâàæàåì<? if( $u->info['sex'] == 0 ) { echo 'ûé'; }else{ echo 'àÿ'; } ?></b> <?=$u->info['login']?>, áëàãîäàðèì Âàñ çà äîïîëíåíèå ñòàòüè!<br />
<br />
Íàçâàíèå ñòàòüè: &quot;<b><?=$_POST['lib_title']?></b>&quot;<br />
Ññûëêà äëÿ ïðîñìîòðà: <a target="_blank" href="https://new-combats.com/library/<?=$mbpage['url_name']?>/">https://new-combats.com/library/<?=$mbpage['url_name']?>/</a>
<hr />
Ìû öåíèì ïðîäåëàííóþ Âàìè ðàáîòó è ïîñòàðàåìñÿ êàê ìîæíî ñêîðåå ðàññìîòðåòü çàÿâêó íà äîáàâëåíèå äàííîé ñòàòüè
<br /><br /><br /><br /><br /><br /><br /><br />
, ñ óâàæåíèåì<br />
Àäìèíèñòðàöèÿ Áîéöîâñêîãî Êëóáà "new-combats".
<?
}else{
echo 'Ïðîèçîøëà îøèáêà èçìåíåíèÿ ñòàòüè.';
}
}else{
echo 'Ïðîèçîøëà îøèáêà èçìåíåíèÿ ñòàòüè!<br><b>Ñòàòüÿ íå íàéäåíà, ëèáî ó Âàñ íåò ïðàâ äëÿ å¸ èçìåíåíèÿ.</b>';
}
}else{
echo 'Ïðîèçîøëà îøèáêà èçìåíåíèÿ ñòàòüè.<br><b>Ñòàòüÿ íå íàéäåíà, ëèáî ó Âàñ íåò ïðàâ äëÿ å¸ èçìåíåíèÿ.</b>';
}
}else{
$sid = 0;
mysql_query('INSERT INTO `library_content` (`type`,`uid`,`time`,`title`,`url_name`,`text`) VALUES (
"0","'.$u->info['id'].'","'.time().'","'.mysql_real_escape_string($_POST['lib_title']).'","id'.time().'","'.mysql_real_escape_string($_POST['con_text']).'"
)');
$sid = mysql_insert_id();
if($sid > 0) {
mysql_query('UPDATE `library_content` SET `url_name` = "id'.$sid.'" WHERE `id` = "'.$sid.'" LIMIT 1');
?>
<b>Óâàæàåì<? if( $u->info['sex'] == 0 ) { echo 'ûé'; }else{ echo 'àÿ'; } ?></b> <?=$u->info['login']?>, áëàãîäàðèì Âàñ çà äîáàâëåíèå ñòàòüè!<br />
<br />
Íàçâàíèå ñòàòüè: &quot;<b><?=$_POST['lib_title']?></b>&quot;<br />
Íîìåð Âàøåé ñòàòüè: #<?=$sid?><br />
Ññûëêà äëÿ ïðîñìîòðà: <a target="_blank" href="https://new-combats.com/library/id<?=$sid?>/">https://new-combats.com/library/id<?=$sid?>/</a>
<hr />
Ìû öåíèì ïðîäåëàííóþ Âàìè ðàáîòó è ïîñòàðàåìñÿ êàê ìîæíî ñêîðåå ðàññìîòðåòü çàÿâêó íà äîáàâëåíèå äàííîé ñòàòüè
<br /><br /><br /><br /><br /><br /><br /><br />
, ñ óâàæåíèåì<br />
Àäìèíèñòðàöèÿ Áîéöîâñêîãî Êëóáà "new-combats".
<?
}else{
echo 'Ïðîèçîøëà îøèáêà äîáàâëåíèÿ ñòàòüè.<br><b>Îáðàòèòåñü ê Àäìèíèñòðàöèè!</b>';
}
}
}else{
if( isset($url[3]) && $url[3] != '' ) {
$mbpage = mysql_fetch_array(mysql_query('SELECT * FROM `library_content` WHERE `url_name` = "'.mysql_real_escape_string($url[3]).'" AND `delete` = "0" ORDER BY `id` DESC LIMIT 1'));
if(isset($mbpage['id']) && ($mbpage['uid'] == $u->info['id'] || $u->info['admin'] > 0) && ($mbpage['moder'] == 0 || $u->info['admin'] > 0) ) {
//all okey
}else{
unset($mbpage);
echo '<div align="center" style="background-color:#e8b8b8;border:1px solid #b93939;color:#b93939;padding:5px;"><small>';
echo 'Äàííàÿ ñòàòüÿ íå íàéäåíà. Ëèáî ó Âàñ íåò ïðàâä äëÿ å¸ ðåäàêòèðîâàíèÿ.';
echo '</small></div>';
}
}
?>
<form method="post" action="https://new-combats.com/library/new/<?=$mbpage['url_name']?>">
<?
if( isset($mbpage['id']) ) {
if( isset($_POST['save2']) ) {
//Èçìåíåíèÿ
if( $u->info['admin'] > 0 ) {
$red500 = false;
if( isset($_POST['lib_urlname']) && $_POST['lib_urlname'] != '' && $_POST['lib_urlname'] != $mbpage['url_name'] ) {
mysql_query('UPDATE `library_content` SET `delete` = "'.time().'" WHERE `url_name` = "'.$mbpage['url_name'].'" AND `id` != "'.$mbpage['id'].'"');
$mbpage['url_name'] = htmlspecialchars($_POST['lib_urlname'],NULL,'cp1251');
mysql_query('UPDATE `library_content` SET `url_name` = "'.mysql_real_escape_string($mbpage['url_name']).'" WHERE `id` = "'.$mbpage['id'].'" LIMIT 1');
$red500 = true;
}
if( isset($_POST['lib_prov']) && $_POST['lib_prov'] == '1' && $_POST['lib_prov'] != '' && $_POST['lib_prov'] != '0') {
$mbpage['moder2'] = $u->info['id'];
}else{
$mbpage['moder2'] = 0;
}
if( $mbpage['moder2'] != $mbpage['moder'] ) {
mysql_query('UPDATE `library_content` SET `delete` = "'.time().'" WHERE `url_name` = "'.$mbpage['url_name'].'" AND `id` != "'.$mbpage['id'].'"');
mysql_query('UPDATE `library_content` SET `moder` = "'.mysql_real_escape_string($mbpage['moder2']).'" WHERE `id` = "'.$mbpage['id'].'" LIMIT 1');
$mbpage['moder'] = $mbpage['moder2'];
}
if( $red500 == true ) {
echo '<script>top.location.href="https://new-combats.com/library/new/'.$mbpage['url_name'].'/"</script>';
}
}
if( $u->info['admin'] > 0 || $u->info['id'] == $mbpage['uid'] ) {
if( $_POST['lib_title'] != $mbpage['title'] || $_POST['con_text'] != $mbpage['text'] ) {
$mbpage['title'] = $_POST['lib_title'];
$mbpage['text'] = $_POST['con_text'];
$mbpage['time'] = time();
mysql_query('UPDATE `library_content` SET `time` = "'.time().'",`title` = "'.mysql_real_escape_string(htmlspecialchars($mbpage['title'],NULL,'cp1251')).'",`text` = "'.mysql_real_escape_string($mbpage['text']).'" WHERE `id` = "'.$mbpage['id'].'" LIMIT 1');
}
}
}
?>
<input name="hide_id" value="<?=$mbpage['url_name']?>" type="hidden" />
<?
}
?>
<table width="100%" border="0" cellspacing="0" cellpadding="5">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150">Íàçâàíèå ñòàòüè:</td>
<td><input style="width:350px;" name="lib_title" type="text" id="lib_title" maxlength="100" value="<?=$mbpage['title']?>" /></td>
</tr>
<?
if( $u->info['admin'] > 0 ) {
?>
<tr>
<td width="150">URL-NAME:</td>
<td><input style="width:350px;" name="lib_urlname" type="text" id="lib_urlname" maxlength="100" value="<?=$mbpage['url_name']?>" /></td>
</tr>
<tr>
<td width="150">Ïðîâåðåííàÿ ñòàòüÿ:</td>
<td><input type="checkbox" <? if($mbpage['moder'] > 0){ echo 'checked="checked"'; } ?> name="lib_prov" id="lib_prov" value="1" /> <?
if($mbpage['moder']>0) {
echo $u->microLogin($mbpage['moder'],1);
}
?></td>
</tr>
<?
}
?>
</table></td>
</tr>
<tr>
<td>
<div style="padding:10px;width:560px;border:1px solid black;">
<textarea class="w100p" name="con_text" id="con_text" cols="45" rows="5">
<?=$mbpage['text']?>
</textarea>
</div>
</td>
</tr>
<tr>
<td><table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150">Äàòà ïóáëèêàöèè:</td>
<td>
<?
if(isset($mbpage['id'])) { echo date('d.m.Y',$mbpage['time']); }else{ echo date('d.m.Y'); }
if($u->info['admin'] > 0 || $u->info['id'] == $mbpage['uid']) {
?>
<button name="save2" type="submit" style="float:right">Ñîõðàíèòü</button>
<? } ?>
<button name="save" type="submit" style="float:right">Îïóáëèêîâàòü</button>
</td>
</tr>
<tr>
<td>Àâòîð:</td>
<td><?=$u->microLogin($mbpage['uid'],1)?></td>
</tr>
</table></td>
</tr>
</table>
</form>
<script>
CKEDITOR.inline( 'con_text' );
</script>
<?
}
?>
</div>
<?
}else{
/*
echo '<script>function bigimg(obj){ alert($(\'aid\'+obj).html(\'href\')); }</script>';
*/
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `library_content` WHERE `url_name` = "'.mysql_real_escape_string($url[2]).'" AND `delete` = "0" ORDER BY `id` DESC LIMIT 1'));
if( isset($pl['id']) && $url[3] == 'delete' && $u->info['admin'] > 0) {
mysql_query('UPDATE `library_content` SET `delete` = "'.time().'" WHERE `url_name` = "'.mysql_real_escape_string($url[2]).'"');
unset($pl);
}
if( isset($pl['id']) ) {
if($pl['moder'] == 0) {
echo '<div align="center" style="background-color:#e8b8b8;border:1px solid #b93939;color:#b93939;padding:5px;"><small>Äàííàÿ ñòàòüÿ íå ïðîøëà ïðîâåðêó è èíôîðìàöèÿ íà íåé íå ïîäòâåðæäåíà!</small></div>';
}
echo '<div class="lib-txt-title">'.$pl['title'].'</div><div class="lib-txt">'.$pl['text'].'</div>';
if($pl['uid'] > 0 || $u->info['admin'] > 0) {
echo '<hr><small><div> &nbsp; Äàòà ïóáëèöàöèè: '.date('d.m.Y',$pl['time']).' &nbsp; / &nbsp; Àâòîð: '.$u->microLogin($pl['uid'],1).'';
if($pl['uid'] == $u->info['id'] || $u->info['admin'] > 0) {
echo ' &nbsp; / &nbsp; <a target="_blank" href="https://new-combats.com/library/new/'.$pl['url_name'].'/">Èçìåíèòü</a>';
if( $u->info['admin'] > 0 ) {
echo ' &nbsp; / &nbsp; <a href="https://new-combats.com/library/'.$pl['url_name'].'/delete/">Óäàëèòü</a>';
}
}
echo '</div></small>';
}
}else{
echo '<div align="center" style="background-color:#e8b8b8;border:1px solid #b93939;color:#b93939;padding:5px;"><small>Ñòàòüÿ íå íàéäåíà. Ñêîðåå âñåãî îíà áûëà óäàëåíà, ëèáî åùå íå ñîçäàíà.</small></div>';
}
}
?>