function show_post_list($thread_id)
 {
     global $g_user_id;
     $this->tpl->set_file('file_post_list', 'forum/tpl/forum_post_list.html', 1);
     $this->tpl->set_var('delete', '');
     $this->tpl->set_var('vip', '');
     $mas = $this->get_posts((int) $thread_id);
     $cnt = count($mas);
     $forum_info = $this->get_forum_by_thread($thread_id);
     $thread_info = $this->get_thread($thread_id);
     if ($cnt == 0) {
         return $this->userErr->Out("Tokios temos nëra.  Pasitikrinkit URL!");
     }
     if (empty($forum_info)) {
         return $this->userErr->Out("Forumo kuriai priklauso tema nebeegzistuoja. Gryþkit á forumø sàraðà.");
     }
     // apdorojam postu sarasa jei tuscia
     for ($x = 0; $x < $cnt; $x++) {
         $mas[$x]['body'] = do_ubb($mas[$x]['body'], "ForumLink");
         if (empty($mas[$x]['subject'])) {
             $mas[$x]['subject'] = $x != 0 ? '' : do_ubb(htmlspecialchars($mas[$x]['thread_name']));
         } else {
             $mas[$x]['subject'] = do_ubb(htmlspecialchars($mas[$x]['subject']));
         }
         $x == 0 ? $mas[$x]['first'] = '' : ($mas[$x]['first'] = '2');
         $x % 2 == 0 ? $mas[$x]['number'] = '' : ($mas[$x]['number'] = '2');
     }
     $this->add_hit($thread_id);
     $this->tpl->set_loop('list', $mas);
     $this->tpl->set_var('page_title', $forum_info['name']);
     $this->tpl->set_var('category_info_info', $forum_info['description']);
     $this->tpl->set_var('forum_id', $forum_info['id']);
     $this->tpl->set_var('thread_id', $thread_id);
     if ($this->is_admin()) {
         $this->tpl->set_var('delete', ' | <a href="page.simple;menuname.forum;forum.' . $forum_info['id'] . ";tid.{$thread_id};event.delete_thread\">trinti</a>");
         $vip_title = (int) $thread_info['vip'] == 0 ? 'normalus' : 'vip';
         $this->tpl->set_var('vip', 'Statusas: <a href="page.simple;menuname.forum;forum.' . $forum_info['id'] . ";tid.{$thread_id};event.viptoggle_thread\">{$vip_title}</a>");
     }
     if (!isset($this->user->id) || empty($this->user->id)) {
         $this->tpl->set_var('infotext', $this->tpl->process('PleaseLogin', 'PleaseLogin'));
     } else {
         if ($thread_info['vip'] == 1 && !$this->is_admin()) {
             $this->tpl->set_var('infotext', $this->tpl->process('PleaseLogin', 'VipThread'));
         } else {
             if ($this->post_error != '') {
                 $this->tpl->set_var('postext', htmlspecialchars(stripslashes($GLOBALS['subject'])));
                 $this->tpl->set_var('postbody', htmlspecialchars(stripslashes($GLOBALS['body'])));
                 $out = $this->userErr->Out($this->post_error);
                 $out .= '<br><br>';
                 $out .= $this->tpl->process('NewPost', 'NewPost');
                 $this->tpl->set_var('infotext', $out);
             } else {
                 $this->tpl->set_var('postext', 'Re: ' . strip_tags($mas[0]['thread_name']));
                 $this->tpl->set_var('postbody', '');
                 $this->tpl->set_var('infotext', $this->tpl->process('NewPost', 'NewPost'));
             }
         }
     }
     return $this->tpl->process('temp_out', 'file_post_list', 2);
 }
Example #2
0
 function event_news_submit()
 {
     global $url, $subject, $info, $text, $category, $keywords, $g_user_id;
     if (empty($subject)) {
         $this->error = 'reikia antraðtës<br>';
     }
     if (empty($category)) {
         $this->error .= 'reikia temos<br>';
     }
     if (empty($info)) {
         $this->error .= 'reikia santraukos<br>';
     }
     if (!isset($g_user_id)) {
         $this->error .= 'reikia prisijungti prie sistemos<br>';
     }
     if ($this->error) {
         return true;
     }
     $mail_text = "\n\t\t\n{$subject}\n{$info} \nhttp://art.scene.lt/control/\n\t\t\n    \n    ";
     $info = do_ubb($info);
     $text = do_ubb($text);
     $subject = htmlchars($subject);
     $this->db->query("INSERT INTO avnews (subject, info, full_text, posted, visible, category_id, submiter, keywords) \n\t\t\tVALUES ('{$subject}', '{$info}', '{$text}', NOW(), 0, {$category}, {$g_user_id}, '{$keywords}')");
     $this->result = 'ok';
     mail("*****@*****.**", 'art.scene atsiusta naujiena', $mail_text, "MIME-Version: 1.0\nContent-Type: text/plain; charset=Windows-1257\nContent-Transfer-Encoding: 8bit\nFrom: art.scene automatas <*****@*****.**>\n");
     return true;
 }
 function pickup_submit()
 {
     avControl::pickup_submit();
     $this->value = do_ubb($this->value);
 }
 /**
  * kvieciama komentuojant darba
  */
 function event_work_comment()
 {
     global $url, $subject, $comment, $parent_id, $g_user_id, $g_usr, $g_tpl;
     if (empty($comment)) {
         $this->error .= 'tuðèias komentaras<br>';
     }
     if (empty($parent_id)) {
         $this->error .= 'neþinomas darbas<br>';
     }
     if (empty($g_user_id)) {
         $this->error .= 'reikia prisijungti prie sistemos<br>';
     }
     if (!$g_usr->can_i_comment()) {
         $this->error .= 'ðiuo metu negali komentuoti';
     }
     if ($this->error) {
         return true;
     }
     $comment = do_ubb($comment);
     $comment = smartWrap($comment, 30);
     // [alias] skaidom ilgus piktybiðkus þodþius
     $subject = htmlchars($subject);
     // patikrinam kad nebutu netyciom dubliu
     $this->db->query("SELECT * FROM avcomments\n\t\t\tWHERE table_name='{$this->table}' AND parent_id={$parent_id} AND subject='{$subject}' AND info='{$comment}' LIMIT 1");
     if ($this->db->not_empty()) {
         $this->error .= 'nesiøsk dukart<br>';
     }
     if ($this->error) {
         return true;
     }
     $this->db->query("INSERT INTO avcomments (subject, info, posted, parent_id, table_name, user_id) \n\t\t\tVALUES ('{$subject}', '{$comment}', NOW(), {$parent_id}, '{$this->table}', {$g_user_id})");
     $this->db->query("UPDATE avworks_stat SET comment_count = comment_count + 1 WHERE work_id={$parent_id}");
     $this->db->clear_cache_tables('avcomments');
     // siunciam meila autoriui
     $work = $this->db->get_array("SELECT * FROM avworks WHERE id='{$parent_id}'");
     $author = $work['submiter'];
     $user_info = $this->db->get_array("SELECT * FROM u_user_info WHERE uid='{$author}'");
     $this->db->clear_cache_name('workcomments');
     if ($user_info['mail_comments'] && $author != $g_user_id) {
         $user = $this->db->get_array("SELECT * FROM u_users WHERE id='{$author}'");
         $g_tpl->set_file('comment', 'darbai/tpl/mail_comment.txt');
         $g_tpl->set_var('id', $parent_id);
         $g_tpl->set_var('work_title', $work['subject']);
         $g_tpl->set_var('title', $subject);
         $g_tpl->set_var('username', $g_usr->username);
         $g_tpl->set_var('info', undo_ubb($comment));
         $g_tpl->set_var('date', date('Y.m.d'));
         mail($user['email'], 'komentaras apie tavo darbà', $g_tpl->process('', 'comment'), "MIME-Version: 1.0\nContent-Type: text/plain; charset=Windows-1257\nContent-Transfer-Encoding: 8bit\nFrom: art.scene automatas <*****@*****.**>\n", "*****@*****.**");
     }
     redirect($url);
 }
 function event_send_message()
 {
     global $url, $subject, $comment, $parent_id, $g_user_id, $g_usr, $g_tpl;
     if (empty($g_user_id)) {
         $this->error .= 'reikia prisijungti prie sistemos<br>';
     }
     if ($this->error) {
         return true;
     }
     $comment = do_ubb($comment);
     $subject = htmlchars($subject);
     $this->db->query("INSERT INTO avcomments (subject, info, posted, parent_id, table_name, user_id, new) \n\t\t\tVALUES ('{$subject}', '{$comment}', NOW(), {$parent_id}, 'u_users', {$g_user_id}, 1)");
     // siunciam meila autoriui
     $user_info = $this->db->get_array("SELECT * FROM u_user_info WHERE uid='{$parent_id}'");
     if ($user_info['mail_comments']) {
         $user = $this->db->get_array("SELECT * FROM u_users WHERE id='{$parent_id}'");
         $g_tpl->set_file('comment', 'users/tpl/mail_message.txt');
         $g_tpl->set_var('title', $subject);
         $g_tpl->set_var('username', $g_usr->username);
         $g_tpl->set_var('user_id', $g_user_id);
         $g_tpl->set_var('info', undo_ubb($comment));
         $g_tpl->set_var('date', date('Y.m.d'));
         mail($user['email'], "asmeninë þinutë nuo {$g_usr->username}", $g_tpl->process('', 'comment'), "MIME-Version: 1.0\nContent-Type: text/plain; charset=Windows-1257\nContent-Transfer-Encoding: 8bit\nFrom: art.scene automatas <*****@*****.**>\n", "*****@*****.**");
     }
     redirect($url);
 }
 function event_work_submit()
 {
     global $url, $subject, $info, $work, $category, $thumbnail, $color, $g_user_id, $g_usr, $g_tpl;
     if (empty($subject)) {
         $this->error = 'reikia pavadinimo<br>';
     }
     if (empty($category)) {
         $this->error .= 'reikia kategorijos<br>';
     }
     $work = $_FILES['work'];
     if (empty($work) || 'none' == $work) {
         $this->error .= 'reikia atsiøsti darbà<br>';
     }
     if (!isset($g_user_id)) {
         $this->error .= 'reikia prisijungti prie sistemos<br>';
     }
     if ($error = $this->check_cannot_post()) {
         $this->error .= $error;
     }
     if ($this->error) {
         return true;
     }
     $work_name = $_FILES['work']['name'];
     $work_size = $_FILES['work']['size'];
     $work_types = array('gif', 'jpg', 'png', 'swf');
     $work_type = substr($work_name, strlen($work_name) - 3, 3);
     if (!in_array(strtolower($work_type), $work_types)) {
         $this->error .= 'blogas darbo failas, gali bûti tik .jpg, .gif, .png, .swf<br>';
     }
     if ($thumbnail != '' && $thumbnail != 'none') {
         $thumb_name = $_FILES['thumbnail']['name'];
         $thumb_size = $_FILES['thumbnail']['size'];
         $thumb_types = array('gif', 'jpg', 'png');
         $thumb_type = substr($thumb_name, strlen($thumb_name) - 3, 3);
         if (!in_array(strtolower($thumb_type), $thumb_types)) {
             $this->error .= 'blogas maþas paveiksliukas, gali bûti tik .jpg, .gif, .png<br>';
         }
     }
     if ($work_size < 10240) {
         $this->error .= 'per maþas darbo failas, limitas 10kb<br>';
     }
     if ($this->flash_category != $category && $work_size > 30720000) {
         $this->error .= 'per didelis darbo failas, limitas 300kb<br>';
     }
     if ($this->error) {
         return true;
     }
     // kopijuojam darba!
     $work_name = clean_name($work_name);
     $work_dest = $this->ini->read_var('avworks', 'works_dir') . $work_name;
     while (file_exists($work_dest)) {
         $work_name = "_" . $work_name;
         $work_dest = $this->ini->read_var('avworks', 'works_dir') . $work_name;
     }
     $work = $_FILES['work']['tmp_name'];
     copy($work, $work_dest);
     unlink($work);
     // gaminam thumbnaila
     // jei ok dedam atsiusta thumbnail
     if ($thumbnail != 'none') {
         // vadinam taip pat kaip darba, kad nereiktu tikrinti dublikatu
         $thumbnail = $_FILES['thumbnail']['tmp_name'];
         $thumb_dest = $this->ini->read_var('avworks', 'thumbnails_dir') . $work_name . '.jpg';
         $exec_src = $this->ini->read_var('avworks', 'convert_exec') . " -resize " . $this->thumb_x . "x" . $this->thumb_y . " {$thumbnail} jpg:{$thumb_dest}";
         exec($exec_src);
         $thumbnail_name = $work_name . '.jpg';
         if (!file_exists($thumb_dest)) {
             //galbut animuotas gifas? padarom pirma kadra
             if (file_exists($thumb_dest . '.0')) {
                 $this->error = '';
                 rename($thumb_dest . '.0', $thumb_dest);
             } else {
                 $this->error .= 'nepavyko padaryti maþo paveiksliuko<br>';
             }
         } else {
             $this->error = '';
         }
     }
     // jei problemos, gaminam is atsiusto darbo
     if (($thumbnail == 'none' || $this->error) && $category != $this->flash_category) {
         // vadinam taip pat kaip darba, kad nereiktu tikrinti dublikatu
         $thumb_dest = $this->ini->read_var('avworks', 'thumbnails_dir') . $work_name . '.jpg';
         $exec_src = $this->ini->read_var('avworks', 'convert_exec') . " -resize " . $this->thumb_x . "x" . $this->thumb_y . " {$work_dest} jpg:{$thumb_dest}";
         exec($exec_src);
         $thumbnail_name = $work_name . '.jpg';
         if (!file_exists($thumb_dest)) {
             //galbut animuotas gifas? padarom pirma kadra
             if (file_exists($thumb_dest . '.0')) {
                 $this->error = '';
                 rename($thumb_dest . '.0', $thumb_dest);
             } else {
                 $this->error .= 'nepavyko padaryti maþo paveiksliuko<br>';
             }
         } else {
             $this->error = '';
         }
     } elseif ($this->error) {
         $this->error .= 'nepavyko padaryti maþo paveiksliuko<br>';
     }
     // jei problemos, dedam default
     if ($this->error || empty($thumbnail_name)) {
         $thumbnail_name = 'nothumbnail.gif';
     }
     isset($color) || ($color = '');
     isset($info) || ($info = '');
     //wordwrap($comment, 30, " ", true) // senas variantas
     //smartWrap($text,30); // naujas variantas
     $info = smartWrap(do_ubb($info), 30);
     $subject = wordwrap(htmlchars($subject), 20, " ", true);
     // cia html'o nebus, todel standartinis wordwrap
     $color = clean_hex($color);
     $this->db->query("INSERT INTO avworks (subject, info, posted, thumbnail, file, submiter, category_id, color, file_size)\n\t\t\t\t\t\t\tVALUES ('{$subject}', '{$info}', NOW(), '{$thumbnail_name}', '{$work_name}', {$g_user_id}, {$category}, '{$color}', {$work_size})");
     // TODO: update avworks_stat
     $last_id = $this->db->get_insert_id();
     $this->db->query("insert into avworks_stat \n  (work_id, subject, info, posted, thumbnail, file, submiter, category_id, \n  views, color, file_size, submiter_name, category_name) \nselect w.id, w.subject, w.info, w.posted, w.thumbnail, w.file, w.submiter, w.category_id, \n  w.views, w.color, w.file_size, \n  u.username, c.name from avworks w, u_users u, avworkcategory c\nwhere w.submiter = u.id AND c.id = w.category_id AND w.id={$last_id}");
     $g_tpl->set_file('new_work', 'darbai/tpl/mail_new_work.txt');
     $g_tpl->set_var('id', $this->db->get_insert_id());
     $g_tpl->set_var('title', $subject);
     $g_tpl->set_var('username', $g_usr->username);
     $g_tpl->set_var('info', undo_ubb($info));
     $g_tpl->set_var('date', date('Y.m.d'));
     $this->db->clear_cache_tables('avworks');
     // $g_usr->mass_mail('art.scene naujas darbas', $g_tpl->process('temp', 'new_work'), 'mail_works');
     $this->result = true;
     return true;
 }