[PHP] Need Help.

2009-07-14 Thread Girish Padia
Dear Sir,

I am facing two problem while developing my site in php.
1) I want to delete browser history whenever i migrate from one page to
another. so that user can never press "Back" button.
2) I have 20 users who have access to my site. Right now I am checking this
using cookies. I want to know which is better to track user login : Cookies
or Session ?

Please do reply.

With regards,

Girish


Re: [PHP] Need Help.

2009-07-14 Thread Ashley Sheridan
On Tue, 2009-07-14 at 11:59 +0530, Girish Padia wrote:
> Dear Sir,
> 
> I am facing two problem while developing my site in php.
> 1) I want to delete browser history whenever i migrate from one page to
> another. so that user can never press "Back" button.
> 2) I have 20 users who have access to my site. Right now I am checking this
> using cookies. I want to know which is better to track user login : Cookies
> or Session ?
> 
> Please do reply.
> 
> With regards,
> 
> Girish

You can't delete the users browser history, but what you can do is use
an entirely AJAX based website, so that there is no back/forward option.
However, this may be a little complex for you unless you have at least a
fair understanding of HTML Dom, and Javascript.

To understand which is betterm you need to understand how they work.
Cookies are persistent text files left on the users computer. They are
limited in the amount of data you can store in them, but they can store
information across physical browsing sessions. For example, you could
use them to remember a users preferred layout for your site, etc.

Sessions variables are all stored on your server, and generally last
only for the time that a visitor is on your site. They are referenced
automatically by PHP through a session ID, which is usually stored in a
cookie, but you can force it to be sent only in the URL if you wish.

The advantage that sessions have over cookies is the ability to store
more data, and as it is server-side, you can store things without
worrying too much about that data being accessed by someone other than
your user. Cookies have the advantage of persistence over time
(depending on how long you prefer to store them). You should not that
some users see cookies as invasive, and may have them turned off in the
browser. I'd say if you can do something server or client-side, you're
better off doing it where you have the greatest control, a la
server-side.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Need Help.

2009-07-14 Thread Carlos Medina

Hi Girish,
You can save the SEssion id in a Cookie to make it available over 
requests and over days too. If you use Sessions stored on DB, you can 
get more security, when the SEssion Cookie is stored Encrypted. Other 
Option is to send the Session id, most know as PHPSESSIONID, as GET 
Variable.


REgards

Carlos

Ashley Sheridan schrieb:

On Tue, 2009-07-14 at 11:59 +0530, Girish Padia wrote:

Dear Sir,

I am facing two problem while developing my site in php.
1) I want to delete browser history whenever i migrate from one page to
another. so that user can never press "Back" button.
2) I have 20 users who have access to my site. Right now I am checking this
using cookies. I want to know which is better to track user login : Cookies
or Session ?

Please do reply.

With regards,

Girish


You can't delete the users browser history, but what you can do is use
an entirely AJAX based website, so that there is no back/forward option.
However, this may be a little complex for you unless you have at least a
fair understanding of HTML Dom, and Javascript.

To understand which is betterm you need to understand how they work.
Cookies are persistent text files left on the users computer. They are
limited in the amount of data you can store in them, but they can store
information across physical browsing sessions. For example, you could
use them to remember a users preferred layout for your site, etc.

Sessions variables are all stored on your server, and generally last
only for the time that a visitor is on your site. They are referenced
automatically by PHP through a session ID, which is usually stored in a
cookie, but you can force it to be sent only in the URL if you wish.

The advantage that sessions have over cookies is the ability to store
more data, and as it is server-side, you can store things without
worrying too much about that data being accessed by someone other than
your user. Cookies have the advantage of persistence over time
(depending on how long you prefer to store them). You should not that
some users see cookies as invasive, and may have them turned off in the
browser. I'd say if you can do something server or client-side, you're
better off doing it where you have the greatest control, a la
server-side.

Thanks
Ash
www.ashleysheridan.co.uk



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



Re: [PHP] MySQL Queries in PHP

2009-07-14 Thread Tom Chubb
2009/7/14 Eddie Drapkin 

> On Tue, Jul 14, 2009 at 2:29 AM, Tom Chubb wrote:
> > Hi List,
> > Just wanted to pick your brains please?
> > I'm trying to standardise on the way I query databases and move away from
> > the Dreamweaver built-in functions (which I know you all hate!) ;)
> > I've been on this list for about 5 years now and I don't think I've ever
> > heard anyone mention the Pear packages, eg: MDB_QueryTool and wondered if
> > there was any reason why not?
> > I found some classes on phpclasses and have already started using one of
> > them by Henry Chen and there are plenty more.
> > I am still using Dreamweaver as the text editor for PHP on a Mac and
> trying
> > to code things manually but building SQL queries are one of the biggest
> > problems I come across.
> > To be honest, Dreamweaver used to be fine but for me, historically on
> both
> > PC and Mac, after a while it decides that it can connect to the DB but
> > cannot see any of the tables which prevent using the wizards which is why
> > I'm moving away from it.
> > All tutorials on the net are different and I'd like some info on the best
> > practices that you guys follow when dealing with MySQL.
> > Thanks in advance,
> >
> > Tom
> >
> > PS - I'm only dealing with simple queries: show, insert, update, delete,
> > etc.
> >
>
> I've always enjoyed writing SQL myself, as it is sort of challenging
> and interesting to do, so I've always written them by hand.  I'd
> recommend learning SQL yourself, as the queries tools generate, in my
> experience, are never quite as useful as hand-written, nor as fast.
> It's not that difficult to do and if you can't write queries yourself,
> whether you do or not, no one is going to take you very seriously as a
> web developer.  So, my best suggestion to you is to just buck up and
> learn SQL, as useless as that is.
>

That's still useful Eddie, and I suspect that's what a lot of people
actually do.
I do understand SQL (at a very basic level) but I'm trying to start using
the same custom functions for future projects and thought, "I wonder if
there's anything in Pear?"


Re: [PHP] MySql Injection advice

2009-07-14 Thread Michael A. Peters

Eddie Drapkin wrote:

Things I have used prepared statements for:
1. SELECT
2. UPDATE
3. INSERT
4. DELETE
5. Stored procedures

Things I am aware of that prepared statements are not capable of doing:

What have you read that prepared statements can't do?  I've not heard
of anything, nor have I encountered anything, myself.  And given that
I am prone to making errors, I like the fact that my work flow
prevents a mistake I make leading to an unnoticed vulnerability.


There was some stuff specified in the MySQL documentation.

I *think* for example selection data resulting from a union of two 
tables with the AS TABLE modifier. I might be wrong about that.


It was nothing I frequently do.

I do have one really ugly query that does joins of one table and another 
table that actually is a union of two tables - but that particular query 
does not use any user provided data (it's part of my range map 
generation script) so I don't use prepared statements with it anyway.


There's actually a bug in it (my huge query) though not significant, I'm 
planning to just break it up into several smaller queries and use php to 
do the hard work since that's easier to read and performance isn't an 
issue (run by server twice a month to generate a png image, never run by 
user).


But yeah - the stuff in the documentation where prepared statements 
don't work is pretty obscure stuff.


I believe MDB2 simulates prepared statements for databases without 
native prepared statements anyway.


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



Re: [PHP] Need Help.

2009-07-14 Thread kranthi
Hi Girish,

1. You cannot modify the browser Back button (any thing on the
client's computer for that matter).
2. I strongly oppose the use of Cookies for tracking the user login,
due to security reasons. Cookies are saved on the client's computer
and he/she can easily modify the information present. But that is
impossible with sessions.

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



Re: [PHP] phpscriptor.com

2009-07-14 Thread LinuxManMikeC
On Mon, Jul 13, 2009 at 2:39 AM, Reese wrote:
> Paul M Foster wrote:
>>
>> On Sat, Jul 11, 2009 at 08:14:35AM -0700, PHPScriptor wrote:
>>
>>> Ok this may look like spam but what the hell...
>>>
>>> I'm the owner of phpscriptor.com, I had bigg plans with this domainname
>>> but... well yes, no time. So I'm selling it. I don't want to make profit
>>> out
>>> of it. So for, lets say 200 dollar, you can have to domainname. And if
>>> you
>>> want, you get the website free with it.
>
> Why am I reminded of the Vincent D'Onofrio "Edgar"-cum-cochroach
> character when I read those lines above? I found myself adopting
> the cochroach accent as I read the first line. Seriously.
>
>> You don't want to make a profit, yet you're selling it for $200? Those
>> two statements are contradictory.
>
> He has a lot of mouths to feed. Plus if he's been sitting on it,
> the $200 might let him break even.
>
> I've learned that much, eh?
>
> SL
>


According to WHOIS, he registered the domain name in December 2007,
renewed in 2008, it will currently expire December 2009 if not
renewed.  The site had its first news item published in July 2008, six
months after registering the domain name.  The longest he's possibly
had a hosting plan (just assuming he got it with the domain) is about
1 1/2 years.  If he had any sense when he was shopping for hosting
plans and domain registration, he couldn't have spent more than $120
so far.  If he's buying hosting by the year, maybe $160.  At minimum
he's making $40 profit on the capital.  Even if you get the website,
its nothing special to search engines, doesn't stand out visually or
content-wise, and I doubt it gets much traffic yet.  I'd only want the
domain name, and I'd still feel cheated at half the price.  There's a
lot of work left to make something out of phpscriptor.com.

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



[PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Anton Heuschen
This is just a general question,

I am not 100% on when to use global $var , and $this->var  and how/what
about the GLOBAL vars 

Lets say I have one file I  call config.php here I connect to the db, to
ldap etc  the connection "var" I can then use in a file on its own ...
obviously after I include "config.php"   lets say in config.php my DB
connect was $dbconnect 

In my index.php page I then use $dbconnect again  but do I simply use
$dbconnect again ... or must I say global $dbconnect and then use it in the
rest of the DB calls? or use GLOBALS .. Within a class I can use $this->var
correct ... but its not something to be used in a basic "procedural" if I
can call it that page...


Lets say with my config.php and its connection to the db ...where I have
$dbconnect .. in a class I can also use it, do I access  this var
straight as $dbconnect or use $this->dbconnect = $dbconnect (and define it
as global $dbconnect first before doing this)

I am getting my results and seems to working most of the time, but not sure
if I am using calls to global or $this->var ..when its not required and
calling the var direct would of sufficed.

I have never really used GLOBAL vars, so not sure how this ties in or if it
might be even more helpful ...

Some suggestions or pointers or examples would be appreciated just to clear
up some confusion.


Regards

Oh and if one class uses methods in another class  do I instansiate a
new object of the other class  I have seen use of OtherClass::Method
  is this better method of $obj = new OtherClass()  use


[PHP] Email security

2009-07-14 Thread Tiji varghese
Hello,

I've implemented a contact form on my website that would email me the contents 
of the form and also add it to the database. Its working perfectly but I'm not 
too sure about the security part. I don't know much about the security issues 
concerned with email forms and the measures to check it. Please help.

Thanks,
Tiji



  See the Web's breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.com/

Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Eric Butera
On Tue, Jul 14, 2009 at 6:21 AM, Anton Heuschen wrote:
> This is just a general question,
>
> I am not 100% on when to use global $var , and $this->var  and how/what
> about the GLOBAL vars 
>
> Lets say I have one file I  call config.php here I connect to the db, to
> ldap etc  the connection "var" I can then use in a file on its own ...
> obviously after I include "config.php"   lets say in config.php my DB
> connect was $dbconnect 
>
> In my index.php page I then use $dbconnect again  but do I simply use
> $dbconnect again ... or must I say global $dbconnect and then use it in the
> rest of the DB calls? or use GLOBALS .. Within a class I can use $this->var
> correct ... but its not something to be used in a basic "procedural" if I
> can call it that page...
>
>
> Lets say with my config.php and its connection to the db ...where I have
> $dbconnect .. in a class I can also use it, do I access  this var
> straight as $dbconnect or use $this->dbconnect = $dbconnect (and define it
> as global $dbconnect first before doing this)
>
> I am getting my results and seems to working most of the time, but not sure
> if I am using calls to global or $this->var ..when its not required and
> calling the var direct would of sufficed.
>
> I have never really used GLOBAL vars, so not sure how this ties in or if it
> might be even more helpful ...
>
> Some suggestions or pointers or examples would be appreciated just to clear
> up some confusion.
>
>
> Regards
>
> Oh and if one class uses methods in another class  do I instansiate a
> new object of the other class  I have seen use of OtherClass::Method
>   is this better method of $obj = new OtherClass()  use
>

You're really opening a big can of worms here, but it'll be a good
adventure.  Just keep at it and try reading some real books on the
subject.

If you include a file, all of those variables are magically in the
current scope.  So when you include config.php inside your index.php,
you can use $dbconnect directly.

Use $this-> when you are inside a class using a dynamic call on a
method or property of that class.

class Foo {
  protected $bar;
  public function __construct() {
$this->bar = 'wee';
  }
  public function setBar($value) {
$this->bar = $value;
  }
}

Inside the class you would use this-> to reference bar or call any of
that classes methods/props.  Outside you would use it like this:
$foo = new Foo;
$foo->setBar('blah');

If you haven't used globals yet, please do not feel compelled to do so
now.  There are all sorts of ways of dealing with passing around your
application state.  Globals can be used by a skilled programmer of
course, but I'd shy away from them.

I'd also recommend reading some of these pages:
http://www.php.net/manual/en/language.variables.scope.php
http://www.php.net/manual/en/language.oop5.php


Hope this helps!

-- 
http://www.ericbutera.us/

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



Re: [PHP] Email security

2009-07-14 Thread Eric Butera
On Tue, Jul 14, 2009 at 7:46 AM, Tiji varghese wrote:
> Hello,
>
> I've implemented a contact form on my website that would email me the 
> contents of the form and also add it to the database. Its working perfectly 
> but I'm not too sure about the security part. I don't know much about the 
> security issues concerned with email forms and the measures to check it. 
> Please help.
>
> Thanks,
> Tiji
>
>
>
>      See the Web's breaking stories, chosen by people like you. Check out 
> Yahoo! Buzz. http://in.buzz.yahoo.com/


The main thing to be aware of would be 'email header injection.'  Do
not allow returns/newlines in any of the mail header fields you
populate from user input.  Also require a valid email address and
verify that it has a valid domain name.

Next up would just be the annoyance of a client receiving tons of spam
messages.  There are a lot of automated programs crawling the web just
filling out every form it finds looking for vulns to exploit.  Even if
your form has no holes in it, the client will still get all of this
unwanted junk from the automated tests.  You can try to come up with
some clever ways of stopping that.

-- 
http://www.ericbutera.us/

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



Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Darren Karstens
> Oh and if one class uses methods in another class  do I instansiate a
> new object of the other class  I have seen use of OtherClass::Method
>   is this better method of $obj = new OtherClass()  use

The :: is used to access static methods of a class. Static methods can
be used without creating an instance of the class because they dont
use any of the classes member variables.
For example say you have a class with a function for calculating the
area of a rectangle:
class SomeMathFunctions {
public function calculateRectangle($width, $height) {
return $width*$height;
}
}

To use this function you would need to first create an instance of the
class then call the method using the normal -> :
$funcs = new SomeMathFunctions();
$area = $funcs->calculateRectange(10,15);

But if you create the function as static by using " public static
function calculateRectangle($width, $height) { "
then you can access the method by using just 1 call:
$area = SomeMathFunctions::calculateRectange(10,15);

So for creating utility functions its better to use static methods
since you dont get the overhead of creating a new instance of the
class.

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



Re: [PHP] MySql Injection advice

2009-07-14 Thread Martin Scotta
you can do that with IPs because it is an implementation of an integer.

look:
I take a integer value: 2130706433
express it as binary: 1110001
now I have to look it as bytes: 1110      0001
express the bytes as decimals: 127 0 0 1

does this number means anything to you?
IPv4 are just simples integer values stored as bytes

Here you have another example
192.168.0.1
192 = 1100
168 = 10101000
0 = 
1 = 0001

all together is 110010101001
which my calc says it is 3232235521 (it doesn't understand the
negative implementation of numbers)

Telephone numbers are quite different, but in sort way they similars
8765-4321 can be the same as +0871187654321 (if you are in the same are code)

I think the solution should be based in your audience target.

On Tue, Jul 14, 2009 at 4:43 AM, Ashley
Sheridan wrote:
> On Tue, 2009-07-14 at 01:52 -0400, Andrew Ballard wrote:
>> On Mon, Jul 13, 2009 at 4:18 PM, Haig Dedeyan wrote:
>> > for the phone #'s, I'm using int as the data type & storing each part of 
>> > the
>> > phone # in its own cell,
>> >
>> > When it gets displayed, I add a dash in between each part of the phone #'s
>> > (country code-area code-1st set of digits-last set of digits)
>> >
>> > Cheers
>> >
>> > Haig
>>
>> I disagree. Telephone numbers are not actually numbers; they are
>> sequences of numeric digits. Unlike IP addresses where 10.0.0.1 is
>> equivalent to 010.000.000.001, leading zeros are significant; they are
>> part of the data, not just padding to be inserted automatically by the
>> database or by a formatting function in the presentation layer. When
>> you validate an area code in the North American numbering plan, do you
>> validate that it is a number between 1 and 999 or do you validate that
>> it is a string of exactly 3 decimal-digit characters long? Expand that
>> to international phone numbers, and the zeros become even more
>> significant since you can't easily make assumptions about the length
>> of various segments in a phone number.
>>
>> Sorry, but I just don't see any advantage to storing them as integers.
>>
>> Andrew
>
> Yeah, that makes sense. Last time I tried to store a phone number as a
> number was at school, when I realised that none of the leading zeros
> were preserved. On UK phone numbers, there's always a leading zero
> unless you're calling directory enquiries or emergency services!
>
> Also, IP addresses can be converted to IP numbers with the long2ip()
> function of PHP, which means you can store them as long ints and do
> normal number comparisons on them, great for matching an IP address to a
> range of 'valid' ones.
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

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



Re: [PHP] Need Help.

2009-07-14 Thread Martin Scotta
hahahahahaha

How are you to delete my history?
The fact that you "develop" a website does not allow you to take the
control of my browser.

But you can avoid the history to be populated by using javascript


 Click to lalalal


The replace() method loads a new page, specified by URL, in the
current browser window.
The new page replaces the previous page's position in the history list.

On Tue, Jul 14, 2009 at 5:51 AM, kranthi wrote:
> Hi Girish,
>
> 1. You cannot modify the browser Back button (any thing on the
> client's computer for that matter).
> 2. I strongly oppose the use of Cookies for tracking the user login,
> due to security reasons. Cookies are saved on the client's computer
> and he/she can easily modify the information present. But that is
> impossible with sessions.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

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



RE: [PHP] Need Help.

2009-07-14 Thread Bob McConnell
From: Martin Scotta
> 
> hahahahahaha
> 
> How are you to delete my history?
> The fact that you "develop" a website does not allow you to take the
> control of my browser.
> 
> But you can avoid the history to be populated by using javascript
> 
> 
>  Click to lalalal
> 

That would prevent me from navigating the site since I won't enable
JavaScript in my browser until I have trust in your website not to allow
any installation of malware on my computer. That trust must be earned by
you, since trust is not associative. Yes, there are a lot of sites that
I can't visit because of that. Right now I won't even enable JS for
either my bank or credit card issuer since neither has demonstrated the
knowledge, desire or ability to protect their servers or my browser.

Bob McConnell

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



Re: [PHP] Scope of Variables and use of global and this->var

2009-07-14 Thread Martin Scotta
do you need to use global?
IMO you should use just 1 global variable, thats is what I call "entry point"

My scripts looks like...

require_once 'loader.php';
Loader::registerAutoload();
$foo = new Foo();
$foo->doStuff();

This way you can develop faster and do maintenance better avoiding
problems with third-party.

Here you have some rules for remember how to access

you want a $var from outside and you are outside an object or
function? => use the $var
you want a $var from outside you are inside an object or function? =>
global $var o $GLOBALS['vars'] (better to pass it as arg)
you want a $var from an object and you are inside the same object? =>
use $this->var (better $this->getVar() )
you want a $var from an object and you are inside other object? => use
$object->getVar() or Class::getVar()


It is a good practice to declare the object members as "protected" and
provide s/getters for each member (when your design allow it). Also
you can overload by using the __get, __set and __call
It is really easy to make an "automagic" object

Class AutoMagic
{
protected $_vars = array();

public/*mixed*/
function __get(/*string*/$name)
{
return isset( $this->{ $name } ) ? $this->_vars[ 
strtolower($name) ] : null;
}

public/*mixed*/
function __set(/*string*/$name,/*mixed*/$value)
{
return $this->_vars[ strtolower($name) ] = $value;
}

public/*boolean*/
function __isset(/*string*/$name)
{
return array_key_exists( strtolower($name), $this->_vars );
}

public/*void*/
function __unset(/*string*/$name)
{
if( isset( $this->{ $name } ))
unset( $this->_vars[ strtolower($name) ] );
}

public/*mixed*/
function __call(/*string*/$method,array $args)
{
$type = strtolower( substr( $method, 0, 3 ) );
$property = substr( $method, 3 );

switch( $type )
{
case 'get':
return $this->{ $property };

case 'set':
if( !array_key_exists(0, $args) )
trigger_error( 'Bad call in ' . 
get_class($this) . '::' . $method
.'. Method needs an argument' );

return $this->{ $property } = $args[0];

case 'has':
return isset( $this->{ $property } );

case 'del':
unset( $this->{ $property } );
return;
}
trigger_error( 'Bad call in ' . get_class($this) . '::' . 
$method );
}
}

On Tue, Jul 14, 2009 at 10:01 AM, Darren
Karstens wrote:
>> Oh and if one class uses methods in another class  do I instansiate a
>> new object of the other class  I have seen use of OtherClass::Method
>>   is this better method of $obj = new OtherClass()  use
>
> The :: is used to access static methods of a class. Static methods can
> be used without creating an instance of the class because they dont
> use any of the classes member variables.
> For example say you have a class with a function for calculating the
> area of a rectangle:
> class SomeMathFunctions {
>    public function calculateRectangle($width, $height) {
>        return $width*$height;
>    }
> }
>
> To use this function you would need to first create an instance of the
> class then call the method using the normal -> :
> $funcs = new SomeMathFunctions();
> $area = $funcs->calculateRectange(10,15);
>
> But if you create the function as static by using " public static
> function calculateRectangle($width, $height) { "
> then you can access the method by using just 1 call:
> $area = SomeMathFunctions::calculateRectange(10,15);
>
> So for creating utility functions its better to use static methods
> since you dont get the overhead of creating a new instance of the
> class.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

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



Re: [PHP] Need Help.

2009-07-14 Thread Martin Scotta
I know... this is not for a php thread... but...

If you look at the HTML the "a" tag is made completely unobtrusive.
The link will still working without javascript.

This is the original tag (with javascript)
 
 Click to lalalal
 

This is how the browser looks it without javascript
 
 Click to lalalal
 

I've said it is not for a php thread

On Tue, Jul 14, 2009 at 10:29 AM, Bob McConnell wrote:
> From: Martin Scotta
>>
>> hahahahahaha
>>
>> How are you to delete my history?
>> The fact that you "develop" a website does not allow you to take the
>> control of my browser.
>>
>> But you can avoid the history to be populated by using javascript
>>
>> 
>>      Click to lalalal
>> 
>
> That would prevent me from navigating the site since I won't enable
> JavaScript in my browser until I have trust in your website not to allow
> any installation of malware on my computer. That trust must be earned by
> you, since trust is not associative. Yes, there are a lot of sites that
> I can't visit because of that. Right now I won't even enable JS for
> either my bank or credit card issuer since neither has demonstrated the
> knowledge, desire or ability to protect their servers or my browser.
>
> Bob McConnell
>



-- 
Martin Scotta

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



[PHP] Weird domain seting in setcookie()

2009-07-14 Thread Michelle Konzack
Hello,

on two websites I have encountered that cookies are not working properly
and are accesibel from other subdomains which I do not  want.  The  line
is:

setcookie('AdminOnCrack', $drug, $timeout, '/', $_SERVER['HTTP_HOST']);

but the "domain" is always prefixed with a ".".

OK, now I have tested it using:

setcookie('AdminOnCrack', $drug, $timeout, '/', 'myspace.tdwave.net');

but with the same problem. I do not want that the cookies are  available
in <*.myspace.tdwave.net>.

Any suggestions?

Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   c/o Shared Office KabelBW  ICQ #328449886
+49/177/9351947Blumenstasse 2 MSN LinuxMichi
+33/6/61925193 77694 Kehl/Germany IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] MySQL Queries in PHP

2009-07-14 Thread Jan G.B.
2009/7/14 Tom Chubb 

> 2009/7/14 Eddie Drapkin 
>
> > On Tue, Jul 14, 2009 at 2:29 AM, Tom Chubb wrote:
> > > Hi List,
> > > Just wanted to pick your brains please?
> > > I'm trying to standardise on the way I query databases and move away
> from
> > > the Dreamweaver built-in functions (which I know you all hate!) ;)
> > > I've been on this list for about 5 years now and I don't think I've
> ever
> > > heard anyone mention the Pear packages, eg: MDB_QueryTool and wondered
> if
> > > there was any reason why not?
> > > I found some classes on phpclasses and have already started using one
> of
> > > them by Henry Chen and there are plenty more.
> > > I am still using Dreamweaver as the text editor for PHP on a Mac and
> > trying
> > > to code things manually but building SQL queries are one of the biggest
> > > problems I come across.
> > > To be honest, Dreamweaver used to be fine but for me, historically on
> > both
> > > PC and Mac, after a while it decides that it can connect to the DB but
> > > cannot see any of the tables which prevent using the wizards which is
> why
> > > I'm moving away from it.
> > > All tutorials on the net are different and I'd like some info on the
> best
> > > practices that you guys follow when dealing with MySQL.
> > > Thanks in advance,
> > >
> > > Tom
> > >
> > > PS - I'm only dealing with simple queries: show, insert, update,
> delete,
> > > etc.
> > >
> >
> > I've always enjoyed writing SQL myself, as it is sort of challenging
> > and interesting to do, so I've always written them by hand.  I'd
> > recommend learning SQL yourself, as the queries tools generate, in my
> > experience, are never quite as useful as hand-written, nor as fast.
> > It's not that difficult to do and if you can't write queries yourself,
> > whether you do or not, no one is going to take you very seriously as a
> > web developer.  So, my best suggestion to you is to just buck up and
> > learn SQL, as useless as that is.
> >
>
> That's still useful Eddie, and I suspect that's what a lot of people
> actually do.
> I do understand SQL (at a very basic level) but I'm trying to start using
> the same custom functions for future projects and thought, "I wonder if
> there's anything in Pear?"
>

Well, PDO is an approach. There are abstractions available like dddbl, which
I believe are quite useful.
Check www.dddbl.de

Don't know about other pear classes, though

regards


[PHP] How to set find pathes for PHP CLI?

2009-07-14 Thread Tir
I have many scripts that I need execute with PHP CLI. They are located in a 
few directories. I don't want to write full path to script every time when I 
start it. Therefore I've added this paths to the PATH environment variable. 
But PHP don't find my scripts. How could i set paths on which PHP would find 
my script when i call e.g. "php -f my_script.php"? 



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



[PHP] [GD] Image errors

2009-07-14 Thread Il pinguino volante

Hi to all

I get a problem processing an image with GD libraries.

This is my function

   public function showPicture($id) {
   header('Content-type: image/jpeg');
   $mime = mime_content_type($this->updir.$id.'.png');
   $type = explode('/',$mime);
   $type = 'imagecreatefrom'.$type[1];
   $immagine = $tipo($this->updir.$id.'.png');
   imagejpeg($immagine,null,100);
   imagedestroy($immagine);
   }

If i commentize the "header" function i get a lot of strange simbols 
(such as the code of a jpeg image!) but no errors.
The result of this code is a blank page. In Firefox the title sets to 
"picture.php (JPEG image)" and if i right-click it and click on 
"Proprieties" i get "0px × 0px (resized as 315px × 19px)".


P.S.: I get the same result when I write $immagine = 
imagecreatefromjpeg(...)


(Sorry for my english)

Thanks in advance,
Alfio.

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



RE: [PHP] Weird domain seting in setcookie()

2009-07-14 Thread Bob McConnell
From: Michelle Konzack
> 
> on two websites I have encountered that cookies are not working
properly
> and are accesibel from other subdomains which I do not  want.  The
line
> is:
> 
> setcookie('AdminOnCrack', $drug, $timeout, '/',
$_SERVER['HTTP_HOST']);
> 
> but the "domain" is always prefixed with a ".".
> 
> OK, now I have tested it using:
> 
> setcookie('AdminOnCrack', $drug, $timeout, '/', 'myspace.tdwave.net');
> 
> but with the same problem. I do not want that the cookies are
available
> in <*.myspace.tdwave.net>.
> 
> Any suggestions?

In Firefox 3.0 under Tools->Options->Privacy, uncheck "Accept
third-party cookies".

Bob McConnell

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



Re: [PHP] How to set find pathes for PHP CLI?

2009-07-14 Thread Ashley Sheridan
On Tue, 2009-07-14 at 20:46 +0400, Tir wrote:
> I have many scripts that I need execute with PHP CLI. They are located in a 
> few directories. I don't want to write full path to script every time when I 
> start it. Therefore I've added this paths to the PATH environment variable. 
> But PHP don't find my scripts. How could i set paths on which PHP would find 
> my script when i call e.g. "php -f my_script.php"? 
> 
> 
> 
When you set the paths, did you restart the computer? Windows needs a
full restart if you edit your paths; Linux machines won't, but you've
not mentioned  what your OS is.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Martin Scotta
$immagine = $tipo($this->updir.$id.'.png');

$tipo is undefined


On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
volante wrote:
> Hi to all
>
> I get a problem processing an image with GD libraries.
>
> This is my function
>
>   public function showPicture($id) {
>       header('Content-type: image/jpeg');
>       $mime = mime_content_type($this->updir.$id.'.png');
>       $type = explode('/',$mime);
>       $type = 'imagecreatefrom'.$type[1];
>       $immagine = $tipo($this->updir.$id.'.png');
>       imagejpeg($immagine,null,100);
>       imagedestroy($immagine);
>   }
>
> If i commentize the "header" function i get a lot of strange simbols (such
> as the code of a jpeg image!) but no errors.
> The result of this code is a blank page. In Firefox the title sets to
> "picture.php (JPEG image)" and if i right-click it and click on
> "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
>
> P.S.: I get the same result when I write $immagine =
> imagecreatefromjpeg(...)
>
> (Sorry for my english)
>
> Thanks in advance,
> Alfio.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
Martin Scotta

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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Ashley Sheridan
On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
> $immagine = $tipo($this->updir.$id.'.png');
> 
> $tipo is undefined
> 
> 
> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
> volante wrote:
> > Hi to all
> >
> > I get a problem processing an image with GD libraries.
> >
> > This is my function
> >
> >   public function showPicture($id) {
> >   header('Content-type: image/jpeg');
> >   $mime = mime_content_type($this->updir.$id.'.png');
> >   $type = explode('/',$mime);
> >   $type = 'imagecreatefrom'.$type[1];
> >   $immagine = $tipo($this->updir.$id.'.png');
> >   imagejpeg($immagine,null,100);
> >   imagedestroy($immagine);
> >   }
> >
> > If i commentize the "header" function i get a lot of strange simbols (such
> > as the code of a jpeg image!) but no errors.
> > The result of this code is a blank page. In Firefox the title sets to
> > "picture.php (JPEG image)" and if i right-click it and click on
> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
> >
> > P.S.: I get the same result when I write $immagine =
> > imagecreatefromjpeg(...)
> >
> > (Sorry for my english)
> >
> > Thanks in advance,
> > Alfio.
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
> 
> 
> -- 
> Martin Scotta
> 
Also, it doesn't look like you're actually doing anything with $type

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Martin Scotta
He is calling the function by variable

something like this

$func = 'var_dump';

$func( new Foo );

On Tue, Jul 14, 2009 at 1:30 PM, Ashley
Sheridan wrote:
> On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
>> $immagine = $tipo($this->updir.$id.'.png');
>>
>> $tipo is undefined
>>
>>
>> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
>> volante wrote:
>> > Hi to all
>> >
>> > I get a problem processing an image with GD libraries.
>> >
>> > This is my function
>> >
>> >   public function showPicture($id) {
>> >       header('Content-type: image/jpeg');
>> >       $mime = mime_content_type($this->updir.$id.'.png');
>> >       $type = explode('/',$mime);
>> >       $type = 'imagecreatefrom'.$type[1];
>> >       $immagine = $tipo($this->updir.$id.'.png');
>> >       imagejpeg($immagine,null,100);
>> >       imagedestroy($immagine);
>> >   }
>> >
>> > If i commentize the "header" function i get a lot of strange simbols (such
>> > as the code of a jpeg image!) but no errors.
>> > The result of this code is a blank page. In Firefox the title sets to
>> > "picture.php (JPEG image)" and if i right-click it and click on
>> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
>> >
>> > P.S.: I get the same result when I write $immagine =
>> > imagecreatefromjpeg(...)
>> >
>> > (Sorry for my english)
>> >
>> > Thanks in advance,
>> > Alfio.
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>>
>>
>> --
>> Martin Scotta
>>
> Also, it doesn't look like you're actually doing anything with $type
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>



-- 
Martin Scotta

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



Re: [PHP] Weird domain seting in setcookie()

2009-07-14 Thread Michelle Konzack
Hi Bob,

Am 2009-07-14 11:46:16, schrieb Bob McConnell:
> In Firefox 3.0 under Tools->Options->Privacy, uncheck "Accept
> third-party cookies".

What has this to do with the Webbrowser?

In the PHP manual it is written:

[ url 'http://de.php.net/manual/en/function.setcookie.php' ]

domain

The domain that the cookie is available. To make the cookie available on
all subdomains of example.com then you'd set it to '.example.com'. The .
is not required but makes it compatible with more browsers. Setting it
to www.example.com will make the cookie only available in the www
subdomain. Refer to tail matching in the » spec for details.



This mean, if I wan to have the COOKIE available in the subdomains

foo.myspace.tdwave.net
bar.myspace.tdwave.net
baz.myspace.tdwave.net

I have to use the domain ".myspace.tdwave.net" with a preceding DOT. But
this is not what I want because I want to have the COOKIE only available
in

myspace.tdwave.net

so, I have set the the domain  explicit  to  "myspace.tdwave.net"  which
should register the cookie as it is according to the PHP manual or not?

Thanks, Greetings and nice Day/Evening
Michelle Konzack

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   c/o Shared Office KabelBW  ICQ #328449886
+49/177/9351947Blumenstasse 2 MSN LinuxMichi
+33/6/61925193 77694 Kehl/Germany IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


Re: [PHP] [GD] Image errors

2009-07-14 Thread Ashley Sheridan
On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote:
> He is calling the function by variable
> 
> something like this
> 
> $func = 'var_dump';
> 
> $func( new Foo );
> 
> On Tue, Jul 14, 2009 at 1:30 PM, Ashley
> Sheridan wrote:
> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
> >> $immagine = $tipo($this->updir.$id.'.png');
> >>
> >> $tipo is undefined
> >>
> >>
> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
> >> volante wrote:
> >> > Hi to all
> >> >
> >> > I get a problem processing an image with GD libraries.
> >> >
> >> > This is my function
> >> >
> >> >   public function showPicture($id) {
> >> >   header('Content-type: image/jpeg');
> >> >   $mime = mime_content_type($this->updir.$id.'.png');
> >> >   $type = explode('/',$mime);
> >> >   $type = 'imagecreatefrom'.$type[1];
> >> >   $immagine = $tipo($this->updir.$id.'.png');
> >> >   imagejpeg($immagine,null,100);
> >> >   imagedestroy($immagine);
> >> >   }
> >> >
> >> > If i commentize the "header" function i get a lot of strange simbols 
> >> > (such
> >> > as the code of a jpeg image!) but no errors.
> >> > The result of this code is a blank page. In Firefox the title sets to
> >> > "picture.php (JPEG image)" and if i right-click it and click on
> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
> >> >
> >> > P.S.: I get the same result when I write $immagine =
> >> > imagecreatefromjpeg(...)
> >> >
> >> > (Sorry for my english)
> >> >
> >> > Thanks in advance,
> >> > Alfio.
> >> >
> >> > --
> >> > PHP General Mailing List (http://www.php.net/)
> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Martin Scotta
> >>
> > Also, it doesn't look like you're actually doing anything with $type
> >
> > Thanks
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
> 
> 
> 
> -- 
> Martin Scotta
> 

Bottom post ;)

$type = explode('/',$mime);
$type = 'imagecreatefrom'.$type[1];

$immagine = $tipo($this->updir.$id.'.png');
imagejpeg($immagine,null,100);
imagedestroy($immagine);

I'm not sure you understood what I meant. line 2 above $type is assigned
to the string 'imagecreatefrom'.$type[1];

Now I assume that was to be used later in some sort of eval() statement,
but its never called again, so the line really does nothing.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Weird domain seting in setcookie()

2009-07-14 Thread Lists

Michelle Konzack wrote:
[snip]

so, I have set the the domain  explicit  to  "myspace.tdwave.net"  which
should register the cookie as it is according to the PHP manual or not?

Thanks, Greetings and nice Day/Evening
Michelle Konzack



the above will still make the cookie available to:

> foo.myspace.tdwave.net
> bar.myspace.tdwave.net
> baz.myspace.tdwave.net


Donovan



--
  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
  D. BROOKE   EUCA Design Center
   WebDNA Software Corp.
  WEB:> http://www.euca.us  |   http://www.webdna.us
  =o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o=o
  WebDNA: [** Square Bracket Utopia **]

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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Martin Scotta
On Tue, Jul 14, 2009 at 1:48 PM, Ashley
Sheridan wrote:
> On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote:
>> He is calling the function by variable
>>
>> something like this
>>
>> $func = 'var_dump';
>>
>> $func( new Foo );
>>
>> On Tue, Jul 14, 2009 at 1:30 PM, Ashley
>> Sheridan wrote:
>> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
>> >> $immagine = $tipo($this->updir.$id.'.png');
>> >>
>> >> $tipo is undefined
>> >>
>> >>
>> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
>> >> volante wrote:
>> >> > Hi to all
>> >> >
>> >> > I get a problem processing an image with GD libraries.
>> >> >
>> >> > This is my function
>> >> >
>> >> >   public function showPicture($id) {
>> >> >       header('Content-type: image/jpeg');
>> >> >       $mime = mime_content_type($this->updir.$id.'.png');
>> >> >       $type = explode('/',$mime);
>> >> >       $type = 'imagecreatefrom'.$type[1];
>> >> >       $immagine = $tipo($this->updir.$id.'.png');
>> >> >       imagejpeg($immagine,null,100);
>> >> >       imagedestroy($immagine);
>> >> >   }
>> >> >
>> >> > If i commentize the "header" function i get a lot of strange simbols 
>> >> > (such
>> >> > as the code of a jpeg image!) but no errors.
>> >> > The result of this code is a blank page. In Firefox the title sets to
>> >> > "picture.php (JPEG image)" and if i right-click it and click on
>> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
>> >> >
>> >> > P.S.: I get the same result when I write $immagine =
>> >> > imagecreatefromjpeg(...)
>> >> >
>> >> > (Sorry for my english)
>> >> >
>> >> > Thanks in advance,
>> >> > Alfio.
>> >> >
>> >> > --
>> >> > PHP General Mailing List (http://www.php.net/)
>> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Martin Scotta
>> >>
>> > Also, it doesn't look like you're actually doing anything with $type
>> >
>> > Thanks
>> > Ash
>> > www.ashleysheridan.co.uk
>> >
>> >
>>
>>
>>
>> --
>> Martin Scotta
>>
>
> Bottom post ;)
>
> $type = explode('/',$mime);
> $type = 'imagecreatefrom'.$type[1];
>
> $immagine = $tipo($this->updir.$id.'.png');
> imagejpeg($immagine,null,100);
> imagedestroy($immagine);
>
> I'm not sure you understood what I meant. line 2 above $type is assigned
> to the string 'imagecreatefrom'.$type[1];
>
> Now I assume that was to be used later in some sort of eval() statement,
> but its never called again, so the line really does nothing.
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>

Mmmm, No

$type = explode('/',$mime); # type is array
$type = 'imagecreatefrom'.$type[1]; # type is a string

He is actually re-assigning the var ussing the content of the var.
Sounds crazy, but I use this method a lot, it helps to keep the scope clean.

-- 
Martin Scotta
ps. "tipo" is "type" in Spanish

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



RE: [PHP] Doubts concerning a general Insert method

2009-07-14 Thread MEM
Ok... according to the above posts, I've started to create my generic CRUD 
class however, I'm wondering:

Any of you have already used a DAO design pattern in conjunction with a CRUD 
generic class? 
Know that I'm trying to create a generic CRUD class on a DAO Design pattern, it 
seems that it makes no sense at all.

Is there an advantage on doing this?

My thought:
On a "insert to database" scenario for example:
Without the CRUD generic class: to do an insert, we instantiate a DAO class and 
then call the insert method. Nothing more. Done.

With the CRUD generic class: maybe we will have less code on the DAO site but, 
at the end, to insert a record, we still need to instantiate a DAO and call a 
insert method SO...

I see not big advantage on using both...

Can I have your advice on this please?


Thanks,
Márcio


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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Ashley Sheridan
On Tue, 2009-07-14 at 14:16 -0300, Martin Scotta wrote:
> On Tue, Jul 14, 2009 at 1:48 PM, Ashley
> Sheridan wrote:
> > On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote:
> >> He is calling the function by variable
> >>
> >> something like this
> >>
> >> $func = 'var_dump';
> >>
> >> $func( new Foo );
> >>
> >> On Tue, Jul 14, 2009 at 1:30 PM, Ashley
> >> Sheridan wrote:
> >> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
> >> >> $immagine = $tipo($this->updir.$id.'.png');
> >> >>
> >> >> $tipo is undefined
> >> >>
> >> >>
> >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
> >> >> volante wrote:
> >> >> > Hi to all
> >> >> >
> >> >> > I get a problem processing an image with GD libraries.
> >> >> >
> >> >> > This is my function
> >> >> >
> >> >> >   public function showPicture($id) {
> >> >> >   header('Content-type: image/jpeg');
> >> >> >   $mime = mime_content_type($this->updir.$id.'.png');
> >> >> >   $type = explode('/',$mime);
> >> >> >   $type = 'imagecreatefrom'.$type[1];
> >> >> >   $immagine = $tipo($this->updir.$id.'.png');
> >> >> >   imagejpeg($immagine,null,100);
> >> >> >   imagedestroy($immagine);
> >> >> >   }
> >> >> >
> >> >> > If i commentize the "header" function i get a lot of strange simbols 
> >> >> > (such
> >> >> > as the code of a jpeg image!) but no errors.
> >> >> > The result of this code is a blank page. In Firefox the title sets to
> >> >> > "picture.php (JPEG image)" and if i right-click it and click on
> >> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
> >> >> >
> >> >> > P.S.: I get the same result when I write $immagine =
> >> >> > imagecreatefromjpeg(...)
> >> >> >
> >> >> > (Sorry for my english)
> >> >> >
> >> >> > Thanks in advance,
> >> >> > Alfio.
> >> >> >
> >> >> > --
> >> >> > PHP General Mailing List (http://www.php.net/)
> >> >> > To unsubscribe, visit: http://www.php.net/unsub.php
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> Martin Scotta
> >> >>
> >> > Also, it doesn't look like you're actually doing anything with $type
> >> >
> >> > Thanks
> >> > Ash
> >> > www.ashleysheridan.co.uk
> >> >
> >> >
> >>
> >>
> >>
> >> --
> >> Martin Scotta
> >>
> >
> > Bottom post ;)
> >
> > $type = explode('/',$mime);
> > $type = 'imagecreatefrom'.$type[1];
> >
> > $immagine = $tipo($this->updir.$id.'.png');
> > imagejpeg($immagine,null,100);
> > imagedestroy($immagine);
> >
> > I'm not sure you understood what I meant. line 2 above $type is assigned
> > to the string 'imagecreatefrom'.$type[1];
> >
> > Now I assume that was to be used later in some sort of eval() statement,
> > but its never called again, so the line really does nothing.
> >
> > Thanks
> > Ash
> > www.ashleysheridan.co.uk
> >
> >
> 
> Mmmm, No
> 
> $type = explode('/',$mime); # type is array
> $type = 'imagecreatefrom'.$type[1]; # type is a string
> 
> He is actually re-assigning the var ussing the content of the var.
> Sounds crazy, but I use this method a lot, it helps to keep the scope clean.
> 

It's not crazy, I do it a lot, but he *does nothing with it* after that,
and the scope of the variable is limited to the function.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] [GD] Image errors

2009-07-14 Thread Martin Scotta
Why are you ussing GD?
All you need is output the image to the browser?

try this... I didn't test/run this code, but it may work...

public function showPicture( $id ) {
  header('Content-type:' . mime_content_type( $this->updir . $id .
'.png' ) );
  readfile( $this->updir . $id . '.png' );
  }

hey, look, just 2 lines!

On Tue, Jul 14, 2009 at 2:20 PM, Ashley
Sheridan wrote:
> On Tue, 2009-07-14 at 14:16 -0300, Martin Scotta wrote:
>> On Tue, Jul 14, 2009 at 1:48 PM, Ashley
>> Sheridan wrote:
>> > On Tue, 2009-07-14 at 13:41 -0300, Martin Scotta wrote:
>> >> He is calling the function by variable
>> >>
>> >> something like this
>> >>
>> >> $func = 'var_dump';
>> >>
>> >> $func( new Foo );
>> >>
>> >> On Tue, Jul 14, 2009 at 1:30 PM, Ashley
>> >> Sheridan wrote:
>> >> > On Tue, 2009-07-14 at 13:27 -0300, Martin Scotta wrote:
>> >> >> $immagine = $tipo($this->updir.$id.'.png');
>> >> >>
>> >> >> $tipo is undefined
>> >> >>
>> >> >>
>> >> >> On Tue, Jul 14, 2009 at 12:48 PM, Il pinguino
>> >> >> volante wrote:
>> >> >> > Hi to all
>> >> >> >
>> >> >> > I get a problem processing an image with GD libraries.
>> >> >> >
>> >> >> > This is my function
>> >> >> >
>> >> >> >   public function showPicture($id) {
>> >> >> >       header('Content-type: image/jpeg');
>> >> >> >       $mime = mime_content_type($this->updir.$id.'.png');
>> >> >> >       $type = explode('/',$mime);
>> >> >> >       $type = 'imagecreatefrom'.$type[1];
>> >> >> >       $immagine = $tipo($this->updir.$id.'.png');
>> >> >> >       imagejpeg($immagine,null,100);
>> >> >> >       imagedestroy($immagine);
>> >> >> >   }
>> >> >> >
>> >> >> > If i commentize the "header" function i get a lot of strange simbols 
>> >> >> > (such
>> >> >> > as the code of a jpeg image!) but no errors.
>> >> >> > The result of this code is a blank page. In Firefox the title sets to
>> >> >> > "picture.php (JPEG image)" and if i right-click it and click on
>> >> >> > "Proprieties" i get "0px × 0px (resized as 315px × 19px)".
>> >> >> >
>> >> >> > P.S.: I get the same result when I write $immagine =
>> >> >> > imagecreatefromjpeg(...)
>> >> >> >
>> >> >> > (Sorry for my english)
>> >> >> >
>> >> >> > Thanks in advance,
>> >> >> > Alfio.
>> >> >> >
>> >> >> > --
>> >> >> > PHP General Mailing List (http://www.php.net/)
>> >> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> >> --
>> >> >> Martin Scotta
>> >> >>
>> >> > Also, it doesn't look like you're actually doing anything with $type
>> >> >
>> >> > Thanks
>> >> > Ash
>> >> > www.ashleysheridan.co.uk
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Martin Scotta
>> >>
>> >
>> > Bottom post ;)
>> >
>> > $type = explode('/',$mime);
>> > $type = 'imagecreatefrom'.$type[1];
>> >
>> > $immagine = $tipo($this->updir.$id.'.png');
>> > imagejpeg($immagine,null,100);
>> > imagedestroy($immagine);
>> >
>> > I'm not sure you understood what I meant. line 2 above $type is assigned
>> > to the string 'imagecreatefrom'.$type[1];
>> >
>> > Now I assume that was to be used later in some sort of eval() statement,
>> > but its never called again, so the line really does nothing.
>> >
>> > Thanks
>> > Ash
>> > www.ashleysheridan.co.uk
>> >
>> >
>>
>> Mmmm, No
>>
>> $type = explode('/',$mime); # type is array
>> $type = 'imagecreatefrom'.$type[1]; # type is a string
>>
>> He is actually re-assigning the var ussing the content of the var.
>> Sounds crazy, but I use this method a lot, it helps to keep the scope clean.
>>
>
> It's not crazy, I do it a lot, but he *does nothing with it* after that,
> and the scope of the variable is limited to the function.
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>



-- 
Martin Scotta

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



[PHP] Alphabetical pagination

2009-07-14 Thread Miller, Terion
I am trying to make a page that displays a-z like a b c d e etc as links
then when you click open one it reloads itself and shows only the query
results that go with that letter...i'm not getting itI get a page that
says ARRAY over and over...

What I have so far:
  $name\n";

} 


}



$alphabet = range('A', 'Z');

foreach ($alphabet as $letter) {

echo '' . $letter . '';

} 


 



?>


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



[PHP] Pattern Matching

2009-07-14 Thread VamVan
Hello Guys,

I have a question related to pattern matching and wildcards. This is the
scenario.

I have friendly urls on my website. So retrive their path as arguments for
every page.

so for example if I have www.xx.com/contact/me my args array will be

args(
   0 => contact,
   1 => me
)

My requirement is to change the page title on the fly with specific
patterns, so what I do is define a look up table with these columns.

path, pageTitle

contact/me - Contact US

perfect match would be easy because I can exactly look for what I want.

It becomes tricky when I introduce wild cards like contact/* for example. It
could also be contact/me/*

How would I match patterns for this kind of relative matches.? Any ideas
anyone?

Thanks,
V


Re: [PHP] Alphabetical pagination

2009-07-14 Thread Dan Shirah
>
> I am trying to make a page that displays a-z like a b c d e etc as links
> then when you click open one it reloads itself and shows only the query
> results that go with that letter...i'm not getting itI get a page that
> says ARRAY over and over...
>
> What I have so far:
> 
> if(!isset($_SESSION['RestaurantList']))
>
> {
>  // List not grabbed yet, so run
> query and store in $_SESSION
>
>$sql = "SELECT
> DISTINCT name FROM restaurants  GROUP BY name DESC";
>
> $result = mysql_query($sql) or die(mysql_error()) ;
>
> $count = mysql_num_rows($result);
>
> echo $count;
>
>
> while($row = mysql_fetch_array($result)) {
>
>
>
> $name=array($row['name'],0,1);
>
> //$name = array('name');
>
>echo " href=\"page.php?name=" .$name. "\"> $name\n";
>
> }
>
>
>}
>
>
>
> $alphabet = range('A', 'Z');
>
> foreach ($alphabet as $letter) {
>
> echo '' . $letter . '';
>
> }
>
>
>
>
>
>
> ?>
>

Well, are you opposed to using Javascript?

//javascript function




//You could make a hidden form field to store the value of the letter
selected.




//Perform your query and search only for the letter if it isn't blank.

//Print out all your letters

//Have the links call a javascript function that updates the letter selected
and resubmits the form to perform your new query
$letter


Something like that. I haven't tested any of that code just typed it up real
quick to give you an idea of one way to possibly do it.

Hope that helps.

Dan


[PHP] Mac OS X Server

2009-07-14 Thread The Doctor
ALl right,

I just install MySQL 5.1.36 on a Mac OS X Server but the PHP
is looking at the Mysql 5.0.67 ?

How do I tell the php.ini to look at the 5.1 instead of the 5.0?

-- 
Member - Liberal International  This is doc...@nl2k.ab.ca
Ici doc...@nl2k.ab.ca God, Queen and country! Beware Anti-Christ rising!
Never Satan President Republic!
The fool says in his heart, "There is no God". They are corrupt, and their ways 
are vile; there is no one who does good. - Ps 53:1

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



Re: [PHP] Alphabetical pagination

2009-07-14 Thread Andrew Ballard
On Tue, Jul 14, 2009 at 3:38 PM, Miller,
Terion wrote:
> I am trying to make a page that displays a-z like a b c d e etc as links
> then when you click open one it reloads itself and shows only the query
> results that go with that letter...i'm not getting itI get a page that
> says ARRAY over and over...
>
> What I have so far:
>                             
> if(!isset($_SESSION['RestaurantList']))
>
> {
>                                      // List not grabbed yet, so run
> query and store in $_SESSION
>
>                                                        $sql = "SELECT
> DISTINCT name FROM restaurants  GROUP BY name DESC";
>
> $result = mysql_query($sql) or die(mysql_error()) ;
>
> $count = mysql_num_rows($result);
>
> echo $count;
>
>
> while($row = mysql_fetch_array($result)) {
>
>
>
> $name=array($row['name'],0,1);




Why are you setting the value of $name to an array? If you try to echo
$name after this statement (as you are below), PHP will echo the word
"Array".



>
> //$name = array('name');
>
>                                                        echo " href=\"page.php?name=" .$name. "\"> $name\n";
>
> }
>
>
>                                                                    }
>
>
>
> $alphabet = range('A', 'Z');
>
> foreach ($alphabet as $letter) {
>
> echo '' . $letter . '';
>
> }
>
>
>
>
>
>
> ?>

If the list of restaurants is very long, I wouldn't store it in a
session variable. It is the same for every person who visits your
site, so there is little use storing separate redundant copies in
session scope where it will needlessly fill up disk space and/or
memory.

As far as the query is concerned, you could do this:



I would also consider whether you really need the keyword DISTINCT in
the query. In a properly normalized table, name should probably
already be distinct (and constrained by a UNIQUE index on that
column).

Andrew

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



RE: [PHP] Email security

2009-07-14 Thread Dewey Williams

> -Original Message-
> From: Tiji varghese [mailto:tij...@yahoo.co.in]
> Sent: Tuesday, July 14, 2009 7:47 AM
> To: PHP General
> Subject: [PHP] Email security
>
> Hello,
>
> I've implemented a contact form on my website that would email me the
> contents of the form and also add it to the database. Its working
> perfectly but I'm not too sure about the security part. I don't know
> much about the security issues concerned with email forms and the
> measures to check it. Please help.
>
> Thanks,
> Tiji

[Dewey Williams]

There are a number of easy to use sanitizing scripts available for 
processing forms for email and database use - find and use one! Forms 
are notoriously easy to compromise for sending spam and corrupting web 
sites.


A program I have used in the past is FormMail by 
http://www.tectite.com.  There are many other FormMail programs 
available by the same name - this one is well documented and easy to set 
up.  It doesn't provide as much database security as you may want, but 
it does a good job of hiding email and preventing cross-site scripting 
attacks.


Dewey Williams


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



[PHP] General good practice question about functions directory location

2009-07-14 Thread Al
Most of my scripts are written for use on shared hosts.  I've generally put my 
function and config files in a web-space directory.  However, I been thinking it 
would be less bother to make stuff more secure if the functions, et al, were 
above the root directory.


I realize, some hosts still don't let the owner use the space above the 
document_root.  So, I'll provide a means so the directory can be installed under 
it.


What's your opinion and practice?

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



[PHP] Thanx

2009-07-14 Thread Girish Padia
Dear All,

Thanx for the responce shown by you all. Your responce helped me to clear my
doubts. Well, I am very much new to PHP developements. You can visit me at
http://www.girishphpmysql.blogspot.com. I am willing to know about sessions
to track the user login and logout. Your same responce will help me again.




fromLists 
toGirish Padia 

date14 July 2009 19:39
subjectRe: [PHP] Need Help.

hide details 19:39 (14 hours ago) Reply



Girish Padia wrote:

Dear Sir,

I am facing two problem while developing my site in php.
1) I want to delete browser history whenever i migrate from one page to
another. so that user can never press "Back" button.




Why?

I could see a purpose for this if there is a form post
and you don't want the user to resubmit... but, are you wanting this
feature globally?

Donovan


[PHP] I have an idea

2009-07-14 Thread Martin Scotta
Hi

Do you noted that all the discussion here are about problems, bugs, or
just "urgent pleaaase help me"
I have an idea. It is not really THE idea... but it is.
What happen if tell this idea to the community? I don't know, so,
let's take a look.


PHP is a great language. You can do a lot of things with him, even
have fun with it.
My idea is to make a simple game where your have to write some AI to
beat the other players AI

The idea, as simple as it looks, is really difficult to implement
specially about security

so, do you like me idea?

-- 
Martin Scotta

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



[PHP] Scrapping email content

2009-07-14 Thread Areba Collins
Hello guys, i have a quick one:

Im working on an app that reads email and converts it into a post on a
forum, everything works fine except the threaded comments at the
bottom. I would like to delete everything that is from a previous
email (which usually begins with on this ate, so and so wrote : and
then comments preceeded by >>

Does anyone know a straightforward function to accomplish this?

Regards,
Collins -Nairobi KE.

-- 
If you have an apple and I have an apple and we exchange these apples
then you and I will still each have one apple. But if you have an idea
and I have an idea and we exchange these ideas, then each of us will
have two ideas.

George Bernard Shaw

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



Re: [PHP] How to set find pathes for PHP CLI?

2009-07-14 Thread Tir
Linux (RHEL). PHP 5.2. 



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



Re: [PHP] Alphabetical pagination

2009-07-14 Thread Jim Lucas

Andrew Ballard wrote:

On Tue, Jul 14, 2009 at 3:38 PM, Miller,
Terion wrote:

I am trying to make a page that displays a-z like a b c d e etc as links
then when you click open one it reloads itself and shows only the query
results that go with that letter...i'm not getting itI get a page that
says ARRAY over and over...

What I have so far:





Why are you setting the value of $name to an array? If you try to echo
$name after this statement (as you are below), PHP will echo the word
"Array".




//$name = array('name');

   echo " $name\n";

}


   }



$alphabet = range('A', 'Z');

foreach ($alphabet as $letter) {

echo '' . $letter . '';

}






?>


If the list of restaurants is very long, I wouldn't store it in a
session variable. It is the same for every person who visits your
site, so there is little use storing separate redundant copies in
session scope where it will needlessly fill up disk space and/or
memory.

As far as the query is concerned, you could do this:



I would also consider whether you really need the keyword DISTINCT in
the query. In a properly normalized table, name should probably
already be distinct (and constrained by a UNIQUE index on that
column).

Andrew



Also, since this is MySQL, you need to make sure you make it non case-sensitive by using ILIKE instead of LIKE in that 
SELECT statement.


$sql = "SELECT DISTINCT name FROM restaurants WHERE name iLIKE '$index_letter%' 
GROUP BY name DESC";

--
Jim Lucas

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



Re: [PHP] A prepared statements question

2009-07-14 Thread Jim Lucas

Jason Carson wrote:

Hello everyone,

I am having a problem getting my prepared statements working. Here is my
setup...

index.php -> authenticate.php -> admin.php

1)index.php has a login form on it so when someone enters their username
the form redirects to another page I call authenticate.php.

2)In the authenticate.php file I want to use prepared statements to
interact with the MySQL database. I want to compare the username submitted
from the form with the username in the database.

3)If the login username was legitimate then you are forwarded to admin.php

Its step 2 I am having problems with. Here is what I have but I don't
think it makes any sense and it doesn't work.


$link = mysqli_connect($hostname, $dbusername, $password, $database);
$stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
adminusers=?");
mysqli_stmt_bind_param($stmt, 's', $username);
$result = mysqli_stmt_execute($stmt);

$count=mysqli_num_rows($result);

if($count==1){
header("location:admin.php");
} else {
echo "Failure";
}

Any help is appreciated.


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



For anyone reading this thread, here is the final code that I used...

$link = mysqli_connect($hostname, $username, $password, $database);
$stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
adminusers=?);
mysqli_stmt_bind_param($stmt, "s", $adminuser);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$count = mysqli_stmt_num_rows($stmt);

if($count==1){
header("location:admin.php");
} else {
echo "Failure";
}




I hope not, because you have a parse error on your second line, mysqli_prepare()

Might want to close your double-quoted string

--
Jim Lucas

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