query( "SELECT * FROM " . PREFIX . "_table where id= '$id'" );
$row = $db->get_row();
if( $db->num_rows() < 1 ) {
msgbox( $lang['all_err_1'], "Заказа под таким номером не найдено" );
} else {
if ( $row['runame'] ){ $title = stripslashes($row['runame']); }
elseif ( $row['enname'] ){ $title = stripslashes($row['enname']); }
$metatags['title'] = 'Стол заказов' . ' » ' . $title . ' » ' . $config['home_title'];
$inetlink = explode("\n", stripslashes($row['answer']));
$inetlink_1 = 'Перейти в новость';
$inetlink_s = $inetlink_1 . join("$inetlink_2 | $inetlink_1", $inetlink) . $inetlink_2;
$status = intval($row['status']);
switch ($status) {
case "0":
$status = '' . $lang_table['edit_status_0'] . '';
$answer = '';
break;
case "1":
$status = '' . $lang_table['edit_status_1'] . '';
$answer = '';
break;
case "2":
$status = '' . $lang_table['edit_status_2'] . '';
if (empty($row['answer'])) {$answer = $lang_table['cause1'];
} else {$answer = $lang_table['cause0'] . stripslashes($row['answer']); }
break;
case "3":
$status = '' . $lang_table['edit_status_3'] . '';
$answer = "
Новость с выполненным заказом: " . $inetlink_s;
break;
}
if ( $member_id['user_group'] == '1' OR $user_group[$member_id['user_group']]['admin_table'] OR $member_id['user_group'] == $table_config['grouplevel'] ) {
$admin_url = '' . $lang_table['edit'] . '';
}
$tpl->load_template('tableview.tpl');
$tpl->set( '{adminlink}', $admin_url );
$row['date'] = /*strtotime*/($row['date']);
if (date(Ymd, $row['date']) == date(Ymd, $_TIME)) {
$tpl->set('{date}', $lang['time_heute'].langdate(" в H:i", $row['date']));
} elseif (date(Ymd, $row['date']) == date(Ymd, ($_TIME - 86400))) {
$tpl->set('{date}', $lang['time_gestern'].langdate(" в H:i", $row['date']));
} else {
$tpl->set('{date}', langdate($table_config['timestamp_active'], $row['date']));
}
$tpl->set( '{id-orders}', $id );
$tpl->set( '{autor}', "" .$row['autor']. "" );
$tpl->set( '{runame}', stripslashes($row['runame']));
$tpl->set( '{enname}', stripslashes($row['enname']));
$tpl->set( '{category}', stripslashes($row['category']));
$tpl->set( '{fileyear}', stripslashes($row['fileyear']));
$tpl->set( '{status}', $status);
$tpl->set( '{answer}', $answer);
$tpl->set( '{editor}', "" .$row['editor']. "" );
if( $row['editor'] ) {
$tpl->set( '[editor]', "" );
$tpl->set( '[/editor]', "" );
} else {
$tpl->set( '{editor}', "" );
$tpl->set_block( "'\\[editor\\](.*?)\\[/editor\\]'si", "" );
}
$tpl->compile( 'content' );
$tpl->clear();
}
}
elseif ( $_REQUEST['action'] == "doadd" ) {
$metatags['title'] = $lang_table['description2'] . ' » ' . $config['home_title'];
$timeweek = $_TIME - (intval($table_config['timeweek']) * 86400);
$row_doadd = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_table WHERE autor = '" . $member_id['name'] . "' AND date >'$timeweek' AND status != '2' AND status != '3'");
if ($row_doadd['count'] >= 1) { $is_doadd = false; }
else { $is_doadd = true; }
if (isset($_POST['send'])) {
$stop = "";
$user_n = $db->safesql(trim($member_id['name']));
$runame = $db->safesql(strip_tags(trim($_POST['runame'])));
$enname = $db->safesql(strip_tags(trim($_POST['enname'])));
$category = $db->safesql(strip_tags(trim($_POST['category'])));
$fileyear = $db->safesql(strip_tags(trim($_POST['fileyear'])));
$link = $db->safesql(strip_tags(trim($_POST['link'])));
if ( trim( $runame ) != "" or $runame ){ $name = $runame; }
if ( trim( $enname ) != "" or $enname ){ $name = $enname; }
if( !$name ){$stop .= $lang_table['err_name'];}
if ( trim( $category ) == "" or ! $category ) {$stop .= $lang_table['orders_err_category'];}
if ( trim( $fileyear ) == "" or ! $fileyear ) {$stop .= $lang_table['err_year'];}
if (!is_numeric($fileyear)) {$stop .= $lang_table['err_year_type'];}
if( strlen( $runame ) > 40 ) {$stop .= '
' . $lang_table['orders_err_name'] . '';}
if( strlen( $fileyear ) > 4 ) {$stop .= '' . $lang_table['orders_err_year'] . '';}
if( strlen( $category ) > 20 ) {$stop .= '' . $lang_table['orders_err_category'] . '';}
if (intval($table_config['auto_wrap'])) {
$link = preg_split('((>)|(<))', $link, -1, PREG_SPLIT_DELIM_CAPTURE);
$n = count($link);
for ($i = 0; $i < $n; $i++) {
if ($link[$i] == "<") {
$i++;
continue;
}
$link[$i] = preg_replace("#([^\s\n\r]{" . intval($table_config['auto_wrap']) . "})#i", "\\1
", $link[$i]);
}
$link = join("", $link);
}
if ( $stop ) {
msgbox($lang['all_err_1'], "$lang[all_prev]");
} else {
$db->query("INSERT INTO " . PREFIX . "_table SET date='$_TIME', autor='$user_n', runame='$runame', enname='$enname', fileyear='$fileyear', category='$category'");
$cache->clear("toporders", $config['skin']);
if ( $table_config['msgs_adm'] == "yes" ) {
$step = 0;
$result = $db->query("SELECT user_id, name, email FROM " . USERPREFIX . "_users WHERE user_group = '$table_config[grouplevel]'");
$path = $config['http_home_url'];
$subject = $lang_table['msgs_subject'];
$user_from = $lang_table['msg_user_from'];
$message .= $runame . " / " . $enname . " ({$fileyear})";
$user_n = "" . $user_n . "";
$table_config['msgs_type0'] = stripslashes( html_entity_decode( $table_config['msgs_type0'] ) );
$table_config['msgs_type0'] = str_replace( "{%username_from%}", $user_n, $table_config['msgs_type0'] );
$table_config['msgs_type0'] = str_replace( "{%category%}", $category, $table_config['msgs_type0'] );
$table_config['msgs_type0'] = str_replace( "{%text%}", $message, $table_config['msgs_type0'] );
$table_config['msgs_type0'] = str_replace( "{%date%}", date("d.m.Y H:i:s", $_TIME), $table_config['msgs_type0'] );
$table_config['msgs_type0'] = str_replace( "{%ip%}", $_SERVER['REMOTE_ADDR'], $table_config['msgs_type0'] );
if ( $table_config['msgs_type'] == "0" ) {
while ($row = $db->get_row($result)) {
$db->query("INSERT INTO " . USERPREFIX . "_pm (subj, text, user, user_from, date, pm_read, folder) values ('$subject', '$table_config[msgs_type0]', '$row[user_id]', '$user_from', '$_TIME', 'no', 'inbox')");
$db->query("UPDATE " . USERPREFIX . "_users set pm_all=pm_all+1, pm_unread=pm_unread+1 WHERE user_id='$row[user_id]'");
$step++;
}
} else {
//$recipient = $db->super_query( "SELECT email FROM " . USERPREFIX . "_users WHERE user_group = '$table_config[grouplevel]'" );
include_once SYSTEM_DIR . '/classes/mail.class.php';
$mail = new dle_mail( $config, true );
$mail->from = $config['admin_mail'];
while ($recipient = $db->get_row($result)) {
$mail->send( $recipient['email'], $subject, $table_config['msgs_type0'] );
$step++;
}
if( $mail->send_error ) msgbox( $lang['all_info'], $mail->smtp_msg );
else die(header("Location: " . $_SERVER['PHP_SELF'] . '?do=table'));
}
$db->free($result);
}
$db->free();
die(header("Location: " . $_SERVER['PHP_SELF'] . '?do=table')); // commment line to Test $mail->send_error
}
} else {
if (!$is_logged) {
msgbox($lang['all_err_1'], "$lang_table[not_logged]");
} elseif ($is_doadd != true) {
msgbox($lang['all_err_1'], "$lang_table[one_orders]");
} else {
$tpl->load_template('table.tpl');
$tpl->set( '{description}', $lang_table['description2'] );
$tpl->set_block( "'\\[doadd\\](.*?)\\[/doadd\\]'si", "" );
$tpl->set( '[newadd]', "" );
$tpl->set( '[/newadd]', "" );
$category_s = explode(",", stripslashes($table_config['category']));
$category = "