Re: [PHP] implode()
$BannerSize = implode($_POST['BannerSize'], ','); Looks like you have your arguments backwards; try: $BannerSize = implode(',',$_POST['BannerSize']); --Greg
Re: [PHP] Rounded rectangle in php
It is certainly possible, but to my knowledge, there is no built-in method for doing so. After a quick Google, it looks like this has been done before: http://www.assemblysys.com/dataServices/php_roundedCorners.php http://us3.php.net/manual/en/function.imagefilledrectangle.php#42815 But if you're looking to reinvent the wheel: 1.) Given any three noncolinear points, you can construct a circle. (whose center is at the intersection of perpendicular bisectors of line segments connecting these points) 2.) Using imageline(), you can draw the sides of your rectangle, minus the corners. At the "empty space" where each corner would be you would have the ends of two lines--two points. 3.) Then you need to choose a third point that is "between" those two. (there is a certain line that the "between" point should lie on) 4.) Once you have three points, you can calculate the center and radius of the circle that passes through them. Then use imagearc() to draw the "rounded corner". -- Greg On Thu, Jan 29, 2009 at 8:36 AM, Jônatas Zechim wrote: > Hi there, is it possible do make a rounded rectangle in php, i can do a > ellipse, but i need a space between the corners, i need to make something > like this: > > http://superbrush.files.wordpress.com/2008/03/086.jpg > > not the color and the shadows, only the form. > > > zechim > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Php warning message
> > *$boardFile = "MessageBoard.txt"; > $boardFileHandle = fopen($boardFile,"r"); > for ($counter = 1; !feof($boardFileHandle); $counter += 1) { > $colorLine = fgets(boardFilehandle); > if ($counter % 2 == 0) { > echo "$colorline"; > } else { > echo $colorline; > } > } > fclose($boardFileHandle);* Looks like you're missing a $ on line 4: $colorLine = fgets(boardFilehandle); Should be $colorLine = fgets($boardFilehandle); [snip] I may be showing my ignorance here... But on your if ($counter % 2 ==0) line what does the "%" do? Was that possibly a typo? [/snip] It's the modulus operator; he's trying to make every other line a different color. :) -- Greg
Re: [PHP] PHP 5 file_get_contents() problems
The actual setting is allow_url_fopen. allow_url_include controls whether or not you can use a remote URL as an include (however, if allow_url_fopen is off, then allow_url_include will also be off.) The short answer to your question is: yes, there is a way. Several ways, in fact. You could use curl, or you could use an Http client written in php. The latter involves using either the socket_ or the fsocket functions. * http://scripts.incutio.com/httpclient/ On Tue, Mar 18, 2008 at 10:11 AM, Chris <[EMAIL PROTECTED]> wrote: > I've encountered a situation where under PHP 5 the file_get_contents() > function will not work properly (actually not at all) if the php.ini > Filesystem configuration parameter, allow_url_include is set to OFF. > According to the PHP documentation allow_url_include is intended to > limiting PHP from accessing scripts on other servers. > > I have read posts that suggest setting allow_url_include to ON as > a solution. Well that's great if you have the ability to modify your > php.ini. But what if you have an account on a shared hosting system > and the hosting company will NOT make the requested change? > > Is there a work around to this or how would one access remote web services > if allow_url_include is OFF. This looks like a huge problem since many > services, like PayPal's IPN and Google maps geocoding, rely on > communication > with their servers. > > Thanks, > Chris > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] PHP 5 file_get_contents() problems
for security reasons, allow_url_include can only be set from the main php.ini On Tue, Mar 18, 2008 at 10:22 AM, Thijs Lensselink <[EMAIL PROTECTED]> wrote: > Quoting Chris <[EMAIL PROTECTED]>: > > > I've encountered a situation where under PHP 5 the file_get_contents() > > function will not work properly (actually not at all) if the php.ini > > Filesystem configuration parameter, allow_url_include is set to OFF. > > According to the PHP documentation allow_url_include is intended to > > limiting PHP from accessing scripts on other servers. > > > > I have read posts that suggest setting allow_url_include to ON as > > a solution. Well that's great if you have the ability to modify your > > php.ini. But what if you have an account on a shared hosting system > > and the hosting company will NOT make the requested change? > > > > Is there a work around to this or how would one access remote web > services > > if allow_url_include is OFF. This looks like a huge problem since many > > services, like PayPal's IPN and Google maps geocoding, rely on > communication > > with their servers. > > > > Try ini_set("allow_url_include", "1"); In your script. (not tested) > > If that doesn't help. You can use CURL for this : > http://php.net/manual/en/ref.curl.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] strange list behavior when replying to message on list
Yeah. I always forget to reply to all. The problem is with the headers. Whereas other lists have a reply-to: in the email headers, this list does not. It annoys the hell out of me. On Sat, Mar 22, 2008 at 11:13 AM, Mark Weaver <[EMAIL PROTECTED]> wrote: > Hi all, > > I'm wondering if anyone else happens to be using Mozilla Thunderbird and > seeing this behavior, and also if this behavior is a feature or a bug. > > When I hit the reply button to respond to a message most of the time the > actual sender's address is the one the message is being sent to rather > than the list itself. This is the first mailing list I've been on that > I've seen this behavior; all other lists I'm on when one hits the reply > button, or CTRL+R the mailing list's address is inserted as it should be > and is expected. > > I know with some email clients there is a menu item specifically there > for responding "to the list" based on whether or not there is a > list-header in the header information but that isn't an available option > with Thunderbird. Is anyone else seeing this behavior or is there > something I'm missing? > > Mark > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] De-Duplicate A Query Result List
Sounds like you want something like the following: SELECT DISTINCT category FROM `contacts` WHERE state='california'; --GREG
Re: [PHP] Array and Object
Take a look at array_walk(), array_walk_recursive(), array_map() in the PHP manual. On Mon, Mar 24, 2008 at 2:04 PM, tedd <[EMAIL PROTECTED]> wrote: > At 10:23 AM -0700 3/24/08, VamVan wrote: > >Well anyways please let me handle the problems with decoding.mail.com> > wrote: > > > At 10:00 AM -0700 3/24/08, VamVan wrote: > >> >I cannot do that. because Simple xml element retrieves everything in > >> >UTF8. I need to decode it to latin1 for comparison with another > array. > >> > >> Unless there is something here that I don't understand, there is no > >> decoding UTF-8 to Latin1 > >> > >> Latin1 is a subset of UTF-8 -- what you find (characters) in Latin 1 > >> is the same as in UTF-8. > >> > >> If you have a code point (character) that lies outside of the range > >> of Latin 1, then there is no solution. > >> > >> Cheers, > >> > > > tedd > > I'm not stopping you. > > When you figure out how to decode UTF-8 to Latin, I would like to see it. > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Array and Object
That top post was totally not I... It was my roommate playing with my computer *nods*.
[PHP] Re: [PHP-DB] php4 to php5
Sounds like you're talking about the register_globals functionality. It's a php.ini setting that will cause $_POST['foo'] or $_GET['foo'] to be copied to the global variable $foo. This is somewhat of a security risk, thus disabled by default. There's another superglobal array that you might find useful: $_REQUEST. $_REQUEST consists of variables from $_GET,$_POST,$_COOKIE (in that order, I believe). http://us3.php.net/manual/en/reserved.variables.php http://us3.php.net/manual/en/ini.core.php#ini.register-globals --GREG On Thu, Apr 3, 2008 at 6:40 PM, ioannes <[EMAIL PROTECTED]> wrote: > I suppose I am behind the time in migrating from php4 to 5. That said, my > main problem is getting variables recognised. I can see how to do it - you > need to identify all the variables that could be sent from the page and then > assign a name, as in $myvar=$_GET['myvar'] and ditto for POST variables if > any. Is there a function to convert all get and post variables to $_GET and > $_POST, or is that a security concern? The further I have got is this: > > function php5($var) { > if(ISSET($_POST[$var])&&$_POST[$var]<>"") { > $newvar=$_POST[$var]; > } else { > $newvar=$_GET[$var]; > } > return $newvar; > } > > $input_variable=php5('input_variable'); > > however I would like to do this for all variable, I tried iterating > through the $_GET and $_POST arrays but could not get it to work. > > Anyway the main reason I am writing is: > > - where the web page form uses the POST method, but there are parameters > in the URL after the ? sign, these 'get' parameters seem to stay there when > you submit the form from eg button. So, let's say the > script will add a line if addlines=y, if before you submit the form you have > ?addline=y in the URL you will continue to add lines according to the script > even though there is no hidden variable on the page called 'addline', > because every time you submit the form with POST you have addline=y in the > URL - if the script looks at GET variables then this will feed into the > script. This does not seem to happen with php4 - if the page does not > submit an 'addline' variable from a form field, it will not feed into the > script. So what's the rationale for that (the URL submitting the variables) > and what is the usual solution? The problem arises on this particular page > because of a mix of buttons, some are javascript and send the addline=y with > onClick. > > John > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] How to jump to line number in large file
fseek($handle, 1, SEEK_CUR); // or fseek($handle, $pos) $t = fgetc($handle); This probably won't help you, but given a quick glance, it looks like you're incrementing the file pointer by 2 positions on each iteration of your while loop. The fgetc() function returns the character at the current position and increments the file pointer by 1. I haven't tried this, but perhaps using strpos would be faster? Use strpos to seek to find the first "\n", then use the offset parameter to seek to the second, and so on, until strpos() returns false. --GREG
Re: [PHP] Arbitrary mathematical relations, not just hashes
On Sun, Apr 6, 2008 at 7:52 PM, Kelly Jones <[EMAIL PROTECTED]> wrote: > Many programming languages (including Perl, Ruby, and PHP) support hashes: > > $color['apple'] = 'red'; > $color['ruby'] = 'red'; > > $type['apple'] = 'fruit'; > $type['ruby'] = 'gem'; > > This quickly lets me find the color or type of a given item. > > In this sense, color() and type() are like mathematical functions. > > However, I can't easily find all items whose $color is 'red', nor all > items whose $type is 'fruit'. In other words, color() and type() > aren't full mathematical relations. > > Of course, I could create the inverse function as I go along: > > $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to > value > > and there are many other ways to do this, but they all seem kludgey. > > Is there a clean way to add 'relation' support to Perl, Ruby, or PHP? > > Is there a language that handles mathematical relations > naturally/natively? > > I realize SQL does all this and more, but that seems like overkill for > something this simple? > > -- > We're just a Bunch Of Regular Guys, a collective group that's trying > to understand and assimilate technology. We feel that resistance to > new ideas and technology is unwise and ultimately futile. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Arbitrary mathematical relations, not just hashes
(sorry I just hit send on a blank email; I'm absent-minded) First, in the strictest mathematical sense, a relation from a set $a to a set $b is a subset of the cross-product $a x $b. (obviously, the mathematical notation is not a great way to represent this in a program.) Hence, a relation is a set of ordered pairs: array(array('apple','red'), array('ruby','red')) is a relation from the objects to the colors. For a relation R from A to B, the inverse relation is defined by (b,a) for all a in A and B in b. Thus, the inverse relation of objects ~ colors would be: array(array('red','apple'), array('red','ruby')). A function is a special case of a relation: functions have the property that if a in A is related to b in B by the relation R and a is related to c by the relation R, then a = c. It follows that mathematically, there is no function f:color->object. As you suggest, each element of the relation colors~objects relation must return a list in order to be a function. So... How does SQL solve this problem? SQL has indexes. You have a list of objects: 'apple', 'type' => 'fruit', 'color' => 'red' ), array( 'name' => 'ruby', 'type' => 'gem', 'color' => 'red' ) ); ?> Given a type, you would like to find all objects with that type. One way to accomplish this might be: Obviously, the time increased to complete a search will increase with the size of the $objects array. This is where the indexes come in: Suppose we would like to easily be able to locate an object given a color, a type, or its name: $object) foreach ($keys as $key) { if (!isset($indexes[$key][$object[$key]])) $indexes[$key][$object[$key]] = array(); $indexes[$key][$object[$key]][] = $n; } ?> The above produces the following array: Array ( [color] => Array ( [red] => Array ( [0] => 0 [1] => 1 ) ) [type] => Array ( [fruit] => Array ( [0] => 0 ) [gem] => Array ( [0] => 1 ) ) [name] => Array ( [apple] => Array ( [0] => 0 ) [ruby] => Array ( [0] => 1 ) ) ) Conceptually, this is all SQL does. Anyway... I wouldn't actually do any of that in an application. I'd probably go with what Casey suggested. -- GREG Disclaimer: The above is intended only to be conceptual. Any attempt at parsing may fail. Technical accuracy is not guaranteed. P.S. Sorry for the math. I was bored :p > However, I can't easily find all items whose $color is 'red', nor all > items whose $type is 'fruit'. In other words, color() and type() > aren't full mathematical relations. > > Of course, I could create the inverse function as I go along: > > $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to value By definition, not all relations are functions, nor all functions invertible. The function inverse_color(object) specifies more than What you're referring to sounds like an index: given an object, you can easi On Sun, Apr 6, 2008 at 8:15 PM, Casey <[EMAIL PROTECTED]> wrote: > On Sun, Apr 6, 2008 at 4:52 PM, Kelly Jones <[EMAIL PROTECTED]> > wrote: > > Many programming languages (including Perl, Ruby, and PHP) support > hashes: > > > > $color['apple'] = 'red'; > > $color['ruby'] = 'red'; > > > > $type['apple'] = 'fruit'; > > $type['ruby'] = 'gem'; > > > > This quickly lets me find the color or type of a given item. > > > > In this sense, color() and type() are like mathematical functions. > > > > However, I can't easily find all items whose $color is 'red', nor all > > items whose $type is 'fruit'. In other words, color() and type() > > aren't full mathematical relations. > > > > Of course, I could create the inverse function as I go along: > > > > $inverse_color['red'] = ['apple', 'ruby']; # uglyish, assigning list to > value > > > > and there are many other ways to do this, but they all seem kludgey. > > > > Is there a clean way to add 'relation' support to Perl, Ruby, or PHP? > > > > Is there a language that handles mathematical relations > naturally/natively? > > > > I realize SQL does all this and more, but that seems like overkill for > > something this simple? > > > > -- > > We're just a Bunch Of Regular Guys, a collective group that's trying > > to understand and assimilate technology. We feel that resistance to > > new ideas and technology is unwise and ultimately futile. > > > > > Something like this? > > $objects = array( > 'apple' => array( > 'type' => 'fruit', > 'color' => 'red' > ), > 'ruby' => array( > 'type' => 'gem', > 'color' => 'red' > ) > ); > > // Search for all red objects. > $red = array(); > foreach ($object
Re: [PHP] limit mail() function
As far as I know, there's no way you can do this via PHP. PHP doesn't "know" about users on the system. Generally, PHP is run as an apache module, and thus the scripts are run as the user apache is running as. So to start with, you'd probably need to be running a Fast CGI + SuExec setup or something similar. I'm not sure how, or if there is a way to do this in postfix. The mail() function calls the sendmail binary, so one sort of hackish way might be to move this binary and write a wrapper script that keeps track of per-user rate limits, and then invokes the real sendmail binary. Of course, in this case, you'd also probably want to make sure the real sendmail binary couldn't be executed and that users could not write to the file that keeps track of the rate-limit. -- Greg On Tue, Apr 8, 2008 at 12:37 PM, Jordi Moles <[EMAIL PROTECTED]> wrote: > hello everyone, > > first of all... i'm sorry if this has been asked like a million times > before... but i've been looking for info about this and found nothing so > far. > > anyway > > I've got a server with apache2 and postfix and php5 providing hosting to > some clients. I've got this big problem about clients sending spam > massively, either consciously or because they website have been hacked. The > main way to spam is by using the "mail()" function. > So far, i've only found how to disable the use of the mail() function > completely in the php.ini file, but it's not a really good option to me, > cause i run some server scripts to check for some things and they send some > mails when they find something wrong. > > So... i would like to know what options i have if i want to limit this > function... > > can i disable the function only for some users? > may be i can set a rate limit for it? > > thanks. > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] limit mail() function
>Pardon me, but that's one kludgy idea Hence my use of the term hackish. But really, is isn't all that kludgy. An software solution that implements this natively would have to keep track of the stats somehow; undoubtely via some sort of stats file. So the real difference is that two processes are run, instead of one. Yet, by the same "wrapper" logic, is it not kludgy that php invokes the sendmail binary, instead of using some sort of native php implementation? And again, by the same logic, the sendmail binary that comes with many MTAs is simply a wrapper to allow normal sendmail usage. >postfix has rate-limitation facilities you can use for this I'm aware of several configuration directives that limit rate, none of which directly limit the send rate local users. Perhaps some kludgly or elusive trick involving multiple options would do the trick; I don't claim to be a postfix expert. Perhaps, instead of making empty statements, you might choose to enlighten me as per the exact configuration that will accomplish this. Of course, I spent some time googling, but it appears that not too many people know (or at least write about) how to implement such functionality. I did manage to find two interesting items in my searches: http://www.postfix.org/anvil.8.html http://www.opennix.com/email/postfix/policy/ratelimit.html The former doesn't appear to be magical, and from what my limited and apparently klugdy thoughts permit me to deduce, it seems to bear, conceptually, at least a degree (Celsius, mind you) of similarity to the aforementioned kludgy statistics idea... I didn't find any documentation regarding the implementation of anvil. And the latter, well that's not even a native postfix solution, so apparently, I have failed to find the alleged rate-limitation. All cynical, superficial, and sarcastic storming somewhat consummate, I can at last take solace knowing that I would, had you _suggested_ a better solution, or had I not, kludgy though it apparently was, put some effort into finding a solution, pardoned you. And with the sarcasm, sincerity, and cynicism now accomplished, permit me to offer my most sincere apologies for the above rude, and overly verbose post. -- Greg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require_once dying silently
Is it possible that something is "going wrong" between the definition of $CFG->foo and when you require that could cause $CFG->dirroot to be null? Then it would point to /lib/setup.php, which definitely shouldn't exist and should thus throw an error, but maybe it's worth looking into. That would rule out any error reporting problems anyway. Have you tried something to the effect of on the first line of setup.php? Adding after the require_once() might also help. > I've confirmed that the file setup.php exists and is readable. I apologize if this seems obvious, but for the sake of brainstorming... it's readable by the user running apache, right? And even if it weren't, that should have thrown an error *shrugs* That's all I can think of. I hope it is of some use to you. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] require_once dying silently
>the above won't work, as the parser will try to interpret $CFG and put it in the string first, In that case, $CFG is either null, or it is indeed an object. If it is a standard object, which I it appears to be, then a fatal error will be thrown because there is no __tostring() function. If it's null, then require_once is referencing a directory beginning with '->', again, there *should* be an error. Anyway.. I've seen $obj->property used many times in double quotes, and never had a problem with that working. Personally though, I always use the curly braces though because it highlights better in VIM :p >Also, OOP is nice and all (not to start a thread about OOP again), but putting your config into an object seems a bit overdo to me. Me too!! (not to continue the unstarted OOP discussion) It's a practice I've seen used more than once. I think people find that syntax attractive. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Socket create with ssl server
The sockets extension is a much "lower" level interface to sockets than the fsockets/stream_ functions in PHP. Unlike with the aforementioned, with the sockets extension, you can't just expect to magically get an ssl connection by using "ssl://". Your problem is that the sockets extension has no idea what you mean by "ssl://"; and since "ssl://foo" is clearly not a valid domain name, resolution fails. Short Answer: use fsockets if you need SSL ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Hack question
> I can sort of figure what is doing; but, I can't figure out what the hacker > is using it for. It will allow him to upload and execute arbitrary code on your server. Generally speaking, arbitrary code execution is a bad thing. :). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] WHERE is syntax doc'ed for saying: if (expr1 *OR* expr2 *AND* expr3)
if (stripos(strrev($file), "gpj.") === 0) || (stripos(strrev($file), "fig.") === 0) || (stripos(strrev($file), "gnp.") === 0) { You have too many parenthesis: if (stripos(strrev($file), "gpj.") === 0) <-- this ends the if statement; the next || is unexpected. Also, at the end, you're missing a parentheses at the end: (stripos(strrev($file), "gnp.") === 0) should be(stripos(strrev($file), "gnp.") === 0)) -- GREG
Re: [PHP] Source Code Analysis
>Perhaps detecting >if a variable has not been initialized within the code This is an E_NOTICE level error. [EMAIL PROTECTED] ~ $ php test.php Notice: Undefined variable: foo in /home/mario/test.php on line 3
Re: [PHP] Query-within-a-query with mySQL/PHP
>Basically I somehow need to do a GROUP BY producer, and yet somehow at the same time, find out all the matching vintages (years), that go along with that group and return them the same time the producer group is returned. If I'm following you correctly, you have a column "year" in your group, and rather than returning just one year in your result set, you would like every year in the group. This can be accomplished with the group_concat() [1] function: SELECT field1,field2,field3, GROUP_CONCAT(distint year) as years FROM table WHERE conditions GROUP BY foo; [1] http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat -- GREG.