[PHP] Re: PHP5 Static functions called through __call() that don't exist... yet
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. > > > 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("\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("is_$type($_test) === ". > (TypeAssert::$assert->$type($test)? > 'true': > 'false'). > "\n" >); > } > echo("\n"); > ?> > > > Original Message Text > >> Hi all, >> >> I am building an assertType object using static functions. What I want to >> keep away from is the following: >> >> >> public static function assertString($para){ >> return $answer; >> }; >> public static function assertBool($para){ >> return $answer; >> }; >> ... >> public static function assertArray($para){ >> return $answer; >> }; >> >> >> What I would like to do is replace this with the following: >> >> >> 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(''); >> echo(TypeAssert::string('test')); >> echo(''); >> >> >> 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 ten
Re: [PHP] Security Question, re directory permissions
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php5 cert
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/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Just to prove my point (used to be -> Re: [PHP] People's misbehavior on the list)
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Just to prove my point (used to be -> Re: [PHP] People's misbehavior on the list)
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 Static functions called through __call() that don't exist... yet
Jared Farrish wrote: > Hi all, > > I am building an assertType object using static functions. What I want to > keep away from is the following: > > > public static function assertString($para){ >return $answer; > }; > public static function assertBool($para){ >return $answer; > }; > ... > public static function assertArray($para){ >return $answer; > }; > > > What I would like to do is replace this with the following: > > > 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(''); > echo(TypeAssert::string('test')); > echo(''); > > > 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 $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. $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: type = new TypeChecker; } } $check = new Tester; echo $check->type->string('test'); ?> Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Security Question, re directory permissions
I use Hosting Matters. It is super reliable and solid. itoctopus wrote: I'm genuinely interested to know with whom you're hosting... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Include files....
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: > > include 'defaults.php'; > > $link = mysql_connect($server, $username, $password) or die('Could > not connect: ' . mysql_error()); > echo 'Connected successfully '; > mysql_select_db($database) or die('Could not select database: ' . > mysql_error()); > echo 'DB selected '; > > $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 "$Record $FName, $LName, $Add1, $Add2, > $City, $State, $Zip, $Date, $subName, $subEmail, > $subPhone, $chkMember[$row], $chkAdd[$row], $chkDel[$row]"; > > echo "Name Address"; > echo " $FName $LName $Add1 $Add2 $Date"; > > }; > > > > > ?> > * > 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() [ href='function.mysql-connect'>function.mysql-connect]: 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] > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mime type over http post?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Adserver programming with php
Hi there, I am thinking about creating a kind of adserver which is customized for my needs. As I would be most confident in doing this with php, I am asking myself if this is the right choice or if it would be wiser to take a C++ aproach for example to get a higher performance just in case the site grows fast. Do you guys think that a php build webserver would be able to scale and perform well enough for serving millions of adimpressions daily? Thank you for any advice, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Adserver programming with php
Em Sábado 19 Maio 2007 21:15, Merlin escreveu: > I am thinking about creating a kind of adserver which is customized for > my needs. As I would be most confident in doing this with php, I am > asking myself if this is the right choice or if it would be wiser to > take a C++ aproach for example to get a higher performance just in case > the site grows fast. > Do you guys think that a php build webserver would be able to scale and > perform well enough for serving millions of adimpressions daily? > IIRC, AFAIK, using PHP or C or Java or C++ or anything else, your webserver will do all the "dirty work"... If you'd portuguese skills, read [1], otherwise, I'll recomend you to build careful your server... And just put Web server (i.e. Apache) on it... DB server, mail server and other server must be in other machines... "Build careful" means: use a _good_ Linux distro... If you can use Gentoo [2], you'll get better results... [1] - http://archives.gentoo.org/gentoo-user-br/msg_11719.xml [2] - www.gentoo.org HTH -- Davi Vidal [EMAIL PROTECTED] [EMAIL PROTECTED] -- "Religion, ideology, resources, land, spite, love or "just because"... No matter how pathetic the reason, it's enough to start a war. " pgpdsYkCHDWsy.pgp Description: PGP signature
Re: [PHP] Adserver programming with php
Merlin wrote: Hi there, I am thinking about creating a kind of adserver which is customized for my needs. As I would be most confident in doing this with php, I am asking myself if this is the right choice or if it would be wiser to take a C++ aproach for example to get a higher performance just in case the site grows fast. Do you guys think that a php build webserver would be able to scale and perform well enough for serving millions of adimpressions daily? Thank you for any advice, Merlin Just build the darn thing. It is a simple script, if you find that performance is an issue, then change your approach. You can't tell me that your site will explode in usage over night and you wont get the chance to change your design before things get out of hand. -- Jim Lucas "Some men are born to greatness, some achieve greatness, and some have greatness thrust upon them." Unknown -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Adserver programming with php
Use php and get the site on the air ASAP, so it generates revenue. You can a quickly and cheaply upgrade the hardware if the need arises. The OS and webserver software will probably make a bigger difference. Seems like I recall someone said Google and Yahoo use PHP. Merlin wrote: Hi there, I am thinking about creating a kind of adserver which is customized for my needs. As I would be most confident in doing this with php, I am asking myself if this is the right choice or if it would be wiser to take a C++ aproach for example to get a higher performance just in case the site grows fast. Do you guys think that a php build webserver would be able to scale and perform well enough for serving millions of adimpressions daily? Thank you for any advice, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Adserver programming with php
Google is a Python shop primarily, but Yahoo employs a good chunk of the PHP internals development team, like Rasmus and Sara Goleman. They do a ton with PHP. On Saturday 19 May 2007, Al wrote: > Use php and get the site on the air ASAP, so it generates revenue. > > You can a quickly and cheaply upgrade the hardware if the need arises. The > OS and webserver software will probably make a bigger difference. Seems > like I recall someone said Google and Yahoo use PHP. > > Merlin wrote: > > Hi there, > > > > I am thinking about creating a kind of adserver which is customized for > > my needs. As I would be most confident in doing this with php, I am > > asking myself if this is the right choice or if it would be wiser to > > take a C++ aproach for example to get a higher performance just in case > > the site grows fast. > > Do you guys think that a php build webserver would be able to scale and > > perform well enough for serving millions of adimpressions daily? > > > > Thank you for any advice, > > > > Merlin -- Larry Garfield AIM: LOLG42 [EMAIL PROTECTED] ICQ: 6817012 "If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it." -- Thomas Jefferson -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php