$_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'] ); $mysess_vars = serialize(array_merge($mysess_vars_tmp, unserialize($read_sess))); $write_sess = pgsql_session_write($sess_name, $mysess_vars); //------------------------------------------ ///////// ## END ## SESSION WRITE } //////////// setup session variables // read the session then write with these values: $read_sess = pgsql_session_read($sess_name); $tmp_read = unserialize($read_sess); if ($_POST['month_select']) { $mysess_vars = array ('month' => $_POST['month_select'], 'year' => $_POST['year_select']); $write_sess = pgsql_session_write($sess_name, serialize(array_merge($tmp_read, $mysess_vars))); } else { $today=getdate(); $mysess_vars = array ('month' => $today['mon'], 'year' => $today['year']); $write_sess = pgsql_session_write($sess_name, serialize(array_merge($tmp_read, $mysess_vars))); } //////////// setup session variables // then read back into $month_sess_vars and $year_sess_vars for the rest of the script $read_sess = pgsql_session_read($sess_name); $tmp_read = unserialize($read_sess); $month_sess_vars = $tmp_read['month']; $year_sess_vars = $tmp_read['year']; //////////// setup HTML Layout include("include/class.layout"); setdefault("window",array("bgcolor"=>"#cccccc")); newhtml(&$w); insert($w, $h = wheader("PHP Photo Gallery")); include("include/js.php"); insert($h,style("a { font-size: 11px; }",array())); setdefault("table",array("cellpadding"=>"0","cellspacing"=>"0","bgcolor"=>"#99aacc","width"=>"650","height"=>"500")); setdefault("text",array("size"=>"1", "face" =>"verdana,arial,helvetica")); // print header table insert($w,$t2 = table(array("cellpadding"=>"5","cellspacing"=>"0","cols"=>"3","width"=>"800","height"=>"5"))); // column 1 insert($t2,$c = cell(array("colspan"=>"1","valign"=>"middle","align"=>"left"))); insert($c,text("PHP Photo Gallery",array("color"=>"white"))); // column 2 insert($t2,$c = cell(array("colspan"=>"1","valign"=>"middle","align"=>"right"))); insert($c, $f = form(array("name"=>"change_date","method"=>"post","action"=>$_SERVER[PHP_SELF]))); $month_array = array ( "1"=>"January", "2"=>"February", "3"=>"March", "4"=>"April", "5"=>"May", "6"=>"June", "7"=>"July", "8"=>"August", "9"=>"September", "10"=>"October", "11"=>"November", "12"=>"December", ); insert($f, select($month_array,array("onchange"=>"this.form.submit()","name"=>"month_select"), $month_sess_vars)); // column 3 insert($t2,$c = cell(array("colspan"=>"1","valign"=>"middle","align"=>"right"))); insert($f, select(array("2003"=>"2003","2002"=>"2002"),array("onchange"=>"this.form.submit()","name"=>"year_select"), $year_sess_vars)); /////////////////////// // print body table insert($w,$t = table(array("cellpadding"=>"18","cellspacing"=>"0","cols"=>"4","width"=>"800","height"=>"460"))); ///////////////////////////////////////////////////////////////// ///// initialise database $dbconn2 = pg_connect ("host=localhost port=5432 dbname=photo_album user=postgres"); if (!$dbconn2) { print "could not connect
"; } $query = "SELECT * FROM photos"; $result = pg_query ($dbconn2,$query); while($i = pg_fetch_array($result)) { $today=getdate($i['filetime']); if ($today['mon']==$month_sess_vars) { insert($t,$c = cell(array("colspan"=>"1","bgcolor"=>"#cccccc","valign"=>"top","align"=>"center"))); $thumb_link = str_replace("/home/httpd/htdocs/album/images/", "images/", $i['thumb']); $image_link = str_replace("/home/httpd/htdocs/album/images/", "images/", $i['image']); $fullsize_link = str_replace("/home/httpd/htdocs/album/images/", "images/", $i['original']); insert($c,anchor("Javascript:Start('".$image_link."')",image($thumb_link, array("alt"=>"Image ID: ".$i['id'],"border"=>"0")))); $display_date = $today['weekday']." ". $today['mday']." ".$today['month'].", ".$today['year']; $display_time = sprintf("%02d", $today['hours']).":". sprintf("%02d", $today['minutes']); insert($c,text("
".$display_date." - ".$display_time,array("size"=>"1","color"=>"#667799"))); //// LINK TO DOWNLOAD RAW IMAGE, ALSO REPORTS FILESIZE $filesize_raw = ((filesize ($fullsize_link))/1024); $filesize_KB = round($filesize_raw); $tmpi = substr($i["original"], -12); $grabimage = "include/passthru.php?id=".$i["id"]."&link=".$tmpi; insert($c,anchor($grabimage,"
Raw image for 6x4 prints
[ ".$filesize_KB." KB ]")); } } ////////////////////////////////////////////////////////////////////// // print footer table $exec_time = array_sum(explode(' ', microtime())) - $t_start; insert($w,$t = table(array("cellpadding"=>"1","cols"=>"1","width"=>"800","height"=>"10"))); insert($t,$c = cell(array("colspan"=>"1"))); insert($c,text("Page generated in " . sprintf("%0.2f",$exec_time) . " seconds", array("size"=>"1", "face" =>"verdana,arial,helvetica","color"=>"black"))); printhtml($w); ?>