[PHP] Open a stream to the shell..

2004-08-28 Thread Joel Kitching
Hello, is it possible to open a stream in which I can write commands
and read output from them to a shell like bash?  I want to do this
because this program can not be completed with just a `backtick` or
shell_exec() command, as it's somewhat user-interactive.

As an example, let's say I want to get cdecl to explain to me what
char *horse means.  I would type:

# icdecl/i
Type `help' or `?' for help
cdecl iexplain char *horse/i
declare horse as pointer to char
cdecl iexit/i

...where input is surrounded by ithese/i.  This would be difficult
or impossible to do with shell_exec, especially if halfway-through you
have to do some calculating before you can know what to ask cdecl
next.

So I want to know whether you can somehow open a stream to a shell,
and execute commands there.  Like...

$fp = fopen('/bin/bash', 'rw');
$output = fgets($fp);
fputs($fp, 'cdecl');
$output = fgets($fp);
$output = fgets($fp);
fputs($fp, 'explain char *horse');
$expl = fgets($fp);
/* Right now you could do some calculations and figure out what to do next. */
$output = fgets($fp);
fputs($fp, 'exit');
$output = fgets($fp);
fclose($fp);

Now this obviously wouldn't work, as it would overwrite the bash
executable if you had proper access, but it's just to get the idea
across.

So, does anyone know how I can do this?

-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



[PHP] PHP5 OOP

2004-08-10 Thread Joel Kitching
Hello, I'm trying to get the hang of OOP here but can't quite figure
out how to relate these classes.  I've got one for the main project,
one for the database, and one for a user.  Somehow I need to get the
user access to the database, without cumbersome constructor calls
involving a copy of the instance of the class itself.

// main project class
class gfusion {
protected static $db;
function __construct() {
$this-db = new db;
}
}


// database class
class db {
private $link;
private $query;
private $result;
...
function query($query);
function fetch_row();
function fetch_rows();
...
}


// user class
class user {
private $id;
private $group_id;
private $login;
private $password;
/* Somehow I need to get the db class instance here. */

function __construct($id = false) {
if (is_numeric($id)) {
print_r($this);
$this-db-query('SELECT * FROM user WHERE id = ' . $id);
$user_info = $this-db-get_row();

$this-id = $user_info['id'];
$this-group_id   = $user_info['group_id'];
$this-login  = $user_info['login'];
$this-password   = $user_info['password'];
}
}
...
}

 
I tried extending the user class from the project class, but that
didn't work, because the $db var was empty.  I tried changing it to
static, but it didn't inherit the $db variable for some reason.  So,
how can I make this work, so I can write a bunch of classes that can
blindly use $this-db or something similar without having to worry
about setting it in the constructor?  I thought about setting it as a
global, but that didn't seem very... OOP.

-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



Re: [PHP] Re: How to escape apostrophe in HTML textbox exactly???

2004-06-30 Thread Joel Kitching
What's wrong with addslashes() on the way in and stripslashes() on the
way out?  Why would you want to convert it to it's HTML entity?

-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



Re: [PHP] Re: How to escape apostrophe in HTML textbox exactly???

2004-06-30 Thread Joel Kitching
 1. addslashes() is not as robust as other solutions like
 mysql_escape_string().

What exactly is the difference between the two?

 2. in either case the slashes will be non-existant when the data is
 actually inserted into the database.
 
 for example:
 
 $mystring = hello here is my string. it has an ' (apostrophe) in it.;
 
 $sql = 
 INSERT INTO data
 (thestring)
 VALUES ('$mystring');
 
 when then is parsed it will look like this:
 
 INSERT INTO data
 (thestring)
 VALUES ('hello here is my string. is has an ' (apostrophe) in
 it.')
 
 as you can see the ' in the original string is going to cause a problem.
 by escaping it with mysql_escape_string() (or another comparable
 function) you'll get the following:
 
 INSERT INTO data
 (thestring)
 VALUES ('hello here is my string. is has an \' (apostrophe) in
 it.')
 
 this string, although it now contains a slash that we originally did not
 want, this slash not exist once the data is actually inserted into the
 database. it's merely there to tell the database hey, please ignore the
 ' that comes directly after me.
 
 s... when you pull the data *out* of the database the \ will not
 exist and you therefore do not need to perform stripslashes().

I tried using addslashes() on the string in the query, and then
SELECTing it, and the slashes are included.  Does
mysql_escape_string() not do this?

 
 and now to the second part... why use htmlentities()? that is for
 displaying data within a form element OR (i hope i have this right)
 preventing XSS (Cross Site Scripting attacks).
 
 hope this helps!
 chris.
 
 


-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



[PHP] OOP, Classes, Sharing Code

2004-06-28 Thread Joel Kitching
I'm kind of new to OOP, so bear with me here...

I have a portfolio which contains albums.  These albums contain
photos.  So it would be natural to declare the classes:

Portfolio
Album
Photo

It seems to me that none of these classes have the is a
relationship, and therefore can not be extended from each other. 
The reason I wish to do this, is because listing albums and listing
photos use almost exactly the same code.

i.e.

// The constructor would automatically fill in the album's variables
from the database.
$album = new Album($album_id);
// This would print out the HTML for the list of photos.
$album-list_photos();

... or the same thing with Portfolio, which would list the albums. 
The only thing that's different is the links to which the anchors are
pointing, and the content.  (Thumbnails.)

So my question is, should I just duplicate the code in each class
(Portfolio and Album), or is there a better way of organizing all of
this?

-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



Re: [PHP] OOP, Classes, Sharing Code

2004-06-28 Thread Joel Kitching
On Mon, 28 Jun 2004 13:41:19 -0500, Jay Blanchard
[EMAIL PROTECTED] wrote:
 If you are going to duplicate code why not just create a generic class
 with the code that would be duplicated and then extend the class as
 required?
 

What generic class name would be appropriate in this case?  I just
can't see how I would link the two together.  Also, they would have to
use fairly generic variables names if I were to do this.  Like using
the variable $items for the array of classes of either albums or
photos.

Or maybe this is exactly what OOP is about and I'm just starting to get it.

-- 
Joel Kitching
http://midgardmanga.keenspace.com/

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



Re: [PHP] Re: Php survey+database

2004-06-23 Thread Joel Kitching
I think he wants us to tell him how to set up PHP and a database, and
then write some PHP code to add survey results to the database.  So,
get on it!

On Thu, 24 Jun 2004 13:07:28 +1000, Ligaya Turmelle [EMAIL PROTECTED] wrote:
 
 So what is your question.
 
 Respectfully,
 Ligaya Turmelle
 
 Tommie Ramirez.Andujar [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
  Dear colleagues..
 
  I am new to php and I am trying to do the following, to create a php file
  that may contain some kind of form or survey and the data entered may be
  added to a database...
  Here the code of the html form
 
  -
  html
  head
  titleSurvey/title
  meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
  /head
 
  body
   p strongSurvey/strong/p
  form action= method=post name=importance  id=importance
table width=605 border=0
  tr
td strongIs reading important? /strong/td
  /tr
  tr
td  yes
  input name=radiobutton type=radio value=radiobutton/td
  /tr
  tr
td no
  input name=radiobutton type=radio value=radiobutton/td
  /tr
  tr
td maybe
  input name=radiobutton type=radio value=radiobutton/td
  /tr
  tr
td i don't know
  input name=radiobutton type=radio value=radiobutton/td
  /tr
  tr
td iquest;Why? /td
  /tr
  tr
td textarea name=textarea cols=85 rows=5 /textarea/td
  /tr
/table
  /form
  br
  /body
  /html
  
 
 
  __
  msc. tomas alberto ramirez.andujar
  webmaster - cejisoft - +53 32 26 24 51
  universidad pedagogica jose marti. camaguey
  circunvalacion norte km 51/2 cp 74670. cuba
  email : [EMAIL PROTECTED]
  url: http://www.esicm.cu/cejisoft
 
 
 
  
  Este mensaje ha sido analizado por MDaemon Antivirus v2.21.
  Instituto Superior Pedagógico de Camaguey, Cuba.
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] hi all can you read me ?

2004-06-20 Thread Joel Kitching
I'm not quite sure, do you have something written on you?

On Mon, 21 Jun 2004 01:51:51 +0200, Pierre [EMAIL PROTECTED] wrote:
 
 Hi all just wanna check if you can read me
 
 Thx
 


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



Re: [PHP] plz help!compiled php but iam still getting old version ???

2004-06-20 Thread Joel Kitching
Try looking in your apache configuration files for a reference to a
PHP library file or something...  Though I don't see the logic in
installing an older version either.

On Sun, 20 Jun 2004 21:53:37 -0400, Michael Lauzon [EMAIL PROTECTED] wrote:
 
 Why do you want to install 4.3.3, when the latest version is 4.3.7?
 
 
 
 On Mon, 21 Jun 2004 19:07:32 -0400 (EDT), Ravi [EMAIL PROTECTED] wrote:
 
  HI,
 
  existing configuration :
  PHP Version 4.3.4 ( default rpm with fedora fc2 install)
  Server version: Apache/2.0.49 (default with fedora fc2 install)
  Server built:   May  6 2004 07:15:13
 
  NOw i want to install 4.3.3 , so i compiled and install ( with no errors )
  if i type  php -v  at shell iam getting correct version *BUT if tried
  phpinfo() in browser iam getting still OLD version :( restarted apache but
  no use.
 
  please help
 
  - thanks for your time.
 
  --- knowledge is power share it - ravi.us ---
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
 --
 Michael Lauzon, Founder
 The Quill Society
 http://www.quillsociety.org/
 [EMAIL PROTECTED]
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Regular Expressions Tester/designer

2004-06-19 Thread Joel Kitching
On Sat, 19 Jun 2004 17:23:53 -0400, Al [EMAIL PROTECTED] wrote:
 
 Anyone know of a good regular expressions tester/designer for php coding
 running  windows.
 
 I've looked at the Rad Software Regular Expressions Designer and it
 looks pretty good except that it is intended for .net and it really
 doesn't seem to be entirely PCRE compatible.
 
 Thanks
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

You could always just use a simple online one like...

http://www.quanetic.com/regex.php

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



Re: [PHP] cookie question

2004-06-19 Thread Joel Kitching
Did you do this before you sent some outut?  This would send headers,
therefore causing you to not be able to send the cookie header.

On Sat, 19 Jun 2004 15:51:00 -0600, water_foul
[EMAIL PROTECTED] wrote:
 
 whats wrong with this script
 setcookie('link' . $loopnum . '',$url,time()+3600*200);
 setcookie('name' . $loopnum . '',$name,time()+3600*200);
 it doesn't write the cookies
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] cookie question

2004-06-19 Thread Joel Kitching
Are you sure you're trying to access them properly, and on the next
page refresh?

ex)

?php
// Print an individual cookie
echo $_COOKIE[TestCookie];
echo $HTTP_COOKIE_VARS[TestCookie];

// Another way to debug/test is to view all cookies
print_r($_COOKIE);
? 

On Sat, 19 Jun 2004 15:56:36 -0600, water_foul
[EMAIL PROTECTED] wrote:
 
 all i did was a function and some conditionals
 Joel Kitching [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
  Did you do this before you sent some outut?  This would send headers,
  therefore causing you to not be able to send the cookie header.
 
  On Sat, 19 Jun 2004 15:51:00 -0600, water_foul
  [EMAIL PROTECTED] wrote:
  
   whats wrong with this script
   setcookie('link' . $loopnum . '',$url,time()+3600*200);
   setcookie('name' . $loopnum . '',$name,time()+3600*200);
   it doesn't write the cookies
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] cookie question

2004-06-19 Thread Joel Kitching
There are many examples (in the comments) at the manual entry for
set_cookie at php.net; go try one of those.

On Sat, 19 Jun 2004 16:07:34 -0600, water_foul
[EMAIL PROTECTED] wrote:
 
 i did that and it doesn't say that theere there, how do you set cookies so
 that theyy dont expire (maby the expiration is set wrong.. i'm a newb
 with cookies
 
 Joel Kitching [EMAIL PROTECTED] wrote
 Are you sure you're trying to access them properly, and on the next
  page refresh?
 
  ex)
 
  ?php
  // Print an individual cookie
  echo $_COOKIE[TestCookie];
  echo $HTTP_COOKIE_VARS[TestCookie];
 
  // Another way to debug/test is to view all cookies
  print_r($_COOKIE);
  ?
 
  On Sat, 19 Jun 2004 15:56:36 -0600, water_foul
  [EMAIL PROTECTED] wrote:
  
   all i did was a function and some conditionals
   Joel Kitching [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
  
  
Did you do this before you sent some outut?  This would send headers,
therefore causing you to not be able to send the cookie header.
   
On Sat, 19 Jun 2004 15:51:00 -0600, water_foul
[EMAIL PROTECTED] wrote:

 whats wrong with this script
 setcookie('link' . $loopnum . '',$url,time()+3600*200);
 setcookie('name' . $loopnum . '',$name,time()+3600*200);
 it doesn't write the cookies

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


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


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



Re: [PHP] Re: hellllppp my php kills the browser

2004-06-19 Thread Joel Kitching
Perhaps you would be better off going to IRC, as you seem to have many
(smaller) questions...

On Sat, 19 Jun 2004 17:42:26 -0600, water_foul
[EMAIL PROTECTED] wrote:
 
 i fixed it i had an endless loop oops :)
 Water_foul [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 
 
  i dont know why but the following code kills the browser:
  ?php
  //the function for adding new addresses
  function loop_new_address($loopnum,$url,$name){
  //the ${'link' . $loopnum} says put $link and add $loopnum to the end
  if(isset($_COOKIE['link' . $loopnum . ''])){
  loop_new_address_help($loopnum+1,$url,$name);
  }
  else{
  setcookie('link' . $loopnum . '',$url,time()+3600,'/');
  setcookie('name' . $loopnum . '',$name,time()+3600,'/');
  setcookie('link' . $loopnum . '',$url,time()+3600);
  setcookie('name' . $loopnum . '',$name,time()+3600);
  print('a href=$url' . $name . '/a was added');
  };
  };
  //A function to let loop_new_address loop
  function loop_new_address_help($loopnum,$url,$name){
  loop_new_address($loopnum,$url,$name);
  };
  if(isset($_GET['new'])) {
  loop_new_address(1,$_GET['url'],$_GET['name']);
  };
  print('table');
  print('trtdform Method=GET
  action=module/personal/delete.phpdelete/td/tr');
  //write code
  $writenum=1;
  while(isset($_COOKIE['link' . $writenum . ''])==true){
  print('a href=' . $_COOKIE['link' . $writenum . ''] . '' .
 $_COOKIE['name'
  . $writenum . ''] . '/a');
  };
  include('links.htm')
  ?
  trtdinput type=submit value=Delete Checked/form/td/tr
  /table
  table
  trtdform METHOD=GET ACTION=module/personal/links.phpinput
  type=hidden name=new value=1/tdtd/td/tr
  trtdSite name/tdtdINPUT TYPE=text NAME=name VALUE=/td/tr
  trtdsite url (if it is not on this site it MUST contain
  http://;)/tdtdINPUT TYPE=text NAME=url VALUE=/td/tr
  trtd/tdtdINPUT TYPE=SUBMIT VALUE=Continue/form/td/tr
  /table
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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