PDA

View Full Version : ADDON: About Text AddOn


tommaso
05-11-2007, 02:47 PM
Hi all,

I did a little addon that allows to use two new tags:

<ABOUT_TEXT>
<ABOUT_TEXT_ALT>

I use it on my site to write down a couple of words about me.
Without it I had to open html template files to change text.

I hope you enjoy it (and test it btw).

I had an issue about the text lengh which is now restricted to mysql varchar type maximum (255). I tried to use text/longtext types but my server seems to not accept it.
Any suggestion?

download it here: http://www.tomsights.net/templates/tomsights06/admin_about_text.zip
live here: http://www.tomsights.net/index.php?x=about

bye
Tommaso
TomSights.net (http://www.tomsights.net)

dakwegmo
05-11-2007, 03:11 PM
Hey cool. I was going to suggest this is a feature for 1.7, then decided it might be better as an addon. I'll have to test it when I get home.

Dennis
05-13-2007, 05:52 PM
Nice addon, I'll surely have a look at it.

sentinel
05-14-2007, 10:16 PM
I had an issue about the text lengh which is now restricted to mysql varchar type maximum (255). I tried to use text/longtext types but my server seems to not accept it.


what error did arise when u tried to use text as data type.. afaik tinytext, text, mediumtext and longtext should be supported since 4.0 (which for sure matches the needs for pp)

[edit] did you use DEFAULT values with text data type too? because text and blob can not have default values. without the default values in the ALTER statements it should work

tommaso
05-15-2007, 08:36 AM
Thanks Sentinel!

I cut the default value and now it works with text type.
Updated here: http://www.tomsights.net/templates/tomsights06/admin_about_text.zip

At this time the two fileds "about_text" and "about_text_alt" must be removed before reinstalling the addon.

I'll work on a tool to delete them from the the db via pixelpost addon page.

bye
Tommaso
TomSights.net (http://www.tomsights.net/)

dhdesign
05-15-2007, 11:23 AM
Nice addon! Am going to give it a try later this AM.

A couple of comments I have after looking at the code:

1. Most of the other addons that I have installed (advanced comment stats and image stats) create a new database table to store their info in. Your addon is altering the pixelpost config table. Would it be easier to code the install/uninstall portions if you created a new table called 'about', rather than altering the configuration table?

2. In the code, you are using <font> tags to show the message that the texts have been updated. The <font> tag is deprecated and should probably be changed to <span> tags (<span style=\"color: blue;\">Updated about texts.</span>).

Dkozikowski
05-16-2007, 05:04 AM
Nice start but this must be refined some more.

As dhdesign has stated, creating its own table is a much better practice than adding onto pixelposts default tables.

Also, you insert the about text into the database "as is" without taking the proper steps to encode and decode the text.

For example, when someone enters the following about text:

Hello there. This is dwilkinsjr's photoblog.

it will insert into the database as:

Hello there. This is dwilkinsjr\'s photoblog.

Sometimes, the database will not add the \ by itself and then some issues may arise.

Anyway, when this same person uses the tag to display their about text on their website, the \ will remain depending on the servers magic_quote settings.

Hopefully you understand what I am saying. I tried to explain it as best as possible. I will clean your addon up for you and reconfigure it to use its own database table. If you wish to see this copy, please send me a private message.

tommaso
05-16-2007, 07:40 AM
Thanks dwilkinsjr, I will continue on your version with the part of uninstall.


2. In the code, you are using <font> tags to show the message that the texts have been updated. The <font> tag is deprecated and should probably be changed to <span> tags (<span style=\"color: blue;\">Updated about texts.</span>).

I will fix this too. Thanks

bye

Dkozikowski
05-16-2007, 08:00 AM
Thanks dwilkinsjr, I will continue on your version with the part of uninstall.

I'm not sure what you mean about the uninstall part but here is a much cleaner and properly encoded script.

The code is bellow but it may be easier to grab it from http://public.dwilkinsjr.com/pixelpost/forumFiles/admin_about_text.phps


<?php

/*
About Text AddOn - Version 1.01
Last update: 05/16/2007
First version: 05/11/2007
Written by: Tommaso Carullo - tom|at|tomsights|dot|net - www.tomsights.net
Refined by: Dwilkinsjr - dwilkinsjr|at|dwilkinsjr|dot|com - www.dwilkinsjr.com
Requires Pixelpost version 1.5 or newer

CHANGE LOG:
05/15/2007: Fixed the problem about data types (thanks to Sentinel, www.digitalview.at)
05/11/2007: First test emission, it works but have an open issue on data type of about fields

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*/


$addon_name = "<a name=\"ATA\"></a>About Text Addon";
$addon_version = "1.01";
$addon_description = "Type the text to be displayed with &lt;ABOUT_TEXT&gt; or &lt;ABOUT_TEXT_ALT&gt; tags.<br />\n";
$addon_description .= "<p>Created by <a href='http://www.tomsights.net'>Tommaso Carullo</a> Refined by <a href='http://www.dwilkinsjr.com'>Dwilkinsjr</a></p>\n";

global $pixelpost_db_prefix;

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."abouttxt` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`about_txt` TEXT NOT NULL,`about_txt_alt` TEXT NOT NULL)");


if($_POST['action'] == "update_abouttxt") {

### query the about text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### add slashes to special chars like ' and "
$about_txt = addslashes($_POST['about_txt']);

### add slashes to special chars like ' and "
$about_txt_alt = addslashes($_POST['about_txt_alt']);

### check if an id is currently present within the about text database
if($abouttxt['id'] != '') {

### we have an id so we can simply update the current row
@mysql_query("UPDATE `".$pixelpost_db_prefix."abouttxt` SET `about_txt` = '".$about_txt."', `about_txt_alt` = '".$about_txt_alt."'");
} else { ### if we made it down here, there is no id present in the database, we need to use the insert statement

@mysql_query("INSERT INTO `".$pixelpost_db_prefix."abouttxt` (`about_txt`, `about_txt_alt`) VALUES('".$about_txt."','".$about_txt_alt."')");
}
}

### query the about text database again and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### remove those slashes we previously added for viewing
$about = $abouttxt['about_txt'];
$about = stripslashes($about);

### remove those slashes we previously added for viewing
$about_alt = $abouttxt['about_txt_alt'];
$about_alt = stripslashes($about_alt);


### lets output our form
$addon_description .= "\n<form name=\"abouttxtaddon\" id=\"formATA\" method=\"post\" action=\"#ATA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_abouttxt\" />\n\n";

$addon_description .= "<table border=\"0\" cellspacing=\"2\" cellpadding=\"3\">\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td align=\"left\" valign=\"middle\">&nbsp;About Main Lang:</td>\n";
$addon_description .= " </tr>\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td align=\"center\" valign=\"middle\"><textarea name=\"about_txt\" id=\"about_txt\" rows=\"3\" cols=\"30\">".$about."</textarea></td>\n";
$addon_description .= " </tr>\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td></td>\n";
$addon_description .= " </tr>\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td align=\"left\" valign=\"middle\">&nbsp;About Alternative Lang:</td>\n";
$addon_description .= " </tr>\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td align=\"center\" valign=\"middle\"><textarea name=\"about_txt_alt\" id=\"about_txt_alt\" rows=\"3\" cols=\"30\">".$about_alt."</textarea></td>\n";
$addon_description .= " </tr>\n";
$addon_description .= " <tr>\n";
$addon_description .= " <td align=\"right\" valign=\"middle\"><input type=\"submit\" name=\"Submit\" value=\"Submit\" /></td>\n";
$addon_description .= " </tr>\n";
$addon_description .= "</table>\n\n";

$addon_description .= "</form>\n\n";


### finally, our template tags
$tpl = str_replace("<ABOUT_TEXT>",$about,$tpl);
$tpl = str_replace("<ABOUT_TEXT_ALT>",$about_alt,$tpl);
?>

dhdesign
06-11-2007, 01:58 PM
dwilkinsjr -

I refined the code you wrote to remove the table layout for the admin form. Feel free to use this version if you want.


<?php
/*
About Text AddOn - Version 1.01
Last update: 05/16/2007
First version: 05/11/2007
Written by: Tommaso Carullo - tom|at|tomsights|dot|net - www.tomsights.net
Refined by: Dwilkinsjr - dwilkinsjr|at|dwilkinsjr|dot|com - www.dwilkinsjr.com
Requires Pixelpost version 1.5 or newer

CHANGE LOG:
05/15/2007: Fixed the problem about data types (thanks to Sentinel, www.digitalview.at)
05/11/2007: First test emission, it works but have an open issue on data type of about fields

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*/


$addon_name = "<a name=\"ATA\"></a>About Text Addon";
$addon_version = "1.01";
$addon_description = "Type the text to be displayed with &lt;ABOUT_TEXT&gt; or &lt;ABOUT_TEXT_ALT&gt; tags.<br />\n";
$addon_description .= "<p>Created by <a href='http://www.tomsights.net'>Tommaso Carullo</a>. Refined by <a href='http://www.dwilkinsjr.com'>Dwilkinsjr</a>.</p>\n";

global $pixelpost_db_prefix;

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."abouttxt` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`about_txt` TEXT NOT NULL,`about_txt_alt` TEXT NOT NULL)");


if($_POST['action'] == "update_abouttxt") {

### query the about text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### add slashes to special chars like ' and "
$about_txt = addslashes($_POST['about_txt']);

### add slashes to special chars like ' and "
$about_txt_alt = addslashes($_POST['about_txt_alt']);

### if there is no id present in the database, we need to use the insert statement
if($abouttxt['id'] == '') {

@mysql_query("INSERT INTO `".$pixelpost_db_prefix."abouttxt` (`about_txt`, `about_txt_alt`) VALUES('".$about_txt."','".$about_txt_alt."')");
} else { ### if we made it down here, we have an id and we can simply update the current row

@mysql_query("UPDATE `".$pixelpost_db_prefix."abouttxt` SET `about_txt` = '".$about_txt."', `about_txt_alt` = '".$about_txt_alt."'");
}
}

### query the about text database again and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### remove those slashes we previously added for viewing
$about = $abouttxt['about_txt'];
$about = stripslashes($about);

### remove those slashes we previously added for viewing
$about_alt = $abouttxt['about_txt_alt'];
$about_alt = stripslashes($about_alt);

### lets output our form
$addon_description .= "\n<form name=\"abouttxtaddon\" id=\"formATA\" method=\"post\" action=\"#ATA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_abouttxt\" />\n\n";
$addon_description .= "About Main Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt\" id=\"about_txt\" rows=\"10\" cols=\"90\">".$about."</textarea><br /><br />\n";
$addon_description .= "About Alternative Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt_alt\" id=\"about_txt_alt\" rows=\"10\" cols=\"90\">".$about_alt."</textarea><br /><br />\n";
$addon_description .= "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />\n";
$addon_description .= "</form>\n\n";


### finally, our template tags
$tpl = str_replace("<ABOUT_TEXT>",$about,$tpl);
$tpl = str_replace("<ABOUT_TEXT_ALT>",$about_alt,$tpl);
?>

Dkozikowski
06-11-2007, 04:44 PM
Nice. I liked the table, made it more clean in my eyes.

Anyway, I use something a little more custom than this.

Same concept but the ALT language box does not show if it's not enabled.

Dr.Ozdi
06-16-2007, 10:36 PM
Very usefull, thanks for it!

Is possible use it for HTML tags or Java/PHP script? For example voting, adsence script, search input etc
Dr.

Dkozikowski
06-17-2007, 12:02 AM
Yes, html works and PHP should also.

Dr.Ozdi
06-17-2007, 07:50 AM
HTML tags are OK, but Java/PHP doesn't work....script in source is the same like in "Text Addon" textarea. I don't see fault
Dr.

Dkozikowski
06-17-2007, 08:00 AM
Well I was not sure if PHP worked but I assumed it would but it does not.

This is normal as Pixelpost does not allow PHP tags to be parsed within template files.

You need an addon to parse the PHP code instead.

Dr.Ozdi
06-17-2007, 08:19 AM
Bad news.
I tried to found this addon and changed Google-search addon as well but without succes. Do you know addon which is the easiest to change?
Dr.

Dkozikowski
06-17-2007, 09:53 AM
What are you trying to do? post the code here and i'll throw it in an addon for you.

Dr.Ozdi
06-17-2007, 05:49 PM
Thanks dwilkinsjr.
I want to enjoy to link exchange service, use Adsence or something like that. Below code for link exchange, it use external "something.dat" file. In middle is part in comment for case server don't provide CURL.


<?php

function ziskej_odkazy($soubor)
{
//*************nacteni souboru***************
$data = "";
if($cil = @fopen($soubor, "r"))
{
$data = @fread($cil, filesize($soubor));
@fclose($cil);
}
else
{
echo '<p>CHYBA: Soubor nelze otevřít. Ověřte, že je soubor vytvořen ve stejném adresáři, odkud je spouštěn skript a že má práva 666.</p>';
}
//************rozparsovani dat***************
$data = explode("\n", $data);
$velikost = count($data);
for($i = 0; $i < $velikost; $i++)
{
$data[$i] = explode(";;;", trim($data[$i]));
}
return $data;
}

function vypis_odkazy($soubor, $zobrazeni, $oddelovac, $barva_textu, $barva_pozadi, $velikost_textu)
{
$pole_odkazu = ziskej_odkazy($soubor);
echo "<table style=\"border:none; font-size:".$velikost_textu."px;".$barva_pozadi."\">\n";
if($zobrazeni == 2) echo "<tr>\n";
$velikost = count($pole_odkazu);
for($i = 0; $i < $velikost; $i++)
{
if((strlen($pole_odkazu[$i][0]) > 0) and (strlen($pole_odkazu[$i][1]) > 0))
{
if($zobrazeni == 1) echo "<tr>\n";
echo "<td>";
echo "<a href=\"".$pole_odkazu[$i][1]."\" title=\"".$pole_odkazu[$i][2]."\" style=\"color:".$barva_textu.";\">".$pole_odkazu[$i][0]."</a>";
echo "</td>\n";
if(($i+2 < $velikost)&&($zobrazeni == 2)&&(strlen($oddelovac) > 0)) echo "<td style=\"width:10px; text-align:center; color:".$barva_textu.";\">".$oddelovac."</td>\n";
if($zobrazeni == 1) echo "</tr>\n";
}
}
if($zobrazeni == 2) echo "</tr>\n";
echo "</table>\n";
}

function update($url, $soubor)
{
//--nacteni dat ze serveru (zakomentujte, pokud vas hosting nepodporuje CURL)-
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$obsah = curl_exec($ch);
curl_close($ch);
//----------------------------------------------------------------------------

//--nacteni dat ze serveru (odkomentujte, pokud vas hosting nepodporuje CURL)-
/*$obsah = "";
if($cil = @fopen($url, "r"))
{
$obsah = @fread($cil, filesize($url));
@fclose($cil);
}*/
//----------------------------------------------------------------------------

if(ereg(";;;", $obsah))//jestlize se podarilo nacist spravna data
{
if($cil = fopen($soubor, "w"))
{
fwrite($cil, $obsah);
fclose($cil);
}
}
else if(ereg("###", $obsah))//pro stranku neexistuji zadne odkazy
{
if($cil = @fopen($soubor, "w"))
{
fwrite($cil, '');
fclose($cil);
}
}
else//aktualizace casu souboru v pripade, ze se nepodarilo propojit k serveru
{
if(filesize($soubor) > 0)
{
$cil = @fopen($soubor, "r");//nacteni dat z lokalniho souboru
$data = fread($cil, filesize($soubor));
fclose($cil);
}
else $data = '';
$cil = fopen($soubor, "w");
fwrite($cil, $data);
fclose($cil);
}
}

function burza_odkazu()
{
//**********nastaveni**********
$soubor = 'soubor_076069.dat';
$zobrazeni = 1;
$oddelovac = '|';
$barva_textu = '#000000';
$barva_pozadi = '';
if($barva_pozadi != '') $barva_pozadi = ' background-color: '.$barva_pozadi.';';
$velikost_textu = '11';
$xmlid = 'RI3Y7FRSCNG3XHX4AJ5X';
if((filemtime($soubor) < (time() - 3600)) or (filesize($soubor) < 20))
{
$uri = isset($_SERVER['REQUEST_URI']) ? urlencode($_SERVER['REQUEST_URI']) : "";
$agent = isset($_SERVER['HTTP_USER_AGENT']) ? urlencode($_SERVER['HTTP_USER_AGENT']) : "";
update("http://www.burzaodkazu.cz/server.php?xmlid=".$xmlid."&uri=".$uri."&agent=".$agent, $soubor);
}
vypis_odkazy($soubor, $zobrazeni, $oddelovac, $barva_textu, $barva_pozadi, $velikost_textu);
}

//************************************************** ****************************

burza_odkazu();

?>

dhdesign
08-01-2007, 04:02 AM
dwilkinsjr -

How hard would it be to make an addon like this one, only use it to manage a links page with? My links list has gotten quite long, and I want to move them to a separate page, but don't want to have to manage the list via FTP - would be much easier to do it in Pixelpost.

I thought about just going through and changing "about" to "links" and saving it with a different filename, but wasn't sure if that would work or not.

Dkozikowski
08-01-2007, 04:34 AM
Yup, basically. So you don't have to do the work I took the time to change all the necessary values.


<?php
/*

Pixelpost 1.6 FINAL
Written by: Dwilkinsjr
Written for: Pixelpost www: http://www.pixelpost.org/

<!--

__ _ ____ _ _
____/ / __(_) / /__(_)___ _____ (_)____
/ __ / | /| / / / / //_/ / __ \/ ___/ / / ___/ LINK LIST ADDON v0.1
/ /_/ /| |/ |/ / / / ,< / / / / (__ ) / / /
\__,_/ |__/|__/_/_/_/|_/_/_/ /_/____/_/ /_/
http://dwilkinsjr.com/___/


-->

Contact: dwilkinsjr@dwilkinsjr.com
Copyright (c) 2007 <http://wwww.dwilkinsjr.com>

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*/


$addon_name = "<a name=\"LLA\"></a>Link List Editor";
$addon_version = "0.1";
$addon_description = "Type the text to be displayed with the <code>&lt;LINK_LIST&gt;</code> tag.<br /><br />\n";

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."linklist` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`link_list` TEXT NOT NULL)");


if($_POST['action'] == "update_linklist") {

### query the about text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."linklist`");
$linklist = @mysql_fetch_array($cquery);

### add slashes to special chars like ' and "
$link_list = addslashes($_POST['link_list']);

### if there is no id present in the database, we need to use the insert statement
if($linklist['id'] == '') {

@mysql_query("INSERT INTO `".$pixelpost_db_prefix."linklist` (`link_list`) VALUES('".$link_list."')");
} else { ### if we made it down here, we have an id and we can simply update the current row

@mysql_query("UPDATE `".$pixelpost_db_prefix."linklist` SET `link_list` = '".$link_list."'");
}
}

### query the about text database again and pullout all the rows
$query = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."linklist`");
$linklist = @mysql_fetch_array($query);

### remove those slashes we previously added for viewing
$links = $linklist['link_list'];
$links = stripslashes($links);


### lets output our form
$addon_description .= "\n<form name=\"linklistaddon\" id=\"formLLA\" method=\"post\" action=\"#LLA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_linklist\" />\n\n";
$addon_description .= "Links:<br />\n";
$addon_description .= "<textarea name=\"link_list\" id=\"link_list\" rows=\"10\" cols=\"90\">".$links."</textarea><br /><br />\n";
$addon_description .= "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />\n";
$addon_description .= "</form>\n\n";
$addon_descripton .= "<br /><br />ADDON Author: Dwilkinsjr (<a href='http://www.dwilkinsjr.com/myaddons' target='_blank'>dwilkinsjr.com</a>)";


### finally, our template tags
$tpl = str_replace("<LINK_LIST>",$links,$tpl);
?>

dhdesign
08-01-2007, 11:15 AM
Thank you!!! Will get it installed on my blog a bit later this morning.

dhdesign
08-03-2007, 01:16 PM
I've gotten this addon installed, and it's working great - it's so much easier to keep those lists updated! You can see it in action here (http://www.kpimages.net/index.php?x=links).

Dkozikowski
08-03-2007, 01:59 PM
Lookin' good :)

tommaso
09-03-2007, 02:33 PM
hi, my site is going to discontinue. This is the addon code at the time I am writing.
bye

<?php
/*
About Text AddOn - Version 1.01
Last update: 05/16/2007
First version: 05/11/2007
Written by: Tommaso Carullo - tom|at|tomsights|dot|net - www.tomsights.net
Refined by: Dwilkinsjr - dwilkinsjr|at|dwilkinsjr|dot|com - www.dwilkinsjr.com
Requires Pixelpost version 1.5 or newer

CHANGE LOG:
05/15/2007: Fixed the problem about data types (thanks to Sentinel, www.digitalview.at)
05/11/2007: First test emission, it works but have an open issue on data type of about fields

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*/


$addon_name = "<a name=\"ATA\"></a>About Text Addon";
$addon_version = "1.01";
$addon_description = "Type the text to be displayed with &lt;ABOUT_TEXT&gt; or &lt;ABOUT_TEXT_ALT&gt; tags.<br />\n";
$addon_description .= "<p>Created by <a href='http://www.tomsights.net'>Tommaso Carullo</a>. Refined by <a href='http://www.dwilkinsjr.com'>Dwilkinsjr</a>.</p>\n";

global $pixelpost_db_prefix;

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."abouttxt` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`about_txt` TEXT NOT NULL,`about_txt_alt` TEXT NOT NULL)");


if($_POST['action'] == "update_abouttxt") {

### query the about text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### add slashes to special chars like ' and "
$about_txt = addslashes($_POST['about_txt']);

### add slashes to special chars like ' and "
$about_txt_alt = addslashes($_POST['about_txt_alt']);

### if there is no id present in the database, we need to use the insert statement
if($abouttxt['id'] == '') {

@mysql_query("INSERT INTO `".$pixelpost_db_prefix."abouttxt` (`about_txt`, `about_txt_alt`) VALUES('".$about_txt."','".$about_txt_alt."')");
} else { ### if we made it down here, we have an id and we can simply update the current row

@mysql_query("UPDATE `".$pixelpost_db_prefix."abouttxt` SET `about_txt` = '".$about_txt."', `about_txt_alt` = '".$about_txt_alt."'");
}
}

### query the about text database again and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### remove those slashes we previously added for viewing
$about = $abouttxt['about_txt'];
$about = stripslashes($about);

### remove those slashes we previously added for viewing
$about_alt = $abouttxt['about_txt_alt'];
$about_alt = stripslashes($about_alt);

### lets output our form
$addon_description .= "\n<form name=\"abouttxtaddon\" id=\"formATA\" method=\"post\" action=\"#ATA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_abouttxt\" />\n\n";
$addon_description .= "About Main Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt\" id=\"about_txt\" rows=\"10\" cols=\"90\">".$about."</textarea><br /><br />\n";
$addon_description .= "About Alternative Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt_alt\" id=\"about_txt_alt\" rows=\"10\" cols=\"90\">".$about_alt."</textarea><br /><br />\n";
$addon_description .= "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />\n";
$addon_description .= "</form>\n\n";


### finally, our template tags
$tpl = str_replace("<ABOUT_TEXT>",$about,$tpl);
$tpl = str_replace("<ABOUT_TEXT_ALT>",$about_alt,$tpl);
?>