php-general Digest 12 Oct 2004 18:34:00 -0000 Issue 3049
Topics (messages 199251 through 199267):
Re: Is there any way of knowing User Currently Logged On?
199251 by: Warren Vail
199259 by: Gryffyn, Trevor
Re: sending SMS messages to mobile phones from PHP
199252 by: Andrew Cowles
B/W Image
199253 by: Ulrik Witschass
199256 by: M. Sokolewicz
199257 by: M. Sokolewicz
fpassthru failure with mozilla
199254 by: dthmtluncrn.gmail.com
199262 by: dthmtluncrn.gmail.com
199263 by: Matt M.
199264 by: ApexEleven
Program that does registration, rsvp, reminders, etc??
199255 by: James Stewart
With a graphic image, making text transparent
199258 by: Todd Cary
199260 by: Chris Dowell
Re: Working out the image path...partly solved, please have a look at my code
199261 by: Matt M.
Remote grabbed images are blank
199265 by: Mag
creating a folder in php
199266 by: Adil
199267 by: John Nichel
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 ---
If it throws out garbage, you should be able to execute the "who" command on
the remote system, which should show users that are currently signed on to a
Unix or Linux system and if you do it all in the perl script, you can format
the output to look pretty much the same (in case you haven't figured it out
the @users_list is an array, very similar to PHP arrays actually [IMHO]).
If you modified the perl script to detect the garbage, it could simply do a
telnet connection and execute the "who" command. There are probably ways
that use privileged commands similar to the one used for your windows
solution on remote Linux Unix, but I don't know them, and I'm not sure it's
a good idea to use them in a PHP script, but you can get opinions the other
way as well. If all your machines are behind the same firewall, away from
the internet, the risk could be less if you have a good firewall. For your
telnet connection from perl look for the net:telnet perl module at
http://www.cpan.org/modules/by-module/Net/ , if you know PHP you will find
perl quite easy I think.
Good luck.
Warren Vail
-----Original Message-----
From: Mulley, Nikhil [mailto:[EMAIL PROTECTED]
Sent: Monday, October 11, 2004 9:54 PM
To: Vail, Warren; Mulley, Nikhil; [EMAIL PROTECTED]
Subject: RE: [PHP] Is there any way of knowing User Currently Logged On?
Hi Vail,
My Worry is that If a remote OS is not Windows, then this would throw out
garbage,
Where as this Perl Script would work well at a Windows Side ,Bcoz I am using
the 'Win32' Module ,is there any other module such that .....
We cannot even predict ( or I believe there is no exact way ) what the
remote OS could be :(
Nikhil.
-----Original Message-----
From: Vail, Warren [mailto:[EMAIL PROTECTED]
Sent: Monday, October 11, 2004 11:33 PM
To: 'Mulley, Nikhil'; [EMAIL PROTECTED]
Subject: RE: [PHP] Is there any way of knowing User Currently Logged On?
If you code in php something like the following, you just might be able to
use the perl script;
$ok = exec("path/to/Perl myperscriptname.pl server", $result); // you may
have to straighten out syntax
Foreach($result as $line) {
echo $line; // or you could process the results
}
Hope this helps,
Warren Vail
-----Original Message-----
From: Mulley, Nikhil [mailto:[EMAIL PROTECTED]
Sent: Monday, October 11, 2004 9:52 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Is there any way of knowing User Currently Logged On?
Hi Guys,
Is there any way of finding the current user logged on the remote system
I have a perl script which gets the user name who is currently logged on a
remote Windows Machine
#LoggedOnUsers(server, userRef).pl
use Win32::NetAdmin;
use strict;
use vars qw($server @users_list);
if(@ARGV>0){
$server=$ARGV[0];
}
else{
print "\n\nEnter a valid Hostname or IP Address : ";
chomp($server=<STDIN>); }
Win32::NetAdmin::LoggedOnUsers($server,[EMAIL PROTECTED]);
foreach(@users_list) {
print "\n$server -- $_";
}
This one gets the users logged in on a remote Windows machine , Is there a
similar way of finding / doing the same regardless of an OS, Can it be done
through a Web Browser ????
Any Clues ??
--Nikhil.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B324274
Here's a link that talks about how to do it in IIS for Windows Server
2003. It's for when you're logging into a domain though, are you doing
that with all those different platforms? The client accessing the web
server has to be logged into the domain for it to function. There might
be something similar you can do if you're running a web server on a unix
system and you're logged into another unix system. And if your web
server is on a unix system, but your client is a Windows box with a
domain authenticated user, you can probably still access the LOGON_USER
variable.
-TG
> -----Original Message-----
> From: Mulley, Nikhil [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 12, 2004 1:02 AM
> To: Gryffyn, Trevor; [EMAIL PROTECTED]
> Cc: John Holmes; Mulley, Nikhil
> Subject: RE: [PHP] Is there any way of knowing User Currently
> Logged On?
>
>
> How do I turn on the Integrated Authentication turned on.
>
>
> Ours is a mixed heterogenous network which has
> Windows,Linux,Solaris,BSD Lindows,Linspire and many other OS
> all together,So How Do I?
>
> -----Original Message-----
> From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 12, 2004 1:07 AM
> To: [EMAIL PROTECTED]
> Cc: John Holmes; Mulley, Nikhil
> Subject: RE: [PHP] Is there any way of knowing User Currently
> Logged On?
>
>
> It does and Windows Integrated Authentication has to be turned on (and
> Anonymous access turned off).
>
> I just got my company to configure that so my PHP scripts
> could grab the
> authenticated user for logging purposes.
>
> -TG
>
> > -----Original Message-----
> > From: John Holmes [mailto:[EMAIL PROTECTED]
> > Sent: Monday, October 11, 2004 2:49 PM
> > To: Mulley, Nikhil
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Is there any way of knowing User Currently
> > Logged On?
> >
> >
> > Mulley, Nikhil wrote:
> >
> > > Is there any way of finding the current user logged on the
> > remote system
> >
> > You can try $_SERVER['LOGON_USER'], but I think the
> "remote" computer
> > has to be in the same domain as the server...
> >
> > --
> >
> > ---John Holmes...
> >
> > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
> >
> > php|architect: The Magazine for PHP Professionals - www.phparch.com
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--- End Message ---
--- Begin Message ---
You can send an SMS via kapow easily using PHP.
Here are a few examples of how you can send (via HTTP Get/Post & email).
assuming you have defined a couple of variables;
$user = "youruser";
$pass = "yourpass";
$mob = "447971325173";
$message = urlencode("This is just a test SMS message from kapow.co.uk");
You can send the message via HTTP Get using the fopen() function, like this;
fopen("http://www.kapow.co.uk/scripts/sendsms.php?username=$user&password=$pass&mobile=$mob&sms=$message","r")
That's it... your message will be on it's way (and should arrive within
about 10 seconds).
Alternatively you could send via email by using the mail() function;
mail("[EMAIL PROTECTED]","$message","$user\n$pass");
If you have set-up your account to automatically trust your sending address
then you don't need to include the user/pass details in the email, so it'd
work with just;
mail("[EMAIL PROTECTED]","$message","");
You can also make an HTTP Post. The best way to do this is by writing a
quick HTTP Post function using sockets... you should be able to find an
example on this mailing list. If not then I'll happily send you one.
Best regards,
Andy
Andrew Cowles
====================================
KAPOW! SMS Communication Solutions
WEB: http://www.kapow.co.uk/
EMAIL: [EMAIL PROTECTED]
TEL: 0870 757 1610 or FAX: 0870 757 1615
====================================
Cygnet Internet Services Ltd ( http://www.cygnet.co.uk/ )
====================================
Thanks. Your SMS service looks ideal for what I need but how do I make an
HTTP request from PHP to kapow?
Can I just use fopen()?
Please can you give a PHP example.
We operate an SMS Gateway service (http://www.kapow.co.uk/) which would
do
exactly what you need.
It's been reliably sending SMS since 1995 - and MANY of our clients use
PHP.
What you'd probably want to do is make an HTTP Get / Post request
directly
from your script to our servers, alternatively you can use our
Email-to-SMS
interface and then just generate an email.
Using either method with PHP should get you up and running in a few
minutes.
--- End Message ---
--- Begin Message ---
Hello List,
I browses the PHP Manual for some time now but didn't find exactly what I
was looking for.
I need to turn images uploaded by a user to b/w images to use them in
pdflib, the resulting PDF has to be black and white.
Now my question:
a) is this possible?
if(a)
b) do I do this with PHP Image functions (maybe colorallicate and stuff like
that) or is it possible to actually do that in PDFLib?
thanks in advance for any help
Ulrik
--- End Message ---
--- Begin Message ---
Ulrik Witschass wrote:
Hello List,
I browses the PHP Manual for some time now but didn't find exactly what I
was looking for.
I need to turn images uploaded by a user to b/w images to use them in
pdflib, the resulting PDF has to be black and white.
Now my question:
a) is this possible?
yes, it is.
if(a)
b) do I do this with PHP Image functions (maybe colorallicate and stuff like
that) or is it possible to actually do that in PDFLib?
I don't think it's doable using PDFLib, but you could write an
implementation yourself. Here's one I just wipped up (so it might not
work correctly).
<?php
$im = imagecreatefromWHATEVER($path);
$size = getimagesize($path);
$width = $size[0];
$height = $size[1];
$greyScaled = imagecreate($width, $height);
$pallet = array();
for($y=0;$y<$height;$y++) {
for($x=0;$x<$width;$x++) {
$index = imagecolorat($im, $x, $y);
$rgba = imagecolorsforindex($im, $index);
$newC = (($rgba['red']+$rgba['green']+$rgba['blue'])/3)
if(!isset($pallet[$newC])) {
$color = imagecolorallocate($greyScaled, $newC, $newC, $newC);
} else {
$color = $pallet[$newC];
}
imagesetpixel($greyScaled, $x, $y, $color);
}
}
header('Content-type: image/png');
imagepng($greyScaled);
imagedestroy($im);
imagedestroy($greyScaled);
?>
thanks in advance for any help
Ulrik
--- End Message ---
--- Begin Message ---
M. Sokolewicz wrote:
Ulrik Witschass wrote:
Hello List,
I browses the PHP Manual for some time now but didn't find exactly what I
was looking for.
I need to turn images uploaded by a user to b/w images to use them in
pdflib, the resulting PDF has to be black and white.
Now my question:
a) is this possible?
yes, it is.
if(a)
b) do I do this with PHP Image functions (maybe colorallicate and
stuff like
that) or is it possible to actually do that in PDFLib?
I don't think it's doable using PDFLib, but you could write an
implementation yourself. Here's one I just wipped up (so it might not
work correctly).
what'll ya know... seems I forgot a line (*ashamed*)
it should be
<?php
$im = imagecreatefromWHATEVER($path);
$size = getimagesize($path);
$width = $size[0];
$height = $size[1];
$greyScaled = imagecreate($width, $height);
$pallet = array();
for($y=0;$y<$height;$y++) {
for($x=0;$x<$width;$x++) {
$index = imagecolorat($im, $x, $y);
$rgba = imagecolorsforindex($im, $index);
$newC = (($rgba['red']+$rgba['green']+$rgba['blue'])/3)
if(!isset($pallet[$newC])) {
$color = imagecolorallocate($greyScaled, $newC, $newC, $newC);
$pallet[$newC] = $color; // notice this line? it was
missing :)
} else {
$color = $pallet[$newC];
}
imagesetpixel($greyScaled, $x, $y, $color);
}
}
header('Content-type: image/png');
imagepng($greyScaled);
imagedestroy($im);
imagedestroy($greyScaled);
?>
--- End Message ---
--- Begin Message ---
I'm using fpassthru so users must log in to have access to certain
files. The users are accessing the fpassthru script with an https
connection. The code works fine with IE but sends inline ascii text
with mozilla/firefox. The code looks like this:
$filepath = "bla/bla/files/";
$filename = "file.zip";
$fullpath = "$filepath/$filename";
header( ' Pragma: ');
header( ' Content-Type: application/force-download' );
header( ' Content-Type: application/octet-stream ' );
header( ' Content-length:'.(string)(filesize($fullpath)));
header( ' Cache-Control: private' );
header( " Content-Disposition: attachment; filename='$filename'");
$fh = fopen("$filepath/$filename", "rb");
fpassthru($fh);
Any ideas? Everything I've read says with the content type set to
application, and the disposition set to attachment I should be set,
but it doesnt seem to be the case.
--- End Message ---
--- Begin Message ---
I'm using fpassthru so users must log in to have access to certain
files. The users are accessing the fpassthru script with an https
connection. The code works fine with IE but sends inline ascii text
with mozilla/firefox. The code looks like this:
$filepath = "bla/bla/files/";
$filename = "file.zip";
$fullpath = "$filepath/$filename";
header( ' Pragma: ');
header( ' Content-Type: application/force-download' );
header( ' Content-Type: application/octet-stream ' );
header( ' Content-length:'.(string)(filesize($fullpath)));
header( ' Cache-Control: private' );
header( " Content-Disposition: attachment; filename='$filename'");
$fh = fopen("$filepath/$filename", "rb");
fpassthru($fh);
Any ideas? Everything I've read says with the content type set to
application, and the disposition set to attachment I should be set,
but it doesnt seem to be the case.
--- End Message ---
--- Begin Message ---
> $filepath = "bla/bla/files/";
> $filename = "file.zip";
> $fullpath = "$filepath/$filename";
>
> header( ' Pragma: ');
> header( ' Content-Type: application/force-download' );
> header( ' Content-Type: application/octet-stream ' );
> header( ' Content-length:'.(string)(filesize($fullpath)));
> header( ' Cache-Control: private' );
> header( " Content-Disposition: attachment; filename='$filename'");
>
> $fh = fopen("$filepath/$filename", "rb");
> fpassthru($fh);
it looks good to me. You might want to try: header('Pragma:
no-cache'); instead of header( ' Pragma: ');
Also, install http://livehttpheaders.mozdev.org/ on mozilla. Will
help with debugging
--- End Message ---
--- Begin Message ---
Why use fpassthru? I just use readfile, is there a difference?
On Tue, 12 Oct 2004 11:11:54 -0500, Matt M. <[EMAIL PROTECTED]> wrote:
> > $filepath = "bla/bla/files/";
> > $filename = "file.zip";
> > $fullpath = "$filepath/$filename";
> >
> > header( ' Pragma: ');
> > header( ' Content-Type: application/force-download' );
> > header( ' Content-Type: application/octet-stream ' );
> > header( ' Content-length:'.(string)(filesize($fullpath)));
> > header( ' Cache-Control: private' );
> > header( " Content-Disposition: attachment; filename='$filename'");
> >
> > $fh = fopen("$filepath/$filename", "rb");
> > fpassthru($fh);
>
> it looks good to me. You might want to try: header('Pragma:
> no-cache'); instead of header( ' Pragma: ');
>
> Also, install http://livehttpheaders.mozdev.org/ on mozilla. Will
> help with debugging
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>
--- End Message ---
--- Begin Message ---
On Oct 11, 2004, at 2:06 PM, John Holmes wrote:
Does anyone know of a program that does event and user registration,
sends RSVPs, reminders, etc?? I'm basically looking for a _simple_
evite.com clone I can use on a site.
The only one I've found in a quick search is iVITE at
http://www.hotscripts.com/Detailed/31859.html. Does anyone have any
recommendations on that script or any other ideas?
I did some searching for such a system a couple of months back,
primarily looking for something free. The one system I found was an
extremely messy perl implementation which I ditched after a couple of
hours' testing.
In the end, I started work on my own. It's in perl (wanted to get some
more experience with CGI::Application), uses MySQL and still needs a
fair bit of work (other projects got in the way) but if you want to try
it out it's on my site at:
http://jystewart.net/webdev/invite.html
James.
--
James Stewart : Web Developer
Work: http://jystewart.net
Play: http://james.anthropiccollective.org
--- End Message ---
--- Begin Message ---
I would like to place text on a graphic but vary the transparency of the
text. Can this be done with the gd library?
Todd
--- End Message ---
--- Begin Message ---
http://uk.php.net/imagecolorallocatealpha
Todd Cary wrote:
I would like to place text on a graphic but vary the transparency of
the text. Can this be done with the gd library?
Todd
--- End Message ---
--- Begin Message ---
> /../imgs/blah.jpg should return
> http://www.textx.com/t1/t2/imgs/blah.jpg
>
> but its returning:
> http://www.textx.com/t1/t2/t3/imgs/blah.jpg
>
> and this: /../../imgs/blah.jpg
> should return: http://www.textx.com/t1/imgs/blah.jpg
>
> but its returning:
> http://www.textx.com/t1/t2/imgs/blah.jpg
>
> in both cases one extra level directory :-(
>
> Any ideas?
ok, I gave it a try and honestly this is probably over my head :) but
here is something to try
<?php
$url='http://www.textx.com/t1/t2/t3/blah.html';
function ret_url($rel_path, $base = '')
{
$base_path = substr($base, 0, strpos($base, '/',7));
if(substr($rel_path,0,1)=='/' && strpos($rel_path,'/../') === false)
{
return $base_path.$rel_path;
}
elseif(strpos($rel_path,'://') > 0)
{ return $rel_path; }
else {
return collapse(dirname($base),$rel_path);
}
return $rel_path;
}
/* this function removes the /../ parts */
function collapse($path,$rel_path)
{
$parsed = parse_url($path);
preg_match_all('/\/\.\./',$rel_path, $matches);
if(($count = count($matches[0])) > 0) {
$parts = preg_split('/\//', $parsed['path'], -1, PREG_SPLIT_NO_EMPTY);
for ($i = 1;$i <= $count; $i++) {
array_pop($parts);
}
$path = str_replace($parsed['path'], '/'.implode($parts,'/'), $path);
}
$rel_path = (preg_match('/^\//',$rel_path)) ? $rel_path :'/'.$rel_path;
$path = preg_replace('/\/\.\./', '', $path.$rel_path);
return $path;
}
$uris = array();
$uris[] = '/blah.jpg';
$uris[] ='/imgs/blah.jpg';
$uris[] ='imgs/blah.jpg';
$uris[] ='../imgs/blah.jpg';
$uris[] ='/../imgs/blah.jpg'; // ## not working ##
$uris[] ='/../../imgs/test.jpg'; // ## not working ##
$uris[] ='http://some-site-blah.com/imgs/blah.jpg';
echo '<table border=1>';
foreach($uris as $uri)
{
echo '<tr><td>'.htmlspecialchars($uri).'</
td><td>'.htmlspecialchars(ret_url($uri,$url)).'</td></tr>';
}
echo '</table>';
?>
--- End Message ---
--- Begin Message ---
Hi,
I got a pretty good code snippet from Zend to grap a
remote image and save it to disk, the problem is, when
it saves to my disk i am unable to open the
images...they are blank and the file matches the
remote images filesize...
Heres the code I got from Zend:
############ Start code ##############
<?php
function GrabImage($url,$filename="") {
if($url==""):return false;endif;
if($filename=="") {
$ext=strrchr($url,".");
if($ext!=".gif" && $ext!=".jpg"):return
false;endif;
$filename=date("dMYHis").$ext;
}
ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img);
[EMAIL PROTECTED]($filename, "a");
fwrite($fp2,$img);
fclose($fp2);
return $filename;
}
$img=GrabImage("URL-TO-IMAGE-COMES-HERE","");
if($img):echo '<pre><img
src="'.$img.'"></pre>';else:echo "No image
there.";endif;
?>
############### End image code ###########
Any idea whats wrong?
Thanks,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
Here's what i'm trying to do in php and using a mySQL database:
I want a button on a page that if clicked it launches the browser's or OS's
"Save As" window, allowing me to specify where to save my file and/or create
a new folder. This needs to work on Mac and PC.
thx in advance
Adil..
--- End Message ---
--- Begin Message ---
Adil wrote:
Here's what i'm trying to do in php and using a mySQL database:
I want a button on a page that if clicked it launches the browser's or OS's
"Save As" window, allowing me to specify where to save my file and/or create
a new folder. This needs to work on Mac and PC.
thx in advance
Adil..
RTFM
http://us2.php.net/header
--
John C. Nichel
�berGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--- End Message ---