[PHP] sessions problem, need help

2003-02-19 Thread Noel Akins
Hello,
I'm new to sessions and I know a little php, but don't use it enough to 
remember it. I'm trying to use sessions for a couple of reasons. I will 
explain as i go along.

My index.html is this (www.loveobjects.com) -not porn my host uses version 
4.0.6

html
head
script language=javascript
!--
  var cWidth=0, cHeight=0; fsize=12;
function clientSize() {
  if( typeof( window.innerWidth ) == 'number' ) { //Non-IE
cWidth = window.innerWidth;
cHeight = window.innerHeight;
  }
  else {
if( document.documentElement 
( document.documentElement.clientWidth || 
document.documentElement.clientHeight ) ) {//IE 6+ in 'standards 
compliant mode'
  cWidth = document.documentElement.clientWidth;
  cHeight = document.documentElement.clientHeight;
}
else {
  if( document.body  ( document.body.clientWidth || 
document.body.clientHeight ) ) {   //IE 4 compatible
 cWidth = document.body.clientWidth;
 cHeight = document.body.clientHeight;
  }
}
  }
  location.replace('http://www.loveobjects.com/test_1.php?w='+cWidth+'h='+cHeight+'fSize='+fsize);
}
--
/script
/head
body bgcolor=#00; onload=javascript:clientSize();/body
/html

You can see that it gets the client window size and sets a default font 
size, then redirects, sending along the vars in the url string.


The test_1.php looks like this.

?php
session_start();
header(Cache-control: private);
$HTTP_SESSION_VARS['width'] =  $HTTP_GET_VARS['w'];
$HTTP_SESSION_VARS['height'] =  $HTTP_GET_VARS['h'];
$HTTP_SESSION_VARS['fontS'] =  $HTTP_GET_VARS['fSize'];
$HTTP_SESSION_VARS['fontC'] =  $HTTP_GET_VARS['cFont'];
$HTTP_SESSION_VARS['id'] =  session_id();
header(Location: 
http://www.loveobjects.com/test_2.php?id=.$HTTP_SESSION_VARS['id']);
?

But, this gives me a 404.
I've tried to use a link instead of the header() such as:

print(a href=\/test_2.php?id=.$HTTP_SESSION_VARS['id'].this/a);

Which will create a 
href=./test_2.php?id=b5c93c1f165018cda39d0d751d27d368this/a and show in 
the status bar as 
http://www.loveobjects.com/test_2.php?id=b5c93c1f165018cda39d0d751d27d368
but this gives me a 404 too. (The _ is there in test_2.php. in the above 
line. You just don't see it with the whole link underlined).

I don't want to pass along the client and font vars by means of the GET 
vars to test_2.php. I want them in the session vars. I want to be able to 
change the font size, or let the user change the font size. And I don't 
want a font size var hanging around in the url string. I also want to limit 
what info and be bookmarked. I also don't want to rely on cookies to send 
the session id and other stuff.

test_2.php looks like this:

?php
session_start();
header(Cache-control: private);
require($_SERVER[DOCUMENT_ROOT] . Pagemaker.class);
$pagemaker = new Pagemaker;
$pagemaker-set_fontsize($HTTP_SESSION_VARS['fontC'],$HTTP_SESSION_VARS['FontC']);
$pagemaker-set_stdwidth($HTTP_SESSION_VARS['width']);
$pagemaker-set_stdheight($HTTP_SESSION_VARS['height']);
$pagemaker-find(test_1);
//print($pagemaker-Errno);
print($pagemaker-Error);
print($pagemaker-haltmsg);
print($pagemaker-contents);
?

Pagemaker.class worked before I started wwith all this session stuff. (with 
different code ofcourse)

Please help. Any suggestions will be helpful.
Thanks
Noel




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] new to classes, need help

2002-12-24 Thread Noel Akins
I'm trying to get my head around php classes. I want to write a small php 
file (call it genericly uniquepagesomething.php) that will call the 
pagemaker.class.  For example Apples3.php that calls pagemaker.class. In 
pagemaker.class, it will look up page 3 of the topic apples from a table 
and get the text file. It will also look up the proper template to 
use.  pagemaker.class will then insert the text file into the template and 
print it out to the browser.

Here is what I have cobbled together so far from various things i've read.

- uniquepagesomething.php 
?php
require(pagemaker.class);
$pagemaker = new pagemaker;
$pagemaker-find($findpage, $pagesomething);
$pagemaker-make(pagesomething);
?


- pagemaker.class 
?php
class pagemaker
 var $Host = ; // Hostname of our MySQL server.
 var $Database = ; // Logical database name on that server.
 var $User = ; // User und Password for login.
 var $Password = ;

 var $Link_ID  = 0;  // Result of mysql_connect().
 var $Query_ID = 0;  // Result of most recent mysql_query().
 var $Record   = array();  // current mysql_fetch_array()-result.
 var $Row;   // current row number.

 var $Errno= 0;  // error state of query...
 var $Error= ;

 function find($findpage,$pagesomething) {
  $this-$findpage=$pagesomething;  //fix this to split the 
topic and page number
  $this-$Query_String=select tmplt, image, file, desc from 
pages where ;  //fix this too
  $this-connect();

  #   printf(Debug: query = %sbrn, $Query_String);

  $this-Query_ID = 
mysql_query($this-Query_String,$this-Link_ID);
  $this-Row   = 0;
  $this-Errno = mysql_errno();
  $this-Error = mysql_error();
  if (!$this-Query_ID) {
 $this-halt(Invalid SQL: .$Query_String);
  }

  return $this-Query_ID;
 }
 function halt($msg) {
  printf(bDatabase error:/b %sbr\n, $msg);
  printf(bMySQL Error/b: %s (%s)br\n,
  $this-Errno,
  $this-Error);
  die(Session halted.);
 }

 function connect() {
  if (0 == $this-Link_ID ) {
  $this-Link_ID=mysql_connect($this-Host, $this-User, 
$this-Password);
  if (!$this-Link_ID) {
 $this-halt(Link-ID == false, connect failed);
  }
  if (!mysql_query(sprintf(use 
%s,$this-Database),$this-Link_ID)) {
 $this-halt(cannot use database .$this-Database);
  }
  }
 }
 find();
?

Is this going anywhere in the right direction?
any comments are welcome
Thanks



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] disabling page caching, yes or no

2001-01-30 Thread Noel Akins

Hello,
I'm trying to build the first page to a database driven website.  The first 
thing I'm trying to do is detect if cookies are enabled on the users 
browser, and then, via a header(location: mysite.php), redirect the user to 
either a cookie supported page, or cookie unsupported page.  I will use 
sessions, in some form or another on each.
My concern is that this first page, or any following page, not be cached. 
In the #php channel,  it was said, or I understood from what was said, that 
by default, php pages aren't cached.  It was also mentioned that I should 
make each url unique by using time() or uid of some kind.  In the php 
manual, under Header(), it listed four ways to disable caching. they are:

header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always 
modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0

Should I be concerned about page caching? If so, should I use one of the 
header() statements, a combination of header() statements? Can I use a 
combination of header() statements?  The first page can't have a unique 
url.  The following one would be unique by use of sessions I would think, 
but that may not keep them from being cached, would it?
Any direction would be of great help to me.
Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] confused about getenv arguements

2001-01-27 Thread Noel Akins

Hello,
I found this script at zend. Please note the getenv("HTTP_REFFERER").

?

/* Anti-leech bandwidth protecter by Corey Milner, http://www.odey.com.
Turn the refererring URL into a variable */
$from = getenv("HTTP_REFERER");

/* Check to see if the URL in the variable is a valid referrer. Add the 
page URL which you would like people to arrive from here. */
if ($from != "http://www.yoursite.com/validpage.htm")

/* If the URL is valid, page loads now */

/* If URL is invalid the following error message and proper link appears, 
enter your custom error message and a hyperlink to the valid URL you 
entered above here*/
{print(" Sorry you have tried to link to a page which does not accept 
visitors directly. br
a href=http://www.yoursite.com/validpage.htmCLICK HERE/a to enter");

/* Prevent the rest of the page from loading */
exit;}

?

I went to check getenv in the php manual, and it said "You can see a list 
of all the environmental variables by using phpinfo(). You can find out 
what many of them mean by taking a look at the CGI specification, 
specifically the page on environmental variables.

I made a php script phpinfo(INFO_ALL) to return everything for my host and 
did not see HTTP_REFFERER, not did I see any of the other args that were in 
the comments on the getenv page.
I looked at the linked cgi pages and didn't find anything there either.

If by not seeing these HTTP_like variables in my phpinfo, does that mean 
they are unavailable to me to use? Do they have to be setup during the 
install of php/apache?
Where can I get more info on these getenv args/vars?

Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] sessions without cookies?

2001-01-26 Thread Noel Akins

Would there be any point in using php sessions if you aren't using cookies? 
You have to store login info anyway, why not just use a temp table to store 
transaction info and write to the database at the end of a session? From 
what I've read on sessions, you have to use cookies
thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]