php-general Digest 14 Aug 2004 14:19:02 -0000 Issue 2936

Topics (messages 193779 through 193793):

Re: String compare of 7 text strings
        193779 by: Brent Clements
        193780 by: Hannes Magnusson
        193782 by: Ed Lazor

Re: php+iptables
        193781 by: Joel n.solanki

Re: looking for a good FormMail PHP script
        193783 by: raditha dissanayake

Getting the size of a mysql table using php
        193784 by: Brent Clements
        193785 by: Greg Donald

Open all subdirectories in a directory
        193786 by: PHPDiscuss - PHP Newsgroups and mailing lists
        193787 by: PHPDiscuss - PHP Newsgroups and mailing lists
        193788 by: PHPDiscuss - PHP Newsgroups and mailing lists
        193789 by: Hannes Magnusson
        193790 by: John Holmes

str_replace - is it case sensitive
        193791 by: Andrew W
        193792 by: Hannes Magnusson

php die function for MySQL connection errors
        193793 by: John Gostick

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Let me rephase my question in my previous email:

I'd like to compare 7 strings(which are in an array). Each string should be
the same, if they are not, a message should be outputted. How would one do
this outside of using a huge if/then statement?

Thanks,
Brent
----- Original Message ----- 
From: "Brent Clements" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 13, 2004 9:07 PM
Subject: [PHP] String compare of 7 text strings


I wanted to see if anyone has an easier way to do this. The end result is
this: I need to compare 7 different text strings(which are in an array).
They should all be the same, if they are not the same, a message should be
outputted saying they weren't.

How would one do this outside of using a huge if/then statement?

Thanks,
Brent

--- End Message ---
--- Begin Message ---
sort ( $array );
if ( $array[ 0 ] !== $array[ count ( $array )-1 ] ) {
  // Not all fields in the array are the same...
}

On Fri, 13 Aug 2004 21:10:50 -0500
[EMAIL PROTECTED] (Brent Clements) wrote:

> Let me rephase my question in my previous email:
> 
> I'd like to compare 7 strings(which are in an array). Each string should be
> the same, if they are not, a message should be outputted. How would one do
> this outside of using a huge if/then statement?
> 
> Thanks,
> Brent
> ----- Original Message ----- 
> From: "Brent Clements" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, August 13, 2004 9:07 PM
> Subject: [PHP] String compare of 7 text strings
> 
> 
> I wanted to see if anyone has an easier way to do this. The end result is
> this: I need to compare 7 different text strings(which are in an array).
> They should all be the same, if they are not the same, a message should be
> outputted saying they weren't.
> 
> How would one do this outside of using a huge if/then statement?
> 
> Thanks,
> Brent

--- End Message ---
--- Begin Message ---
Nice solution =)

> -----Original Message-----
> sort ( $array );
> if ( $array[ 0 ] !== $array[ count ( $array )-1 ] ) {
>   // Not all fields in the array are the same...
> }

--- End Message ---
--- Begin Message ---
Great ..I will surely do what u told me. This really sounds good to work
on.
I will start implementing this in 1 or 2 days. Can i contact youi
personally if i need little help ?

Regards and thank for your help 

Joel
On Thu, 2004-08-12 at 21:20, Robby Russell wrote:
> On Thu, 2004-08-12 at 01:31, Joel n.solanki wrote:
> > Dear all Gurus,
> > 
> > I have read little manul from www.php.net
> > I want to create web based firewall with php+iptables . Can any one give
> > me some documentation or guides or Examples ??I am using redhat linux
> > ..all things are installed.
> > I have little understood that i need to use shell_exec and exec to run
> > linux command. I am very newbie to php even dont know html so i m having
> > tough days with php.
> > if any one could help me out.
> > any docs.
> 
> Unlike the other responses, I'll give you a different approach.
> 
> Are you attempting to build a web based 'interface' to iptables? So you
> can add/edit/drop rules for iptables?
> 
> If I were to build such an app, this is how I would build it.
> 
> I would build 3 layers to this app.
> 
> - a database (postgresql or mysql)
>   - store all your rules, comments, timestamps, etc
> 
> - web based interface
>   - an interface that allows you to add, edit, modify the data in the
> database
>   - give this interface only the necessary ability to do this, nothing
> more so that your firewall configuration remains fairly secure.
> 
> - cron script
>   - a script on the server (written in php, perl, python, whatever) 
>   - performs a lookup in the database and checks for any new changes
> since its last run
>   - gets the changes and builds the necessary iptables configuration
> script and writes to a file on the server.
>   - add a row that records when you did this so that next time you know
> when to look for new records from.
> 
> You *could* use exec here to run iptables or you could have another cron
> script that is just a bash script that runs the iptables config file
> that you write with the cron script.
> 
> This is how *I* would approach this. This allows for flexibility of each
> piece of the code. For example, one day you might want to pick up python
> and build a cross platform GUI application that will allow you to manage
> the rules like you did in the web interface. If this might even be the
> case then you might want to consider PostgreSQL and building your
> database structure and building server side functions (plperl, plPHP,
> etc) that allow you to perform simple queries to add/edit/modify data.
> 
> example: SELECT blockIP('192.168.1.100');
> 
> ...is a little cleaner than:
>   INSERT INTO tablename (ip_address, block) VALUES ('192.168.1.100', t);
> 
> This way all your system logic is stored in your database schema and not
> in your code. Then a new interface is a breeze to develop and deply.
> 
> Once again, this is just one approach and might seem like more work but
> after doing this kind of thing for the last several years I'm growing
> weary of typing the same logic over and over to new interfaces. heh. 
> 
> 
> Happy coding!
> 
> your local PostgreSQL advocate,
> 
> Robby Russell
-- 
Joel N.Solanki
Network Administrator
Phone No: 0265-550001/2/3/4/5 Ext: 211/212
Digtial 2 Virtual Internet Service Provider.
http://www.packetraptor.com/
http://www.d2visp.com/
Gujarat (India)

--- End Message ---
--- Begin Message ---
Juan Nin wrote:

Hi

I'm looking for a good FormMail PHP script which beheaves like Matt Wright's FormMail.pl script (but lacks it's exploitable problems :)

I found several on the net, but didn't like them too much...

any recommendations?

you have obviously not looked at the PHP manual.

--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.

--- End Message ---
--- Begin Message ---
How does one get the size of a mysql table using php? I tried taking a look at how 
phpmyadmin does it but got lost in the code. Anyone have any simple or elegant ways of 
doing this?

-Thanks
Brent

--- End Message ---
--- Begin Message ---
On Sat, 14 Aug 2004 01:52:31 -0500, Brent Clements
<[EMAIL PROTECTED]> wrote:
> How does one get the size of a mysql table using php? I tried taking a look at how 
> phpmyadmin does it but got lost in the code. Anyone have any simple or elegant ways 
> of doing this?


show table status like 'table_name';

size = Data_length + Index_length


-- 
Greg Donald
http://destiney.com/

--- End Message ---
--- Begin Message ---
Hello Professionals,
Can anybody help me to open all subdirectories in a directory,
I used is_dir() to check whether it is a dir, and if yes,
I recursively called it with the new dir name.
But  all subdirectories are not open the recursion is not working for more
than 1 level.
I tested it in windows server.
Expecting your help,
Jacob.

--- End Message ---
--- Begin Message ---
Hello Professionals,
Can anybody help me to open all subdirectories in a directory,
I used is_dir() to check whether it is a dir, and if yes,
I recursively called it with the new dir name.
But  all subdirectories are not open the recursion is not working for more
than 1 level.
I tested it in windows server.
Expecting your help,
Jacob.

--- End Message ---
--- Begin Message ---
Hello Professionals,
Can anybody help me to open all subdirectories in a directory,
I used is_dir() to check whether it is a dir, and if yes,
I recursively called it with the new dir name.
But  all subdirectories are not open the recursion is not working for more
than 1 level.
I tested it in windows server.
Expecting your help,
Jacob.

--- End Message ---
--- Begin Message ---
On 14 Aug 2004 12:52:12 -0000
[EMAIL PROTECTED] (Phpdiscuss - Php Newsgroups And Mailing Lists) wrote:

> Hello Professionals,
> Can anybody help me to open all subdirectories in a directory,
> I used is_dir() to check whether it is a dir, and if yes,
> I recursively called it with the new dir name.
> But  all subdirectories are not open the recursion is not working for more
> than 1 level.
Try to call is_dir() with full/path/to/dir ( realpath() may come in handy ) and/or 
chdir() to the dir.

> I tested it in windows server.
> Expecting your help,
> Jacob.

--- End Message ---
--- Begin Message --- PHPDiscuss - PHP Newsgroups and mailing lists wrote:
Hello Professionals,
Can anybody help me to open all subdirectories in a directory,
I used is_dir() to check whether it is a dir, and if yes,
I recursively called it with the new dir name.
But  all subdirectories are not open the recursion is not working for more
than 1 level.
I tested it in windows server.
Expecting your help,

Expecting your code...

Have you looked at the opendir manual page to see if there are any examples, there?

--

---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message --- Is the str_replace function case sensitive, I cant seem to find any answer on the PHP manual website or in my books.

If it is, is there anyway to make it case insensitive so it can handle mIxEd CaSe woRdS in any combination?

Thanks
AW

--- End Message ---
--- Begin Message ---
On Sat, 14 Aug 2004 14:37:09 +0100
[EMAIL PROTECTED] (Andrew W) wrote:

> Is the str_replace function case sensitive, I cant seem to find any 
> answer on the PHP manual website or in my books.
Yes. For case in-sensitve use str_ireplace
Look at the PHP manual one more time under "See also"

> 
> If it is, is there anyway to make it case insensitive so it can handle 
> mIxEd CaSe woRdS in any combination?
> 
> Thanks
> AW

--- End Message ---
--- Begin Message ---
Hi,

I have a quick question about using the PHP die() function. I'm building a
site around a MySQL database, and when I connect to the database from a PHP
page I use the following code:




  $connection = mysql_connect($host, $user, $password)
   or  die("Error connecting to SQL server");
  $db = mysql_select_db($database, $connection)
   or die("'Error connecting to database");



Simple enough so far right? So if there is a problem connecting in anyway,
an error message appears. What I want though is to redirect to a properly
separate error page, rather than just have a basic text mesage.



I changed the code to this:



  $connection = mysql_connect($host, $user, $password)
   or die("Error connecting to SQL server");
  $db = mysql_select_db($database, $connection)
   or header('Location: ../errors/databaseselect.php');



Which works fine (tested by deliberately misnaming database so it can't find
it).


However if I then use the same approach for the server connection error,
like below, it doesn't work.


  $connection = mysql_connect($host, $user, $password)
   or header('Location: ../errors/servererror.php');
  $db = mysql_select_db($database, $connection)
   or header('Location: ../errors/databaseselect.php');

I get a variety of error messages dependant on what I tweek to try and make
it work. I've tried all I can think of, and I've tried putting the header
function inside a die function to no avail. I don't understand why it works
for the database connect error but not the server error.

If anyone has any suggestions as to what the problem is or how I could
improve my technique I'd love to know. I'm sure I can't be the only person
who has wanted to do something like this, but I can't find any references
online to anything other than simple text error messages. I'm relatively new
to PHP but not programming in general so please don't be afraid to fire big
words at me.




Thanks in advance!

John G


--- End Message ---

Reply via email to