l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
April 21: Google Glass
Next Installfest:
TBD
Latest News:
Mar. 18: Google Glass at LUGOD's April meeting
Page last updated:
2002 Feb 03 10:14

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] reading files into a web page (long scripts)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] reading files into a web page (long scripts)



Peter Jay Salzman wrote:
[snip]
> how can i do this?  i *think* php can do this, but i don't know a lick
> of php.  can someone give me explicit instructions on how to do this
> sort of thing?
> 
> if it makes a difference, i'm putting a form on the same page that adds
> text to /www/pcgm/bulletins.

Hi Pete,

I like to place content in a postgres database as a binary large objects
(blobs). http://www.cvbig.org/others/ is a an example of multiple blob
calls for both layout and content.

<?PHP
        echo "<html><body><title>CVBIG | Other SIGs</title>";
        $conn = pg_connect("dbname=cvbig port=5432");

        #header from db
        pg_Exec($conn, "BEGIN");
        $oid_result = pg_Exec($conn, "SELECT header FROM layout");
        $oid = pg_Result($oid_result, 0, "header");
        $handle = pg_loopen($conn, $oid, "r");
        $text = pg_loread($handle, 100000);
        $text = preg_replace("/\\\/","", $text);
        echo "$text";
        pg_Exec($conn, "COMMIT");
 
        #grab sig list from local_sigs and display
        $result = pg_Exec($conn, "SELECT * FROM local_sigs ORDER BY
NAME");
        $num_rows = pg_numrows($result);
        echo "<P><b>We are not alone!</b></p><p>Here are some local
interest groups worth visiting.</p><p>";
        while ($i<$num_rows){
                $group = pg_Result($result, $i, "name");
                $link = pg_Result($result, $i, "link");
                $description = pg_Result($result, $i, "description");
                echo "<p><a href=$link>$group</a>:<br>$description</p>";
                $i++;
        }
 
 
        #footer from db
        pg_Exec($conn, "BEGIN");
        $oid_result = pg_Exec($conn, "SELECT footer FROM layout");
        $oid = pg_Result($oid_result, 0, "footer");
        $handle = pg_loopen($conn, $oid, "r");
        $text = pg_loread($handle, 100000);
        $text = preg_replace("/\\\/","", $text);
        echo "$text";
        pg_Exec($conn, "COMMIT");
 
        echo "</body></html>";
?>

I have another page to add, edit, or delete content. This can easily be
altered for a bulletin board.

<html>
<title>Admin: Local Sigs</title>
<body background="../Texture_lt_gray_004.jpg">
<H2>Admin: Local Sigs</H2>
<?PHP
        $current_date = date("m-d-Y");
        echo "User <b>".getenv(Remote_User)."</b> logged on from
".getenv(Remote_Addr)." on ".$current_date."<
br>";
        $user_id = getenv(Remote_User);
        $conn = pg_connect("dbname=cvbig port=5432");
        function mylink(){echo "<a
href=http://www.cvbig.org/admin/>Administration Page</a>";}

        if (!$SUBMIT && !$ADD && !$NEW_SUBMIT){
                echo "Edit any or all of the following fields or add a
new entry.<br><br>";
                $query = pg_Exec($conn, "SELECT * FROM local_sigs ORDER
BY name");
                $num_rows = pg_numrows($query);
                while ($i< $num_rows){
                        $name = pg_Result($query, $i, 'name');
                        $link = pg_Result($query, $i, 'link');
                        $description = pg_Result($query, $i,
'description');
                        echo "<form enctype=multipart/form-data
action=local_sigs.php method=post>";
                        echo "<input type=hidden name=OLDNAME
value=$name>";
                        echo "SIG:<br><TEXTAREA COLS=50 ROWS=1
NAME=NAME>$name</textarea><br>";
                        echo "Link:<br><TEXTAREA COLS=50 ROWS=1
NAME=LINK>$link</textarea><br>";
                        echo "Description:<br><TEXTAREA COLS=100 ROWS=5
WRAP=VIRTUAL NAME=DESCRIPTION>$descrip
tion</textarea><br>";
                        echo "<input type=submit name=SUBMIT
value=submit-$name>";
                        echo "</form>";
                        $i++;
                }
                echo "<form enctype=multipart/form-data
action=local_sigs.php method=post>";
                echo "<input type=submit name=ADD value=add><br><br>";
                echo "</form>";
                mylink();
                exit;
        }
        if (!$SUBMIT && $ADD){
                echo "<form enctype=multipart/form-data
action=local_sigs.php method=post>";
                echo "SIG:<br><TEXTAREA COLS=50 ROWS=1
NAME=NAME></textarea><br>";
                echo "Link:<br><TEXTAREA COLS=50 ROWS=1
NAME=LINK></textarea><br>";
                echo "Description:<br><TEXTAREA COLS=100 ROWS=5
WRAP=VIRTUAL NAME=DESCRIPTION></textarea><br>"
;
                echo "<input type=submit name=NEW_SUBMIT value=submit>";
                echo "</form>";
                mylink();
                exit;
        }

        if ($SUBMIT){
 
                #display new values
                echo "The database has been updated with the following
values:<br><br>";
                $query = pg_Exec($conn, "SELECT * FROM local_sigs WHERE
name = '$NAME'");
                $name = pg_Result($query, 0, 'name');
                $link = pg_Result($query, 0, 'link');
                $description = pg_Result($query, 0, 'description');
                echo "<b>Name:</b> $name<br>";
                echo "<b>Link:</b> $link<br>";
                echo "<b>Description:</b><br><TEXTAREA COLS=100 ROWS=5
WRAP=VIRTUAL NAME=DESCRIPTION>$description</TEXTAREA><br>";
                mylink();
                exit;
        }
        if ($NEW_SUBMIT){
                #insert text
                $insert = pg_Exec($conn, "INSERT INTO local_sigs
(name,link,description) VALUES ('$NAME','$LINK','$DESCRIPTION')");
 
                #display new values
                echo "The following values have been inserted in the
database:<br><br>";
                $query = pg_Exec($conn, "SELECT * FROM local_sigs WHERE
name = '$NAME'");
                $name = pg_Result($query, 0, 'name');
                $link = pg_Result($query, 0, 'link');
                $description = pg_Result($query, 0, 'description');
                echo "<b>Name:</b> $name<br>";
                echo "<b>Link:</b> $link<br>";
                echo "<b>Description:</b><br><TEXTAREA COLS=100 ROWS=5
WRAP=VIRTUAL NAME=DESCRIPTION>$description</TEXTAREA><br>";
                mylink();
                exit;
        }
?>
</body>
</html>
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.