Re: [php-list] Searching record problem

2008-11-21 Thread listgroups08
- Original Message - 
From: <[EMAIL PROTECTED]>
To: 
Sent: Saturday, November 22, 2008 7:19 AM
Subject: Re: [php-list] Searching record problem


- Original Message - 
From: "Mohammad Ashrafuddin Fredousi"

hi,
anyone have the joomla 1.5 manual(developer's technical manual)? if so, please 
send it to me at
[EMAIL PROTECTED] if not, then what process you suggested to learn joomla 1.5 
in a easy way?

thanx

Hi Mohammad Ashrafuddin Fredousi,

Joomla is old. If you are just starting out then take a look at some of the 
Rapid Application
Development platforms (RAD's) available now.

I don't have a direct answer to your question but I can say that Joomla is 
based in the 'Smarty'
templating engine so you may be better off googling for Smarty. Depends on what 
you want to know, If
you are just wanting to know the administrative interface then go look for a 
Joomla manual. If you
are hands on in the code then google Smarty.

Thanks.




OOPS!

I was thinking of another CMS.

http://docs.joomla.org/Developers#Reference_Pages



Re: [php-list] Searching record problem

2008-11-21 Thread listgroups08
- Original Message - 
From: "Mohammad Ashrafuddin Fredousi"

hi,
anyone have the joomla 1.5 manual(developer's technical manual)? if so, please 
send it to me at 
[EMAIL PROTECTED] if not, then what process you suggested to learn joomla 1.5 
in a easy way?

thanx

Hi Mohammad Ashrafuddin Fredousi,

Joomla is old. If you are just starting out then take a look at some of the 
Rapid Application 
Development platforms (RAD's) available now.

I don't have a direct answer to your question but I can say that Joomla is 
based in the 'Smarty' 
templating engine so you may be better off googling for Smarty. Depends on what 
you want to know, If 
you are just wanting to know the administrative interface then go look for a 
Joomla manual. If you 
are hands on in the code then google Smarty.

Thanks. 



Re: [php-list] Searching record problem

2008-11-21 Thread listgroups08
- Original Message - 
From: "yousuf hussain"

Dear members:

I came across a problem that while searching a record 
from a database it 
only returns one field record. i want to search it with different option.
  Code is given below
  Only Unit record is returned



 

 
  
  
  
  
  
  
  
 

It is really good to see the use of associative MySQL arrays. I only use 
mysql_fetch_assoc() 
although an array of rows is numerically indexed. This saves much heartache 
when making changes to 
the database structure.

  

I would do this differently -
  

php is mostly white space insensitive so take advantage of this. It makes code 
easier to read by 
placing spaces between all units of code. I use $var['key'] rather than 
$var["key"] as there is no 
need to parse a variable key for other variables.

In fact I never use echo("The time is $time"); instead I use echo('The time is' 
. $time); Especially 
with mysql queries. Just remember to have spaces where needed -
$query = 'SELECT COUNT(*) FROM users, groups';
$query .= ' WHERE users.GroupID = groups.GroupID';
$query .= ' AND groups.GroupType = ' . $grouptype;

MySQL doesn't need single quotes (') around table and field names if you use 
the white space 
correctly in queries UNLESS you have spaces in table or field names in the 
database. Save yourself a 
lot of trouble tracking down missing or extra quotes in query string by not 
using spaces in 
table/field names in the database.

The echo 'test'; verses my echo('test'); is a bad habit of mine. I was well 
into learning php before 
I discovered that echo was a primitive rather than a function. Like return, 
continue, break etc.

Here are some simple database abstractions.

//  function db_connect() 

function db_connect()
  {
  global $db_handle;
  $db_handle = mysql_connect('host', 'username', 'password'); // Local access
  mysql_select_db('databasename'); // Local access
  }



//  function db_to_array() 

function db_to_array($query)
  {
  global $db_handle;
  $result = mysql_query($query, $db_handle);
  if(mysql_error($db_handle)) echo(mysql_error($db_handle) . "\n" . 
$query . "\n");
  if(mysql_num_rows($result) == 0) return FALSE;
  if(mysql_error($db_handle)) echo(mysql_error($db_handle) . "\n" . 
$query . "\n");
  $responce = mysql_fetch_row($result);
  return $responce[0];
  }



//  function db_to_arrays() 

function db_to_arrays($query)
  {
  //echo($query . "\n");
  global $db_handle;
  $result = mysql_query($query, $db_handle);
  if(mysql_error($db_handle)) echo(mysql_error($db_handle) . "\n" . 
$query . "\n");
  if(mysql_num_rows($result) == 0) return FALSE;
  if(mysql_error($db_handle)) echo(mysql_error($db_handle) . "\n" . 
$query . "\n");
  while($array = mysql_fetch_assoc($result))
{
$db_data[] = $array;
}
  return $db_data;
  }








Re: [php-list] MySQL field type information

2008-11-20 Thread listgroups08
- Original Message - 
From: "HELLBOY"

>   Hello all,
> I want to know how to get information about field types. I am using MyISAM.
>
> I can see some MySQL instructions that can do this for one field at a time
> but I want to get the
> stats for a whole table at once.
>
> For example -
>
> How do I get information on each field of a table as to weather or not that
> field can be null?
>
> And how do I get each data type for each of the fields in a table?
>
> I need the 'NOT NULL' / 'NULL' to force the administrator to allow access
> to this field for users
> who are permitted to add data items.
>
> I also need the data type so that I can associate validation REGEX with a
> field type as the data
> base is too broad to script individual field validations in php.
>
> Any pointers for REGEX for various MySQL data types would be greatly
> appreciated as I have no real
> experience with REGEX.
>
> Thanks all, Robert.
>
>
>
--
Hi,
I think I have an answer.
query for ur question is -  'DESCRIBE *tablename'*;
just execute this query, It will return a resultset of field details for
given table in the format--
*Field | Type | Null | Key | Default | Extra*
It means u will have required information in resultset.

REgards,
Rider.
-
Hello HELLBOY,

Thank you, absolutely perfect!

Just one other thing would be helpful.

Can anyone give me a link to information that describes the information 
returned in the fields 'KEY' 
and 'EXTRA'?

Thanks all, Robert. 



[php-list] MySQL field type information

2008-11-20 Thread listgroups08
Hello all,
 I want to know how to get information about field types. I am 
using MyISAM.

I can see some MySQL instructions that can do this for one field at a time but 
I want to get the 
stats for a whole table at once.

For example -

How do I get information on each field of a table as to weather or not that 
field can be null?

And how do I get each data type for each of the fields in a table?

I need the 'NOT NULL' / 'NULL' to force the administrator to allow access to 
this field for users 
who are permitted to add data items.

I also need the data type so that I can associate validation REGEX with a field 
type as the data 
base is too broad to script individual field validations in php.

Any pointers for REGEX for various MySQL data types would be greatly 
appreciated as I have no real 
experience with REGEX.

Thanks all, Robert. 



Re: [php-list] How do I get form elements values BEFORE SUBMIT & AFTER SUBMIT????

2008-11-18 Thread listgroups08
- Original Message - 
From: "HELLBOY"

Hi All,
Here is the reason why i ak asking for ur help.

I have a edit form in which the values already stored in DB are populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before submitting &
after submitting.
I HAVE TO COMPARE  these values so that i can send only changed values to
server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.

Regards,
Rider


Hello HELLBOY,

After re-reading you post I have a suggestion. 


 $value)
  {
  echo('' . "\n");
  echo('' . 
"\n");
  }
?>


Re: [php-list] How do I get form elements values BEFORE SUBMIT & AFTER SUBMIT????

2008-11-18 Thread listgroups08
- Original Message - 
From: "HELLBOY"

Hi All,
Here is the reason why i ak asking for ur help.

I have a edit form in which the values already stored in DB are populated.
User can edit some or all the values in the form.
then he submit the form.

NOW I WANT SOME JAVASCRIPT / PHP FUNCTIONALITY WHICH WILL GIVE ME THE
types & values OF ALL ELEMENTS ON FORM WHICH SHOULD BE before submitting &
after submitting.
I HAVE TO COMPARE  these values so that i can send only changed values to
server.

I HAD TRIED form.elements in JAVASCRIPT BUT IT GIVES SAME VALUES.

Regards,
Rider
---
Hello HELLBOY,

If you want to do something before submitting a form then you are talking about 
browser code and 
this group is about php - a server code so we can't help you with this question 
here.

In any case some people disable Javascript so you need a system based plain 
HTML with perhaps some 
Javascript for extra but not required functions.

Why not just send on all the fields, changed or not, and sort it out on the 
server. The server has 
to validate the data anyway.

When you have done that, then worry about any Javascript but please don't ask 
here unless you are 
looking at some php generated AJAX.

What you are asking can be done in Javascript but this is the wrong group to 
ask about Javascript.

Thanks. 



Re: [php-list] Re: PHP newbie help

2008-11-12 Thread listgroups08
- Original Message - 
From: "brucewhealton"



Ok, I'm a bit confused on the single and double quotes.  If single
quotes does not replace the variable, then how would this work:
echo('');
The first choice from below?   Would that work with the single quotes?
I see that this would work:
print "";

I thought I was going to have to worry about escaping the < > and "
characters but none of these solutions require that.  Why?
Thanks,
Bruce




Hello Bruce,
   Someone mentioned that strings encapsulated in double quotes 
are parsed for 
variables etc only in print and echo primates however I seem to remember the 
same parsing when using 
the eval function so I suspect that this parsing exists for all strings 
encapsulated in double 
quotes.

My general rule is to use literal quotes ' for everything that does not need to 
be parsed -
$_SERVER['PHP_SELF']
echo('' . "\n");
I also use only double quotes in HTML that is sent as output.

To escape things in double quotes -
\" - double quote
\r - return
\n - new line

> If single quotes does not replace the variable, then how would this work:
> echo('');
The variable is not within quotes as the first quote is closed by a quote of 
the same type.

> Would this work with the single quotes?
> print "";

This - below will not work because the variable is within single quotes -
print '';
In fact it would cause an error

> I see that this would work:
> print "";

yes and another way to write it is -
print "";
But these only work because of the dot before jpg and without this dot php 
would be looking for the 
variable $numberjpg

> I thought I was going to have to worry about escaping the < > and "
> characters but none of these solutions require that.  Why?

< and > do not need escaping in php as the php open and close tags are 
< and > are only different for HTML as they are opening and closing tags there 
and hence < >

A double quote only needs to be escaped when a string is encapsulated in double 
quotes otherwise it 
would terminate the string prematurely




Re: [php-list] PHP newbie help

2008-11-11 Thread listgroups08
- Original Message - 
From: "brucewhealton" 

Hello all,
I thought this would be very easy but I'm doing something
wrong here.  I want to create a display of an image using a variable.
 In static html it is


I want the topbanner to change depending on the month of the year. 
So, I calculate that with this, easy enough:


I have six banners so I if $monthnum is greater than 6, I subtract 6.
 This so far is very easy.

Now, I want to build up the image tag using the php values.  So, I
have the following (this is just the part of the code for displaying
the image.

echo "";

I used the \ to escape the " on the first line where it should be
src="images/topbanner"

What's wrong here?
Thanks,
Bruce


$number = 0 + date('n');
if($number > 6) {$number = $number - 6;}
echo('');

you were missing the . before jpg






Re: [php-list] Basic Auth user/pass

2008-11-11 Thread listgroups08
- Original Message - 
From: "Wade Smart"

[EMAIL PROTECTED] wrote:

>
> The new question!
>
> I am running WAMP 2.0 (the latest version) as a development environment on 
> windows XP and I am 
> very
> happy with it but now there is one problem.
>
> How do I get Basic Auth to work on WAMP just the same way Basic Auth runs on 
> my Linux based 
> servers?
>
> All seems to be ok in XP but the encripted strings that are used in .htaccess 
> or passwd files do 
> not
> work with the same passwords that are used in the Linux environment.
>
> I am quite happy to use a different encryption algorithm in the development 
> environment and then 
> to
> swap algorithms when a site goes online but I don't know what algorithm to 
> use on a windows based
> server (not IIS - still Apache).
>
> Another possibility may be to get Apache to store passwords in plain text. 
> This would be fine in a
> development environment. Is this possible? And if so How do I confure it so?
>
> Thanks.

2008 0859 GMT-5

http://us3.php.net/features.http-auth

Did you read this page at php?

One of the things I really dislike is moving back and forth from Windows
to Linux for the exact problem you are facing now. The security that is
available on Linux naturally is missing in Windows.

I read an article in Linux Magazine that (and I cant remember the exact
details here) said to use mysql and encrypt your passwords there. You
have a username and password file - the username is plain text the
passwords are encrypted.


Wade
-- 
Registered Linux User: #480675
Linux since June 2005


Hello Wade,

I did read that page but it was mostly about getting PHP to send a 401. I won't 
doing this. I will 
let Apache do it and I will just retrieve the already validated user name with 
$_SERVER['PHP_AUTH_USER'] or $_SERVER['REMOTE_USER']

Some may laugh! The one thing that I did not try in the WAMP environment was a 
plain text password 
in the passwd file. Well it turns out the WAMP does not encrypt the passwords 
so that worked 
immediately.

I normally do as you mentioned with MySQL. That is store the username and a 
md5() of the password in 
a MySQL database. I learnt not to use the MySQL password function as the 
encryption changed in 
previous versions. However md5() is well specified and will not change.

The other thing I do as well is to write some javascript into the login page to 
md5() the password 
before it is sent. I then check for a straight match or a md5() match to the 
stored md5() of the 
password. The md5() match is for those who don't have javascript enabled. For 
those who do have it 
enabled then their password is sent in an encrypted form.

The let down of basic auth is that it sends the password in plain text but in 
most cases this is the 
outcome anyway.

Even though this method will work on Windows/Apache it will not work on 
Windows/IIS but I am not 
bothered about that, all my servers are Linux/Apache.

Thanks, Now I better get back to the real task.



Re: [php-list] Basic Auth user/pass

2008-11-10 Thread listgroups08
- Original Message - 
From: listgroups08

Hello all,

I am creating a web based interface to a large database that includes personal 
information.

In the past I have used php session control to authenticate members but now due 
to the personal
information, I am wondering if I should make things more secure.

Members will come and go and an administrator will have to approve new members 
and delete members
from time to time.

I am considering getting php to manages a .htaccess file so that the security 
of Apache basic auth
is added as a layer around php.

The problem is that different users will have access to a different range of 
information which will
overlap in places.

I am not really concerned that one member may attempt to hack privileges, it is 
more about the
general public.

Is there a way to find out the current users basic auth user name? If there is 
then I can simply use
php to determine access privileges by the basic auth user name and have the 
best of both worlds so
to speak.

I know there are POSIX commands that relate to file access but what is there in 
php that will tell
me a users basic auth username?

Thanks,



It's me again. I found the answers to the last questions and now I have a new 
question.

The answers are -
User Name: $_SERVER['PHP_AUTH_USER']
Password: $_SERVER['PHP_AUTH_PW']
Auth Type: $_SERVER['AUTH_TYPE']

And to generate an encryption for use in .htaccess passwd file for Basic Auth 
(Linux) -
$string = $username . ':' . crypt($password, base64_encode($passoword))) . "\n";

One CAUTION - Basic Auth (require valid-user) is session based on the server. 
The user being 'GROUP' 
in the attributes 'OWNER', 'GROUP', 'USER' or 'USER', 'GROUP', 'WORLD'.

This means that if you are on a shared server then another person on the same 
server can use a basic 
auth page on their website that links to your restricted area and the server 
will allow the session 
to continue as authorised (valid-user). So you have to destroy the session at 
the start or better 
still re-authenticate the user in the background and register a authentication 
flag into the 
session.



The new question!

I am running WAMP 2.0 (the latest version) as a development environment on 
windows XP and I am very 
happy with it but now there is one problem.

How do I get Basic Auth to work on WAMP just the same way Basic Auth runs on my 
Linux based servers?

All seems to be ok in XP but the encripted strings that are used in .htaccess 
or passwd files do not 
work with the same passwords that are used in the Linux environment.

I am quite happy to use a different encryption algorithm in the development 
environment and then to 
swap algorithms when a site goes online but I don't know what algorithm to use 
on a windows based 
server (not IIS - still Apache).

Another possibility may be to get Apache to store passwords in plain text. This 
would be fine in a 
development environment. Is this possible? And if so How do I confure it so?

Thanks.



[php-list] Basic Auth user/pass

2008-11-10 Thread listgroups08
Hello all,

I am creating a web based interface to a large database that includes personal 
information.

In the past I have used php session control to authenticate members but now due 
to the personal 
information, I am wondering if I should make things more secure.

Members will come and go and an administrator will have to approve new members 
and delete members 
from time to time.

I am considering getting php to manages a .htaccess file so that the security 
of Apache basic auth 
is added as a layer around php.

The problem is that different users will have access to a different range of 
information which will 
overlap in places.

I am not really concerned that one member may attempt to hack privileges, it is 
more about the 
general public.

Is there a way to find out the current users basic auth user name? If there is 
then I can simply use 
php to determine access privileges by the basic auth user name and have the 
best of both worlds so 
to speak.

I know there are POSIX commands that relate to file access but what is there in 
php that will tell 
me a users basic auth username?

Thanks,




[php-list] MySQL and browser close

2008-11-06 Thread listgroups08
Hello all,
I have a simple question about what may happen when a web page that 
is accessing MySQL 
is closed by the browser.

I have to script a database in simple MySQL and I need to be able to detect 
when a roll back 
condition may exist.

If a web page has a MySQL transaction such as INSERT will any initiated INSERT 
complete even if the 
browser is closed or is there a possibility of some fields being INSERTed and 
others not?

Thanks. 



Re: [php-list] image download

2008-11-05 Thread listgroups08
- Original Message - 
From: "zari lahr"

Dear sir..


this is what i am working out

==

" />



one thing that i have just stored the image name in mysql and store the all 
image in a saperate 
folder name images..as shown in the code above.. i want that when i click the 
download button the 
download box open and the image start to download.

regards

---



" />



download.php ...
\n");
return FALSE;
}
  if(!is_readable("images/" . $filename))
{
//echo("[" . $filename . "] Is not readable\n");
return FALSE;
}
  header("Cache-Control: public, must-revalidate");
  header("Pragma: hack");
  header("Content-Type: application/octet-stream");
  header("Content-Length: " . filesize($filename));
  header('Content-Disposition: attachment; filename="' . $filename . '"');
  header("Content-Transfer-Encoding: binary\n");
  readfile("images/" . $filename);
  return TRUE;
  }

?>
Hacking not permitted etc

Also note that this script can be placed ate the beging if the script that 
generated the image 
selection page so that the pinter can be ...


" />

 



Re: [php-list] image download

2008-11-05 Thread listgroups08
- Original Message - 
From: listgroups08

- Original Message - 
From: "zari lahr"

Dear sir..


this is what i am working out

==

" />



one thing that i have just stored the image name in mysql and store the all 
image in a saperate 
folder name images..as shown in the code above.. i want that when i click the 
download button the 
download box open and the image start to download.

regards



Hello Zari,
We type below previous posts in this group.

You didn't mention what file types that the image files are. ie - .jpeg . jpg 
.png .gif .bmp

You need another php file to force the download. See the headers() function on 
php.net

The above code will need to be changed to -

" 
/>

The important part is to make sure that the only files that the download script 
will download are 
image files from the correct location.

I need to know what file types are acceptable to write the validation for you.

Thanks, Rob.




Correction - 



" />



Does the image path have any spaces?


Re: [php-list] image download

2008-11-05 Thread listgroups08
- Original Message - 
From: "zari lahr"

Dear sir..


this is what i am working out

==

" />



one thing that i have just stored the image name in mysql and store the all 
image in a saperate 
folder name images..as shown in the code above.. i want that when i click the 
download button the 
download box open and the image start to download.

regards



Hello Zari,
We type below previous posts in this group.

You didn't mention what file types that the image files are. ie - .jpeg . jpg 
.png .gif .bmp

You need another php file to force the download. See the headers() function on 
php.net

The above code will need to be changed to -

" 
/>

The important part is to make sure that the only files that the download script 
will download are 
image files from the correct location.

I need to know what file types are acceptable to write the validation for you.

Thanks, Rob.



Re: [php-list] optimized fusebox

2008-11-02 Thread listgroups08
- Original Message - 
From: "Purwo Hadi"

Hi,Guys do anyone know how to enhance fusebox performance. More bigger the 
circuit become more 
slower. Is there any way to increase loading speed. Thanks before




Hi Purwo,
   I doesn't seem that may here are using FuseBox or they don't 
have an answer. I don't 
use it but I had a quick look at it. As it is based on ZEND I really don't 
think there will be much 
room to improve on the developers coding.

I saw that it is XML based. I don't know how much it is dependent on XML but if 
it is greatly 
dependent then converting to the FuseBox implicit coding may improve 
performance.

Other than that upgrade the server performance or look for another framework.

I didn't see any database abstraction on the FuseBox website so it seems that 
it would not be 
strongly useful for strongly database driven websites???






Re: [php-list] Re: session_start

2008-10-27 Thread listgroups08
- Original Message - 
From: "bryan_is_south" 

> Hello Bryan,
> 
> Your session save path is wrong. 
> 
> It is pointing to c:/tmp\ which does not exist. 
> 
> Open your php.ini file in a text editor. 
> It should be in c:\phpdev5\bin\php\ or c:\phpdev5\bin\php\phpx.x.x\
> 
> Make sure of the path to your temporary directory exists. 
> It should be c:\phpdev5\tmp\
> 
> In php.ini look for the setting session.save_path
> Change '/tmp' to the correct setting. This should be - 
> 'c:\phpdev5\tmp'
> 
> Then you must restart your server. 
> 
> Thanks, Robert.
>

---

Hello Robert and others,

I have made sure that all my slashes are \ now, but still I am getting
the same messages (and I do restart my Apache after each change I make).

Should there already be a folder called 'tmp' or do I make this folder
myself?

Also, in php.ini, is the doc_root important too, because I have been
changing that too, but I don't know exactly what it should say.

Right now, these two lines look like this:

doc_root = "C:\phpdev5\www\Metalopia Website\"
session.save_path = "phpdev5\tmp\"

But of course I've tried several combinations of changing little
things, like removing quotations, removing the final slash, altering
the beginning of the paths, etc.

Any further information on what I am doing wrong? All help is appreciated.

Thank you,

-bryan




Hi,
I thought doc_root was simply HTTP_root so it shouldn't need to be changed 
from what you have. 

Try - 
doc_root = "C:\phpdev5\www\Metalopia Website"
session.save_path = "C:\phpdev5\tmp" <-- create this if it doesn't already 
exist. 
No trailing slashes. 







Re: [php-list] Re: session_start

2008-10-27 Thread listgroups08
- Original Message - 
From: "fw7oaks"

The point about  Windows or Linux is that they expect different 'backslashes' 
that is / or \  in fact Linux is clever 
and can cope with both while Windows can't.

So what's causing the problem is this /tmp\ses...

If you changed it to  \tmp\ses

it will probably work - no guarantee, but it's not much effort to try :-)

Easily done, by the way, Linux is case sensitive for file names and Windows 
isn't - that's another good sticking point.



I agree about the sticking points.

Nothing worse than opening a server directory to find -
'contactus.php'
'ContactUs.php'
'contact us.php'

Or even worse -
'Contact%20Us.php'

Another thing that I have noticed is that sometimes Apache will pick up a 
partially matched file names when there are 
multiple dots.

Like disabled.old.htaccess or .htaccess.old.dontuse

I don't remember what file it was, I don't think it was .htaccess but I do 
remember it took ages to find.

The other thing that I have noticed is that if you have the html

instead of either correct notations -

or

The server will look for a file actually named 'one%20space.jpg'
It then reverts to 'one space.jpg' and finds that if it is there but seems to 
take forever to find it.




Re: [php-list] Re: session_start

2008-10-27 Thread listgroups08
- Original Message - 
From: "bryan_is_south" 

> And it gives me three error messages:
> 
> 2 like this: "Warning: open(/tmp\sess_..., O_RDWR) failed: No such
> file or directory (2) in ..."
> And another that says "Failed to write session data (files). Please
> verify that the current setting of session.save_path is correct..."

> 
> 
> /tmp\sess_...
> 
> Linux or Windows?
> 
> Make up your mind lol!
>



I'm on Windows. XP to be exact. But that is the error it gives me...
The only thing I changed in those was I took out the long string of
letters and numbers. Here is the full error messages without any
deletions though:

Warning: open(/tmp\sess_a68c3a0287f2393832cc6a40b5d77755, O_RDWR)
failed: No such file or directory (2) in c:\phpdev5\www\metalopia
website\sessions.php on line 2

Warning: open(/tmp\sess_a68c3a0287f2393832cc6a40b5d77755, O_RDWR)
failed: No such file or directory (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on
line 0



Is this abnormal for Windows or something?
Any ideas for getting it running?

Thanks,
-bryan




Hello Bryan,

Your session save path is wrong. 

It is pointing to c:/tmp\ which does not exist. 

Open your php.ini file in a text editor. 
It should be in c:\phpdev5\bin\php\ or c:\phpdev5\bin\php\phpx.x.x\

Make sure of the path to your temporary directory exists. 
It should be c:\phpdev5\tmp\

In php.ini look for the setting session.save_path
Change '/tmp' to the correct setting. This should be - 
'c:\phpdev5\tmp'

Then you must restart your server. 

Thanks, Robert. 



Re: [php-list] session_start

2008-10-26 Thread listgroups08
- Original Message - 
From: "bryan_is_south"

Hello all,

I'm trying to add Sessions to my site, but I am getting an error message.

All I have so far is



And it gives me three error messages:

2 like this: "Warning: open(/tmp\sess_..., O_RDWR) failed: No such
file or directory (2) in ..."
And another that says "Failed to write session data (files). Please
verify that the current setting of session.save_path is correct..."

I have tried fiddling around changing some settings in my php.ini, but
nothing seems to work.

All help is much appreciated. Thank you

-bryan



/tmp\sess_...

Linux or Windows?

Make up your mind lol!


Re: [php-list] How to Validate for E-Mail Address?

2008-10-19 Thread listgroups08
- Original Message - 
From: "Diane"

Hi,

What specific code would I have to add to make my contact form only
accept an E-Mail Address where it is asked for?  Right now it will
accept anything:

http://dkjwebs.com/contact.php


-- 
Best regards,

Diane Jensen
http://dkjwebs.com/




Hi Diane,
 I had a look at the contact page but I don't understand what you 
want to do?

There are several layers of e-mail address validation.

One is to use REGEX like someone else suggested. This just makes sure the 
format for the e-mail address is valid. The 
e-mail address itself my be false.

The next is to send an e-mail to that address and see what happens and this is 
a lot more complex and may take some time 
even days.

In a simple contact for only the REGEX test is normally used. This can also be 
done in Javascript but that of course 
depends on the client browser having Javascript enabled.

IF you clarify what you want to achieve then we may be able to help further.

Thanks, Robert. 



Re: [php-list] Re: file creator

2008-10-16 Thread listgroups08
--- In php-list@yahoogroups.com, "Phill Sparks" <[EMAIL PROTECTED]> wrote:
>
> On Thu, Oct 16, 2008 at 4:57 PM, cosminx2003 <[EMAIL PROTECTED]> wrote:
> > I want to build a file creator.
> > Look how it will work : it will create a file file.txt, will rename it
> > in .zip|.rar|.iso|etc and then will put a filesize (unlimited
> > filesize), but i don't know how to put a specific filesize to a file,
> > is it possible? For example "file.txt" has 0 bytes, i want to change
> > its filesize to 100 bytes. Is it possible? if yes with what function?
>
> The only way I know would be to write 100 bytes of nothing to the
> file.  Something like fwrite($fp, str_repeat("\0", $length)) might
> work?
>

Yes it works, i used the same method but i want to know if it's
another method.


No, In php files are simply data streams and not blocks of data. So there is no 
way to set a file size in php except but to stream 
out the data to the file system.




Re: [php-list] Re: Yahoo Login with php curl

2008-10-16 Thread listgroups08
- Original Message - 
From: "cosminx2003" 
--- In php-list@yahoogroups.com, <[EMAIL PROTECTED]> wrote:
>
> - Original Message - 
> From: "cosminx2003"
> 
> Hi, i want to login on yahoo with php cURL, i made a script but i
> can't make it work fine (it gives me blank page).
> Please tell me how can i fix it.
> Thanks

---
.tries is a hidden input.
and i think you're right .challenge is a code that changes at every
refresh
How can i fix these problems?




PS: What version of PHP are you scripting for. It is much easier to register 
HTTP: and HTTPS: data streams in 5.x.x


Re: [php-list] Re: Yahoo Login with php curl

2008-10-16 Thread listgroups08
- Original Message - 
From: "cosminx2003"

--- In php-list@yahoogroups.com, <[EMAIL PROTECTED]> wrote:
>
> - Original Message - 
> From: "cosminx2003"
>
> Hi, i want to login on yahoo with php cURL, i made a script but i
> can't make it work fine (it gives me blank page).
> Please tell me how can i fix it.
> Thanks
>


> Hello,
>   I have done this before but I used header information to
control the cookie without using cURL.
>
> Some things that don't look right to me -
>
> curl_setopt ($ch, CURLOPT_URL, 'http://login.yahoo.com/config/login?');
>
> Shouldn't the '?' be with the rest of the query string instead here -
> "?login=$username&passwd=$password&.src=&..
>
> and -
>
> &.tries=5
>
> did you copy this from a browser? will it work manually into a browser?
>
> and
>
> &.challenge=ydKtXwwZarNeRMeAufKa56.oJqaO
>
> Is some sort of session token? Has it expired?
>

.tries is a hidden input.
and i think you're right .challenge is a code that changes at every
refresh
How can i fix these problems?



Hello cosminx2003,
  I haven't used cURL before so I will just outline 
the basic principle.

Start with a plain URL that you would normally navigate to in a browser without 
any POST forms being previously sent.

POST (or GET) the login details and use returned headers (or cURL) to capture 
any cookies and/or session variables.

Send the cookie and session variables to the remote server in the headers along 
with any necessary query string.

Then you will get the desired page that you can strip the HTML to get any 
needed information.

Last time I wrote one of these types of scrips it was for a server that did not 
have cURL and was running PHP version 4.x.x

I still have these scripts here but they're hard on the eyes as the connection 
to the remote server was done at a raw socket level.

I can find them and send them on if you want.

Thanks, Robert




Re: [php-list] Yahoo Login with php curl

2008-10-15 Thread listgroups08
- Original Message - 
From: "cosminx2003"

Hi, i want to login on yahoo with php cURL, i made a script but i
can't make it work fine (it gives me blank page).
Please tell me how can i fix it.
Thanks

http://login.yahoo.com/config/login?');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS,
"login=$username&passwd=$password&.src=&.tries=5&.bypass=&.partner=&.md5=&.hash=&.intl=us&.tries=1&.challenge=ydKtXwwZarNeRMeAufKa56.oJqaO&.u=dmvmk8p231bpr&.yplus=&.emailCode=&pkg=&stepid=&.ev=&hasMsgr=0&.v=0&.chkP=N&.last=&.done=");

curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt ($ch, CURLOPT_COOKIEFILE, "cookies.txt");

curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; U; PPC
Mac OS X;en) AppleWebKit/419.2.1 (KHTML, like Gecko) Safari/419.3');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$result=curl_exec ($ch);
curl_close ($ch);
echo $result;



Hello,
  I have done this before but I used header information to control the 
cookie without using cURL.

Some things that don't look right to me -

curl_setopt ($ch, CURLOPT_URL, 'http://login.yahoo.com/config/login?');

Shouldn't the '?' be with the rest of the query string instead here -
"?login=$username&passwd=$password&.src=&..

and -

&.tries=5

did you copy this from a browser? will it work manually into a browser?

and

&.challenge=ydKtXwwZarNeRMeAufKa56.oJqaO

Is some sort of session token? Has it expired? 



Re: [php-list] Indenting code

2008-10-13 Thread listgroups08
- Original Message - 
From: "Gordon Stewart"

is there a good utility / programme to use - That will automatically
indent PHP scripts (make them easier to read)

-
As an afterthought -

I use Crimson Editor for php.

I use MetaPad for text as it has excelent search and replace that includes 
\n\r\t charactors. I often import a list of variables or 
constants into MetaPad and use the search and replace to turn it into a block 
of php code or mysql query string. Then back to 
Crimson Editor.

I use ConTEXT editing HTML/Javascript as it is very good at highlighting these 
expectialy Javascript.

Any one have better sugestions?

Robert. 



Re: [php-list] Indenting code

2008-10-13 Thread listgroups08
- Original Message - 
From: "Gordon Stewart"

is there a good utility / programme to use - That will automatically
indent PHP scripts (make them easier to read)

-
Hi Gordon,
 I use Crimson Editor as it has excellent syntax highlighting. 
It also has auto indent but I turn that off because I 
indent differently.

Robert. 



Re: [php-list] mysql LIMIT/COUNT again

2008-10-13 Thread listgroups08
- Original Message - 
From: "Daniel Israel" 


On Oct 12, 2008, at 6:31 PM,  wrote:




Try:

SELECT COUNT(*) FROM Assignments, Classes, Instructors, Departments  
WHERE Assignments.ClassID = Classes.ClassID AND
Classes.DepartmentID = Departments.DepartmentID AND  
Classes.InstructorID = Instructors.InstructorID

What gets returned is one row with one field (You have to read  
that...   calling mysql_num_rows() will return 1)

-D. Israel

Thanks Daniel,

I just used - 
$query = str_replace('*', 'COUNT(*)', $query)

before I added the LIMIT and ORDER BY instructions and it works perfectly. 

Robert.


[php-list] mysql LIMIT/COUNT again

2008-10-12 Thread listgroups08
Hi,
I am using the following query to get results from a mysql database.

$query = 'SELECT * FROM Assignments, Classes, Instructors, Departments';
$query .= ' WHERE Assignments.ClassID = Classes.ClassID';
$query .= ' AND Classes.DepartmentID = Departments.DepartmentID';
$query .= ' AND Classes.InstructorID = Instructors.InstructorID';
If($departmentid != "") $query .= ' AND Departments.DepartmentID = ' . 
$departmentid;
if($instructorid !="") $query .= ' AND Instructors.InstructorID = ' . 
$instructorid;
If($orderby != "") $query .= ' ORDER BY ' . $orderby;
$query .= ' LIMIT ' . ((0 + $page - 1) * $perpage) . ',' . $perpage;

This works fine but I need to count the number of matches that would have 
occurred if I didn't specify a LIMIT.

I tried wrapping COUNT() around the whole Query string minus the LIMIT and 
ORDER but the following errors occurred -

mysql query -
SELECT COUNT(SELECT * FROM Assignments, Classes, Instructors, Departments WHERE 
Assignments.ClassID = Classes.ClassID AND 
Classes.DepartmentID = Departments.DepartmentID AND Classes.InstructorID = 
Instructors.InstructorID)

PHP error -
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result 
resource in C:\wamp\www\database\assignments.php on line 
122

mysql error -
You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use 
near 'SELECT * FROM Assignments, Classes, Instructors, Departments WHE



In the above query I could just do 'SELECT COUNT(SELECT * FROM Assignments)'

But I need queries like -
SELECT COUNT(SELECT * FROM Assignments, Classes, Instructors, Departments WHERE 
Assignments.ClassID = Classes.ClassID AND 
Classes.DepartmentID = Departments.DepartmentID AND Classes.InstructorID = 
Instructors.InstructorID AND Departments.DepartmentID = 
5)

I am only new to mysql so any help would be much appreciated.

Robert.



[php-list] mysql LIMIT / COUNT

2008-10-10 Thread listgroups08
Hi all,

I have a quick question.

If I am getting a small range of results using the mysql LIMIT function then 
how can I tell how many results there would have been 
if I didn't use LIMIT with the same query?

Thanks. 



Re: [php-list] sorting nested arrays

2008-10-10 Thread listgroups08
- Original Message - 
From: "Wade Smart" 

I have a nested array.

[0]
( [0] = 4 [1] = value1)
[1]
( [0] = 2 [1] = value2)


There are a about a hundred or so everything this runs.

The first value (4 or 2) are value indicators for the value (value1 or 
value2). Like a ranking of sorts.

These values are ranked in groups from 1 to 20. There could be 30 items 
that fall in the ranking of 15 category. There might be only five items 
ranked as a 5.

So what I want to do is sort these according to rank. So I want all the 
ones at the top and 20's at the bottom. Im not sure how to do this :)

Im looking through the php functions for arrays but Im not sure how to 
sort based on the first value of a nested array.

Wade



Hi Wade, 

I can't see an easy way to do it with php array functions. It looks like you 
have to flatten the array. 

foreach($array as $this_array)
  {
  foreach($this_array as $key => $value)
{
$new_array[$value] = $key;
}
  }
$result = arsort($new_array, SORT_NUMERIC);

It should also be easier in php v 5.x.x because you can move keys and values as 
sets. 




Re: [php-list] displayin pieces in same location

2008-10-09 Thread listgroups08
- Original Message - 
From: listgroups08

- Original Message - 
From: "Tedit kap"

hello, what i am trying to do is, after hitting the submit button in a form, 
the questions and the submit button should disappear
and at the same place the results should show up. right now the form is posting 
to another page, which i dont know how to display at
the same location of the form. i tried posting the form to itself but all it 
does is, it still continues to display the questions
after submitting. please help.

AJAX method -



Wow, that script really sux. I didn't realise how long ago I wrote it. The fact 
that it was written for php v 4.x.x should have 
given it away!

I can actually write AJAX without the (X) cos I don't use XML. That was no 
example!

Sorry. 



Re: [php-list] displayin pieces in same location

2008-10-09 Thread listgroups08
- Original Message - 
From: "Tedit kap"

hello, what i am trying to do is, after hitting the submit button in a form, 
the questions and the submit button should disappear 
and at the same place the results should show up. right now the form is posting 
to another page, which i dont know how to display at 
the same location of the form. i tried posting the form to itself but all it 
does is, it still continues to display the questions 
after submitting. please help.

AJAX method -

- vote.htm --



Vote Example page






function vote(item)
  {
  item = "http://domainname.com/vote.php?vote="; + item;
  script = document.createElement('script');
  script.src = item;
  head = document.getElementsByTagName('head').item(0);
  head.appendChild(script);
  }










Vote for item 
1
Vote for item 
2
Vote for item 
3
Vote for item 
4











Right click http://domainname.com/vote.php?vote=3";>here and select 
save as to download the Javascript from the server.

Your brower will not download it directly as it has a Javascript mime type.




-

- vote.php 




Re: [php-list] displayin pieces in same location

2008-10-09 Thread listgroups08
- Original Message - 
From: "Tedit kap"

hello, what i am trying to do is, after hitting the submit button in a form, 
the questions and the submit button should disappear 
and at the same place the results should show up. right now the form is posting 
to another page, which i dont know how to display at 
the same location of the form. i tried posting the form to itself but all it 
does is, it still continues to display the questions 
after submitting. please help.



PHP method -




Questions page




What color roses do you like: 







Answer page



I love red roses to






Re: [php-list] Re: bar chart

2008-10-07 Thread listgroups08
- Original Message - 
From: "teditkap"

--- In php-list@yahoogroups.com, <[EMAIL PROTECTED]> wrote:
>
> - Original Message - 
> From: "Tedit kap"
>
> Hi all,
> Can someone refer me to good links or code, for creating a php bar
chart
> please?
> Thanks.
>
> 
>
> Hi Tedit,
> What sort of output do you want? CSS? HTML? Flash? GD
images?
>
>
>
> CSS/HTML/FLASH/GD scripts/libs
>
http://www.hotscripts.com/PHP/Scripts_and_Programs/Graphs_and_Charts/i
ndex.html
>
> PHP GD tutorial
> http://www.phpbuilder.com/columns/wiesendanger20001218.php3
>
> PHP Classes
> http://www.qualityunit.com/postgraph/
> http://www.aditus.nu/jpgraph/
>

GD images is what I need. That is the one always comes up when i
search for drawing a line in php or graph in php...So, my
understanding is, I need to install this set of files called GD
library, into ...where? And then do what exactly? And only after that
the php program works with images? I know you refer me to some good
links but I couldnt solve it, my knowledge of php and coding is just
basic. Can you describe what to do in a few simple steps - if that is
possible...Thanks.


Hi Tedit,
  If you are using a server then I would very much doubt that you 
don't have the GD library installed. Try phpinfo() and 
look for the GD library.

If you are using a WAMP then we need to know what WAMP/Version.

Robert. 



Re: [php-list] Classes

2008-10-07 Thread listgroups08
- Original Message - 
From: listgroups08

Hi all,
I am playing with classes for the first time and I am at a bit of a 
loss in php.
How do I access the properties/functions of the parent class from sub function?
And how do I register resources into the scope of the parent class?



I came up with this -

$parent_class = eval("&" . get_parent_class(this));
$sibling_class = eval("&" . get_parent_class(this) . '->sibling_name');
$parent_variable_scope = &get_class_vars(get_parent_class(this));

The first two should work as there returning references to the current instance 
of the prototyped class but I doubt the third would 
work because it most likely returns a reference to the original class before it 
is prototyped.

There must be a simpler way.

Is there any function or directive that works in the scope of a class like the 
'global' directive works in the environment scope?

I can't seem to find good information on directives (sometimes called 
primitives) in the php manual (php.net). Is there a page that 
lists directives?

Thanks. 



Re: [php-list] Classes

2008-10-07 Thread listgroups08
- Original Message - 
From: "Wade Smart"

listgroups08 wrote:
> Hi all,
> I am playing with classes for the first time and I am at a bit of a
> loss in php.
>
> How do I access the properties/functions of the parent class from sub
> function?
>
> And how do I register resources into the scope of the parent class?
>
> For example if I have -
> class Data_Base
>   {
>   var $server;
>   var $username;
>   var $password;
>   function Data_Base
> {
> $this->server = "127.0.01";
> $this->username = "username";
> $this->password = "password";
> }
>   function Connect
> {
> $handle = mysql_connect($server, $username, $password);
>  }
>   }
>
> How do I get $server etc from the root scope of Data_Base?
>
> And how do I register $handle into the global scope of Data_Base without
> registering it into the global scope of PHP?
>
> ie - does var $server create a scope that is accessible in sub functions or
> is it just in the root scope?
>
> Thanks, Robert.

20081007 1639 GMT-6

Im just starting with objects myself so this might not be right.
But from the reading I was doing today, if you want the $handle you
would do "return $handle" just like a normal function.

Wade


Hi Wade,
  I would have thought that using return in a sub function will 
return the the resource into the global php environment 
but only with assigment ie -

class Data_Base
  {
  function connect
{
$handle = mysql_connect("127.0.0.1", "username", "password");
return $handle;
}
  }
$database = new Data_Base;
$my_handle = $database->connect;

Am I missing something here? Can objects be created without classes? I haven't 
seen anything else in php that will prototype.

I don't want things like a mysql resource handles in the global scope of php. I 
want to completely abstract the database so that 
only the data and validation is returned. And things like mysql resource 
handles only exist in the scope of the class object.

ie -
foreach($database->table->field as $this_field)
  {
  $result = $this_field->is_valid($submited_data);
  if(!$result === TRUE)
{
$re_enter = TRUE;
$error_message .= $result;
}
  }
if($re_enter)
  {
  echo("The following information is not valid, please re-enter\n" . 
$error_mesage)
  }

I don't know if this helps but in javascript 

onmouseover = "dosomething;"
is completely different to -
onmouseover = "dosomething();"

The first registers the existing form of the function dosomething into the 
scope of the mouseover event. So it is like class in php.
However the second executes the function dosomething in the document scope when 
the mouseover event is trigered. So it is like 
function in php.

So in the first, 'this' represents the mouseover event and is NOT in the 
document scope.
However in the second, 'this' represents the element that is moused over and IS 
in the document scope.

In Javascript you can do this -
function dosomething(element)
  {
  element.src = "new_image";
  }
onmouseover = "dosomething(this);"
witch works in the document scope like php functions return variables into the 
php environment scope.

or you can do this
function dosomething()
  {
  this.parent.src = "new_image";
  }
onmouseover = "dosomething;"
The above is not in the document scope but is able to gain access to the parent 
scope and inject a function into the parent scope. 
Because the onmouseover is a trigered event that is trigered by an element in 
the document scope then 'this.parent' is in the 
docuemnt scope even when the event assigned function "dosomething" is NOT.

I want to do the same in php.

I want to be able to access the parent scope of a class and from there I can 
access the scope of class subfunctions but I want to do 
this without entering the global scope of the php environment.

Clear as mud? :)

Thanks, Robert. 



[php-list] Classes

2008-10-07 Thread listgroups08
Hi all,
I am playing with classes for the first time and I am at a bit of a 
loss in php.

How do I access the properties/functions of the parent class from sub 
function?

And how do I register resources into the scope of the parent class?

For example if I have -
class Data_Base
  {
  var $server;
  var $username;
  var $password;
  function Data_Base
{
$this->server = "127.0.01";
$this->username = "username";
$this->password = "password";
}
  function Connect
{
$handle = mysql_connect($server, $username, $password);
 }
  }

How do I get $server etc from the root scope of Data_Base?

And how do I register $handle into the global scope of Data_Base without 
registering it into the global scope of PHP?

ie - does var $server create a scope that is accessible in sub functions or 
is it just in the root scope?

Thanks, Robert.




Re: [php-list] bar chart

2008-10-06 Thread listgroups08
- Original Message - 
From: "Tedit kap"

Hi all,
Can someone refer me to good links or code, for creating a php bar chart 
please?
Thanks.



Hi Tedit,
What sort of output do you want? CSS? HTML? Flash? GD images?



CSS/HTML/FLASH/GD scripts/libs
http://www.hotscripts.com/PHP/Scripts_and_Programs/Graphs_and_Charts/index.html

PHP GD tutorial
http://www.phpbuilder.com/columns/wiesendanger20001218.php3

PHP Classes
http://www.qualityunit.com/postgraph/
http://www.aditus.nu/jpgraph/ 



Re: [php-list] download the image from database

2008-10-06 Thread listgroups08
- Original Message - 
From: "zarilahr"

Dear Sirs

i put up a image in database and i want when a user click on
download link the particular image start to download. I have stored
100 images in mysql and below is the sample mysql query i write and
its work fine .

INSERT INTO `mobile`.`stuff` (`prod_id`, `cat_id`, `image_name`,
`image_path`)
VALUES (NULL, '3', 'Impossible ', 'impossible.jpg');

"please note that prod_id is auto increment."

and here is the php code how i called my all images with the help of
while loop from mysql.

echo '' . '' .
'' . $row['image_name'] . ' ' . '  Download  ' . '';

i want to start download the particular image when i click on the
Download link. Please tell me the code how i can download the image
when i click on Download link.

A screent shot with the name of imagedownlod is attached which can
clarify what exactly i want.

regards
Azhar


NOTE: I am a php newbie - so please anyone that sees a mistake or security 
problem then please say so.

Hi Azhar,
 It looks like you already have a script for the image 
download -

'  Download  '

Anyway - place the following at the absolute beginning of the page that 
displays the images.

\n");
return FALSE;
}
  if(!is_readable("images/" . $filename))
{
//echo("[" . $filename . "] Is not readable\n");
return FALSE;
}
  header("Cache-Control: public, must-revalidate");
  header("Pragma: hack");
  header("Content-Type: application/octet-stream");
  header("Content-Length: " . filesize($filename));
  header('Content-Disposition: attachment; filename="' . $filename . '"');
  header("Content-Transfer-Encoding: binary\n");
  readfile("images/" . $filename);
  return TRUE;
  }

?>

--
'
--
and then change the above html to -
-
''
-


Notes:
URL no longer contains path information for security. All images must be in 
a subfolder (images/) from where the script is running.
To change this to an absolute path then in output_img change the three 
"images/" to "/new_path/"

Thanks, Robert.




Re: [php-list] Log files

2008-10-01 Thread listgroups08
- Original Message - 
From: Rob



Reading the script again I cab see two possible issues that you may want to
check -

1)
function file_lock($lock_filename)
  {
  if(!($handle = file_open($lock_filename, 'w')))
{
return FALSE;
}

Will opening an existing file in write mode fopen($filename, 'w') release
any previous locks on the file ??

2)
function file_passthrough($source_handle, $destination_handle)
  {
  while(!feof($source_handle))
{
$buffer = fread($source_handle, 4096);
fwrite($destination_handle, $buffer);
}
  }

I should have explained that I am somewhat of a newbe to php!
In some other languages the above will write to a RAM buffer and the buffer
will only be written to the file system when the file stream is closed.

Does php have a way to flush a steam buffer to the file system ?

I will look.

Rob.

Here is the fix for the second issue -

function file_passthrough($source_handle, $destination_handle)
  {
  while(!feof($source_handle))
{
$buffer = fread($source_handle, 4096);
fwrite($destination_handle, $buffer);
fflush($destination_handle);
}
  } 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Log files

2008-10-01 Thread listgroups08
- Original Message - 
From: "Bob"



Hi Rob,
Wow, I wasn't expecting you to go to so much trouble, and it's much 
appreciated. There's certainly a lot for me to learn from this, from file 
handling to the way you've organised it. I'm still looking at it in 
amazement!

It works a treat and the layout and use of functions is great, making it 
easier to understand. Also, the http-equiv="refresh" is a neat trick for 
testing it.

I'm slowly realizing not to load a file or array with the data, and work 
directly on the files. It's finally sunk in.

It's not normally the done thing to give someone the complete code, but it 
would have taken a boat load of explaining on how to do it (well in my case, 
grin!).

This line threw me for I while:
$trash = fgets($log_file);
as $trash isn't used anywhere.
But, then I realised this is how you were finding the record line ending, 
which moves the file pointer to it. That's a really cool way of doing it!

I can see now why I couldn't get flock to work correctly, as I'd got it all 
wrong.
I noticed you didn't use flock($handle, LOCK_UN), so is this not needed in 
this case?
I'm still trying to understand the use of a reject.loc ?

$sleep = rand(1, 1);
$time .= $sleep;
usleep($sleep);
I haven't work out why the random sleep yet?
I think you maybe doing something crafty that I'm missing?

Many thanks for this, Bob E.



Hi Bob,

I didn't use flock($handle, LOCK_UN) as this automatically happens when the 
script thread ends. However in some cases it may improve access for other 
scripts.

I wrote the script so that other scripts can access the files as well if 
they first check and lock the lock file.

I haven't used flock before, normally I just create a lock file and check 
for its existence before accessing other files then unlinking it when 
finished. The problem with this is that if a script terminated half way 
through and doesn't unlink the lock file then there is a permanent lock. One 
solution with smaller scripts that run very quickly is to watch the lock 
file for a while longer then the scripts take to run and then access the 
files as normal.

I read somewhere that flock has issues on some platforms and has to open the 
file as write or append so I decided on a separate lock file. The log file 
is opened in read mode.

Also fclose has to be done before renaming files and fclose also unlocks a 
locked file.

The random sleep is from the php.net website. I expect that it is because 
some scripts can end up synchronised so a random delay will break 
synchronism.

Reading the script again I cab see two possible issues that you may want to 
check -

1)
function file_lock($lock_filename)
  {
  if(!($handle = file_open($lock_filename, 'w')))
{
return FALSE;
}

Will opening an existing file in write mode fopen($filename, 'w') release 
any previous locks on the file ??

2)
function file_passthrough($source_handle, $destination_handle)
  {
  while(!feof($source_handle))
{
$buffer = fread($source_handle, 4096);
fwrite($destination_handle, $buffer);
}
  }

I should have explained that I am somewhat of a newbe to php!
In some other languages the above will write to a RAM buffer and the buffer 
will only be written to the file system when the file stream is closed.

Does php have a way to flush a steam buffer to the file system ?

I will look.

Rob. 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Audio recording in php

2008-10-01 Thread listgroups08
- Original Message - 
From: "Gautam Das"

hi there, I have to do a task in which,i need to record any voice message 
and then send it to another user...like we receive text messages from 
another members in community based site...so i need to send voice or audio 
message after recording. i am tired to find in googledo you have link or 
any information how to do it then please send me thanksGoutam
--
Hi,
What medium are the text and voice messages to be sent through?

HTTP or GPRS?

Thanks. 



Re: [php-list] Log files

2008-09-30 Thread listgroups08


- Original Message - 
From: "Bob"

Hi Rob,
Yes, linux and php 4.4 but please don't install another version of php just 
for me, but thanks anyway.

My site is a hobby site, but it seems to attract so much abuse.
I've had quite a few DOS attacks, but the shared server is DOS protected 
(limited max per minute).
My previous log managed to record 3 attempts per second with no trouble.

This stops my visitors seeing the site though, but the max they can afford 
to keep this up is usually about 2 hours, or their other spam doesn't get 
delivered.

It's just a simple log file I'm trying to create, and it's just to record 
the failed attempts to spam me.
It's not a full blow error log like the server logs provides.
I get one genuine message per month (and did get over a100 spam attempts per 
day).
Since I send the "Double Hit" and "Preset Post" messages etc. to a 
non-existant page, it's all more or less stopped now.
This seems to really bugger up their spam list program.

I'm not sure whether eveyone knows what a Double Hit is, but it defeats 
cookie or session protection.
No idea how they do it though?

In the past 2 days, I've had only 3 Double Hits, 2 Preset Posts, and 3 
Profanity errors.
Sending them to a non-existant site is causing them to get really annoyed 
and *try* to swear at me.

I originally created a rolling road log (using a array ) to 
display to the spammer his errors, with an arrow pointing to his latest 
attempt.
This drove them crazy and they tried to bring my site down.
If I put my nice CATCHA image back on, it would all stop, but I like the 
challenge, he-he!

Re: You are still reading the whole file into memory.
If that's what $logdata = file_get_contents($logfile); does, then yes.
If I don't, how can I find half of it, then find the next line break to 
write to the updated file?

Re: File locking is only required if more then one script (or thread) can 
access the log files.
I didn't know that, so it isn't needed in my case.

Thanks, Bob E.


Hi Bob,

  Too late lol, I had already installed php 4.4.4 onto Apache 2.0.63

I have a tested and working script below. I didn't know if you wanted oldest 
first or newest first. It is not hard to reverse it.

flock has issues on some servers that you need to get around by opening the 
file in 'w' or 'w+' to get around. I used a different way of using a 
separate lock file altogether.

--
 $max_filesize)
  {
  fseek($log_file, -$max_filesize, SEEK_END);
  $trash = fgets($log_file);
  }

file_passthrough($log_file, $temp_file);
fwrite($temp_file, $record);
fclose($log_file);
fclose($temp_file);
@unlink($backup_filename);
rename($log_filename, $backup_filename);
rename($temp_filename, $log_filename);

function file_open($filename, $mode)
  {
  if(!($handle = @fopen($filename, $mode)))
{
throw_error("Unable to OPEN file [" . $filename . "]");
return FALSE;
}
  else
{
return $handle;
}
  }

function file_passthrough($source_handle, $destination_handle)
  {
  while(!feof($source_handle))
{
$buffer = fread($source_handle, 4096);
fwrite($destination_handle, $buffer);
}
  }

function file_lock($lock_filename)
  {
  if(!($handle = file_open($lock_filename, 'w')))
{
return FALSE;
}
  $max_lock_time = 1; // 10 seconds
  while($time < $max_lock_time)
{
if(flock($handle, LOCK_EX))
  {
  return TRUE;
  }
$sleep = rand(1, 1);
$time .= $sleep;
usleep($sleep);
}
  throw_error("Unable to LOCK lock file [" . $lock_filename . "]");
  return FALSE;
  }

function throw_error($string)
  {
  global $error_reporting;
  if(!$error_reporting)
{
return;
}
  echo($string . "\n");
  }

?>


Log file test



\n");

$log_file = @fopen($log_filename, 'r');
while($one_line = fgets($log_file))
  {
  echo($one_line . "\n");
  }

?>






Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Log files

2008-09-30 Thread listgroups08
- Original Message - 
From: "Bob"


  $logdata = file_get_contents($logfile);
  $nline = strpos($logdata, "\n", 500);
  $newdata = substr($logdata, $nline);


Hi Bob,
   You are still reading the whole file into memory.

Can you tell me again what version of php you are running? I will set up 
your version of php in a WAMP here for testing.

File locking is only required if more then one script (or thread) can access 
the log files.

I assume you are on linux, windows is different for file locking.

Rob.




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Problems writing to the server

2008-09-30 Thread listgroups08
- Original Message - 
From: listgroups08
- Original Message - 
From: "Pete"

I am having problems writing a file (in fact, it's a Google sitemap) to
a site.

I know that it has something to do with permissions and owners.  But how
can I see what the settings are for this file?  And what "owner" will
PHP be known as?

-- 
Pete Clark


Hi Pete,



Sorry got the permissions wrong!

It should have read - .


So if a script needs to create an read files there are two real options -

1) If the script runs as the account owner then the file has to at least
have permission's 600 and the folder that contains the folder needs at least
300.

2) If the script runs as the 'default www user' then the file needs at least
606 and the folder needs at least 303.

In reality you are not so concerned with owner access restrictions so these
permission's would translate to -

600 => 700
300 => 700
606 => 706
303 => 703

In general, the 'group' access is set to the same as the 'owner' access but 
this is not a good thing if you are on a shared server and have things like 
credit card numbers in files. The only time the 'group' access needs to be 
anything other than 0 is when you are using 'basic auth' protocol or you 
have subusers with FTP accounts.





Please remember to write your response BELOW the previous text.

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links





Re: [php-list] Problems writing to the server

2008-09-30 Thread listgroups08
- Original Message - 
From: "Pete"

I am having problems writing a file (in fact, it's a Google sitemap) to
a site.

I know that it has something to do with permissions and owners.  But how
can I see what the settings are for this file?  And what "owner" will
PHP be known as?

-- 
Pete Clark


Hi Pete,
This issue can be quite different on different servers depending 
on how php is running.

The most common setup is to have php running as an Apache application. In 
this setup http: accessible scripts run with the authority of the default 
www user. Most often the default www user is 'default', 'www', 'www_data', 
'apache' or 'nobody'.

FTP however most often has the authority of the specific hosting account 
owner. So if your FTP login name is 'john" then files uploaded by 'john' 
have the owner 'john'.

On some servers php runs as a CGI which is totally different. In this setup 
the scripts that are accessed via http: run with the authority of the 
account owner.

Also on some servers there is an option to run a 'wrapper' or 'cgi wrapper' 
or 'authority wrapper' or 'owner wrapper' so that optional scripts run with 
the account owners authority while others run with the 'default user' 
authority even when php is running as an Apache application. This however is 
less common.

Putting this all together -

Firstly, you have to determine who is the file owner.

In most cases any file that is uploaded via private FTP will be owned by the 
account owner.

Files that have been created by scripts have the owner of the authority that 
the creating script was running under. Normally this is the 'default www 
user' however if you are using a wrapper or running php as a CGI then the 
owner will most likely be the actual hosting account owner.

So if the script runs as 'default www user' then 'default www user' will be 
the owner of the created file. However if the script is running with the 
authority of the hosting account owner then the hosting account owner will 
be the owner of the created file.

This is why most people have their first trouble when they shift hosting 
accounts. All the original scripts that were uploaded in the first place 
transfer across fine but files that were created by these scripts often 
change owner from the 'default www user' to the account owner due to the FTP 
process from one server to another.

Most people get around this by changing file/folder permission's and in the 
process they compromise the security of their scripts.

How Apache file attributes work -

In Apache there are 3 authorities of access and 3 access controls for each 
of the authorities.

The authorities are -
Owner - is the actual owner of the hosting account.
Group - is the collective group of authorised account owners on a server or 
subusers that have been authorised for your account via 'basic auth' login 
protocol.
User - is the default www user or just anyone using a browser or http: 
access.

The controls are (for files) -
Read - read access to be able to read a file - in php via http: the file is 
parsed so the assessor only sees the results of the code.
Write - Modify/delete access to the file.
Execute - this give the ability to execute code etc.

The controls for folders have different meanings.
The controls are (for folders) -
Read - is the ability to list the files/subfolder in a folder.
Write - is the ability to create, modify or delete files or subfolders in 
the folder.
Execute - is the ability to access (in anyway) files in the folder - like 
the meaning of read is for files.

So if a script needs to create an read files there are two real options -

1) If the script runs as the account owner then the file has to at least 
have permission's 600 and the folder that contains the folder needs at least 
300.

2) If the script runs as the 'default www user' then the file needs at least 
660 and the folder needs at least 330.

In reality you are not so concerned with owner access restrictions so these 
permission's would translate to -

600 => 700
300 => 700
660 => 760
330 => 730

However if your script runs in the owners authority then it is best restrict 
access to the bare minium (first permission's) without this translation.

FTP and cPanel do not show file owners which makes things hard. To use php 
to see the file owners then read up on POSIX functions in php.

To work blind, in most cases you can write a simple script that uploads 
files via the http: POST method and these will match the owner of other 
script created files. This can be done with a textarea html element for 
simple text files. For binary files you have to use the php $_FILES method.

For text file use -
$posted_text = $_POST['textarea_name'];// as in 

Re: [php-list] $_SITE in manual

2008-09-28 Thread listgroups08
- Original Message - 
From: "Wade Smart"

Brian Cummiskey wrote:

> you mean, $_SERVER ?
>
> Wade Smart wrote:
>>
>> 20080928 1905 GMT-6
>>
>> Im looking in the php manual for the values to $_SITE but I cant freakin
>> find anything on it. Anyone have a link?

Ah, no. Im working on someone elses code and it says $_SITE['SITE_URL']

Wade



Hi Wade,
  There is no such animal!

Perhaps they have created the variable $_SITE and registered it into the 
global environment but it does not exist by default.

Look through any includes or other pages that may have been called in the 
same session before the page that has $_SITE

Rob. 



Re: [php-list] Rolling Road Log

2008-09-26 Thread listgroups08
- Original Message - 
From: "Bob"

Hi Rob,
Thanks very much for your help.
I'm going to have to work though it at a later date.
I'm just managing to check my email daily, and that's it at the moment.

I transfer replies to my colour coded editor, then print them out for 
reference.
I have noticed on your past posts that you have some interesting techniques 
also, which I have saved.
Thanks again.
Regards, Bob E.

---
Hi Bob,

Most of what I post is hand written code, often bugs and all!

But that last script for php 4.x.x was straight off the php.net web site.

I really don't spend any time with php 4.x.x any more. I looked to find one 
of my servers that still had it available but no good. And I didn't want to 
install an older version on a WAMP.

Someone mentioned the use of $d = implode($d); and said it would use extra 
memory. I don't see why it would although I agree something like $new_var = 
implode($d); would. Perhaps they can enlighten me?

In any case I only write strings to files. For objects I use serialize(); 
and then write the resulting string.

The code I sent is a bit of a dog with the itineration over an array. Php 
5.x.x has far superior array manipulating functions. You may be able to 
achieve the same if you push the new value and old array into an empty stack 
in php 4.x.x

If I get time I will see what I can do in php 4.x.x but in reality I think 
it is time for you to look for new hosting!

Someone mentioned using fseek. The basic principle is to feed straight from 
one stream to another. This vastly improves speed and the memory usage in 
absolutely minimal compared to other methods. Because it is file steam to 
file stream, the large data file never has to sit in memory. The script I 
sent was only intended for about 100 or less data items.

The problem with fseek is that you need to determine where to seek to. To 
use this efficiently you need to pad your data items out to a fixed record 
length then you can calculate the seek position easily without loading the 
stream into memory. Remember that NULL is stored as a NULL value and uses 
the same storage as a normal character.

If you don't want to used fixed length records then you need a delimiter 
that only exists between records. Then you read character by character and 
count delimiters.
Alternatively you can focus on a file size rather than a number of records. 
This way you can seek to a position say 20KB from the end of the file and 
then just go character by character until immediately past the first found 
delimiter.

Basic principle for fixed record-

Get new data item
Pad it to a fixed record length
fopen input file
flock input file
get size of input file
f seek to size of input file - (desired number of records -1) * record 
length + any needed common adjustment
fopen output file
pass through remaining data from input file to output file
write new record to output file
fclose file streams
unlink input file
rename output file to input file
release flocks

In the past I have done this and there can be server issues from time to 
time so it is best to have a backup file.
new file becomes > log file
log file becomes > backup file
backup file is unlinked

Hope this helps 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Rolling Road Log

2008-09-25 Thread listgroups08
- Original Message - 
From: "Bob"

Hi Rob,
I'm using PHP 4.4.4 (shared server so no choice, other than moving) so can't 
use file_put_contents().
You don't need to write me a complete program, just the concept and main 
points.
I've got to do some of the work myself .

I've never bothered recorded $_SERVER['REMOTE_PORT'] before. What do you use 
it for?
Thanks, Bob E.

p.s. Sorry I'm slow at replying at the moment as I'm rewiring my son's shop.
He's got me doing it as I work cheap. A cup of tea every hour.


Hi Bob,
   Below is the additional code for php version 4.x.x compatibility.

The $_SERVER[REMOTE_PORT] was just a curiosity thing.

Thanks, Rob.

file_put_contnets for php < 5.x.x

 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Rolling Road Log

2008-09-24 Thread listgroups08
- Original Message - 
From: "Bob" <[EMAIL PROTECTED]>

I used to use the following to log specific errors:

But, this meant that sometimes there would only be a few errors shown, if 
the file had reached it's 2 limit and deleted itself.

So I created a rolling road log of a 100. This allows me to view trends 
easier. I'm not sure how efficient this is, or whether it would be suitable 
for high volume?


Has anyone got a better method, or can improve it?
Regards, Bob E.


Hi Bob,

Here is some working example code for php version 4.x.x

It is much simpler and faster in php version 5.x.x because you can just add 
arrays together in a single php function.

As with all file access the file/folder permission's need to be set 
correctly.

Serialize is the safest way to story php objects as TRUE, FALSE, NULL and 
'value not set' are stored and retrieved correctly.

Let me know what version you are running and I will write a better example.

www.domainname.com\n", $text);
  echo($text);
  }

$this_request['REQUEST_DATE'] = gmdate('d/m/Y', 36000 + 
$_SERVER['REQUEST_TIME']);
$this_request['REQUEST_TIME'] = gmdate('h:i:s a', 36000 + 
$_SERVER['REQUEST_TIME']);
$this_request['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
$this_request['REMOTE_PORT'] = $_SERVER['REMOTE_PORT'];
$this_request['REMOTE_HOST'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$this_request['HTTP_REFERER'] = $_SERVER['HTTP_REFERER'];

$data[] = $this_request;

if(file_exists('data.txt'))
  {
  $temp = unserialize(@file_get_contents('data.txt'));
  foreach($temp as $this_request)
{
$data[] = $this_request;
}
  }

if(isset($_GET['delete']))
  {
  $ip = $_GET['delete'];
  if($ip == '')
{
$ip = $_SERVER['REMOTE_ADDR'];
}
  $total = count($data);
  for($count = 0; $count <= $total; $count++)
{
if($data[$count]['REMOTE_ADDR'] == $ip)
   {
   unset($data[$count]);
   }
}
  $show = TRUE;
  }

@file_put_contents('data.txt', serialize($data));

if(isset($_GET['show']))
  {
  $show = TRUE;
  }

if($show)
  {?>




Date
Time
IP
Port
Remote Host
Referer

\n");
foreach($this_request as $key => $value)
  {
  echo('');
  if($key == 'HTTP_REFERER')
{
echo('');
}
  echo($value);
  if($key == 'HTTP_REFERER')
{
echo('');
}
  echo("\n");
  }
echo("\n");
}
  echo("\n\n");
  }

?> 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Google Docs - extract data ?

2008-09-24 Thread listgroups08
- Original Message - 
From: "Gordon Stewart"

Hi,

i know this is possible (& want to do it...) - But i'm wondering if
anyone has already done this & has a working script ?

:- Basically, I want to create a Google doc (thats easy) - Make it
published - so no login required (thats easy)...

:- I'm wanting a PHP script to check that google doc every 24 hours
:- Take away all the HTML codes / Codings etc...
:- So that I'm left with just the bare text of what is entered in the 
doc.

I've checked on a published test document...

the ONLY word is "test" - & the document (HTML) is 33KB in size...

Lots of Divs / HTML / Javascript etc...

Of course - I'll change it (the document) & test on more words /
paragraphs etc - To see how they look in HTML...

But - Is there a script already out there ?

Ps - I don't mind blank lines in my output (or 2-3 bank lines per 1
blank line on the screen...) - as long as its got a space beween
lines/paragraphs


Thanks...

- if none exists already - Would be good to get my teeth into.


strip_tags
(PHP 4, PHP 5)

strip_tags - Strip HTML and PHP tags from a string

Description
string strip_tags ( string $str [, string $allowable_tags ] )
This function tries to return a string with all HTML and PHP tags stripped 
from a given str . It uses the same tag stripping state machine as the 
fgetss() function.

Parameters

  str
  The input string.

  allowable_tags
  You can use the optional second parameter to specify tags which should not 
be stripped.

Note: HTML comments and PHP tags are also stripped. This is hardcoded 
and can not be changed with allowable_tags .


Return Values
Returns the stripped string.



Re: [php-list] Uploading files to local server

2008-09-02 Thread listgroups08
- Original Message - 
From: "bryan_is_south"
Hi all,

This is probably a noob question:

I am creating a site on my local computer only...not on a server, and
I have an upload file part (), but I want to know
if it is possible to still have the files go to a certain directory on
my own computer.
In other words, to make sure its working right before it goes up on a
real server, I test it and select a file in one directory, and when i
submit it, that file automatically is copied and pasted (still in the
original directory too, only a copy would be made) into the new directory.

Thanks,

-bryan




Tested and workin - 


File 1: 
File 2: 


 $thisfile)
  {
  echo("For the form input name that is [" . $key);
  echo("]\n\n");
  echo("Remote file (name) is [" . $thisfile['name']);
  echo("]\n");
  echo("Browsers suggested mime (type) is [" . $thisfile['type']);
  echo("]\n");
  echo("Actual file (size) is [" . $thisfile['size']);
  echo("]\n");
  echo("Server temporary name (tmp_name) is [" . $thisfile['tmp_name']);
  echo("]\n");
  echo("Upload (error) is [" . $thisfile['error']);
  echo("]\n\n\n\n");
  }

?>



Re: [php-list] Re: Uploading files to local server

2008-09-01 Thread listgroups08
- Original Message - 
From: "bryan_is_south"

> Hi Brian,
>  An error for echo($_FILES['upload']['name']); does not
> necessarily mean that there is no $_FILES superglobal.
>
> The above assumes that you are using a form with  NAME="upload">
>
> Try this
>
> if(!is_set($_FILES))
>   {
>   echo("There are no files uploaded\n");
>   die();
>   }
> foreach($_FILES as $key => $thisfile)
>   {
>   echo("For the form input name that is [" . $key . "]\n\n");
>   echo("Remote file (name) is [" . $thisfile['name'] . "]\n");
>   echo("Browsers suggested mime (type) is [" . $thisfile['type'] .
"]\n");
>   echo("Actual file (size) is [" . $thisfile['size'] . "]\n");
>   echo("Server temporary name (tmp_name) is [" .
$thisfile['tmp_name'] .
> "]\n");
>   echo("Upload (error) is [" . $thisfile['error'] . "]\n\n\n\n");
>   }
>

---

Thanks for the codes.
The first isset() part seems to show that the $_FILES is there, but
the foreach loop doesn't go through.  It doesn't even begin the loop.
That doesn't really make sense, but somehow, there is the $_FILES
superglobal, but it can't loop through them.
Is this normal?

Thanks



Hi Brian,
 It seems that $_FILES is set but has no dependents.

I will write some code and test it on a couple of servers and send it to you 
as tested and working code.

It will have to wait until tomorrow.

Thanks, Robert.



Re: [php-list] Re: Uploading files to local server

2008-08-31 Thread listgroups08
- Original Message - 
From: "bryan_is_south"



Okay, so I have to move the uploaded file from the temp folder to a
different folder then using PHP, right?

I tried copying a function from my book, but another problem arose:
there is supposed to be an automatic $_FILES superglobal, but this is
not the case for me. It gives me an error when I try to echo something
like $_FILES['upload']['name'] or such.

Once I get aorund this obstacle, I'll be able to try the new temp
folder stuff.

If you know why my $_FILES superglobal isn't working, please help.

Thank you very much

-bryan

Hi Brian,
 An error for echo($_FILES['upload']['name']); does not 
necessarily mean that there is no $_FILES superglobal.

The above assumes that you are using a form with 

Try this

if(!is_set($_FILES))
  {
  echo("There are no files uploaded\n");
  die();
  }
foreach($_FILES as $key => $thisfile)
  {
  echo("For the form input name that is [" . $key . "]\n\n");
  echo("Remote file (name) is [" . $thisfile['name'] . "]\n");
  echo("Browsers suggested mime (type) is [" . $thisfile['type'] . "]\n");
  echo("Actual file (size) is [" . $thisfile['size'] . "]\n");
  echo("Server temporary name (tmp_name) is [" . $thisfile['tmp_name'] . 
"]\n");
  echo("Upload (error) is [" . $thisfile['error'] . "]\n\n\n\n");
  }



Re: [php-list] Uploading files to local server

2008-08-28 Thread listgroups08
- Original Message - 
From: "bryan_is_south"

Hi all,

This is probably a noob question:

I am creating a site on my local computer only...not on a server, and
I have an upload file part (), but I want to know
if it is possible to still have the files go to a certain directory on
my own computer.
In other words, to make sure its working right before it goes up on a
real server, I test it and select a file in one directory, and when i
submit it, that file automatically is copied and pasted (still in the
original directory too, only a copy would be made) into the new directory.

Thanks,

-bryan

Hello  Brian,
  There can be a large number if differences between your 
local PC's config and the server config. Some of these can strongly affect 
file system operations so please don't assume that something that works on 
your local PC is going to work on the server.

There are two basic ways. One is to 'move' the uploded file from the 
temporary directory in which case the file will retain the ownership of the 
user session. The other is to stream it to the new directory and 'unlink' it 
from the temporary directory. In this case the file will be owned by the 
script authority. There can be many differences and you will have to set 
file and folder permission's in accordance with these differences.

Thanks, Rob. 



Re: [php-list] Slightly off:... Security

2008-08-28 Thread listgroups08
- Original Message - 
From: "Marc Boncz"

Whenever I make a site or application that involves any kind of user 
validation,
I use login/password combinations. Login and password get stored in a 
database,
the login in plain text, the password hashed. When the user forgets his
password, make sure there is a mechanism to create a new one and send that 
to a
pre-approved email address.

Rationale is that hashing passwords irreversibly is the only way to 
guarantee
that NO ONE can access the passwords. Not even staff. Because if paswords 
are
readable, sooner or later someone will do so. It may take years, but one day
someone will.



Moral of the story: NEVER EVER STORE PASSWORDS PLAINTEXT. One doesn't even 
store
mailinglist passwords plaintext, not to mention passwords of any service
involving money...

Marc

Hi Marc,
  Having hashes in a data base that is writable is not that 
secure no matter how complex the encryption algorithm.

For instance, someone can create a new login account with a know username 
and password. They then look for their username in the data base and copy 
the hash associated with their username. They then write the hash into the 
data base for the target user and login with the target username and the 
password they created on the new login account.

A more secure method is to ensure the server has a dedicated IP and then 
create a remote server with a dedicated IP and SSL Cert. Configure apache in 
the secondary server so that it will only answer requests from the IP of the 
primary server. When a password is to be created the primary server sends 
the username and requested password along with some other arbitrary keys 
with predictable values, via SSL to the secondary server. The secondary 
server stores the hash in a local data base and returns a token. When 
someone logs in, the primary server looks up the token and sends that to the 
secondary server via SSL and the secondary server responds via SSL with the 
hash. The primary server then completes the login normally. To share the 
secondary server for a number of primary servers then include the new IP 
addresses in the secondary servers accept list. Also include the requesting 
IP address in the hashing algorithm on the secondary server. Tables have to 
be indexed so that the same user name can exist on the different primary 
servers.

Thanks, Rob. 



Re: [php-list] permissions issue with uploading graphics

2008-08-22 Thread listgroups08
- Original Message - 
From: "Wade Smart"

20080821 1902 GMT-6

Discovered today that a script that the school "THOUGHT" had been working 
for
the past two years - inst!

Their upload script uploads the picture into the images/ dir and then 
creates a
thumnail of it and puts it in the thumb/ dir. That all works.

Their delete script first deletes the photos and then the student data from 
the
db. Ah... the photos have not been deleted.

Looking at the permisions I see that images/ and thumb/ are both 1600775
www-data owner. The picture in images/ is 600600 but the one in thumbs/ is
600644. That is a problem.

All the thumbs have been deleted but the pictures themselves are not. Now, 
Ill
write some code to change the rw permissions of the pic but what Im after 
is,
why is it that the main pic is rw to the owner and non to the group but on 
the
thumb its rw for the owner and read-only for the owner. Why can that one be 
deleted?

Wade


Hello Wade,
  I see no one answered this question for you.

The question itself is a little confusing where you say "but on the thumb 
its rw for the owner and read-only for the owner".

I will offer some explanation that is common but may not be your case.

PHP run's in someone's authority. The authority may be user 
(www,anybody,nobody, apache) or the authority of the visitors. This is often 
the case when php runs as an apache application. In the case all files 
created by PHP will have the default owner "user" (anybody).

PHP can also run with the authority of the account owner. This is often the 
case when php runs as a CGI. Files created with this authority have the 
owner who is the owner of the account "owner".

The difference between the pictures and the thumbnails is that thumbnails 
are created by php and the pictures are not. The pictures are uploaded with 
the authority of "user" so the owner is "user".

The thumbnails are created by the script so the owner is the authority that 
the script runs under.

Clear as mud?

Later versions of php are more frequently run as a CGI. Earlier versions 
where rarely run as a CGI. It is also rear to have php running as an apache 
application to have any authority other than "user" or "group".

It may be the case that the script was running perfectly until a php 
upgrade. Look at the dates of the pictures and that may help pinpoint a 
time.

Thanks, Rob.

PS: Look up POSIX at php.net 



Re: [php-list] Need help about htaccess readwrite mode

2008-08-18 Thread listgroups08
- Original Message - 
From: "birgunj birgunj"

Dear All,

i am trying to learn htaccess mode rewrite.i search the google but i did not 
get simple tutorial which i understand.i also see the documentation apache 
but it is too vast.

please any body have simple tutorial for beginner about htaccess mode 
rewrite.please share with us.

thanks
humayoo

Hi birgunj,

MOD_REWRITE can do a vast number of things right down to redirecting based 
on remote port connections.

Tell us what you want to achieve.

If you just want to re-map URL's to server pathfiles then you need to study 
REGEX.

Here is something simple to get you started -
 http://www.workingwith.me.uk/articles/scripting/mod_rewrite 



[php-list] Riya Britney Banned

2008-08-15 Thread listgroups08
Hello Riya Britney,
   I was just typing a warning message to you when 
you sent the link spam to the group.

I have been suspicious of you from day one due to you e-mail address 
[EMAIL PROTECTED] as I know this e-mail address format is used by 
blogger.

We have had many content thieves her most have blogspot sites. ALL have been 
taken down.

Let this be a warning for you and others that we actively peruse content 
theft from this group and remove any offending sites.

Thank for your the list of blogger sites you sent in your link spam as it 
will help monitor your activities.

You will be banned shortly!

List Owner.

- Original Message - 
From: "Riya Britney" <[EMAIL PROTECTED]>
To: 
Sent: Saturday, August 16, 2008 7:38 AM
Subject: Re: [php-list] wrong phpinfo directive


check php.net site , u can get best info abt php at 
http://phpgreat.blogspot.com

--- On Fri, 8/15/08, Imre Neuwirth <[EMAIL PROTECTED]> wrote:

From: Imre Neuwirth <[EMAIL PROTECTED]>
Subject: Re: [php-list] wrong phpinfo directive
To: php-list@yahoogroups.com
Date: Friday, August 15, 2008, 8:52 PM








--- On Fri, 8/15/08, James Keeline <[EMAIL PROTECTED] com> wrote:
From: James Keeline <[EMAIL PROTECTED] com>
Subject: Re: [php-list] wrong phpinfo directive
To: [EMAIL PROTECTED] s.com
Date: Friday, August 15, 2008, 3:51 PM

--- Imre Neuwirth  wrote:

> I have both Apache 2.2.8 with PHP 5.2.6 installed in their respective

> C:\Program Files\ folders. When I look at the phpinfo() configuration of 
> the

> PHP core, the "include_path" points to ".;C:\php5\pear" . I checked both 
> the

> httpd.conf and php.ini and this parameter does not exist in either file 
> and

> \PEAR is a sub folder of "C:\Program Files\PHP". Can anyone tell me where 
> is

> this parameter specified so that I can correct it?

There may be multiple values in phpinfo() output which are not explicitly 
set

in a php.ini file. If not set, the default values are given. If they are set

in the php.ini file in use, that value should "win."

James

Hello James,

Many thanks. I added the correct parameters to the php.ini and it registered 
properly.











[Non-text portions of this message have been removed]


















[Non-text portions of this message have been removed]




Please remember to write your response BELOW the previous text.

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links





Re: [php-list] what is more indicated ?

2008-08-12 Thread listgroups08
- Original Message - 
From: "LuCiaNo - CeTre"

I'm remaking a system and now i'm making the login part.

 The existent login was made with COOKIES but now i was thinking in to
do with SESSION.

 What is better for this ?

 This is a internal system with some modules that i'm renewing.

 Best Regards or all !
--
Hi,
 Use the php function session_start(). It will use cookies if they are 
available or use session variables in URLs automatically for php >v4.2.0.

Direct use of cookies is better for long term variables rather than 
sessions.

Thanks. 



Re: [php-list] Re: Flash template mail form activation

2008-08-10 Thread listgroups08

 
- Original Message - 
From: "a_wil72" 

Wade,
Thanks for the prompt response. This is the php script that I am 
using:
/n"; 
$headers = 'Content-type: text/html; charset=iso-8859-1';
$comments ="\r\n\n\n"  . "Sender's ip address is " . nl2br($ip);
mail($sendTo, $subject, $comments, $from);

?>

When a visitor hits the send button on my contact form, they recieve 
the "your message was sent, thank you" screen, but the only 
information I recieve in my inbox is the senders ip address. No name 
or email address or the body of the message. Hope this helps

Ashley Wilson
-
Tested script - 

";
$reply = "Reply-To: " . $name . "<" . $email . ">";

$headers = $from . "\r\n";
$headers .= $reply . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
// last "\r\n" above may not be nessesary

mail($to, $subject, $message, $headers);
?>



Re: [php-list] Re: Flash template mail form activation

2008-08-10 Thread listgroups08
Wade,
Thanks for the prompt response. This is the php script that I am
using:
/n";
$headers = 'Content-type: text/html; charset=iso-8859-1';
$comments ="\r\n\n\n"  . "Sender's ip address is " . nl2br($ip);
mail($sendTo, $subject, $comments, $from);

?>





Your message was sent. Thank you.



resizeTo(300, 300)

When a visitor hits the send button on my contact form, they recieve
the "your message was sent, thank you" screen, but the only
information I recieve in my inbox is the senders ip address. No name
or email address or the body of the message. Hope this helps

Ashley Wilson
-
Hello Ashley,
   We post below the previous e-mail in this group.

Your problem is with the line -
$comments ="\r\n\n\n"  . "Sender's ip address is " . nl2br($ip);
Perhaps this should be -
$comments = "\r\n\n\n"  . $comments . "\r\nSender's ip address is " . 
nl2br($ip);

There are also other issues -
You have this line that is not doing anything usefull -
$headers = 'Content-type: text/html; charset=iso-8859-1';

And this -
$comments ="\r\n\n\n"  . "Sen
Perhaps should be -
$comments ="\r\n\r\n"  . "Sen

Also you have no filter in the input leaving your script open to abuse.

The headers in an e-mail are separated from the body by a "\r\n\r\n" while 
each header is separated by "\r\n"

As you are not filtering the From e-mail address and the From address ia a 
part of the headers then someone can do this -
From: [EMAIL PROTECTED]:[EMAIL PROTECTED];[EMAIL PROTECTED] 
etc

Try this -
$comments = $_GET['Comments'];
$comments = str_replace("\r\n", "\n", $comments);
$comments = str_replace("\n.", "\n..", $comments); // for windows servers

And ... well some code woulld be easier -

";
$reply = "Reply-To: " . $name . "<" . $email . ">";

$headers = $from . "\r\n";
$headers .= $reply . "\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
// last "\r\n" above may not be nessesary

mail($to, $subject, $message, $headers);
?>

Just hand typed so may have bugs - I will test it for you if you tell me it 
doesn't work.



Re: [php-list] reposting value of a multi-value drop down box

2008-07-30 Thread listgroups08
- Original Message - 
From: "Wade Smart"

I've kinda jumped projects for the moment to help out the local school 
before
school starts. Im working with a page that has several drop down boxes


   Math
   Arts
   Science


like that. After the page is posted I have to error check all to be sure 
that
certain questions have in fact been answered and if not, repost all of it 
back
to the screen so they can see which have and have not been filled in.

Is there a way to easily do this and show that if Arts was chose but they 
forgot
the next one that Arts and the other selected questions are still selected?

Wade


Hi Wade,

$division['math'] = "Math";
$division['arts'] = "Arts";
$division['science'] = "Science";

echo('' . "\n");

foreach($division as $key => $value)
  {
  echo('' . $value . '' . "\n");
  }
echo('' . "\n");


Just one or two things. I probably have the keys and values back to front 
and remember that php does not allow dots in key names but HTML does.




Re: [php-list] Session variable will not evaluate

2008-07-24 Thread listgroups08
- Original Message - 
From: "Wade Smart"

Wade Smart wrote:
> William Piper wrote:

>> what does print_r($_SESSION); show?
>
> 20080724 1508 GMT-6
>
> Nothing. Its shows nothing.
> session_start() is the first line and Im not doing anything I haven't done
> before. I'm clearing my cache (which shouldn't affect this) to see if it 
> helps.
>
> I'm a bit puzzled.
>
> Wade

20080724 1516 GMT-6

I wiped my cache and deleted my cookies. Now print_r() shows the correct 
values.
Funny thing: still evaluating wrong.

page1.php
if($key === $u && $code === $p){
$_SESSION['authorized'] = "yumyum" ;
header("Location: page1.php");

page2.php
if($_SESSION['authorized'] != "yumyum" ) {
header("Location: http://www.google.com";);
}

print($_SESSION)
'authorized' = "yumyum"

I must be losing it today as this cant be that hard :)

Wade


Hi Wade,
 session_start() requires a cookie to be exchanged with the 
client. Isn't too late then to send another
header("location:...



Re: [php-list] Sorting Multidimensional Arrays

2008-07-17 Thread listgroups08
- Original Message - 
From: "Phill Sparks"

On Sun, Jul 13, 2008 at 2:56 AM,  <[EMAIL PROTECTED]> wrote:
> < Code removed >

You might consider using a service like http://pastebin.com/ to share
code with the list since formatting is removed it makes it very hard
to follow large chunks of code.

Phill



Hi Phill,
   I agree the code was a bit long but this group is about coding.

If you set your e-mail settings at yahoogroups to 'Traditional' then leading 
white space is preserved and the code is easier to read.

Thanks.



Re: [php-list] Sorting Multidimensional Arrays

2008-07-12 Thread listgroups08
- Original Message - 
From: "bryan_is_south"

Hello,

I have a multidimensional array, and would like to sort it by the
value of the last array.

Here's the idea of what I've got:

$Scores[$artist][$album]=$avg;

So the $Scores array contains an array for each artist, and each
$artist array contains an array for each album by them. The value for
the $album array is the average score for the album.

I want to sort this multidimensional array by the $avg, but I can't
figure it out.

Suggestions are much appreciated.

Thank you in advance
-bryan



'. "\n");
  echo("ArtistAlbumRating\n");
  foreach($array as $artist_name => $albums)
{
foreach($albums as $album_name => $rating)
  {
  echo("");
  echo("" . $artist_name . "");
  echo("" . $album_name . "");
  echo("" . $rating . "");
  echo("\n");
  }
}
  echo("\n\n");
  }

function sort_order($array)
  {
  foreach($array as $artist_name => $albums)
{
foreach($albums as $album_name => $rating)
  {
  $order[] = array('artist_name' => $artist_name, 'album_name' => 
$album_name);
  $ratings[] = $rating;
  }
}
  // Bubble sort
  for($compare_end_index = count($ratings) - 2; $compare_end_index >= 0; 
$compare_end_index--)
{
for($compare_index = 0; $compare_index <= $compare_end_index; 
$compare_index++)
  {
  if($ratings[$compare_index] > $ratings[$compare_index + 1])
  // change the '>' above to '<' to reverse the sort order
{
$temp = $ratings[$compare_index];
$ratings[$compare_index] = $ratings[$compare_index + 1];
$ratings[$compare_index + 1] = $temp;
$temp = $order[$compare_index];
$order[$compare_index] = $order[$compare_index + 1];
$order[$compare_index + 1] = $temp;
}
  }
}
  return $order;
  }

function show_ordered_array($array, $order)
  {
  echo(''. "\n");
  echo("ArtistAlbumRating\n");
  foreach($order as $keys)
{
$artist_name = $keys['artist_name'];
$album_name = $keys['album_name'];
$rating = $array[$artist_name][$album_name];
echo("");
echo("" . $artist_name . "");
echo("" . $album_name . "");
echo("" . $rating . "");
echo("\n");
}
  echo("\n\n");
  }

$Scores = init_scores();
show_array($Scores);
$order = sort_order($Scores);
show_ordered_array($Scores, $order);

?> 



Re: [php-list] Sorting Multidimensional Arrays

2008-07-12 Thread listgroups08
- Original Message - 
From: "bryan_is_south"

Hello,

I have a multidimensional array, and would like to sort it by the
value of the last array.

Here's the idea of what I've got:

$Scores[$artist][$album]=$avg;

So the $Scores array contains an array for each artist, and each
$artist array contains an array for each album by them. The value for
the $album array is the average score for the album.

I want to sort this multidimensional array by the $avg, but I can't
figure it out.

Suggestions are much appreciated.

Thank you in advance
-bryan


Hi Bryan,
  This can be done with a bubble sort but bubble sorts are slow. 
PhP has an inbuilt sort function sort() but it is intended for flat arrays 
and not multi dimensional.

The first question that has to be asked is if the results are ranked by 
album irrespective of artist or if the results must still have albums by an 
artist still grouped together.

If they don't have to grouped by artist then you really do have to convert 
to a flat array as a multi dimensional array does not reflect this 
structure.

Here is the basic structure of a bubble sort that can be expanded to multi 
dimensions but remember the inbuit sort() function will be much faster for 
flat arrays.

// to bubble sort flat array $array[] in ascending order ...

for($end_compare_index=count($array) - 2, $end_compare_index >= 0, 
$end_compare_index--)
  {
  for($compare_index = 0, $compare_index <= $end_compare_index, 
$compare_index++)
{
if(array[$compare_index] > array[$compare_index + 1))
  {
  $temp = $array[$compare_index];
  $array[$compare_index] = $array[$compare_index + 1];
  $array[$compare_index + 1] = $temp;
  }
}
  }

The above is just hand typed so it may have typo's.

I think that the best solution is to have a second flat associative array 
that represents the sort order of the first indexed multi dimensional array.

Tell me more about the needed output structure and what it is to used for 
and I will send some code.

Thanks, Robert. 



Re: [php-list] simple poll with results

2008-07-10 Thread listgroups08
- Original Message - 
From: "Tedit kap"

Hi,
I would like to create a simple poll which would list several or more items 
with radio buttons near them, and the users should click and submit to 
select their favorite product. So this should be saved in database. The user 
should also be able to view the results.
I am a beginner php coder so although I have some idea of how to do this, I 
still need guidance.
How can I do this / anyone can send code? Or where shold I look at?
Thanks


Hi Tedit kap,
   I see that you don't seem to be happy with the scripts 
you have found.

If you and others here can come up with a table structure and the insert and 
query strings then I will write a PHP/AJAX script that has HTML as a backup 
if Javascript is disabled.

I generally don't use polls myself as I hate the page reload so I make mine 
AJAX.


Thanks. 



Re: [php-list] Parse error in HTML file

2008-07-07 Thread listgroups08
- Original Message - 
From: "Hayden's Harness Attachment"

Can someone see why my web page is giving the error:

Parse error: syntax error, unexpected T_ELSE in 
/usr/home/choroid/public_html/new/crf_header.php on line  31

For the PHP code:

Increase Font 
Size';
  }
else
  {
echo 'Decrease Font 
Size';
  }
else
  {
echo 'Default Font 
Size';
  }
?>

Thank you for the help.

Angus MacKinnon
--
Hi,

You have -
if ... else ... else
it should be -
if ... else
if ... elseif ... else

also see switch() -
http://php.net/manual/en/control-structures.switch.php





Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] Migrating from Linux/Apache to Windows/IIS

2008-06-25 Thread listgroups08
- Original Message - 
From: "Greg"

I have developed a Content Management Systems in PHP/MySQL which works
well on Linux/Apache platforms.

I have a client with a Windows/IIS server, who wants to use my CMS.

He knows he will have to install PHP and MySQL to use my software,
BUT, am I going to hit any snags? Will code developed for a LAMP
environment work, as-is, in a WIMP environment, or will I have to
'tweak' it?

Anything in particular I need to look out for, for example, sessions,
file uploading via HTTP, image manipulation (GD), etc.

Many thanks for any suggestions or help.

Greg

Hi Greg,
 I have not used IIS so I hope someone else can answer about 
IIS.

Generally the differences between Linux and Windows are -

The file ownership scheme is different and this causes file access problems.
The '/' becomes '\'.
Linux is case sensitive for file names ie a.php and A.php are different 
files and can co-exist.
Windows does not natively support POSIX functions. Important - read up on 
what POSIX actually is to an OS.

So in short, if you are creating or modifying files then you will have 
issues.
If you accessing files outside of the HTTP path or by file system access 
then you will have issues.
Also some security features will not work because - well - windows is 
insecure!

Thanks. 



Re: [php-list] date and mysql

2008-06-23 Thread listgroups08
- Original Message - 
From: "Jennifer Gardner"

Hello,

I am looking for a good tutorial for having the date submitted when a form
is submitted and then being able to display the date in a results
table/page.  Basically, when the form is submitted I want the date submitted
into the mysql table and then I want to display that on a results page.
Thank you in advance for your help.

 Jennifer
--

Hi Jennifer,
Here is some code of mine that may be helpful. It does not 
answer your question about MySQL but it does however show how to deal with 
location issues and how to transfer a time zone (GMT+10) from the server in 
PHP onto the client in Javascript independent of the client locale. You can 
see the generated source at ozwebwiz.info

Thanks, Robert.



Current Server Time





\n");
echo("GMT Time/Date: " . gmdate("g:iA l F j, Y") . "\n");
echo("Cairns Time/Date: " . gmdate("g:iA l F j, Y", time() + 10 * 60 * 60) . 
"\n");

?>

Javascript Time/Date: 





 



Re: [php-list] Parse error

2008-06-18 Thread listgroups08
- Original Message - 
From: "Hayden's Harness Attachment"

Why do I get the following error:

Parse error: syntax error, unexpected T_CASE in 
/usr/home/choroid/public_html/new/crf_header.php on line 29

Line 29 is:

case 'layout_medium':

HTML and PHP code:

http://www.choroideremia.org/new/crf_header.php

Angus MacKinnon
Infoforce Services
-
Hi

PHP errors are often before the reported line so it is good to post a little 
more code.

The reported error means that there is no switch() function open and the 
case native cannot come before a switch(). 




Please remember to write your response BELOW the previous text. 

Community email addresses:
  Post message: php-list@yahoogroups.com
  Subscribe:[EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-listYahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/php-list/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:[EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/



Re: [php-list] help with vbulletin update

2008-06-03 Thread listgroups08
- Original Message - 
From: "Matt"
Subject: [php-list] help with vbulletin update


could someone with experience give me a quick hand updating vb on my
website? thanks


Hi Matt,
 What version to what version? If you have a straight install 
with no addons or hacks then it will be easy.

If you have addons or hacks then things change and it best to research them 
first.

I have no experience with this package but I have installed/updated many 
others in the past. 



Re: [php-list] $_POST problem

2008-05-31 Thread listgroups08
- Original Message - 
From: "shaggy2dope2126" 

So heres the problem. the form works in three parts, all of the them
except for the last part where the mysql queries are ran. The
variables of starting and ending number are not being sent. i have
tried both methods of post and get with the second form and it still
will not work. i tried changing the variable in the for loop form $x
to $y and still nothing. the first for loop using the $_POST variables
works perfect. and i copied the code to the second for loop and
couldn't get it to function. Any one got any ideas as to why?


---
Your form action is POST - 

Re: [php-list] CAN YOU DO SOMETHING CRAZY FOR ME?

2008-05-28 Thread listgroups08
- Original Message - 
From: "olunkwaik"
Subject: [php-list] CAN YOU DO SOMETHING CRAZY FOR ME?


Hi everyone, it's me Iyke(D-SUN), tommorrow Wednesday 28th May, 2008
is my girl's birthday, I don't have much cash to celebrate it or buy
her a present, but I have been brainstorming all weeks how to give her
a gift that will smash her mind.

So can any of you, my great friends call her and tell her happy birthday.




Hello Group,
   The above member was placed on moderation. The above post 
is actually the most offtopic I have ever seen.

We all come different backgrounds and we have different religious, moral and 
social beliefs.

Whilst I accept every members different beliefs, others may see opportunity 
in dispute.

This is why we stick to PHP and related topics. It makes my job as moderator 
easier.

Please remember that there is someone here that -
Approves new members.
Moderates new members.
Deletes SPAM.
Bans SPAMers.
Returns offtopic posters to moderated status.
Bans content thieves.
Take down the sites of content thieves.

Do a google for +"php-list@yahoogroups.com" and you will find many 
(effectively) dead links for sites I have had removed to protect members 
private e-mail addresses.

While slightly offtopics are accepted for example, Apache directives or 
setting up a WAMP, please assist me by not delving to far from or main 
stream topics.

Thank you, Your moderator. 



Re: [php-list] PHP Image copy permissions

2008-05-26 Thread listgroups08
- Original Message - 
From: "Lenny Davila"
I have a script that uploads and resizes an image and puts it in a users
directory

www.mysite.com/members/USERNAME/IMAGE
  _FILE.jpg



While testing I had to delete a few images.  I could not delete them by FTP
or in my plesk control panel.  Only through using winSCP and logging on as
root into the server.   Why is this happening?  I have even  tried to chmod
the file by using this code after the image copy:

chmod($new_image_name, 0777);



Does anyone have any other ideas?



PHP safe mode is on

Thanks,

Lenny



Hi Lenny,
  You haven't given enough information for us to answer this 
question. We don't even know what OS your server is running.

chmod 777 doesn't work on all servers as some sysadmins disable the effect 
of 777 for security.

The most probable answer to your question is that your PHP is running in the 
authority of the user and not the authority of yourself. This means the user 
is the owner of the file and therefore you do not have delete permission 
until you log in as root.

If this bothers you then you can run PHP in a wrap or as a CGI however this 
means your script runs with you authority and a successful hacker can obtain 
all your permission's.

Another option is write a script to delete files and use it in the same way 
as the user ie - from a browser. Of course you need some protection such as 
a password.

Running as a CGI is PHP wide so it is not always the best option. A wrapper 
can be used in a script by script basis. Not all hosting providers have 
wraps available you will have to read up on your providers site.

FTP can run in the same three levels of permission's - user/public - group - 
owner.

Public ftp is user/public. A created ftp user account is group and the root 
ftp account is owner.

A browser window is user/public. A password protected directory can be group 
or owner.

If you want to find out more then use the PHP directory listing commands in 
conjunction with the system POSIX or PHP extensions.

See -
http://php.net/manual/en/ref.info.php
getmyuid
getmypid
get_current_user
filegroup
fileowner
stat




Re: [php-list] How to open php files - very beginner question

2008-05-26 Thread listgroups08
- Original Message - 
From: "nj7874"

I am a beginner to web development.  I want to add a forum to my
website. I found this website that list different forums:
http://mashable.com/2007/08/19/online-forums/
   So I downloaded the
Orca one. I tried to install it, but my computer says it cannot read php
files.

What steps do I take next?

Thank you,

Leslie



I use WAMPServer - 
http://www.en.wampserver.com/



Re: [php-list] pls. help - HOW to call mysql procedure in PHP

2008-05-23 Thread listgroups08
- Original Message - 
From: "arun gupta" 

HOW to call mysql procedure in PHP??
pls. reply ASAP

 
Thanks and Regards,
__

http://dev.mysql.com/doc/refman/5.0/en/stored-procedures.html



Re: [php-list] Substring Path Extracting

2008-05-10 Thread listgroups08
- Original Message - 
From: "lilmouseman"

Hi Everyone. First time poster.

My question is about extracting part of a path from the right.

e.g. folder/images/testimage.jpg

how do I get everything from the right all the way up to the first "/"

Thank you in advance.



Hi Lilmouseman,

I see that you were happy with using basename().

>From your question it seems that you are talking about a URL rather than a 
file path.

For file paths, lookup these functions -
pathinfo() - http://php.net/manual/en/function.pathinfo.php
realpath() - http://php.net/manual/en/function.realpath.php

For HTTP paths, lookup these functions -
parse_url() - http://php.net/manual/en/function.parse-url.php
parse_str() - http://php.net/manual/en/function.parse-str.php

For functions that work with URL's or file paths, lookup these functions -
dirname() - http://php.net/manual/en/function.dirname.php
basename() - http://php.net/manual/en/function.basename.php 



Re: [php-list] File - List Etiquette

2008-05-06 Thread listgroups08
- Original Message - 
From: "John Black"
[EMAIL PROTECTED] wrote:
> - Make sure that the "RE" prefix is before the "[php-list]" prefix or some 
> mail clients will screw up the subject
>
> Good: RE: [php-list] Message Subject
> Bad:  [php-list] RE: Message Subject

I think this one is impossible to enforce/implement  because Yahoo's own
Group messenger does not do it  from the source of the latest "offender"





Hello John,
  Your point has been accepted. Perhaps I have been slack as 
group moderator an I should go and re-write the group policies.

In reality there are only three things that are important to me as far as 
policies go -

1) Content thieves that use e-mail addresses to post group content on the 
web and take several days to weed out. This is my biggest irritation.

2) Members that do not know that we need to post below the original e-mail. 
Once or twice is OK but some members keep going. I have even had one member 
expressing dissatisfaction with my reminders to so called offenders.

3) The biggest pain for most moderators is flaming. With great gratitude, I 
can say that this group has always been very conservative in this respect.

Point 3) has never really been an issue.

Point 2) is an ongoing thing with a group like this and I hope you have 
patience with me. We have been running since September 1999 and we currently 
have 2424 members.

Point 1) results in an immediate ban. There is actually a lot of work that 
goes into this issue on my behalf.

I cannot remain as owner/moderator for too much longer. So if anyone is 
interested then please say so offlist.

Any criticism is graciously appreciated.

Thank you, Robert. 



Re: [php-list] Forms

2008-04-29 Thread listgroups08
- Original Message - 
From: "Alexandra"

Hi everyone,

My name is Alexandra and I just joined today, I don't know any PHP,
but I have encountered an issue that may have to do with PHP
programing. I do simple websites and create contact forms in Front
Page, because I haven't figured out how to do it in Dreamweaver, I
can't figure out how to make the submit button go to the thank you
page in Dreamweaver, which is why I am using FP. I am self taught,
with the exception of complicated forms and php.

Now, here is my issue: when someone fills out a form and clicks
submit, the email I receive comes from: "anonymous@ and a server name
and number" and I would like that when someone fills these forms, to
say the domain name or anything else rather than this email address
that doesn't exist! is there a way to change that? is this something I
can change? or is this something the web hosting company has to change?

Also, the text box where someone can write requests, it is set to no
constrains, but every time someone types something in, it types
everything in one horizontal lineand not like a paragraph or line
under lineis there some fix for that?

Thank you very very much,

Alexandra




Hi Alexandra,

I can't answer some of your questions as they don't relate to PHP so they 
are offtopic in this list.

The action="... of your form will tell you what is sending the email. It is 
most probably a CGI script.

Get the full path from the action="... so that you have 
http://yourdomian.com/cgi/frommail.pl or something like this and put 
directly into your browser. You will most likely get the script name and 
version so that you can study it and make the necessary changes.

If the action="... is something like sendmail.php or anything that ends in 
.php then post a copy of the code from the .php file here so that we can 
tell you how to change it.

PHP allows much more flexibility for sending e-mail but there are security 
risks. Hackers will use your mail server to send tens or hundreds of 
thousands of e-mails at your expense by hacking into a poorly written 
script.

If you want a PHP e-mail script then I suggest you find a prewritten one and 
modify it. See www.hostscripts.com

Alternatively post your form here and we can write the code for you as long 
as we accurately know what you require.

Thanks, Robert.

Please remember to write your response BELOW the previous text. 



[php-list] New group owners

2008-04-29 Thread listgroups08
Hello groups,

I am your group owner and moderator and I have a special request to make. 
Please excuse my offtopic.

My longevity has been reduced from two years to three months so I would like 
to be reduce myself from owner status to moderator only status.

I am happy to remain a moderator however I don't want this group to be lost 
in the event that I can no longer be an owner.

I am asking for potential group owners to come forward.

The functions I preform are as follows -

These groups need approval for new members. Most members are approved but 
some are not for reasons below.

New members posts are moderated until they demonstrate that group policies 
are followed. This eliminates most SPAM.

On occasions that members do not follow the group policies, they are 
returned to moderated status.

OK - that's the basic stuff - now the harder stuff.

Some on the internet are hungry for fresh content that they can use to 
created advertising dollars and yahoo groups are targeted for this reason.

These people broadcast content from various sources including yahoo groups 
and in this process they sometimes display private members e-mail addresses 
in the text of quoted and previous e-mails. This is a big issue that takes 
quite some time investment to resolve.

Most recently see -
http://php-discussion.blogspot.com/
http://belajar-php.blogspot.com/
http://php-source-code.blogspot.com/

These are all sites that I have had removed because they were using a 
subscribed e-mail address to steal content. This is not an issue that is 
specific to my groups. In fact it is a common issue for yahoo groups and 
perhaps others as  well.

Because blogspot is owned by google, I use google alerts to detect these as 
the google bot spiders these sites before other spiders detect them.

I have also written many scripts that run on my personal servers that have 
the dedicated purpose of detecting these abuses of group members e-mail 
addresses.

This is a dynamic situation - as I have learnt over the years - there is no 
ultimate solution. You have to keep ahead of the pack.

If you think you have the dynamic skills to deal with the changing methods 
used by content thieves than please let me know.

My retirement from owner status forthcoming.

EGO will not get anyone any extra points - I want to see demonstrated 
skills.

Your current group owner, Robert Martin. 



Re: [php-list] Convert different data types

2008-04-27 Thread listgroups08
- Original Message - 
From: "Waqas Habib"

[EMAIL PROTECTED] wrote:
- Original Message - 
From: "Waqas Habib"

Thanks. I am giving you my specification with an example.
Suppose i want to send 7-Bytes to a socket. I want to put "1" in first
byte, "0" in second byte, "3" in 3rd byte, and an IP address in remaining
bytes. How can i do it? And also its reverse process.
Hope you understand the problem..

-Waqas





I am not sure what you mean by "reverse process". The above is outgoing
connection and outgoing data.

Do you mean ???
1) Outgoing connection, incoming data?
2) Incoming connection, outgoing data?
3) Icoming connection, incoming data?

Robert.

  

  Thanks.

 From reverce process i mean that if i have to read 25, 26, or 15
bytes from that socket, with same type of arrangements i-e suppose 4
bytes for IP address, remaining bytes for simple data i-e 0;

 Please if you can write example code for this process also (like
you have write for writing on socket).

   -Waqas


Ok, I see "read" in your last post so I assume you mean incoming data. That 
narrows it down to two -

1) Outgoing connection, incoming data?
3) Icoming connection, incoming data? 



Re: [php-list] excel to mysql

2008-04-23 Thread listgroups08
- Original Message - 
From: "fremaje31"

Hello All,

I have a bunch of mailing list in MS Excel format.  I want to upload
them into my MySQL database.  What is the best way to do this?  I've
seen converter software, has anyone used any before and are any of them
free?

Thanks in advance for your assistance,

Tisha



If you have phpmyadmin then you can save then as CSV (Coma Separated Values) 
and the directly import them to an existing table with phpmyadmin.

Do a test one first with an unused table. 



[php-list] How to append an array of arrays to an array

2008-04-21 Thread listgroups08
Hi all,
 
How do I append an array of arrays to an array in php. 

If I have - 
array(0,2,2)
or
[0,2,2]

and I have - 
array(array(1,2,2),array(2,2,2),array(3,2,2))
or
[[1,2,2]
[2,2,2]
[3,2,2]]

How do I append the array of arrays to the array so that I have - 
array(array(0,2,2),array(1,2,2),array(2,2,2),array(3,2,2))
or
[[0,2,2]
[1,2,2]
[2,2,2]
[3,2,2]]

I tried this but it doesn't work
$result = $array . $arrays

Any help would be appreciated. 
I am obviously doing something wrong!



Re: [php-list] Convert different data types

2008-04-16 Thread listgroups08
- Original Message - 
From: "Waqas Habib"

Thanks. I am giving you my specification with an example.
  Suppose i want to send 7-Bytes to a socket. I want to put "1" in first 
byte, "0" in second byte, "3" in 3rd byte, and an IP address in remaining 
bytes. How can i do it? And also its reverse process.
  Hope you understand the problem..

  -Waqas



\n");
  die();
  }
fputs($fh, $output);
fclose($fh);

?>

I am not sure what you mean by "reverse process". The above is outgoing 
connection and outgoing data.

Do you mean ???
1) Outgoing connection, incoming data?
2) Incoming connection, outgoing data?
3) Icoming connection, incoming data?

Robert. 



[php-list] RSS to e-mail

2008-04-16 Thread listgroups08
Hello all,
 I have looking for some scripts to bridge from RSS to e-mail. I 
can find plenty the go from e-mail (generally SMTP) to RSS but none the 
other way around.

Is anyone here aware of some free simple script for this?

How good are PHP's XML functions with RSS?

Are there any pointers you can offer if I have to write my own scripts?

Thanks, Robert. 



Re: [php-list] Convert different data types

2008-04-16 Thread listgroups08
- Original Message - 
From: "Waqas Habib"

Hi, I want to convert my (string, integer) data to binary format. And also 
from binary data to integer format and to string also. Is there any data 
type in php to hold binary data.

  -Waqas Habib

 between -00-00 and -99-99


PHP is a loose type language. There is no BINARY type but rather BINARY is 
an output format.

The php types are -

"boolean" (or, since PHP 4.2.0, "bool")
"integer" (or, since PHP 4.2.0, "int")
"float" (only possible since PHP 4.2.0, for older versions use the 
deprecated variant "double")
"string"
"array"
"object"
"null" (since PHP 4.2.0)

To convert an integer value to a binary string then use decbin($value). This 
is limited to 4 bytes and outputs a string.
To convert a binary string to a integer or floating point value use 
bindec($binarystring).

Integers are 32 bit signed values in PHP.

PHP tries to convert types on the fly-

50 + "5" = 55
"50" . 5 =  "505"

Thanks, Rob.
PS: no cross-posting here 



Re: [php-list] communication with other applications

2008-04-08 Thread listgroups08
- Original Message - 
From: "Waqas Habib"

Hi, My name is waqas. I am new in PHP and facing a problem in using it. I
have an application (not in php) which is trying to connect on a specific
IP and port (8060). After connection it will send messages on that port. I
want to write a php script that can communicate with that application. i am
working at Solaris-9. Any guide...?
Thanks

  -Waqas

-

Hi,
PHP is geared to the HTTP protocol. ie connect - request - response - 
disconnect.

PHP can make outgoing port connections for more complex protocols but it is 
not good for complex incoming protocols. It can be done but don't expect 
complex duplexing.

Tell us what protocol you are using and perhaps we can offer more 
information.

Thanks, Robert. 



Re: [php-list] Re: Adding attachments to e-mails from a form

2008-04-06 Thread listgroups08
- Original Message - 
From: "Ian"
--- In php-list@yahoogroups.com, <[EMAIL PROTECTED]> wrote:
>
> Q: Is there any way to allow someone to attach a file without uploading
> to the web server?
>
> A: No.
>
> You have to upload the file to the tmp directory first, send it via
email
> and then delete it.
>
> Rob.
>

Ok, now other things i've noticed like the attachment link is
specific.. such as image/jpeg, would i have to make a huge if elseif
tree for all different types to upload and then delete later on?




Hi Ian,

This depends on if you trust what the browser sends as a MIME type?

If the browser sends a MIME type then it will be in - 
$_FILES['userfile']['type'] however any hacker can spoof the MIME type. This 
may be a problem depending on what sort of emails you are sending? 
text/attachment or HTML/attachment? ie - Are the images(or other objects) 
going to be in the email or just an attachment?

If you are only allowing image type uploads then the actual MIME type can be 
extracted with the parts of the GD image functions.

For more information google RFC2387.

Robert.



Re: [php-list] Adding attachments to e-mails from a form

2008-04-06 Thread listgroups08
- Original Message - 
From: "Ian"
as per the title.

I've got a form where the user inputs there own name, e-mail address,
subject and then from 2 drop-down selection menus select the type of
email being sent and who to send it to.

I've googled a few scripts but from my understanding they will only
send files currently on the webserver, and who it's being sent to is
static(maybe i'm missing something?).

The Current Code: http://files.iarp.ca/Documents/website/contact.txt
Website Beta Page: http://moha.iarp.ca/contact.php

Is there any way to allow someone to attach a file without uploading
to the web server?



Q: Is there any way to allow someone to attach a file without uploading
to the web server?

A: No.

You have to upload the file to the tmp directory first, send it via email 
and then delete it.

Rob. 



Re: [php-list] Mobile with php

2008-04-03 Thread listgroups08
- Original Message - 
From: "nitin sharma"

I needed the mobile photo send to site
using the email
how its possible and whats the step to follow to create this featured in 
site
this featured is used in the
Use this address to  Photobucket.com
Thanks

-

Hi,
This question is a bit off topic here as you need to make some progress 
before it becomes a question of PHP scripting.

To get you on your way - there are two approaches. One is to hire services 
to bridge between the mobile digital network and your server and the other 
is to make your own gateway.

I live in Australia so I will describe the process here. It may be different 
in your country.

Most more advanced mobile phones can be used as a GPRS modem and they can be 
connected to a local machine as a TCPIP port that you can exclusively bridge 
to your server through a local fire wall.

The steps are as follows and these are not very easy steps

Connect the GPRS enabled phone to a local PC and use the phones software to 
create a GPRS modem port.

Install a third party bridge to bridge between the modem port (USB or 
serial) to TCPIP.

Bridge you local hardware firewall to allow incoming connections between 
your servers IP address and the port that you put the GPRS modem on. (You 
need a dedicated IP on your web server).

Learn the 'AT command' set that is used by GPRS modems and write your 
scripts to upload the media from the phone.

I would like to say more but this is really off topic at this stage.

Thanks. 



Re: [php-list] Create a search by date RANGE

2008-03-30 Thread listgroups08
- Original Message - 
From: "fremaje31" 

Hello All,

I need you all again.  I have a event page that search by date but I 
want visitors/users to be able to search by date range.  I've searched 
Google for this but I must be wording it wrong because I'm not getting 
the solution.

Here's the page I'm referring to - 
http://mybusinesscircle.startlogic.com/events.php

I also need a code to drop events once the date has passed.

Thanks,

Tisha



It's a bit hard without seeing the code!

An example, not the best way as I don't what code you already have. 

function testdate($string)
  {
  $result = substr($string$, 6, 4);
  $result .= substr($string, 0, 2);
  $result .= substr($string, 3, 2);
  return $result;
  }

function inrange($current, $start, $end)
  {
  $current = testdate($current);
  $start = testdate($start);
  $end = testdate$($end);
  if($cuurent < $start) {return FALSE;}
  if($current > $end} (return FALSE;}
  return TRUE;
  }

$startdate = '01/01/2008';
$enddate = '12/31/2008';

foreach($dataitem as $thisdataitem)
  {
  $thisdate = $thisdataitem['date'];
  if(inrange($thisdate, $startdate, $enddate))
{
// echo HTML for this item
}
  $currentdate = date(//please insert date format string for MM/DD/);
  if(testdate($thisdate) < testdate($currentdate))
{
// delete this data item
}
  }

Rob.


Re: [php-list] Slashes showing up after insert from form

2008-03-25 Thread listgroups08
- Original Message - 
From: "whoisquilty"

When I insert into my database from a form, there are slashes added before 
quotes. What do
I need to do to get rid of this?



I have come back to read your original question again.

Some SQL databases require escape characters '\' before quotes on SOME field 
types.

IF your field type does NOT require escapes then you have two option -
1) Remove them on incoming data.
HTML > strislashes() > mysql
2) remove them on outgoing data.
mysql > stripslashes() > HTML

IF your field type DOES require escapes then the only option is to remove 
them on the outgoing side.

The slashes issue for form data is a completely different issue to the 
slashes issue for mysql.




Re: [php-list] Re: Slashes showing up after insert from form

2008-03-25 Thread listgroups08
- Original Message - 
From: "whoisquilty"

Robert - Your solutions all insert the name of the submit button rather than 
pass the form
data.

I've found that I have access to the ini file. But there is no entry for 
magic quotes. Is this
the best way to fix the problem? What do I need to add to do this?

Jeremy


Hello Jeremy,
 I tested with the code below. I don't have magic quotes 
enabled but this should work for you.

Just put the small block of code below, into your script before any $_POST 
variables are used.

if(get_magic_quotes_gpc())
  {
  foreach($_POST as $key => $value)
{
$_POST[$key] = stripslashes($value);
}
  }

If the above does not work then try this instead...
  foreach($_POST as $key => $value)
{
$_POST[$key] = stripslashes($value);
}



Below again is the script that I used to test.














 $value)
{
$_POST[$key] = stripslashes($value);
echo('$_POST[' . $key . '] = [' . $_POST[$key] . ']' . "\n");
}
  }
?>

 



Re: [php-list] Re: Slashes showing up after insert from form

2008-03-25 Thread listgroups08
- Original Message - 
From: "whoisquilty"

Robert - Your solutions all insert the name of the submit button rather than 
pass the form
data.

I've found that I have access to the ini file. But there is no entry for 
magic quotes. Is this
the best way to fix the problem? What do I need to add to do this?

Jeremy



Hello Jeremy,
That sounds like a typo. I will run it in WAMP and check 
it.

I have assumed that you are using ...


Re: [php-list] Slashes showing up after insert from form

2008-03-25 Thread listgroups08
- Original Message - 
From: "whoisquilty"

When I insert into my database from a form, there are slashes added before 
quotes. What do
I need to do to get rid of this?



foreach($_POST as $thisitem)
  {
  $_POST[$thisitem] = stripslashes($_POST[$thisitem]);
  }

or ...
foreach($_POST as $key=>$value)
  {
  $_POST[$key] = stripslashes($value);
  }

to make compatable with different server configs ...
if(get_magic_quotes_gpc())
  {
  foreach($_POST as $key=>$value)
{
$_POST[$key] = stripslashes($value);
}
  }

same for alternate ...
if(get_magic_quotes_gpc())
  {
  foreach($_POST as $thisitem)
{
$_POST[$thisitem] = stripslashes($_POST[$thisitem]);
}
  }

Hope this helps, Robert. 



Re: [php-list] ftp script

2008-03-24 Thread listgroups08
- Original Message - 
From: "Wade Smart"

03242008 1830 GMT-6

Im working on a ftp script and right now Im just learning from the
script on the php site.

This line:

$upload = ftp_put($connection_id, $destination_file, $source, FTP_BINARY);

Im having trouble with: $destination_file

destination file is the remote file path.
So I assume that to be
ftp.servername.com
/ root
/images images directory

so I put $destination_file = "/images";
Warning: ftp_put() [function.ftp-put]: Can't open that file: Is a
directory in ftp_upload_script.php on line 23
FTP upload has failed!

I did try images/ for the destination but that was a invalid path it
said. So I tried /images/ and the same for that.

I just dont understand what its asking for.

Wade



Hello Wade,
   The server name or IP address should be used when you 
open the port connection along with the username and password. The remote 
file path is not needed or accepted when you are opening the connection.

A relative path may work depending on the FTP config ie 'images/' or 
'public_html/images/' or you may need to find the full path ie 
'/usr/www/useres/servername/account/home/public_html/images/'. A relative 
path cannot start with a (back)slash.

The destination must also have the file name ie 
/www/home/public_html/mypic.jpg as this can be different to the source file 
name.

Another problem you will see at times is sym links. The public_html may not 
actually be a folder but just a sym link to another folder like a shortcut 
in Windows. It is best to use the real file past. Although Apache may follow 
sym links for http, it may not follow them for ftp depending on the local 
config. This is especially true for shared servers.

Apache treats folders and files in a similar way. Opening a read stream to a 
folder returns a directory listing and opening a read stream to file returns 
the data in the file.

Hope tis helps. Rob.



  1   2   >