[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PHPwestoz] post early, post often



On Thursday 10 February 2005 23:32, Samuel Cochran wrote:
> Me four. Although I will try be more active.

Here's a simple technique to staying active: post a PHP snippet once a 
month to amaze or appal the other list denizens. I'll start.

I send the odd photo to http://www.burningwell.org/ so that it might 
have a more useful life. It's tedious selecting and uploading 
individual photos, the upload bogs my link down for a minute while a 
couple of megabytes escape down the wire, and the web interface breaks 
occasionally if I do 3 at once, reliably if I do 4. So...

I have a little script (attached as nugrab.sh with attendant PHP 
template) which sucks all of the photos out of my camera into 
$HOME/photos/YYYYMMDD/ and then indexes them, producing a web page with 
thumbnails, 800x600 "moderate" images and the originals.

I wrote a pair of web pages that run on the server on this machine 
(index.phtml, thumb.phtml, moderate.phtml, addpic.phtml and 
doadd.phtml). I can hit that local web interface instantly, find the 
photo(s) I'm interested in uploading, view the moderates to make sure 
they look OK, key in a description, and submit them to a local 
database. At my later convenience (typically when I walk away from the 
machine at night) I run another PHP script from the command line 
(send_selected.php) which scans the database and sends any unsent 
images.

In the scripts (and bw.sql), $$SYMBOL$$ needs to be hand-edited to 
reflect local conditions.

It's a bit messy and ad-hoc, but has saved me several hours so far.

Cheers; Leon

--
http://cyberknights.com.au/     Modern tools; traditional dedication
http://plug.linux.org.au/       Member, Perth Linux User Group
http://osia.net.au/             Member, Open Source Industry Australia
http://slpwa.asn.au/            Member, Linux Professionals WA
http://linux.org.au/            Member, Linux Australia

Add to BurningWell queue

Image to add "> "> Caption:
Autorotate?  
--
-- PostgreSQL database dump
--

SET client_encoding = 'SQL_ASCII';
SET check_function_bodies = false;

SET SESSION AUTHORIZATION 'postgres';

--
-- TOC entry 2 (OID 0)
-- Name: bw; Type: DATABASE; Schema: -; Owner: postgres
--

CREATE DATABASE bw WITH TEMPLATE = template0 ENCODING = 'SQL_ASCII';

\connect bw postgres

SET client_encoding = 'SQL_ASCII';
SET check_function_bodies = false;

--
-- TOC entry 4 (OID 2200)
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;

SET search_path = public, pg_catalog;

SET SESSION AUTHORIZATION '$$USER$$';

--
-- TOC entry 12 (OID 58850)
-- Name: bw; Type: TABLE; Schema: public; Owner: $$USER$$
--

CREATE TABLE bw (
    dir character varying,
    img character varying,
    cap character varying,
    sent boolean,
    autorotate boolean
);
Title: Burning Well Uploads

Browse for BurningWell Uploads

' . $adir . "

\n"; } closedir ($dh); } else { echo '

' . $_GET['sd'] . "

\n"; echo ''; $td = 0; $dh = opendir ('$$HOME$$/photos/' . $_GET['sd']); while (($apic = readdir ($dh)) != false) { if (substr ($apic, -4) == '.jpg') { $files[] = $apic; } } asort ($files); foreach ($files as $apic) { if ($td < 1) echo ''; echo '' . "\n"; ++ $td; if ($td > 3) { echo "\n"; $td = 0; } } if ($td) { while ($td < 3) { echo ''; ++ $td; } echo "\n"; } closedir ($dh); echo '
 
'; } ?>

Attachment: moderate.phtml
Description: application/php

Attachment: thumb.phtml
Description: application/php

Title: Adding image to queue
Missing Caption'; echo '

Hit the Back button and try again.

'; } else { echo "INSERT INTO bw VALUES('" . $_POST[d] . "','" . $_POST['p'] . "','" . $_POST['caption'] . "','false','" . ($_POST['rotate'] == '' ? 'fals' : 'tru') . "e');"; $ph = pg_connect ('dbname=bw host=localhost port=5432 user=$$USER$$ password=$$DBPW$$'); $pq = pg_query ("INSERT INTO bw VALUES('" . $_POST[d] . "','" . $_POST['p'] . "','" . $_POST['caption'] . "','false');"); pg_close ($ph); echo '

Image added. Close me.

'; } ?>

Attachment: send_selected.php
Description: application/php

Attachment: nugrab
Description: application/shellscript

Attachment: index.html.800x600.php-template
Description: application/php