php-general Digest 30 Apr 2007 19:15:24 -0000 Issue 4765
Topics (messages 254137 through 254150):
Re: PHP & MySQL -> Field Title
254137 by: Oliver Block
254138 by: Christian Haensel
Re: phpbb / sessionid nightmare
254139 by: Stut
Re: Object-oriented $_REQUEST?
254140 by: Philip Thompson
Run a script apart from request
254141 by: Brad Fuller
254142 by: Buesching, Logan J
254144 by: Eric Butera
set_time_limit failing...
254143 by: Ashley M. Kirchner
About resource of popen
254145 by: Fernando chucre
Re: small picture into thumbnail
254146 by: WeberSites LTD
254148 by: Robert Cummings
postgreSQL and bytea / image
254147 by: Alain Roger
PHP + COM (IE Button COM Server)
254149 by: Iqbal Naved
What does "<<<" mean?
254150 by: Nick Gorbikoff
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 ---
Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:
> but now I have the problem with the field names and all... can someone
> point me into the right direction?
<http://www.php.net/manual/de/ref.mysql.php>
php-db at lists.php.net
If you need to use an assoc array, use the following SQL Syntax:
INSERT INTO new_table SET key0=value0, key2=value2, ...,
Regards,
Oliver
--- End Message ---
--- Begin Message ---
Hi Oliver,
below is what I used.
----------------------------------------------------
<?
mysql_con();
$insert_q = "INSERT INTO DB1 VALUES(";
$query = "SELECT * FROM vorlauf WHERE satz_nr = '$fzg_id' LIMIT 1";
$doit = mysql_query($query);
$data = mysql_fetch_assoc($doit);
for($i=0; $i<=126; $i++) {
$fieldname = mysql_field_name($doit, $i);
$value = $data[$fieldname];
if($value == "") {
$value="0";
}
if($fieldname == "lfd_id") {
$value="";
}
echo $fieldname." --> ".$value."<br>";
$titel = $fieldname;
$insert_q .= ",'$value'";
}
$insert_q = $insert_q.')';
$insert_q = eregi_replace("\(,","(", $insert_q);
echo "<p>";
echo $insert_q;
mysql_query($insert_q) or die(mysql_error());
echo "Yup";
$del_q = "DELETE FROM vorlauf WHERE satz_nr = '$fzg_id' LIMIT 1";
$do_del = mysql_uery($del_q);
?>
------------------------------------------------
I'm sure there are better ways to do the whole thing :o) But as long as I
need to cpy one record at a time, I don't really care much for speed. I just
put all the stuff into a string and then use that string as query for the
insertion into the second database.
Scripts like that make me feel good when I say "You can be dumb as heck, ás
long as you find a way to resolve your problems" :o) It works, and it took
me just about 10 minutes of research and another 10 of writing :o)
Hope your weather is just as good as ours here...
All the best!
Chris
----- Original Message -----
From: "Oliver Block" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Christian Haensel" <[EMAIL PROTECTED]>
Sent: Monday, April 30, 2007 1:11 PM
Subject: Re: [PHP] PHP & MySQL -> Field Title
Am Montag, 30. April 2007 07:47 schrieb Christian Haensel:
but now I have the problem with the field names and all... can someone
point me into the right direction?
<http://www.php.net/manual/de/ref.mysql.php>
php-db at lists.php.net
If you need to use an assoc array, use the following SQL Syntax:
INSERT INTO new_table SET key0=value0, key2=value2, ...,
Regards,
Oliver
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Brad Sumrall wrote:
Does anyone know what this _utma _utmb _utmc _utmz stuff is?
Obviously it is not a php standard.
Obviously it is what is actually controlling my sessions?
These come from Google services (analytics, adsense, etc), they have
nothing to do with your sessions.
-Stut
--- End Message ---
--- Begin Message ---
On Apr 28, 2007, at 5:13 PM, Robert Cummings wrote:
On Sat, 2007-04-28 at 23:41 +0200, keviN wrote:
<?php
class get
I'm sorry but your code indicates an extreme lack of experience using
PHP in the real world. Your class should be named such that it will
never collide with someone else's class name in the event you might
need
to use third party libraries. A better name for your class follows:
<?php
class get_Z398N24N894287YN043872348N734D83Y78N7D7834
{
}
$get = new get_Z398N24N894287YN043872348N734D83Y78N7D7834();
?>
LOL!!
--- End Message ---
--- Begin Message ---
Hi all,
I am developing a program that does some intensive data processing, and is
triggered from a page hit and/or a SOAP request.
The processing takes on average 30 seconds to 1 minute, which is OK for a
web page (I can use set_time_limit(0) and just display a pseudo-progress bar
animated gif and a "Please wait..." message) but I can't leave the SOAP
request hanging for that long. I need to send a response immediately.
What I really need to do is acknowledge the client that their request has
been received and will be processed, and terminate that request... and THEN
begin the processing.
One way I thought of doing it would be to put the requests into the database
and run a cron job every X minutes, but I would like to avoid this if at all
possible.
Someone had suggested pcntl_fork() but I'm not sure if that will accomplish
what I need it to... if I fork(), then send a response, kill the parent and
let the child run the process, will the HTTP request wait for the child or
will it die with the parent (like I want it to) ?
Any advice is much appreciated.
Thx,
Brad
--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Brad Fuller [mailto:[EMAIL PROTECTED]
> Sent: Monday, April 30, 2007 10:55 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Run a script apart from request
>
> Hi all,
>
> I am developing a program that does some intensive data processing,
and is
> triggered from a page hit and/or a SOAP request.
>
> The processing takes on average 30 seconds to 1 minute, which is OK
for a
> web page (I can use set_time_limit(0) and just display a
pseudo-progress bar
> animated gif and a "Please wait..." message) but I can't leave the
SOAP
> request hanging for that long. I need to send a response immediately.
>
> What I really need to do is acknowledge the client that their request
has
> been received and will be processed, and terminate that request... and
THEN
> begin the processing.
>
> One way I thought of doing it would be to put the requests into the
database
> and run a cron job every X minutes, but I would like to avoid this if
at all
> possible.
>
> Someone had suggested pcntl_fork() but I'm not sure if that will
accomplish
> what I need it to... if I fork(), then send a response, kill the
parent and
> let the child run the process, will the HTTP request wait for the
child or
> will it die with the parent (like I want it to) ?
>
> Any advice is much appreciated.
>
> Thx,
>
> Brad
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
I am not completely familiar with how forking works in PHP applications,
but I am fairly familiar with how it works in UNIX. If you kill the
parent process, I believe it will close the HTTP request, but since it
doesn't handle the SIGCHLD signal after the child is done, the child
process will be left as a zombie process. I believe the only way to
catch the SIGCHLD is to have the script pcntl_waitpid(), which would
then hang the HTTP request.
I haven't tested this, but you can easily test it by:
$pid = pcntl_fork();
if($pid == -1) {
// Something went wrong (handle errors here)
} elseif($pid == 0) {
// This part is only executed in the child
usleep(5000000); //wait 5 seconds... see if the request hangs here
} else {
die();
}
Then wait and see what happens.
Maybe there is someone more experience in this area that can put a few
words in, but that is what I believe to be the case.
-Logan
--- End Message ---
--- Begin Message ---
On 4/30/07, Brad Fuller <[EMAIL PROTECTED]> wrote:
Hi all,
I am developing a program that does some intensive data processing, and is
triggered from a page hit and/or a SOAP request.
The processing takes on average 30 seconds to 1 minute, which is OK for a
web page (I can use set_time_limit(0) and just display a pseudo-progress bar
animated gif and a "Please wait..." message) but I can't leave the SOAP
request hanging for that long. I need to send a response immediately.
What I really need to do is acknowledge the client that their request has
been received and will be processed, and terminate that request... and THEN
begin the processing.
One way I thought of doing it would be to put the requests into the database
and run a cron job every X minutes, but I would like to avoid this if at all
possible.
Someone had suggested pcntl_fork() but I'm not sure if that will accomplish
what I need it to... if I fork(), then send a response, kill the parent and
let the child run the process, will the HTTP request wait for the child or
will it die with the parent (like I want it to) ?
Any advice is much appreciated.
Thx,
Brad
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
This topic comes up every now and again. You can search the mailing
list archives for all sorts of answers. You can also handle this by
using fsockopen and hitting your execute script with a low timeout.
That way it will execute and you don't have to wait for it.
--- End Message ---
--- Begin Message ---
The manual says that set_time_limit has no effect when PHP is
running in safe_mode. Then I have a problem. I have the global
safe_mode turned ON, however I have 'php_admin_value safe_mode 0' set
in a vhost's config. When I load up phpinfo(), it correctly tells me
that the Master Value safe_mode is on, but the Local Value is off. So
then why is set_time_limit still complaining that it can't be set when
running in safe mode, when in theory, safe_mode should not be on for
that vhosts?
--
H | It's not a bug - it's an undocumented feature.
+--------------------------------------------------------------------
Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
IT Director / SysAdmin / Websmith . 800.441.3873 x130
Photo Craft Imaging . 3550 Arapahoe Ave. #6
http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
--- End Message ---
--- Begin Message ---
Hello all,
I make a script for read and interprete the stdout of cmd `ip monitor`. And
I use signal_handler, the script is like this:
<?
declare(ticks = 1);
pcntl_signal(SIGHUP,"sig_handler",false);
$fh = popen('ip monitor','r');
while (!feof($fh))
{
$line = fgets($fh);
analize($line);
}
function analize($line) { ... } ;
function sig_handler($signo) { ... };
?>
this script run in infine loop, or when to cmd 'ip monitor' exist. The
script ever whait the next line of 'ip monitor', ever. Then when I send the
signal SIGHUP to pid of script. In this point the instruction '$line =
fgets($fh);' is aborted and return false to $line. The $fh is modified and
the function feof($fh) return true and I have not access to $fh agaim. But
the kid process 'ip monitor' is not kill.
This is wanted?
--
Fernando Chure
PSL/CE
--- End Message ---
--- Begin Message ---
http://www.php-code-search.com/
Type "thumb" without the "
berber
-----Original Message-----
From: Alain Roger [mailto:[EMAIL PROTECTED]
Sent: Sunday, April 29, 2007 6:16 PM
To: PHP General List
Subject: [PHP] small picture into thumbnail
Hi,
I would like to know how i can display small sized picture in my web
application ?
I mean in my database, picture can have max. 500 Kb, however as on 1 PHP
page i will display 20 pictures at once, i do not want to force end users to
download all 20 pictures (10Mb around) to have an overview.
I would like directly on server to resize picture to display them to end
user in format 100px*120px (for example) and like that size should be around
20 or 50Kb per picture.
I was thinking to use imagecopyresized function for that, but will it no
kill the server CPU and RAM ?
If you have some other suggestion, they are welcome, but do not forget that
i must have pictures in Database and 500 Kb (due to picture printing later
on - so good enough quality).
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
--- End Message ---
--- Begin Message ---
On Mon, 2007-04-30 at 20:17 +0200, WeberSites LTD wrote:
> http://www.php-code-search.com/
>
> Type "thumb" without the "
If you're going to advertise your site, at least post a URL with the
search query embedded you insensitive clod!
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
Hi,
In my PHP page i upload pictures into database. For that i wrote a simple
function which control which user is logged and will upload his picture.
here is the function :
CREATE OR REPLACE FUNCTION sp_a_006("login" character varying, photo bytea)
RETURNS boolean AS
$BODY$
DECLARE
my_id INTEGER :=0;
BEGIN
select into my_id
account_id from accounts where account_login = $1;
IF (my_id != 0) THEN
UPDATE users
SET user_photo = $2
WHERE user_account_id = my_id;
RETURN (TRUE);
ELSE
RETURN (FALSE);
end if;
END;
when i call this function in PHP, i do the following :
$my_query = "select * from immense.sp_a_006
('".$_SESSION["username"]."','{$escaped}')";
$res_pic = pg_query(my_query);
where $escaped = pg_escape_bytea($data);
this inserts the picture only if i add E in front of '{$escaped}' and
becomes E'{$escaped}').
why ?
on another website i do not use function but a simple SQL query as following
and it works :
pg_query("INSERT INTO photo (photo_id,document_orientation_id, photo_date,
photo_image)
VALUES
(nextval('photo_photo_id_seq'),".$orientation_id[0].",NOW(),
'{$escaped}')");
thanks a lot,
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
--- End Message ---
--- Begin Message ---
Hi,
Anybody has implemented a IE button COM server in PHP ? I have found a
python implementation for this in pywin32 package. My objective is to add a
button in ie which will on click save the url in the address bar. I am
attatching the iebutton.py with this mail. Also, this is a link in msdn
instructing add toolbar buttons:
http://msdn2.microsoft.com/en-us/library/aa753588.aspx
Any code snippet will be extremely useful.
Thanks in advance.
-Iqbal Naved
# encoding: latin-1
# PyWin32 Internet Explorer Button
#
# written by Leonard Ritter ([EMAIL PROTECTED])
# and Robert Förtsch ([EMAIL PROTECTED])
"""
This sample implements a simple IE Button COM server
with access to the IWebBrowser2 interface.
To demonstrate:
* Execute this script to register the server.
* Open Pythonwin's Tools -> Trace Collector Debugging Tool, so you can
see the output of 'print' statements in this demo.
* Open a new IE instance. The toolbar should have a new "scissors" icon,
with tooltip text "IE Button" - this is our new button - click it.
* Switch back to the Pythonwin window - you should see:
IOleCommandTarget::Exec called.
This is the button being clicked. Extending this to do something more
useful is left as an exercise.
Contribtions to this sample to make it a little "friendlier" welcome!
"""
# imports section
import sys, os
from win32com import universal
from win32com.client import gencache, DispatchWithEvents, Dispatch
from win32com.client import constants, getevents
import win32com.server.register
import win32com
import pythoncom
import win32api
# This demo uses 'print' - use win32traceutil to see it if we have no
# console.
try:
win32api.GetConsoleTitle()
except win32api.error:
import win32traceutil
from win32com.axcontrol import axcontrol
import array, struct
# ensure we know the ms internet controls typelib so we have access to
IWebBrowser2 later on
win32com.client.gencache.EnsureModule('{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}',0,1,1)
#
IObjectWithSite_methods = ['SetSite','GetSite']
IOleCommandTarget_methods = ['Exec','QueryStatus']
_iebutton_methods_ = IOleCommandTarget_methods + IObjectWithSite_methods
_iebutton_com_interfaces_ = [
axcontrol.IID_IOleCommandTarget,
axcontrol.IID_IObjectWithSite, # IObjectWithSite
]
class Stub:
"""
this class serves as a method stub,
outputting debug info whenever the object
is being called.
"""
def __init__(self,name):
self.name = name
def __call__(self,*args):
print 'STUB: ',self.name,args
class IEButton:
"""
The actual COM server class
"""
_com_interfaces_ = _iebutton_com_interfaces_
_public_methods_ = _iebutton_methods_
_reg_clsctx_ = pythoncom.CLSCTX_INPROC_SERVER
_button_text_ = 'IE Button'
_tool_tip_ = 'An example implementation for an IE Button.'
_icon_ = ''
_hot_icon_ = ''
def __init__( self ):
# put stubs for non-implemented methods
for method in self._public_methods_:
if not hasattr(self,method):
print 'providing default stub for %s' % method
setattr(self,method,Stub(method))
def QueryStatus (self, pguidCmdGroup, prgCmds, cmdtextf):
# 'cmdtextf' is the 'cmdtextf' element from the OLECMDTEXT structure,
# or None if a NULL pointer was passed.
result = []
for id, flags in prgCmds:
flags |= axcontrol.OLECMDF_SUPPORTED | axcontrol.OLECMDF_ENABLED
result.append((id, flags))
if cmdtextf is None:
cmdtext = None # must return None if nothing requested.
# IE never seems to want any text - this code is here for
# demo purposes only
elif cmdtextf == axcontrol.OLECMDTEXTF_NAME:
cmdtext = "IEButton Name"
else:
cmdtext = "IEButton State"
return result, cmdtext
def Exec(self, pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn):
print pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn
print "IOleCommandTarget::Exec called."
#self.webbrowser.ShowBrowserBar(GUID_IETOOLBAR, not
is_ietoolbar_visible())
def SetSite(self,unknown):
if unknown:
# first get a command target
cmdtarget = unknown.QueryInterface(axcontrol.IID_IOleCommandTarget)
# then travel over to a service provider
serviceprovider =
cmdtarget.QueryInterface(pythoncom.IID_IServiceProvider)
# finally ask for the internet explorer application, returned as a
dispatch object
self.webbrowser =
win32com.client.Dispatch(serviceprovider.QueryService('{0002DF05-0000-0000-C000-000000000046}',pythoncom.IID_IDispatch))
else:
# lose all references
self.webbrowser = None
def GetClassID(self):
return self._reg_clsid_
def register(classobj):
import _winreg
subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" %
classobj._reg_clsid_
try:
hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
subKey = _winreg.SetValueEx( hKey, "ButtonText", 0, _winreg.REG_SZ,
classobj._button_text_ )
_winreg.SetValueEx( hKey, "ClsidExtension", 0, _winreg.REG_SZ,
classobj._reg_clsid_ ) # reg value for calling COM object
_winreg.SetValueEx( hKey, "CLSID", 0, _winreg.REG_SZ,
"{1FBA04EE-3024-11D2-8F1F-0000F87ABD16}" ) # CLSID for button that sends
command to COM object
_winreg.SetValueEx( hKey, "Default Visible", 0, _winreg.REG_SZ, "Yes" )
_winreg.SetValueEx( hKey, "ToolTip", 0, _winreg.REG_SZ,
classobj._tool_tip_ )
_winreg.SetValueEx( hKey, "Icon", 0, _winreg.REG_SZ, classobj._icon_)
_winreg.SetValueEx( hKey, "HotIcon", 0, _winreg.REG_SZ,
classobj._hot_icon_)
except WindowsError:
print "Couldn't set standard toolbar reg keys."
else:
print "Set standard toolbar reg keys."
def unregister(classobj):
import _winreg
subKeyCLSID = "SOFTWARE\\Microsoft\\Internet Explorer\\Extensions\\%38s" %
classobj._reg_clsid_
try:
hKey = _winreg.CreateKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
subKey = _winreg.DeleteValue( hKey, "ButtonText" )
_winreg.DeleteValue( hKey, "ClsidExtension" ) # for calling COM object
_winreg.DeleteValue( hKey, "CLSID" )
_winreg.DeleteValue( hKey, "Default Visible" )
_winreg.DeleteValue( hKey, "ToolTip" )
_winreg.DeleteValue( hKey, "Icon" )
_winreg.DeleteValue( hKey, "HotIcon" )
_winreg.DeleteKey( _winreg.HKEY_LOCAL_MACHINE, subKeyCLSID )
except WindowsError:
print "Couldn't delete Standard toolbar regkey."
else:
print "Deleted Standard toolbar regkey."
#
# test implementation
#
class PyWin32InternetExplorerButton(IEButton):
_reg_clsid_ = "{104B66A9-9E68-49D1-A3F5-94754BE9E0E6}"
_reg_progid_ = "PyWin32.IEButton"
_reg_desc_ = 'Test Button'
_button_text_ = 'IE Button'
_tool_tip_ = 'An example implementation for an IE Button.'
_icon_ = ''
_hot_icon_ = _icon_
def DllRegisterServer():
register(PyWin32InternetExplorerButton)
def DllUnregisterServer():
unregister(PyWin32InternetExplorerButton)
if __name__ == '__main__':
win32com.server.register.UseCommandLine(PyWin32InternetExplorerButton,
finalize_register = DllRegisterServer,
finalize_unregister =
DllUnregisterServer)
--- End Message ---
--- Begin Message ---
Hello, folks.
I rember I've since this somewhere in perl and it has somethign to do with
blocks of code. I came across the same thing in some PHP code.
<<< END
....some code....
END
What exactly does it mean.
BTW:
PHP .net search breaks if you search for <<<
Regards,
------------------------------------------------------
Nick
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________
--- End Message ---