php-general Digest 19 May 2007 23:23:54 -0000 Issue 4800
Topics (messages 255229 through 255237):
Re: PHP5 Static functions called through __call() that don't exist... yet
255229 by: Emil Ivanov
255234 by: Greg Beaver
Re: Security Question, re directory permissions
255230 by: Tijnema
255235 by: Al
Re: php5 cert
255231 by: Greg Donald
Re: Just to prove my point (used to be -> Re: [PHP] People's misbehavior on the
list)
255232 by: Stut
255233 by: Stut
Re: Include files....
255236 by: Haydar TUNA
Re: mime type over http post?
255237 by: Ray
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 ---
Hi,
I also think this a good proposal, but you might consider writing to the
internals group, as this group is only for discussions and most of the
people that read it are PHP users and have no idea how the language is made
(including me).
Regards,
Emil Ivanov
""Jared Farrish"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all,
>
> Here is more code, with a test case included. What I would prefer to do is
> call TypeAssist::$string(), instead of TypeAssist::$a->string(). Or at
> least
> __construct() the $a object.
>
> <code>
> <?php
> if (!class_exists('TypeAssert')) {
> class TypeAssert {
> public static $a;
> public static $assert;
> private static $types = array(
> 'array','bool','float','integer','null','numeric',
> 'object','resource','scalar','string'
> );
> function __construct() {
> self::$assert =& self::$a;
> }
> public static function __call($method,$arguments) {
> $obj = self::assertStandardTypes($arguments[0]);
> return $obj->$method;
> }
> public static function assertStandardTypes($para) {
> $r = TypeAssert::getTypesObject();
> foreach ($r as $type=>$v) {
> $func = "is_".strtolower($type);
> if (function_exists($func) === true) {
> if ($func($para) === true) {
> $r->$type = true;
> } else {
> $r->$type = false;
> }
> }
> }
> return $r;
> }
> public static function getTypesObject() {
> $obj = (object) '';
> for ($i = 0; $i < count(self::$types); $i++) {
> $obj->{self::$types[$i]} = (bool) false;
> }
> return $obj;
> }
> }
> }
> TypeAssert::$a = new TypeAssert();
> echo("<pre>\n");
> switch($_GET['type']) {
> case 'int':
> $test = 100;
> $_test = 100;
> break;
> case 'float':
> $test = 100.001;
> $_test = 100.001;
> break;
> case 'null':
> $test = null;
> $_test = 'null';
> break;
> case 'object':
> $test = TypeAssert::$a;
> $_test = '[object]';
> break;
> default:
> $test = 'string';
> $_test = 'string';
> break;
> }
> foreach (TypeAssert::getTypesObject() as $type => $v) {
> echo("<div>is_<b style=\"color: #00a;\">$type</b>(<b>$_test</b>) === ".
> (TypeAssert::$assert->$type($test)?
> '<b style="color: #0a0;">true</b>':
> '<b style="color: #a00;">false</b>').
> "</div>\n"
> );
> }
> echo("</pre>\n");
> ?>
> </code>
>
> Original Message Text
>
>> Hi all,
>>
>> I am building an assertType object using static functions. What I want to
>> keep away from is the following:
>>
>> <code>
>> public static function assertString($para){
>> return $answer;
>> };
>> public static function assertBool($para){
>> return $answer;
>> };
>> ...
>> public static function assertArray($para){
>> return $answer;
>> };
>> </code>
>>
>> What I would like to do is replace this with the following:
>>
>> <code>
>> if (!class_exists('TypeAssert')) {
>> class TypeAssert {
>> private static $types = array(
>> 'array','bool','float','integer','null','numeric',
>> 'object','resource','scalar','string'
>> );
>> public static function __call($method,$arguments) {
>> $obj = self::assertStandardTypes($arguments[0]);
>> return $obj->$method;
>> }
>> public static function assertStandardTypes($para) {
>> $r = TypeAssert::getTypesObject();
>> if (is_array($para)) $r->array = true;
>> if (is_bool($para)) $r->bool = true;
>> if (is_float($para)) $r->float = true;
>> if (is_integer($para)) $r->integer = true;
>> if (is_null($para)) $r->null = true;
>> if (is_numeric($para)) $r->numeric = true;
>> if (is_object($para)) $r->object = true;
>> if (is_resource($para)) $r->resource = true;
>> if (is_scalar($para)) $r->scalar = true;
>> if (is_string($para)) $r->string = true;
>> return $r;
>> }
>> public static function getTypesObject() {
>> $obj = (object) '';
>> for ($i = 0; $i < count(self::$types); $i++) {
>> $obj->{self::$types[$i]} = (bool) false;
>> }
>> return $obj;
>> }
>> }
>> }
>> echo('<pre>');
>> echo(TypeAssert::string('test'));
>> echo('</pre>');
>> </code>
>>
>> I don't think this is possible (see
>> http://marc.info/?l=php-general&m=114558851102060&w=2
>> ). But I would LIKE for it to work (currently, the above code doesn't).
>>
>> Anybody have any insight on how I might get this to work?
>>
>> Thanks!
>>
>> --
>> Jared Farrish
>> Intermediate Web Developer
>> Denton, Tx
>>
>> Abraham Maslow: "If the only tool you have is a hammer, you tend to see
>> every problem as a nail." $$
>>
>
>
>
> --
> Jared Farrish
> Intermediate Web Developer
> Denton, Tx
>
> Abraham Maslow: "If the only tool you have is a hammer, you tend to see
> every problem as a nail." $$
>
--- End Message ---
--- Begin Message ---
Jared Farrish wrote:
> Hi all,
>
> I am building an assertType object using static functions. What I want to
> keep away from is the following:
>
> <code>
> public static function assertString($para){
> return $answer;
> };
> public static function assertBool($para){
> return $answer;
> };
> ...
> public static function assertArray($para){
> return $answer;
> };
> </code>
>
> What I would like to do is replace this with the following:
>
> <code>
> if (!class_exists('TypeAssert')) {
> class TypeAssert {
> private static $types = array(
> 'array','bool','float','integer','null','numeric',
> 'object','resource','scalar','string'
> );
> public static function __call($method,$arguments) {
> $obj = self::assertStandardTypes($arguments[0]);
> return $obj->$method;
> }
> public static function assertStandardTypes($para) {
> $r = TypeAssert::getTypesObject();
> if (is_array($para)) $r->array = true;
> if (is_bool($para)) $r->bool = true;
> if (is_float($para)) $r->float = true;
> if (is_integer($para)) $r->integer = true;
> if (is_null($para)) $r->null = true;
> if (is_numeric($para)) $r->numeric = true;
> if (is_object($para)) $r->object = true;
> if (is_resource($para)) $r->resource = true;
> if (is_scalar($para)) $r->scalar = true;
> if (is_string($para)) $r->string = true;
> return $r;
> }
> public static function getTypesObject() {
> $obj = (object) '';
> for ($i = 0; $i < count(self::$types); $i++) {
> $obj->{self::$types[$i]} = (bool) false;
> }
> return $obj;
> }
> }
> }
> echo('<pre>');
> echo(TypeAssert::string('test'));
> echo('</pre>');
> </code>
>
> I don't think this is possible (see
> http://marc.info/?l=php-general&m=114558851102060&w=2). But I would LIKE
> for
> it to work (currently, the above code doesn't).
>
> Anybody have any insight on how I might get this to work?
Hi Jared,
I think you meant to post to php-general, but I can answer your question.
***PLEASE DO NOT REPLY TO PEAR-GENERAL THANK YOU***
You can achieve what you want through this kind of code
<?php
class TypeChecker
{
private static $types = array(
'array','bool','float','integer','null','numeric',
'object','resource','scalar','string'
);
public static $singleton;
static function init()
{
self::$singleton = new TypeChecker;
}
function __call($method, $args)
{
$test = new StdClass;
foreach (self::$types as $thing) {
$test->$thing = ${"is$thing"}($args[0]);
}
return $test->$method;
}
}
TypeChecker::init()
echo TypeChecker::$singleton->string('test');
?>
However, I don't see any benefit to using static methods here. Just use
an object.
<?php
class TypeChecker
{
private $types = array(
'array','bool','float','integer','null','numeric',
'object','resource','scalar','string'
);
function __call($method, $args)
{
$test = new StdClass;
foreach (self::$types as $thing) {
$test->$thing = ${"is$thing"}($args[0]);
}
return $test->$method;
}
}
$check = new TypeChecker;
echo $check->string('test');
?>
If you're trying to do several assertions and separate them into
classes, do something like so:
<?php
class Tester
{
public $type;
...
function __construct()
{
$this->type = new TypeChecker;
}
}
$check = new Tester;
echo $check->type->string('test');
?>
Greg
--- End Message ---
--- Begin Message ---
On 5/19/07, itoctopus <[EMAIL PROTECTED]> wrote:
I'm genuinely interested to know with whom you're hosting...
No problem, it's www.dapx.com, it hasn't a lot security, safe_mode is
off for example.
If you know the right stuff from another user on the same server, you
can actually do some nice stuff :)
Tijnema
--
itoctopus - http://www.itoctopus.com
"Tijnema" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On 5/19/07, Al <[EMAIL PROTECTED]> wrote:
>> How can anyone, other than the staff, get into my site? Far as I know,
>> other users can't get out of their own domain
>> space and into mine.
>
> That's quite easy, especially when you have SSH access.
> Of course, it will only work with specific settings, and that might be
> blocked on some hosts, but it works for me.
> On my host, accounts for domains are just in /home
> so let's say i have 2 accounts, account a & b.
> their directorys are resp. /home/a & /home/b.
> When i create a diretory with account a at /home/a/dir, and i chmod it
> 757, i can write a file there from account b.
>
> Tijnema
>>
>> Tijnema wrote:
>> > On 5/19/07, Al <[EMAIL PROTECTED]> wrote:
>> >> But, SSH and telnet, etc. require authentication login-in and all the
>> >> executables you mentioned [and others] require
>> >> someone who has access to upload a harmful file to start with. Right?
>> >> Once they are in there, they can do anything they
>> >> please anyhow.
>> >>
>> >> Al.........
>> >
>> > Well, you were talking about a shared linux host, so other people,
>> > from a different account, could just upload files, and if you have a
>> > directory with 757, that user could write to it.
>> >
>> > Tijnema
>> >>
>> >> Tijnema ! wrote:
>> >> > On 5/18/07, Al <[EMAIL PROTECTED]> wrote:
>> >> >> How can they write or edit files there without having ftp access or
>> >> >> the site's file manager?
>> >> >
>> >> > SSH access? Telnet maybe? PHP script? CGI script? ASP script?
>> >> >
>> >> > There are a lot of possible ways someone can write there.
>> >> >
>> >> > Tijnema
>> >> >>
>> >> >> Tijnema ! wrote:
>> >> >> > On 5/18/07, Al <[EMAIL PROTECTED]> wrote:
>> >> >> >> I'm on a shared Linux host and have been wondering about
>> >> security and
>> >> >> >> directory "other" ["world"] permissions.
>> >> >> >>
>> >> >> >> The defaults are 755. The 'others' [world] can read them only.
>> >> >> >>
>> >> >> >> Is there a security hole if a dir on the doc root if a directory
>> >> has
>> >> >> >> permissions 757?
>> >> >> >>
>> >> >> >> If there is a security problem, what is it?
>> >> >> >>
>> >> >> >> Thanks...
>> >> >> >>
>> >> >> >
>> >> >> > If you have a directory with 757 permissions, "world" can create
>> >> >> > new
>> >> >> > files there.
>> >> >> >
>> >> >> > And if you give files 757 (or 646) permissions, then "world" can
>> >> edit
>> >> >> > that file.
>> >> >> >
>> >> >> > So if you have a doc dir, you probably don't want extra files
>> >> >> > there.
>> >> >> > It's not really a security problem, but if somebody notices it,
>> >> >> > he
>> >> >> > might write files there.
>> >> >> >
>> >> >> > Tijnema
>> >> >>
>> >> >> --
>> >> >> PHP General Mailing List (http://www.php.net/)
>> >> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >>
>> >> >>
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I use Hosting Matters. It is super reliable and solid.
itoctopus wrote:
I'm genuinely interested to know with whom you're hosting...
--- End Message ---
--- Begin Message ---
On 5/19/07, Kevin Waterson <[EMAIL PROTECTED]> wrote:
As worthless as the php4 cert.
Mine has been very valuable to me, lots more job interviews and
freelance work compared to before I got it.
--
Greg Donald
http://destiney.com/
--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
PHP Developer wrote:
some people don't remove the "Re:" prefix when answering to the
questions It opens a new topic on the list and that's not appropriate
. Thank ya
---------------------------------
Moody friends. Drama queens. Your life? Nope! - their life, your story.
Play Sims Stories at Yahoo! Games.
Clients that rely on the subject to determine if it a new thread are
broken.
In fact, if you looked the headers of your email you will see a line
like this
message-id: <[EMAIL PROTECTED]>
my client takes that line and make a reference to it like this.
references: <[EMAIL PROTECTED]>
it will also create a new message-id: line. something like this.
message-id: <[EMAIL PROTECTED]>
if anybody replies to my message, the process is repeated.
Real, non-broken, email clients rely on the above lines to determine how
messages belong to one another. Again, it has nothing to do with the
subject line. Look at the subject line of this message.
As always it's not quite that simple. The problem is that there are no
hard and fast rules regarding mail headers, so when threading you can't
guarantee anything.
The "standard", or accepted reference algorithm for threading emails can
be found at http://www.jwz.org/doc/threading.html and is, I believe,
still used in a large number of clients including Thunderbird. Gmail
almost certainly uses their own concoction, but it probably follows
similar rules.
-Stut
--- End Message ---
--- Begin Message ---
Tijnema wrote:
Anyway, it works a lot better than Megasoft Outlook or such, they
don't group anything...
By default, no. But you can organise messages by thread. I don't like
the way "they" display it, but I wish people would get their facts
straight before passing comment on the easy target.
-Stut
--- End Message ---
--- Begin Message ---
Hello,
Short tags (<? ?>) are only available when they are enabled via the
short_open_tag php.ini configuration file directive, or if php was
configured with the --enable-short-tags option. Did you configure your
php.ini file?
--
Republic Of Turkey - Ministry of National Education
Education Technology Department Ankara / TURKEY
Web: http://www.haydartuna.net
"Jason Pruim" <[EMAIL PROTECTED]>, haber iletisinde sunlari
yazdi:[EMAIL PROTECTED]
> Okay, Very Newbie-ish question coming!
>
> I can't figure out why my include won't work... Here's the text:
>
> index.php:
> <?PHP
>
> include 'defaults.php';
>
> $link = mysql_connect($server, $username, $password) or die('Could
> not connect: ' . mysql_error());
> echo 'Connected successfully <BR>';
> mysql_select_db($database) or die('Could not select database: ' .
> mysql_error());
> echo 'DB selected <BR>';
>
> $result = mysql_query($query) or die(mysql_error());
> $num=mysql_numrows($result);
> $i= 0;
>
>
> while($i < $num) {
>
> $FName = mysql_result($result, $i,"FName");
> $LName = mysql_result($result,$i,"LName");
> $Add1 = mysql_result($result, $i,"Add1");
> $Add2 = mysql_result($result, $i,"Add2");
> $City = mysql_result($result, $i,"City");
> $State = mysql_result($result, $i,"State");
> $Zip = mysql_result($result, $i,"Zip");
> $Date = date("m-d-y h:i:s",mysql_result($result, $i, "Date"));
> $Record = mysql_result($result, $i, "Record");
> $subName = mysql_result($result, $i,"subName");
> $subEmail = mysql_result($result, $i,"subEmail");
> $subPhone = mysql_result($result, $i,"subPhone");
> $chkMember = unserialize(mysql_result($result, $i,"chkMember"));
> $chkAdd = unserialize(mysql_result($result, $i,"chkAdd"));
> $chkDel = unserialize(mysql_result($result, $i, "chkDel"));
>
> $i++;
>
> //echo "<P>$Record $FName, $LName,</P> <P>$Add1,<BR> $Add2,<BR></P>
> <P>$City, $State, $Zip,</P> $Date,<BR> $subName, $subEmail,
> $subPhone, $chkMember[$row], $chkAdd[$row], $chkDel[$row]<BR>";
>
> echo "<H3>Name Address</H3>";
> echo "<P id ='test'> $FName $LName $Add1 $Add2 $Date</P>";
>
> };
>
>
>
>
> ?>
> *
> defaults.php:
>
> $server = 'localhost';
> $username = 'USERNAME';
> $password = 'PASSWORD';
> $database = 'DATABASE';
> $query = 'SELECT * FROM current';
>
> Yes I changed the values of username, password, and database. But
> when I use the same info inside the index.php file it all works just
> fine. Here is the error that it gives me:
>
> [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable:
> server in /Volumes/RAIDer/webserver/Documents/tests/legion/index.php
> on line 5
> [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable:
> username in /Volumes/RAIDer/webserver/Documents/tests/legion/
> index.php on line 5
> [Fri May 18 15:32:07 2007] [error] PHP Notice: Undefined variable:
> password in /Volumes/RAIDer/webserver/Documents/tests/legion/
> index.php on line 5
> [Fri May 18 15:32:07 2007] [error] PHP Warning: mysql_connect() [<a
> href='function.mysql-connect'>function.mysql-connect</a>]: Access
> denied for user 'USERNAME'@'localhost' (using password: NO) in /
> Volumes/RAIDer/webserver/Documents/tests/legion/index.php on line 5
>
>
> Thanks in advance for helping me through my obvious friday afternoon
> brain fart...
>
>
>
>
> --
>
> Jason Pruim
> Raoset Inc.
> Technology Manager
> MQC Specialist
> 3251 132nd ave
> Holland, MI, 49424
> www.raoset.com
> [EMAIL PROTECTED]
>
>
>
--- End Message ---
--- Begin Message ---
Thanks for your help everybody.
I think I'll give the other company a link to this thread for the next person
who asks for help.
Ray
On Wednesday 16 May 2007 6:57 pm, Oliver Block wrote:
> Hello Ray,
>
> 1. create the xml markup (dom)
> 2. open a connection to the 3rd party server (fsockopen)
> 3. send the header (fputs)
> 4. send the body (fputs)
> 5. close the connection
>
> Additional Questions?
>
> Best Regards,
>
> Oliver
>
> P.S: I just know better where to look for information:-)
>
> ----- original Nachricht --------
>
> Betreff: [PHP] mime type over http post?
> Gesendet: Mi, 16. Mai 2007
> Von: Ray<[EMAIL PROTECTED]>
>
> > Hello,
> > I'm trying to write a web-based aplication that talks to a third party
> > server.
> > I'm having a hard time getting support from from them. the method of
> > comunication (direct quote from their docs is:
> > "Data will be transferred to [server] via an HTTP POST operation using
> > the MIME type, text/xml"
> >
> > can anybody tell me what this means or how I do it using php?
> > Thanks,
> > Ray
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
> --- original Nachricht Ende ----
--- End Message ---