Blog visitors can change line on LCD...

tec[H]nogeek

New member
hey, can you please send me the script you are using on your site for the LCD? it's really cool and i would love to implement it on my site. As always, i give credit where credit is due.
 

jbs

New member
Okay, here goes...

I'm using JaLCDs for its ability to retrieve external data sources, which I should recommend as a feature to CrystalControl since I would much rather use it than JaLCDs.

The first thing you need to do is create a text file on your webserver that the script can write to, so chmod it to 755 or 777. The PHP script I will give below writes to this file, so you can leave it blank if you want. Mine currently shows:

setvar lcdblog This kicks ass!! Please share the code!;
Once you have done this, open up JaLCDs and click on the "external variables" button and add the URL to your text file like such:

<img src="http://blog.invalidreality.com/jalcds_extdata.gif">

Now integrate the variable into your screen settings however you want. I used the variable name 'lcdblog':

<img src="http://blog.invalidreality.com/jalcds_screen.gif">

Okay, to the PHP. The PHP code goes above the form.

*NOTE: I put two periods in front of items that were parsed by the board. Should be removed prior to implementation.

<pre>
<..?php
if($_POST['lcdchange']) {
$prestuff = "setvar lcdblog ";
$poststuff = ";";
$userstuff = $_POST['sayit'];
$all = $prestuff . $userstuff . $poststuff;
$getgo = fopen("/path/to/yourfile.txt", "w+");
$all2 = stripslashes($all);
$doit = fwrite($getgo, $all2);
}
clearstatcache();
$handle = fopen("/path/to/yourfile.txt", "r");
while (!feof($handle)) {
$buffer = fgets($handle, 4096);
}
fclose($handle);

$echostuff = substr($buffer, 15, -1);
echo stripslashes($echostuff);
if($doit) {
echo "<..br>(success)<..br>";
/* Optional Logging to MySQL
@mysql_connect("localhost", "username", "password");
@mysql_select_db("database name");
$query = "INSERT INTO bloglcd (message, ip) VALUES ('" . $userstuff . "','" . $_SERVER["REMOTE_ADDR"] . "');";
$dbit = @mysql_query($query);
*/
}
?>
</pre>


Then the form (remove the ..):

Code:
<..form action="<..?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<..tr>
<..td valign="top">
<..input name="sayit" size="8" type="text">
<..input type="hidden" name="lcdchange" value="1">
<..input value="Do it." type="submit">
<../td>
<../tr>
<../form>
And finally if you want to log the messages and IPs to MySQL, this is the two column table I made in 5 seconds:

<pre>
CREATE TABLE bloglcd (
id int(8) NOT NULL auto_increment,
message varchar(255) NOT NULL default '',
ip varchar(30) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;

</pre>

So there it is. Respond with any problems/questions.
 
Last edited:
Top