Просмотр файла wap_snapshot/wap_post_works.php

Размер файла: 4.85Kb
<?php
session_start();
include('wap_common.php');


if(!isset($_SESSION['un']) || $_SESSION['un'] = ""){
    wapheader();
    start_card("id","Error");
    print("<p>You must be logged in to post</p>");
    print("<p>Hit the back button on your browser or login <a href=\"wap_login.php\">HERE</a></p>");
    end_card();
    print("</wml>");
}else{
    $forum = $HTTP_POST_VARS['forum'];
    $topic = $HTTP_POST_VARS['topic'];
    $poster = $_SESSION['id'];
    
    $op = $HTTP_POST_VARS['op'];
    
    switch($op){
        case "reply":
            wapheader();
            start_card("id","Post Reply");
            print("<p>");
	     	print("Subject: (Optional)<br/>");
	      	print("<input type=\"text\" name=\"subject\" /><br/>");
	      	print("Text: <br/>");
	      	print("<input type=\"text\" name=\"text\" size=\"256\"/><br/>");
	    	print("</p>");
            print("<do type=\"accept\" label=\"Submit Reply\">");
	      	print("<go method=\"post\" href=\"wap_post.php\">");
	        print("<postfield name=\"subject\" value=\"$(subject)\"/>");
	        print("<postfield name=\"text\" value=\"$(text)\"/>");
            print("<postfield name=\"op\" value=\"submitreply\"/>");
          	//print("<postfield name=\"login\" value=\"login\"/>");
          	print("<postfield name=\"forum\" value=\"$forum\"/>");
         	print("<postfield name=\"topic\" value=\"$topic\"/>");
          	print("<postfield name=\"uid\" value=\"$poster\"/>");
	      	print("</go>");
	    	print("</do>");		
	        break;
        case "new":
            wapheader();
            start_card("id","Post New Topic");
            print("<p>");
	     	print("Subject: (Required)<br/>");
	      	print("<input type=\"text\" name=\"subject\" /><br/>");
	      	print("Text: <br/>");
	      	print("<input type=\"text\" name=\"text\" size=\"256\"/><br/>");
	    	print("</p>");
            print("<do type=\"accept\" label=\"Submit New Post\">");
	      	print("<go method=\"post\" href=\"wap_post.php\">");
	        print("<postfield name=\"subject\" value=\"$(subject)\"/>");
	        print("<postfield name=\"text\" value=\"$(text)\"/>");
            print("<postfield name=\"op\" value=\"submitnew\"/>");
          	//print("<postfield name=\"login\" value=\"login\"/>");
          	print("<postfield name=\"forum\" value=\"$forum\"/>");
         	//print("<postfield name=\"topic\" value=\"$topic\"/>");
          	print("<postfield name=\"uid\" value=\"$poster\"/>");
	      	print("</go>");
	    	print("</do>");		
	        break;
        case "submitreply":
                $error="";
                $subject=$HTTP_POST_VARS['subject'];
                $posttext=$HTTP_POST_VARS['text'];
                $forum=$HTTP_POST_VARS['forum'];
                $topic=$HTTP_POST_VARS['topic'];
                $poster=$HTTP_POST_VARS['uid'];
                $time=time();
                $ip = getenv ("REMOTE_ADDR"); 
                $sql="INSERT INTO " . $TABLE_PREFIX . "posts ( topic_id, forum_id, poster_id, post_time, poster_ip, enable_sig, enable_smilies, enable_html, enable_bbcode, post_username) VALUES ($topic, $forum, $poster, $time, '$ip', 1,1,0,0,'')";
                if(!$db->sql_query($sql)){
                    $error="q0";
                    $ERR = $db->sql_error();
                 }
                $postid = $db->sql_nextid();
                $bbcode_uid = make_bbcode_uid();
                $sql="INSERT INTO " . $TABLE_PREFIX . "posts_text (post_id, post_subject, post_text, bbcode_uid, enable_bbcode) VALUES ($postid,'$subject','$posttext','$bbcode_uid',0)";
                if(!$db->sql_query($sql)){
                    $error="q2";
                    $ERR = $db->sql_error();
                 }
                $sql="SELECT topic_replies FROM ". $TABLE_PREFIX . "topics WHERE topic_id = '$topic'";
                $result=$db->sql_query($sql);
                if(!$result) {
                    $error="q3";
                    $ERR = $db->sql_error();
                 }
                $row=$db->sql_fetchrow($result);
                $numreplies=++$row['topic_replies'];
                $sql="UPDATE " . $TABLE_PREFIX . "topics SET topic_replies = $numreplies, topic_last_post_id = $postid WHERE topic_id = $topic";
                if(!$db->sql_query($sql)) {
                    $error="q4";
                    $ERR = $db->sql_error();
                 }
                wapheader();
                start_card("id","Posted");
                //print("<p>Post ID $postid Forum $forum Topic $topic Poster $poster Text $posttext subject $subject BBCodeUid $bbcode_uid IP $ip Time $time</p>");
                print("<p><a href=\"wap_index.php\">Main Menu</a></p>");
                print( $ERR['message'] . $ERR['code']);
            break;
       
       
       
    }
    end_card();
    print("</wml>");
 }           





?>