Just nu i M3-nätverket
Jump to content

Problem med script


idontknow

Recommended Posts

Hej !

Vet inte om detta är den rätta forumet för denna fråga? Eller om den skulle vara i webdesign eller Mysql. Har hittat ett litet blogg script skrivet i php och mysql. Problemet är det att när jag skriver bokstaven å i bloggen så visas teckenkoden för å istället (å eller ;Å) när det sedan skrivs ut i bloggen. Också i databasen ligger teckenkoden istället för bokstaven. är det scriptet som inte kan hantera å för ö och ä fungerar utmärkt. Skulle vara mycket tacksam för hjälp för scriptet passar mitt användningsområde perfekt.

Bifogar scriptet om någon orkar titta på det.

[log]

 

<?

ini_set("error_reporting", E_ALL);

ini_set("display_errors", "Off");

 

$config_file = "config.php";

include "{$config_file}";

$version = "1.0 RC-8";

 

$session_name = $blog_password . $mysql_table;

 

session_start();

 

require "inc/functions.php";

 

function Protect($string) {

$string = mysql_escape_string(strip_tags(htmlspecialchars($string)));

return $string;

}

 

foreach ($_GET as $name => $value) {

$_GET[$name] = Protect($value);

}

 

foreach ($_POST as $name => $value) {

if ($name != "user_name" && $name != "blog_name" && $name != "blog_description") {

$_POST[$name] = Protect($value);

} else {

$_POST[$name] = stripslashes(htmlspecialchars($value));

}

}

 

if ($_GET['language'] != "") {

$one_year = time() + 31536000;

setcookie("microbloglang", $_GET['language'], $one_year);

$_COOKIE['microbloglang'] = $_GET['language'];

}

 

 

if ($_COOKIE['microbloglang'] == "" AND $_GET['language'] == "") {

if ($blog_language == "") {

$set_language = "english";

} else {

$set_language = $blog_language;

}

$_COOKIE['microbloglang'] = $set_language;

}

 

include "inc/{$_COOKIE['microbloglang']}.lng";

 

// logout

 

if ($_GET['logout'] == "1") {

unset($_SESSION[$session_name]);

}

 

// change style and default language

 

if ($_POST['action'] == $lang['change'] AND $_GET['login'] == "1" AND $_SESSION[$session_name] == "1" AND $lang['change'] != "") {

 

$config = "<?\n\$mysql_server = \"" . $mysql_server . "\";" .

"\n\$mysql_database = \"" . $mysql_database . "\";" .

"\n\$mysql_username = \"" . $mysql_username . "\";" .

"\n\$mysql_password = \"" . $mysql_password . "\";" .

"\n\$mysql_table = \"" . $mysql_table . "\";" .

"\n\$blog_name = \"" . $_POST['blog_name'] . "\";" .

"\n\$blog_description = \"" . $_POST['blog_description'] . "\";" .

"\n\$blog_username = \"" . $blog_username . "\";" .

"\n\$blog_password = \"" . $blog_password . "\";" .

"\n\$user_name = \"" . $_POST['user_name'] . "\";" .

"\n\$blog_script = \"" . $blog_script . "\";" .

"\n\$blog_style = \"" . $_POST['style'] . "\";" .

"\n\$blog_language = \"" . $_POST['default_language'] . "\";" .

"\n\$num_posts = \"" . $_POST['num_posts'] . "\";" .

"\n?>";

 

if (!$fp = fopen($config_file, "w")) {

$error = true;

}

if (fwrite($fp, $config) === false) {

$error = true;

}

if (!fclose($fp)) {

$error = true;

}

 

if ($error === true) {

print_content("{$lang['non_writable_config1']} <b>{$config_file}</b> {$lang['non_writable_config2']}");

} else {

$blog_style = $_POST['style'];

}

}

 

// reload settings

 

include "{$config_file}";

 

//

 

if ($num_posts == "") { $num_posts = "10"; }

 

// default style

 

if ($blog_style == "") { $blog_style = "MarkoBlue"; }

 

function template($transform, $into, $filename) {

 

global $blog_style;

 

$filename = "styles/{$blog_style}/{$filename}.htm";

 

if(!$fd = fopen($filename, "r")) {

print_content("{$lang['template_error']}");

} else {

$template = fread($fd, filesize ($filename));

 

fclose ($fd);

$template = stripslashes($template);

for ($i = 0; $i < count ($transform); $i++) {

$template = str_replace($transform[$i], $into[$i], $template);

}

 

 

return $template;

 

}

}

 

 

 

function print_content($content, $no_container) {

 

global $config_file;

include "{$config_file}";

 

global $version;

 

if ($blog_name == "") {

$blog_name = "&mu;Blog " . $version;

}

 

include "inc/{$_COOKIE['microbloglang']}.lng";

 

$find = array("{blog_name}","{blog_index.php}","{blog_description}");

$replace = array($blog_name,$blog_script,$blog_description);

 

$header = template($find, $replace, "_template_header_");

 

$find = array("{lang_valid_xhtml}","{lang_valid_css}","{lang_valid_rss}");

$replace = array($lang['valid_xhtml'],$lang['valid_css'],$lang['valid_rss']);

 

$footer = template($find, $replace, "_template_footer_");

 

include "inc/{$_COOKIE['microbloglang']}.lng";

 

print $header;

 

if ($no_container == "") { print "\n<div class=\"container\">"; }

 

print $content;

 

if ($no_container == "") { print "\n</div>\n"; } else { print "\n"; }

 

print $footer;

 

exit;

 

}

 

 

// config file does not exists - start setup

 

if (filesize($config_file) == 0 || !file_exists($config_file)) {

 

$error = false;

 

if (!$fp = fopen($config_file, "w")) {

$error = true;

}

if (fwrite($fp, "") === false) {

$error = true;

}

if (!fclose($fp)) {

$error = true;

}

 

if ($error === true) {

 

print_content("{$lang['non_writable_config1']} <b>{$config_file}</b> {$lang['non_writable_config2']}");

 

} else {

$setup_mode = true;

}

 

$setup_content = "<form action=\"?setup=1\" method=\"post\">

<b>{$lang['welcome']}</b><br/><br/>{$lang['language']}: ";

 

 

if ($handle = opendir("inc")) {

// List all the files

while (false !== ($file = readdir($handle))) {

if (substr($file, strlen($file)-3, 3) == "lng") {

$lng_name = substr($file, 0, strlen($file)-4);

$lng_label = strtoupper($file{0}) . substr($file, 1, strlen($file)-5);

$setup_content = $setup_content . "<a href=\"?language={$lng_name}\">{$lng_label}</a> | ";

}

}

closedir($handle);

}

 

$setup_content = $setup_content . "

<br/><br/>

<div class=\"infoSection\">{$lang['database_info']}</div>

{$lang['database_req']}<br/><br/>

{$lang['mysql_server_address']}: <input type=\"text\" name=\"mysql_server\" size=\"25\" value=\"localhost\"/><br/>

{$lang['mysql_server_database']}: <input type=\"text\" name=\"mysql_database\" size=\"25\"/><br/>

{$lang['mysql_server_username']}: <input type=\"text\" name=\"mysql_username\" size=\"25\"/><br/>

{$lang['mysql_server_password']}: <input type=\"password\" name=\"mysql_password\" size=\"25\"/><br/>

{$lang['mysql_server_table']}: <input type=\"text\" name=\"mysql_table\" size=\"25\" value=\"microblog\"/><br/>

{$lang['upgrade']}: <input type=\"checkbox\" name=\"upgrade\" value=\"yes\"/><br/>

 

<div class=\"infoSection\">{$lang['blog_info']}</div>

{$lang['blog_name']}: <input type=\"text\" name=\"blog_name\" size=\"30\"/><br/>

{$lang['blog_decription']}: <input type=\"text\" name=\"blog_description\" size=\"50\"/><br/>

{$lang['choose_an_username']}: <input type=\"text\" name=\"blog_username\" size=\"25\"/><br/>

{$lang['choose_a_password']}: <input type=\"password\" name=\"blog_password\" size=\"25\"/><br/>

{$lang['your_name']}: <input type=\"text\" name=\"user_name\" size=\"30\"/><br/>

 

<br/><br/><input type=\"submit\" value=\"{$lang['continue']}\"/>

</form>";

 

if ($setup_mode === true && $_GET['setup'] != "1") {

print_content($setup_content);

}

 

if ($_GET['setup'] == "1") {

if ($_POST['mysql_server'] == "" || $_POST['mysql_database'] == "" || $_POST['mysql_username'] == "" || $_POST['mysql_table'] == "") {

print_content("{$lang['missing_info']}");

}

if ($_POST['blog_name'] == "" || $_POST['blog_description'] == "" || $_POST['blog_username'] == "" || $_POST['blog_password'] == "") {

print_content("{$lang['missing_info']}");

}

 

mysql_connect($_POST['mysql_server'],$_POST['mysql_username'],$_POST['mysql_password']);

@mysql_select_db($_POST['mysql_database']) or print_content( "{$lang['database_error']}");

 

// write config file:

 

 

$config = "<?\n\$mysql_server = \"" . $_POST['mysql_server'] . "\";" .

"\n\$mysql_database = \"" . $_POST['mysql_database'] . "\";" .

"\n\$mysql_username = \"" . $_POST['mysql_username'] . "\";" .

"\n\$mysql_password = \"" . $_POST['mysql_password'] . "\";" .

"\n\$mysql_table = \"" . $_POST['mysql_table'] . "\";" .

"\n\$blog_name = \"" . $_POST['blog_name'] . "\";" .

"\n\$blog_description = \"" . $_POST['blog_description'] . "\";" .

"\n\$blog_username = \"" . $_POST['blog_username'] . "\";" .

"\n\$blog_password = \"" . md5($_POST['blog_password']) . "\";" .

"\n\$user_name = \"" . $_POST['user_name'] . "\";" .

"\n\$blog_script = \"index.php\";" .

"\n\$blog_style = \"MarkoBlue\";" .

"\n\$blog_language = \"english\";" .

"\n\$num_posts = \"10\";" .

"\n?>";

 

$error = false;

 

 

// create table

 

$mysql_table = $_POST['mysql_table'];

 

if ($_POST['upgrade'] == "") {

 

$query = "CREATE TABLE `{$mysql_table}` ( `title` VARCHAR( 255 ) ,"

. ' `text` TEXT ,'

. ' `comment` VARCHAR( 255 ) ,'

. ' `timestamp` DATETIME ,'

. ' `section` VARCHAR( 255 ) ,'

. ' `hide` VARCHAR( 6 ) ,'

. ' `nocomments` VARCHAR( 6 ) ,'

. ' `email` VARCHAR( 255 ) ,'

. ' `other1` VARCHAR( 255 ) ,'

. ' `other2` VARCHAR( 255 ) ,'

. ' `id` INT( 6 ) NOT NULL auto_increment,'

. ' PRIMARY KEY (id));';

 

$result = mysql_query($query);

 

} else {

 

$result = true;

 

}

 

if (!$result) {

print_content("{$lang['mysql_error']}: " . mysql_error());

} else {

 

if (!$fp = fopen($config_file, "w")) {

$error = true;

}

if (fwrite($fp, $config) === false) {

$error = true;

}

if (!fclose($fp)) {

$error = true;

}

 

if ($error === true) {

 

print_content("{$lang['non_writable_config1']} <b>{$config_file}</b> {$lang['non_writable_config2']}");

 

} else {

 

print_content("{$lang['configuration_completed']} <a href=\"{$blog_script}\">{$lang['click_here']}</a>");

 

}

 

}

 

}

 

 

exit;

}

 

 

 

$login_content = "<div class=\"infoSection\">{$lang['login']}</div>

<form action=\"?login=2\" method=\"post\">

{$lang['username']}: <input type=\"text\" name=\"username\" size=\"25\"/><br/>

{$lang['password']}: <input type=\"password\" name=\"password\" size=\"25\"/><br/>

 

<br/><br/><input type=\"submit\" value=\"{$lang['login']}\"/>

</form>";

 

 

if ($_GET['login'] == "1" AND $_SESSION[$session_name] != "1") {

 

print_content("{$lang['login_to_continue']}" . $login_content);

 

}

 

if ($_GET['login'] == "2" AND $_SESSION[$session_name] != "1") {

 

if ($_POST['username'] == $blog_username && md5($_POST['password']) == $blog_password) {

 

$_SESSION[$session_name] = "1";

 

} else {

print_content("{$lang['wrong_username_or_password']}" . $login_content);

}

 

}

 

 

// user is logged in

 

if ($_SESSION[$session_name] == "1") {

if ($_GET['login'] == "1" || $_GET['login'] == "2") {

 

mysql_connect($mysql_server,$mysql_username,$mysql_password);

@mysql_select_db($mysql_database) or print_content( "{$lang['database_error']}");

 

if ($_GET['edit'] == "1") {

 

$query = "SELECT * FROM {$mysql_table} WHERE id = '{$_GET['id']}';";

$result = mysql_query($query);

$num = mysql_numrows($result);

 

if ($num != "1") { print_content("{$lang['does_not_exist']}"); }

 

$edit_title = stripslashes(mysql_result($result,"0","title"));

$edit_text = stripslashes(mysql_result($result,"0","text"));

$edit_section = stripslashes(mysql_result($result,"0","section"));

$edit_comment = stripslashes(mysql_result($result,"0","comment"));

$edit_email = stripslashes(mysql_result($result,"0","email"));

 

$edit_hide = stripslashes(mysql_result($result,"0","hide"));

$edit_nocomments = stripslashes(mysql_result($result,"0","nocomments"));

 

$edit_query = "&edit=1&id={$_GET['id']}";

 

}

 

 

 

$query = "SELECT DISTINCT section FROM {$mysql_table} WHERE comment = '' AND section NOT LIKE '_microblog%';";

$result = mysql_query($query);

$num = mysql_numrows($result);

 

$num_plus_one = $num + 1;

 

if ($_GET['edit'] != "1") {

 

$text_top = "{$lang['post_new_entry']}";

 

} else {

 

if ($edit_comment == "") {

$text_top = "{$lang['edit_post']}";

$text_bottom = "{$lang['delete_post']}";

} else {

$text_top = "{$lang['edit_comment']}";

$text_bottom = "{$lang['delete_comment']}";

}

 

}

 

 

$post_content = "

 

<script language=\"JavaScript\">

 

function NewSection() {

 

if (document.blog.section.value == '{$lang['new_section_label']}') {

 

var new_section = prompt (\"{$lang['new_section_prompt']}\",\"\")

 

document.blog.section.options[{$num_plus_one}] = new Option(new_section,new_section);

document.blog.section.options[{$num_plus_one}].selected = true;

 

 

}

 

}

 

</script>

 

<br/><div class=\"infoSection\">{$text_top}</div>

<form action=\"?login=1{$edit_query}\" method=\"post\" name=\"blog\">

{$lang['title']}: <br/><input type=\"text\" name=\"title\" class=\"inputTitle\" size=\"80\" value=\"{$edit_title}\"/><br/><br/>

 

<input type=\"button\" value=\"b\" style=\"width:50px;font-weight:bold\" onclick=\"tag('b');\">

<input type=\"button\" value=\"i\" style=\"width:50px;font-style:italic\" onclick=\"tag('i');\">

<input type=\"button\" value=\"u\" style=\"width:50px;text-decoration:underline\" onclick=\"tag('u');\">

<input type=\"button\" value=\"quote\" style=\"width:50px\" onclick=\"tag('quote');\">

<input type=\"button\" value=\"code\" style=\"width:50px\" onclick=\"tag('code');\">

<input type=\"button\" value=\"url\" style=\"width:50px\" onclick=\"tag('url');\">

<input type=\"button\" value=\"img\" style=\"width:50px\" onclick=\"tag('img');\"><br/>

 

{$lang['text']}: <br/><textarea name=\"text\" cols=\"60\" rows=\"15\">{$edit_text}</textarea><br/>";

 

 

if ($edit_comment == "") {

 

$post_content = $post_content . "{$lang['section']}: <select name=\"section\" onChange=\"javascript:NewSection();\"><option ";

 

if ($_GET['edit'] != "1") {

$post_content = $post_content . "selected='selected' ";

}

 

$post_content = $post_content . "value=''></option>";

 

for ($i = 0; $i < $num; $i++) {

 

$section = stripslashes(mysql_result($result,$i,"section"));

 

if ($section != "" AND $section != "_microblog_link_") {

 

if ($edit_section != "" && $edit_section == $section) {

$post_content = $post_content . "\n<option selected='selected' value='{$section}'>{$section}</option>";

} else {

$post_content = $post_content . "\n<option value='{$section}'>{$section}</option>";

}

 

}

 

}

 

$post_content = $post_content . "<option value='{$lang['new_section_label']}'>{$lang['new_section_label']}</option></select>";

 

 

// if ($edit_comment == "")

 

} else {

 

$post_content = $post_content . "{$lang['name']}: <br/><input type=\"text\" name=\"section\" size=\"30\" value=\"{$edit_section}\"/><br/>

{$lang['email']}: <br/><input type=\"text\" name=\"email\" size=\"30\" value=\"{$edit_email}\"/><br/>

";

 

}

 

// hide this post from the front page / don't allow this post to be commented

 

if ($edit_comment == "") {

if ($edit_hide != "") { $checked_hide = " checked='checked'"; }

if ($edit_nocomments != "") { $checked_nocomments = " checked='checked'"; }

 

$post_content = $post_content . "<br/><input type='checkbox'{$checked_hide} name='hide' value='yes'/> {$lang['hide']}";

$post_content = $post_content . "<br/><input type='checkbox'{$checked_nocomments} name='nocomments' value='yes'/> {$lang['do_not_allow_comments']}<br/>";

}

 

if ($_GET['edit'] == "1") {

 

$post_content = $post_content . "<br/><input type='checkbox' name='delete' value='yes'/> {$text_bottom}";

 

}

 

if ($_GET['edit'] != "1") { $button = "{$lang['post']}"; } else { $button = "{$lang['save']}"; }

 

$post_content = $post_content . "<br/><br/><input type=\"submit\" value=\"{$button}\"/>

</form>";

 

if ($_POST['title'] == "" || $_POST['text'] == "") {

 

if ($_GET['post'] == "1" || $_GET['edit'] == "1") {

 

print_content($post_content);

 

} else {

 

mysql_connect($mysql_server,$mysql_username,$mysql_password);

@mysql_select_db($mysql_database) or print_content( "{$lang['database_error']}");

 

if ($_GET['remove'] != "") {

$query = "DELETE FROM {$mysql_table} WHERE id = '{$_GET['remove']}';";

mysql_query($query);

}

 

$admin_menu = "<b>{$lang['microblog_administration']}</b><form action=\"?login=1\" method=\"post\">

<br/><div class=\"infoSection\">{$lang['post_edit']}</div>

<a href=\"?login=1&amp;post=1\">{$lang['post_new']}</a><br/><br/>

{$lang['edit_entry_how1']} <a href=\"{$blog_script}\">{$lang['front_page']}</a> {$lang['edit_entry_how2']}<br/>

<a href=\"?viewall=1\">{$lang['view_all']}</a><br/>

<div class=\"infoSection\">{$lang['links_section']}</div>";

 

 

$query = "SELECT * FROM {$mysql_table} WHERE section = '_microblog_link_' ORDER BY id ASC;";

$result = mysql_query($query);

$num = mysql_numrows($result);

 

for ($i = 0; $i < $num; $i++) {

$link_name = stripslashes(mysql_result($result,$i,"title"));

$link_url = stripslashes(mysql_result($result,$i,"text"));

$link_id = stripslashes(mysql_result($result,$i,"id"));

 

$admin_menu = $admin_menu . "\n<b>{$link_name}</b> ({$link_url}) <a href=\"?login=1&amp;remove={$link_id}\">{$lang['remove']}</a><br/>";

}

 

 

$admin_menu = $admin_menu . "<br/>

{$lang['link_name']}: <input type=\"text\" name=\"title\" size=\"25\"/><br/>

{$lang['link_URL']}: <input type=\"text\" name=\"text\" size=\"25\"/><br/>

<input type=\"hidden\" name=\"section\" value=\"_microblog_link_\" size=\"25\"/>

<br/><input type=\"submit\" value=\"{$lang['submit']}\"/>

</form>";

 

// blog style

 

$admin_menu = $admin_menu . "<br/>

<div class=\"infoSection\">{$lang['appearance']}</div><br/><form action=\"?login=1\" method=\"post\">

{$lang['blog_style']}: <select name=\"style\">

";

 

if ($handle = opendir("styles")) {

// List all the files

while (false !== ($file = readdir($handle))) {

if ($file != "." AND $file != "..") {

if ($file == $blog_style) { $selected = "selected='selected'"; } else { $selected = ""; }

$admin_menu = $admin_menu . "<option value=\"{$file}\" {$selected}>{$file}</option>\n";

}

}

closedir($handle);

}

 

$admin_menu = $admin_menu . "</select>";

 

// default language

 

$admin_menu = $admin_menu . "<br/>

<br/>

{$lang['default_language']}: <select name=\"default_language\">

";

 

if ($handle = opendir("inc")) {

// List all the files

while (false !== ($file = readdir($handle))) {

if (substr($file, strlen($file)-3, 3) == "lng") {

$lng_name = substr($file, 0, strlen($file)-4);

if ($lng_name == $blog_language) { $selected_lng = "selected='selected'"; } else { $selected_lng = ""; }

$lng_label = strtoupper($file{0}) . substr($file, 1, strlen($file)-5);

$admin_menu = $admin_menu . "<option value=\"{$lng_name}\" {$selected_lng}>{$lng_label}</option>\n";

}

}

closedir($handle);

}

 

$admin_menu = $admin_menu . "</select> <br/><br/>

{$lang['blog_name']}: <input type=\"text\" name=\"blog_name\" value=\"{$blog_name}\" size=\"30\"/><br/>

{$lang['blog_decription']}: <input type=\"text\" name=\"blog_description\" value=\"{$blog_description}\" size=\"50\"/><br/>

{$lang['your_name']}: <input type=\"text\" name=\"user_name\" value=\"{$user_name}\" size=\"30\"/><br/><br/>

{$lang['num_posts']}: <input type=\"text\" name=\"num_posts\" value=\"{$num_posts}\" size=\"3\"/><br/><br/>

<input type=\"submit\" name=\"action\" value=\"{$lang['change']}\"/></form>";

 

//

 

$admin_menu = $admin_menu . "<br/><div class=\"infoSection\">{$lang['logout']}</div><br/><a href=\"?logout=1\">{$lang['logout']}</a>";

 

print_content($admin_menu);

 

 

}

 

} else {

 

mysql_connect($mysql_server,$mysql_username,$mysql_password);

@mysql_select_db($mysql_database) or print_content( "{$lang['database_error']}");

 

if ($_GET['edit'] != "1") {

$query = "INSERT INTO {$mysql_table} (title , text , comment , timestamp , section , hide , nocomments , email , other1 , other2 , id) VALUES ( '{$_POST['title']}', '{$_POST['text']}', '', NOW(), '{$_POST['section']}', '{$_POST['hide']}', '{$_POST['nocomments']}', '', '', '', '');";

 

mysql_query($query);

 

print_content("{$lang['entry_posted']} <a href=\"{$blog_script}\">{$lang['click_here']}</a>");

 

} else {

 

if ($_POST['delete'] != "yes") {

 

$query = "UPDATE {$mysql_table} SET title = '{$_POST['title']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

$query = "UPDATE {$mysql_table} SET text = '{$_POST['text']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

$query = "UPDATE {$mysql_table} SET section = '{$_POST['section']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

$query = "UPDATE {$mysql_table} SET hide = '{$_POST['hide']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

$query = "UPDATE {$mysql_table} SET nocomments = '{$_POST['nocomments']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

 

if ($_POST['email'] != "") {

$query = "UPDATE {$mysql_table} SET email = '{$_POST['email']}' WHERE id = '{$_GET['id']}';";

mysql_query($query);

}

 

print_content("{$lang['entry_updated']} <a href=\"{$blog_script}\">{$lang['click_here']}</a>");

 

} else {

 

 

$query = "SELECT * FROM {$mysql_table} WHERE id = '{$_GET['id']}';";

$result = mysql_query($query);

$num = mysql_numrows($result);

$edit_comment = stripslashes(mysql_result($result,"0","comment"));

 

if ($edit_comment == "") {

 

$query = "DELETE FROM {$mysql_table} WHERE id = '{$_GET['id']}';";

mysql_query($query);

$query = "DELETE FROM {$mysql_table} WHERE comment = '{$_GET['id']}';";

mysql_query($query);

 

} else {

 

$query = "DELETE FROM {$mysql_table} WHERE id = '{$_GET['id']}';";

mysql_query($query);

 

}

 

print_content("{$lang['entry_deleted']} <a href=\"{$blog_script}\">{$lang['go_to_the_front_page']}</a>");

 

 

}

 

}

 

 

 

}

 

 

}

}

 

 

 

 

 

// main blog thingies :)

 

mysql_connect($mysql_server,$mysql_username,$mysql_password);

@mysql_select_db($mysql_database) or print_content( "{$lang['database_error']}");

 

$query = "SELECT DISTINCT section FROM {$mysql_table} WHERE comment = '';";

$result = mysql_query($query);

$num = mysql_numrows($result);

 

$result_debug = mysql_query("SELECT * FROM {$mysql_table};");

$upgrade_debug_num = mysql_num_fields($result_debug);

 

if ($upgrade_debug_num == 6) {

 

print_content("<font color=\"#FF0000\"><b>You have upgraded your µBlog version. You must upgrade your database to continue using it! Click <a href=\"upgrade.php\">here</a>.</b></font>");

 

}

 

// sidebar

 

$query_link = "SELECT * FROM {$mysql_table} WHERE section = '_microblog_link_';";

$result_link = mysql_query($query_link);

$num_link = mysql_numrows($result_link);

 

// sections

 

for ($i = 0; $i < $num; $i++) {

$section = stripslashes(mysql_result($result,$i,"section"));

if ($section != "" AND $section != "_microblog_link_") {

$sections = $sections . "\n<a href='?section={$section}'>{$section}</a><br/>";

}

}

 

// sections on a seperate page

 

if ($_GET['sections'] == "1") {

print_content($sections);

}

 

 

// links

 

for ($i = 0; $i < $num_link; $i++) {

$link_name = stripslashes(mysql_result($result_link,$i,"title"));

$link_url = stripslashes(mysql_result($result_link,$i,"text"));

$links = $links . "<a href='{$link_url}' target='_blank'>{$link_name}</a><br/>\n";

}

 

// links on a seperate page

 

if ($_GET['links'] == "1") {

print_content($links);

}

 

// language

 

if ($handle = opendir("inc")) {

// List all the files

while (false !== ($file = readdir($handle))) {

if (substr($file, strlen($file)-3, 3) == "lng") {

$lng_name = substr($file, 0, strlen($file)-4);

$lng_label = strtoupper($file{0}) . substr($file, 1, strlen($file)-5);

$languages = $languages . "<a href=\"?language={$lng_name}\">{$lng_label}</a><br/>\n";

}

}

closedir($handle);

}

 

// languages on a seperate page

 

if ($_GET['languages'] == "1") {

print_content($languages);

}

 

// archive

 

$query_archive = "SELECT DISTINCT MONTH(timestamp) AS month, YEAR(timestamp) AS year FROM {$mysql_table} WHERE comment = '' AND section NOT LIKE '_microblog%';";

$result_archive = mysql_query($query_archive);

$num_archive = mysql_numrows($result_archive);

 

for ($i = 0; $i < $num_archive; $i++) {

$month = stripslashes(mysql_result($result_archive,$i,"month"));

$year = stripslashes(mysql_result($result_archive,$i,"year"));

$transform_month = array("1","2","3","4","5","6","7","8","9","10","11","12");

$into_month = array($lang['january'], $lang['february'], $lang['march'], $lang['april'], $lang['may'], $lang['june'], $lang['july'], $lang['august'], $lang['september'], $lang['october'], $lang['november'], $lang['december']);

 

for ($l = 0; $l < 12; $l++) {

if ($month == $transform_month[$l]) {

$month_word = $into_month[$l];

}

}

 

$archives = $archives . "<a href=\"?month={$month}&amp;year={$year}\">{$month_word} {$year}</a><br/>\n";

}

 

// archives on a seperate page

 

if ($_GET['archives'] == "1") {

print_content($archives);

}

 

// sidebar template

 

$find = array("{lang_administration}","{lang_login}","{lang_sections}","{lang_all}","{sections}","{lang_links}","{links}","{lang_language}","{languages}","{lang_archives}","{archives}","{blog_script}","{lang_search}","{lang_search_button}");

$replace = array($lang['administration'],$lang['login'],$lang['sections'],$lang['all'],$sections,$lang['links'],$links,$lang['language'],$languages,$lang['archives'],$archives,$blog_script,$lang['search'],$lang['search_button']);

 

$body = template($find, $replace, "_template_sidebar_");

 

 

// blog posts and comments

 

if ($_GET['section'] == "") {

$query = "SELECT * FROM {$mysql_table} WHERE comment = '' AND (hide IS NULL OR hide NOT LIKE 'yes') AND section NOT LIKE '_microblog%' ORDER BY id DESC LIMIT 0,{$num_posts};";

} else {

$query = "SELECT * FROM {$mysql_table} WHERE comment = '' AND section = '{$_GET['section']}' AND section NOT LIKE '_microblog%' ORDER BY id DESC LIMIT 0,{$num_posts};";

}

 

if ($_GET['comment'] != "") {

$query = "SELECT * FROM {$mysql_table} WHERE id = '{$_GET['comment']}' AND comment = '' AND section NOT LIKE '_microblog%';";

}

 

if ($_GET['month'] != "" AND $_GET['year'] != "") {

$query = "SELECT * FROM {$mysql_table} WHERE MONTH(timestamp) = {$_GET['month']} AND YEAR(timestamp) = {$_GET['year']} AND comment = '' AND section NOT LIKE '_microblog%' ORDER BY id DESC;";

}

 

if ($_POST['search'] != "") {

$query = "SELECT * FROM {$mysql_table} WHERE (text LIKE '%{$_POST['search']}%' OR title LIKE '%{$_POST['search']}%') AND section NOT LIKE '_microblog%' AND comment = '' ORDER BY id DESC;";

}

 

if ($_GET['viewall'] == "1" AND $_SESSION[$session_name] == "1") {

$query = "SELECT * FROM {$mysql_table} WHERE comment = '' AND section NOT LIKE '_microblog%' ORDER BY id DESC;";

}

 

$result = mysql_query($query);

$num = mysql_numrows($result);

 

for ($i = 0; $i < $num; $i++) {

 

$title = stripslashes(mysql_result($result,$i,"title"));

$text = stripslashes(mysql_result($result,$i,"text"));

$timestamp = stripslashes(mysql_result($result,$i,"timestamp"));

$section = stripslashes(mysql_result($result,$i,"section"));

$nocomments = stripslashes(mysql_result($result,$i,"nocomments"));

 

$id = stripslashes(mysql_result($result,$i,"id"));

 

$day = date("j", strtotime($timestamp));

$month = date("F", strtotime($timestamp));

$year = date("Y", strtotime($timestamp));

 

$hour = date("H", strtotime($timestamp));

$minute = date("i", strtotime($timestamp));

$second = date("s", strtotime($timestamp));

 

 

$transform_month = array("January","February","March","April","May","June","July","August","September","October","November","December");

$into_month = array($lang['january'], $lang['february'], $lang['march'], $lang['april'], $lang['may'], $lang['june'], $lang['july'], $lang['august'], $lang['september'], $lang['october'], $lang['november'], $lang['december']);

 

for ($l = 0; $l < 12; $l++) {

if ($month == $transform_month[$l]) {

$month = $into_month[$l];

}

}

 

$timestamp = $day . ". " . $month . " " . $year . " @ " . $hour . ":" . $minute;

 

$comment_query = "SELECT * FROM {$mysql_table} WHERE comment = '{$id}';";

$comment_result = mysql_query($comment_query);

$comment_num = mysql_numrows($comment_result);

 

$text = bbcode($text);

 

if ($_SESSION[$session_name] == "1") {

$_link = "?login=1&edit=1&id={$id}";

} else {

$_link = "?comment={$id}";

}

 

 

$find = array("{link}","{title}","{text}","{timestamp}","{id}","{lang_comments}","{comment_num}","{section}","{section_link}","{author}","{day}","{month}","{year}","{hour}","{minute}","{second}");

$replace = array($_link,$title,$text,$timestamp,$id,$lang['comments'],"{$comment_num}",$section,"?section={$section}",$user_name,$day,$month,$year,$hour,$minute,$second);

 

$body = $body . template($find, $replace, "_template_post_");

 

}

 

if ($_GET['comment'] != "" AND $num != "0") {

 

$comment_content_query = "SELECT * FROM {$mysql_table} WHERE comment = '{$_GET['comment']}' ORDER BY id ASC;";

$comment_content_result = mysql_query($comment_content_query);

$comment_content_num = mysql_numrows($comment_content_result);

 

$body = $body . "<div class=\"containerComments\"><div class=\"infoSection\">{$lang['comments']}</div>";

 

for ($i = 0; $i < $comment_content_num; $i++) {

 

$comment_title = stripslashes(mysql_result($comment_content_result,$i,"title"));

$comment_text = stripslashes(mysql_result($comment_content_result,$i,"text"));

$comment_name = stripslashes(mysql_result($comment_content_result,$i,"section"));

$comment_timestamp = stripslashes(mysql_result($comment_content_result,$i,"timestamp"));

$comment_email = stripslashes(mysql_result($comment_content_result,$i,"email"));

$comment_id = stripslashes(mysql_result($comment_content_result,$i,"id"));

 

$comment_text = bbcode($comment_text);

 

$day = date("j", strtotime($comment_timestamp));

$month = date("F", strtotime($comment_timestamp));

$year = date("Y", strtotime($comment_timestamp));

 

$hour = date("H", strtotime($comment_timestamp));

$minute = date("i", strtotime($comment_timestamp));

$second = date("s", strtotime($comment_timestamp));

 

$transform_month = array("January","February","March","April","May","June","July","August","September","October","November","December");

$into_month = array($lang['january'], $lang['february'], $lang['march'], $lang['april'], $lang['may'], $lang['june'], $lang['july'], $lang['august'], $lang['september'], $lang['october'], $lang['november'], $lang['december']);

 

for ($l = 0; $l < 12; $l++) {

if ($month == $transform_month[$l]) {

$month = $into_month[$l];

}

}

 

$comment_timestamp = $day . ". " . $month . " " . $year . " @ " . $hour . ":" . $minute;

 

if ($_SESSION[$session_name] == "1") { $comment_title = "<a href=\"?login=1&edit=1&id={$comment_id}\">{$comment_title}</a>"; }

 

$find = array("{title}","{lang_by}","{name}","{text}","{timestamp}","{e-mail}","{day}","{month}","{year}","{hour}","{minute}","{second}");

$replace = array($comment_title,$lang['by'],$comment_name,$comment_text,$comment_timestamp,$comment_email,$day,$month,$year,$hour,$minute,$second);

 

$body = $body . template($find, $replace, "_template_comment_");

 

}

 

if ($comment_content_num == "0") {

$body = $body . "{$lang['no_comments']}";

}

 

 

 

$body = $body . "<div class=\"infoSection\">{$lang['comment_this_post']}</div>";

 

// allow comments

 

if ($nocomments == "") {

 

$body = $body . "<form action=\"?comment={$_GET['comment']}\" method=\"post\">

{$lang['title']}: <br/><input type=\"text\" name=\"comment_title\" class=\"comment_title\" size=\"80\" value=\"Re: {$title}\"/><br/>

{$lang['text']}: <br/><textarea name=\"comment_text\" class=\"commentTextarea\" cols=\"60\" rows=\"7\"></textarea><br/>

{$lang['your_name']}: <br/><input type=\"text\" name=\"comment_name\" size=\"30\"/><br/>

{$lang['your_email']}: <br/><input type=\"text\" name=\"comment_email\" size=\"30\"/><br/>

<br/><input type=\"submit\" name=\"action\" value=\"{$lang['submit']}\"/></form>

 

</div>";

 

} else {

 

// do not allow comments

 

$body = $body . "{$lang['no_commenting']}</div>";

 

}

 

 

if ($_POST['action'] == $lang['submit']) {

 

if ($_POST['comment_title'] != "" && $_POST['comment_text'] != "" && $_POST['comment_name'] != "") {

 

if ($nocomments == "") {

$query = "INSERT INTO {$mysql_table} (title , text , comment , timestamp , section , hide , nocomments , email , other1 , other2 , id) VALUES ( '{$_POST['comment_title']}', '{$_POST['comment_text']}', '{$_GET['comment']}', NOW(), '{$_POST['comment_name']}', '', '', '{$_POST['comment_email']}', '', '', '');";

mysql_query($query);

} else {

print_content("{$lang['no_commenting']}");

}

 

print_content("{$lang['thank_you_for_your_comment']} <a href=\"?comment={$_GET['comment']}\">{$lang['go_back']}</a>");

 

}

 

else {

print_content("{$lang['missing_fields']}");

}

 

}

 

 

 

}

 

 

 

if ($num > 0) {

 

print_content("{$body}", "no_container");

 

}

 

$query = "SELECT * FROM {$mysql_table} WHERE comment = '' AND section NOT LIKE '_microblog%';";

$result = mysql_query($query);

$num = mysql_numrows($result);

 

if ($num == "0") {

print_content("{$lang['empty_blog']} <a href=\"?login=1\">{$lang['click_here']}</a>");

} else {

if ($_GET['section'] == "") {

print_content("{$body} <div class=\"container\">{$lang['does_not_exist']}</div>", "no_container"); // {$lang['does_not_exist']}

} else {

print_content("{$body} <div class=\"container\">{$lang['section_does_not_exist']}</div>", "no_container"); // {$lang['section_does_not_exist']}

}

}

?>

[/log]

 

Link to comment
Share on other sites

  • 2 months later...

Bra fråga... men du kan ju testa att lägga in teckenkoden istället... eller att när man skriver ut så skriver du.

if($bla = tecken)

$bla = å;

simplaste sättet..

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...