php-general Digest 5 Sep 2005 19:57:24 -0000 Issue 3665

Topics (messages 221853 through 221872):

Re: online/offline...but on a list of users
        221853 by: Shaw, Chris - Accenture
        221861 by: Edward Vermillion

Passing by reference, assigning by reference?
        221854 by: Alex Gemmell

Re: exec() may not be safe
        221855 by: Ilja Polivanovas
        221870 by: Rory Browne

Ticket Number
        221856 by: Kenny

how to divide string
        221857 by: Adi Zebic
        221858 by: Shafiq Rehman
        221859 by: Kevin Waterson

Re: AND OR NOT
        221860 by: John Taylor-Johnston
        221863 by: David Robley

Re: I have a special problem
        221862 by: Rory Browne

disable safe_mode with .htaccess ?
        221864 by: Wong HoWang
        221868 by: Rory Browne

Re: Scary nonsense form submissions
        221865 by: Lowell Allen

howto send a whole smarty page to a printer
        221866 by: Steven
        221867 by: David Dorward
        221869 by: £ukasz 'nostra' Wojciechowski
        221871 by: Mikey

Re: Filter based on ctype_print()
        221872 by: Rick Emery

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:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
> <clip>
> > I want to add this same functionality to a forum on the

> same site (the
> forum
> > was custom programmed
> > from scratch and not any of the popular ones), but since in a single
> thread
> > there can be a lot of different
> > people/usernames that answer I would prefer _not_ to do a

> select lookup
> for
> > each username...
> > any ideas on how else it can be done?
> </clip>
>

> I'd say start with a query that pulls the online users into an array,
> then do an array_key_exists() or in_array() against that.
>

> --------------------------------------------
>

> Thanks! Thats a really good idea and one that i didnt think of.
>

> For now it should be okay as there are just a few hundred users, but
> if it gets really big then it might be a bit of a problem...
> if you any other ideas please feel free to reply till then

> I'll try your
> idea out.
>


What about using the 'in' or 'exists' keyword in sql.

for example:
select * from (select username from <the rest of your online select
statement>) a
where a.username in ($username, $username, $username ..)

Use some for loop to build up your 'in' statement.

A better way to do it is using joins and the exists statement, but its too
early for that. :)


************************

This message has been delivered to the Internet by the Revenue Internet e-mail 
service

*************************

--- End Message ---
--- Begin Message ---
Ryan A wrote:
<clip>

I want to add this same functionality to a forum on the same site (the

forum

was custom programmed
from scratch and not any of the popular ones), but since in a single

thread

there can be a lot of different
people/usernames that answer I would prefer _not_ to do a select lookup

for

each username...
any ideas on how else it can be done?

</clip>

I'd say start with a query that pulls the online users into an array,
then do an array_key_exists() or in_array() against that.

--------------------------------------------

Thanks! Thats a really good idea and one that i didnt think of.

For now it should be okay as there are just a few hundred users, but
if it gets really big then it might be a bit of a problem...
if you any other ideas please feel free to reply till then I'll try your
idea out.

Thanks,
Ryan





One of the things to think about with this is, although you may have a few hundred users signed up how many are "online" at once. I've got a forum with a few thousand members, but at any one time there's only about 15 average that are "online". It peaks at about 45 sometimes, but that's rare. So the array in this case is relativly small. Plus it lets you do other things with the infomation like "There are X users online", showing who is reading what and stuff like that.

If your running a site like MySpace or DA then it could be a problem. They tend to break things down though into smaller groups like showing your "friends", or whatever they call them, that are "online".

Another idea that goes with what Chris had said is to use a join on your "online" table. I'm assuming that your having to do a lookup for each post in the forum anyway, just join the "online" table here against the members id or name or whatever your using to track who makes the individual posts. How you do it exactly really depends on how you're building up the forums page.

That would probably be a better situation all around if you're doing a query for each post anyway.
--- End Message ---
--- Begin Message ---
Hi sports fans!

I have a quick "references" related question.

Ok, I'm passing a Page object by reference to another object:

myClass->myFunction($objPage);

What I want to do is store that Page object as part of the myClass object (see definition code below).

My question is this: When assigning the Page object to be a variable of the myClass object do I store a reference to it or a copy of the reference?

class myClass()
{
        var $objPage;

        function myFunction(&$objPage) {
                // this way (a reference to the reference?):
                $this->objPage =& $objPage;

                // or this way (a copy of the reference?):
                $this->objPage = $objPage;

                // code, code, code...
        }
}

Is there much difference? Does it really matter? I'm unsure if this is efficient or not.

Can someone please shed some light on this.

Thanks!

--- End Message ---
--- Begin Message --- By the way Zend Optimizer 2.5.7 is also installed in that PC. Does anybody know what does that [warn] means ?

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

--- End Message ---
--- Begin Message ---
AFAIK Apache on win98 does that.

It's warning you that you are doing unsafe stuff on an unsafe "OS".

On 9/5/05, Ilja Polivanovas <[EMAIL PROTECTED]> wrote:
> By the way Zend Optimizer 2.5.7 is also installed in that PC. Does anybody
> know what does that [warn] means ?
> 
> --
> Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
Hello,

We're in the midst of creating a high volume transaction platform with PHP and MySQL. Each transaction ties to a transaction ID that is in turn an auto_increment, unsigned BIGINT(12).

The problem now is I do not want users to see this running transaction ID when using the system (such that we can roll out surprises for the customer of, say, the 10th million transaction).

We plan to convert the id to something like [A-Z0-9]-[checksums], (e.g. 1X2Z0HTDEKS93-C8P), for simple input-error detection, and we can use it to lookup the relevant id from the database.

Which algorithm(s) in your opinion is the best for the encrypted transaction ID and checksum such that:
- Transaction ID should always be unique
- Running sequence is not predictable (when you have 2 transactions, you don't know how many transactions are between them) - Contains only alphanumeric and case insensitive letters of not more than 15 characters, excluding checksum

We've thought of using the first 15 characters of a MD5 hash, so we can kind of SELECT substring(MD5(t_id)... during lookup, and CRC16 for the checksum. Someone also suggests scrapping the auto_increment field from db and generate our own using the below method

while (t_id exists in db)
  randomize

but i see the 2nd method being quite taxing to the server as you have to query at least one time per transaction.

I appreciate all inputs. Thanks!

Sincerely,
Kenny

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

is there any magic function who can give me from:

$string = " abcdefghijklmnopqrstuwvxyz";

somthing like this:

abcd
efgh
ijkl
mnop
qrst
uwvx
yz

(each 'x' letters go to the next line)

Thanks a lot,

ADI

--- End Message ---
--- Begin Message ---
Hi Zebic

It is pretty much simple./ Look into the code

$text = "abcdefghijklmnopqrstuwvxyz";
$newtext = wordwrap($text, 4, "<br>", 1);
echo $newtext;

// if you want all these chunks in an array use it as
$array = explode("<br>", $newtext);

echo $array[0];
echo $array[1];
echo $array[2];

Regards
Shafiq [http://www.phpgurru.com]


On 9/5/05, Adi Zebic <[EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> is there any magic function who can give me from:
> 
> $string = " abcdefghijklmnopqrstuwvxyz";
> 
> somthing like this:
> 
> abcd
> efgh
> ijkl
> mnop
> qrst
> uwvx
> yz
> 
> (each 'x' letters go to the next line)
> 
> Thanks a lot,
> 
> ADI
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
*** phpgurru.com <http://phpgurru.com> [A php resource provider] ***

\\\|///
\\ - - //
( @ @ ) PHP is too logical for my brain
+---oOOo-(_)-oOOo------------------------------------------+
| Mian Shafiq ur Rehman
| phpgurru.com <http://phpgurru.com> [A php resource provider]
| 107 B, New Town, Multan Road
| Lahore Pakistan
|
| Mobile: 0300 423 9385
|
| ooo0 http://www.phpgurru.com
| ( ) 0ooo E-Mail: [EMAIL PROTECTED]
+---\ (----( )------------------------------------------+
\_) ) /
(_/

--- End Message ---
--- Begin Message ---
This one time, at band camp, Adi Zebic <[EMAIL PROTECTED]> wrote:

> is there any magic function who can give me from:
> 
> $string = " abcdefghijklmnopqrstuwvxyz";
> 
> somthing like this:
> 
> abcd
> efgh
> ijkl
> mnop
> qrst
> uwvx
> yz


$newstring=chunk_split("$string", 4, '<br />');

Kevin

-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

--- End Message ---
--- Begin Message --- Any ideas? Post kind of lost in there since Saturday. Is str_replace the best choice for case sensitive and for swapping " AND "?

<input TYPE="text" NAME="searchenquiry" VALUE="" size=30>

Any suggestion on how to swap AND OR NOT for mysql fulltext syntax in $searchenquiry? A simple parse for " AND " and then str_replace? Is str_replace appropriate for case?

John

--- End Message ---
--- Begin Message ---
John Taylor-Johnston wrote:

> Any ideas? Post kind of lost in there since Saturday. Is str_replace the
> best choice for case sensitive and for swapping " AND "?
> 
>> <input TYPE="text" NAME="searchenquiry" VALUE="" size=30>
>>
>> Any suggestion on how to swap AND OR NOT for mysql fulltext syntax in
>> $searchenquiry?
>> A simple parse for " AND " and then str_replace? Is str_replace
>> appropriate for case?
> 
> John

I think you have a slightly more complex situation than just replacing text
between what I assume is a LIKE or multiple WHERE situation and a fulltext
search. Perhaps if you can give an idea of the type of string you are
likely to get in $searchenquiry, and to what you wish to convert it, we
might be better placed to give advice.

I can envisage that you might get 'bananas NOT pears AND apples' in the
variable; I guess you would currently manipulate that to a query such as
 
"WHERE x = 'bananas' AND x <> 'pears' AND x = 'apples'"

(OK that's not a good example) but if you were to feed that to a fulltext
search you might want

WHERE MATCH (x) AGAINST ('+bananas -pears -apples' IN BOOLEAN MODE)

or maybe something else depending on the version of Mysql and exactly what
you are trying to do with your fulltext search.




Cheers
-- 
David Robley

Why do cats have canine teeth?

--- End Message ---
--- Begin Message ---
If you are uploading to a Unix or Linux server, then you can use the
chmod program to make your files writable.

If you want a program for your local computer to allow you to FTP your
files across, then check out this page.
http://www.thefreecountry.com/webmaster/freeftpclients.shtml

On 9/3/05, Populous Refurbished <[EMAIL PROTECTED]> wrote:
> Hi, with what program i can upload my files in ftp but make it writables, 
> beacause i cant's config nothing and start to build with php.
> &amp;nbsp;
> Thanks.
> 
>

--- End Message ---
--- Begin Message ---
Hello everyone,

I have a special question and want to ask here, hope anyone can answer me.

My server is Apache/1.3.33 with PHP/4.3.10
I have AllowOverride All in my httpd.conf and safe_mode = On in php.ini , I 
want to turn off safe_mode in one folder by .htaccess , is it possiable? I 
don't want to make changes to my httpd.conf or php.ini because that is a 
productive server and shouldn't restart it.

Please help, thank you!

--- End Message ---
--- Begin Message ---
By the looks of things you can't. 

safe_mode changability is set to PHP_INI_SYSTEM

You may be able to put a <Directory ...> type setting into the
httpd.conf file, and have apache re-read its config file by sending it
a USR1 signal.

As it is a production server you may want to test this on a dev server first:

On 9/5/05, Wong HoWang <[EMAIL PROTECTED]> wrote:
> Hello everyone,
> 
> I have a special question and want to ask here, hope anyone can answer me.
> 
> My server is Apache/1.3.33 with PHP/4.3.10
> I have AllowOverride All in my httpd.conf and safe_mode = On in php.ini , I
> want to turn off safe_mode in one folder by .htaccess , is it possiable? I
> don't want to make changes to my httpd.conf or php.ini because that is a
> productive server and shouldn't restart it.
> 
> Please help, thank you!
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

--- End Message ---
--- Begin Message ---
On Sep 4, 2005, at 12:06 PM, Brian Dunning wrote:

Hi all -

I have forms on a number of unrelated web sites that just send me an email for one purpose or another. There are 2 to 6 fields: name, email, comment, etc. No big deal.

Recently I've been getting a lot of weird submissions. I'll receive half a dozen at a time, with all the fields filled with some kind of garbage contents. Here is one example from a form on my americansubstandard.com site:

---snip---
COMMENT: [EMAIL PROTECTED]
NAME: [EMAIL PROTECTED]
---/snip---

Other times one of the fields will contain a complete multipart submission, like this:

---snip---
COMMENT: [EMAIL PROTECTED]
NAME: [EMAIL PROTECTED]
Content-Type: multipart/mixed; boundary=\"===============1655480186==\"
MIME-Version: 1.0
Subject: e8df6b7
To: [EMAIL PROTECTED]
bcc: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]
This is a multi-part message in MIME format.
--===============1655480186==
Content-Type: text/plain; charset=\"us-ascii\"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
xqofli
--===============1655480186==--
---/snip---

I wonder if this is some kind of automated attack attempt. Does anyone recognize this type of thing, and is it potentially dangerous? Should I do something about it?

- Brian

I've gotten the same kind of thing recently from a comment form. Something's definitely going around.

I modified my script to check for various mail header elements within the comments and return an error message if any are found. I also added two returns following my own mail headers, which supposedly prevents an injection of additional headers -- see <http://us2.php.net/manual/en/ref.mail.php#55112>. And see the recent thread on this list -- "Be careful! Look at what this spammer did."

--
Lowell Allen

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

I am using smarty with my php site, I know you can send a whole smarty template page to a variable, is their any way i can easily print that variable out. or am i going about this the wrong way.

I basically want to print the output of the page directly to the printer. I find using the Internet Explorer Print Page button, prints extra text on the top and bottom of the page, which i dont want, also it seems to effect my page formatting a little.

any help would be appreciated
Thanks
steve

--- End Message ---
--- Begin Message ---
Steven wrote:

> I basically want to print the output of the page directly to the
> printer.  I find using the Internet Explorer Print Page button, prints
> extra text on the top and bottom of the page, which i dont want, also it
> seems to effect my page formatting a little.

Presumably you want your HTML to be *rendered* (i.e. you don't want a print
out of the HTML source)? I'm not aware of any tool better then a browser
for doing that (although MSIE would not be my first choice). I'm yet to see
a browser which doesn't allow you to specify which (if any) headers and
footers should be added to the page. Look in your browser's preferences.

-- 
David Dorward       <http://blog.dorward.me.uk/>   <http://dorward.me.uk/>
                     Home is where the ~/.bashrc is

--- End Message ---
--- Begin Message ---
W odpowiedzi na maila (18:09 - 5 września 2005):

> Hi

Hello

> I am using smarty with my php site, I know you can send a whole smarty
> template page to a variable, is their any way i can easily print that
> variable out.  or am i going about this the wrong way.

Why don't you just make another template file witch would be more
printer friendly (i.e. just formated text). You would take your
compiled variable, parse it (threw away all img,swf etc.) and give it
to print tpl.

Personaly I do it with CSS ... i just change my
layout.css to layout_print.css with no backgrounds and black text. But
images still remain.

You can even use XSL ... but it would
require to redesign whole presentation part of your website. More info
here: http://www.w3.org/Style/XSL/

-- 
pozdrawiam
Łukasz "nostra" Wojciechowski
gg.1028640 * icq.23059512 * gsm.609.655.911


----------------------------------------------------------------------
Jedyny taki czat... >>> http://link.interia.pl/f18b0

--- End Message ---
--- Begin Message ---
Łukasz 'nostra' Wojciechowski wrote:

W odpowiedzi na maila (18:09 - 5 września 2005):

Hi

Hello

I am using smarty with my php site, I know you can send a whole smarty
template page to a variable, is their any way i can easily print that
variable out.  or am i going about this the wrong way.

Why don't you just make another template file witch would be more
printer friendly (i.e. just formated text). You would take your
compiled variable, parse it (threw away all img,swf etc.) and give it
to print tpl.

Personaly I do it with CSS ... i just change my
layout.css to layout_print.css with no backgrounds and black text. But
images still remain.

You can even use XSL ... but it would
require to redesign whole presentation part of your website. More info
here: http://www.w3.org/Style/XSL/

If you are running on a Linux server (your e-mail is confusing as a browser is client side and PHP cannot change what happens to the code once it has been sent) then you can use html2ps to render and print a page.

HTH,

Mikey

--- End Message ---
--- Begin Message ---
Quoting Robin Vickery <[EMAIL PROTECTED]>:

On 9/5/05, Rick Emery <[EMAIL PROTECTED]> wrote:

What I really want to do is replace the non-printable character(s) with
printable character(s) (maybe a question mark, or a space), but haven't
been able to find a function that will do it. Maybe something like:

$xmlOutput .= '<remark>';
$xmlOutput .= ctype_print_replace($remarks['Remark'], '');
$xmlOutput .= '</remark>';

$xmlOutput .= preg_replace('/[^[:print:]]/', '?', $remarks['Remark']);

Worked great, thanks!

Rick

--- End Message ---

Reply via email to