Blog()

From Hack Wars Wiki

Jump to: navigation, search

What you need for this to work:

Contents

Site Editor

Enter the following code into Site editor.

<script>
function hideElementsByClass(className)
{
	var all = document.all ? document.all : document.getElementsByTagName('div');
	for (var e = 0; e < all.length; e++)
	if (all[e].className == className)
	all[e].style.display = "none";
	return;
}
 
function show(divName)
{
	var page=document.getElementById(divName);
	hideElementsByClass(page.className);
	page.style.display = "block";
	return true;
}
</script>
<table border="3" bgcolor="red">
<tr>
<td><a onclick="return show('home')">Home</a></td> //You can change this line to <a href=""></a> if you want.
<td><a onclick="return show('TheBlog')">Blog</a></td>
</tr>
</table>
<div class="page" id="home">
//Home stuff here.
</div>
<div class="page" id="TheBlog">
<?Blog?>
</div>

Text Files

Blogs

Create a text file and save it as Blogs.

blog

Create a textfile that holds most of the content of the blog and save it as blog.

<h1><center>Blogs</center></h1>
<?Blogs?>
<hr />
<?newpost?>

newpost

Create a text file named newpost and enter the following:

<b>Note: To edit blogs posts, make note of blog name for me and tell me what the new content is, must have valid reason. Signed: Website Admin
<br />
Note: To remove blogs, please notify the admin with the blog name of the blog you want to remove, must have valid reason. Sign: Website Admin
</b>
<br />
<form name="MainForm2">
Title: <input type="text" name="BlogTitle" />
<br />
<textarea cols="240" name="TextBlog"></textarea>
<br />
<input type="radio" name="RadioAction2" value="SaveB" /> Save post.
<br />
<input type="submit" name="Saver" value="Save Blog" />
<input type="reset" />
</form>

HTTP

Enter

int main(){
    string visitor = getVisitorIP();
    string host = getHostIP();
    string blogs = "Blogs";
    string blists[];
    blists[1] = host;
    if(fileExists("blog")){
        replace("Blog",readFile("blog"));
        replace(blogs,readFile(blogs));
        int bline;
        for(bline=0;bline<3;bline++){
            if(visitor==blists[bline]){
                replace("newpost",readFile("newpost"));
            }
        }
    }
}

Submit

string getp(string variablename){
    return getParameter(variablename);
}


void savepage(string filename,string content){
    writeFile(filename,content);
}


void Log(string logmess){
    logMessage(logmess);
}


void SaveBlog(string adminlog,string poster){
    string logcon = "Post added by "+poster;
    string blogcont = readFile(blogs);
    string title=getp("BlogTitle");
    if(title!=""){
	    string date = getDate();
	    string time = getTime();
        string blogbody = getp("TextBlog");
        if(blogbody!=""){
		    string blogdat="<hr />"+char(10)+"<h2><center>"+title+"</center></h2>"+char(10)+blogbody+char(10)+"<br />"+char(10)+"Posted by "+poster+" at "+time+" "+date+char(10);	    
	        string newblogcont = blogdat+""+blogcont;
		    writeFile(blogs,newblogcont);
		    LogtoFile(adminlog,logcon);
		    replace("statusstuff","Updated blog.");
	    }
    }
}


void LogtoFile(string logname,string logmessage){
    Log(logmessage);
    string date = getDate();
    string time = getTime();
    string logmese = "["+date+"-"+time+"] "+logmessage;
    if(fileExists(logname)){
	    writeLine(logname,logmese);
	}else{
	    savepage(logname,logmese);
	    writeLine(logname,"");
	}
}


int main(){
    string visitor = getVisitorIP();
    string host = getHostIP();
    string blogs = "Blogs";
    string blists[];
    blists[1] = host;
    string radioaction2 = getp("RadioAction2");
    if(radioaction2!=""){
        int bline;
        for(bline=0;bline<2;bline++){
            if(visitor==blists[bline]){
                SaveBlog("BlogLog",visitor);
            }
        }
    }
}
Personal tools