php-windows Digest 18 Feb 2002 03:15:27 -0000 Issue 1005
Topics (messages 12116 through 12119):
Re: access database over multiple pages
12116 by: Pac mon
Re: MING
12117 by: Pac mon
12118 by: Josh Seward
External command output
12119 by: Devon Knowles
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 ---
You could use mysql_pconnect("server","username","password"). This will
return a resource for a currently open connection if one is available
otherwise it will establish a connection.
i.e.
--page1--
$link_id=mysql_pconnect($host,$username,$password);
..... //do stuff
--page2--
$link_id=mysql_pconnect($host,$username,$password);
//link_id is same connection from previous page.
..... //do stuff
Read more about mysql_pconnect here:
http://www.php.net/manual/en/function.mysql-pconnect.php
--------Original Message Follows--------------
Thanks.
Another related question. I know that to connect to a mysql database using
php you use the following statement
$link_id=mysql_connect("hostname","username","password");
My question is if the variable $link_id which is the handle to the database
can persist beyond the web page that create it. I was wondering if this
variable can be a session variable to be reused through the session.
The reason is that the user will be browsing through several web pages each
with a script to perform a particular query of the database. It seems to me
that on every page i would need to use the database connection statement
which means that I have to store the username and password. And you have
help because you have indicated that the session variables are stored on the
server so there is no addtional risk. I wanted to find out if there are any
other solutions besisdes storing the username and password like storing the
database handle $link_id as a session variable. Is this possible?
"Christoph Grottolo" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi Quincy
>
> Session variables are stored on the server, not on the client, so there
is
> no additional risk, if you don't send usernames and passwords back to the
> client with your script. But usually you don't need to store
> username/password because you don't need them in the scripts. You just
store
> a variable which confirms that the user already has authenticated (p.e.
> $sess_auth=true;) which you can check in your scripts, and, if you need,
the
> userID.
>
> Maybe you have a look at some ready-to-use auth solutions written in PHP.
> Look at http://www.zend.com/codex.php?CID=341.
>
> Christoph
>
>
>
> "Quincy" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> | I want to design a web application using php ,that allows the user to
sign
> | in once into the mysql database and then over the course of several
pages
> to
> | perform several queries on the database using their name and password.
> |
> | My question is how can I do this without asking the user to enter his
> name
> | and password on every page so that a query can be performed on the
> | database.My initial thoughts was to store the user name and password as
> | session variables when the person initial signs in. My concern is if
this
> | safe enough as someone else may be able to access the session variables
> and
> | get the user name and password.
> |
> | Can anyone offer any suggestions on the safest way of accessing a
mysql
> | database over several pages using the same user name and password
without
> | asking the user to give this information on every page which needs to
run
> a
> | query on the database.
> |
> |
> |
> |
>
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
-|.gOp.|Pr0fessi0nal
_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com
--- End Message ---
--- Begin Message ---
The SWFBitmap() function takes two parameters. One is optional. The first is
a FILENAME the second is a file that acts as a alphamask. So to correct your
problem do this:
$img = new SWFBitmap($dram);
Read more here:
http://www.php.net/manual/en/function.swfbitmap.php
----Original Message Follows----
For PHP 4.0.8 I had function that converted .jpg in .swf
-----------------
Ming_setScale(20);
$fp = fopen($dram,"r");
$end=10000000;
$i = fread($fp,$end);
$img = new SWFBitmap($i);
fclose($fp);
$m = new SWFMovie();
$m->setDimension(100,100);
$m->add($img);
$m->save("myURL/movie.swf");
ImageDestroy($new);
----------------------------
But whan I install PHP 4.1.1 function stops working on string $img = new
SWFBitmap($i);
and return "Sorry, can't tell what type of file ÿØÿà is in ".
I didn't change anything!
Help is much appreciated!
Thanks,
Josh Seward
[EMAIL PROTECTED]
-|.gOp.|Pr0fessi0nal
_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
--- End Message ---
--- Begin Message ---
I got the example below straight from the link you gave!
I also have the line that you said would correct the problem already in the
code.
$img = new SWFBitmap($i);
Thanks,
----- Original Message -----
From: "Pac mon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, February 17, 2002 1:42 AM
Subject: Re: [PHP-WIN] MING
> The SWFBitmap() function takes two parameters. One is optional. The first
is
> a FILENAME the second is a file that acts as a alphamask. So to correct
your
> problem do this:
>
> $img = new SWFBitmap($dram);
>
> Read more here:
> http://www.php.net/manual/en/function.swfbitmap.php
>
>
> ----Original Message Follows----
> For PHP 4.0.8 I had function that converted .jpg in .swf
> -----------------
> Ming_setScale(20);
> $fp = fopen($dram,"r");
> $end=10000000;
> $i = fread($fp,$end);
> $img = new SWFBitmap($i);
> fclose($fp);
>
> $m = new SWFMovie();
> $m->setDimension(100,100);
> $m->add($img);
> $m->save("myURL/movie.swf");
> ImageDestroy($new);
> ----------------------------
> But whan I install PHP 4.1.1 function stops working on string $img = new
> SWFBitmap($i);
> and return "Sorry, can't tell what type of file ÿØÿà is in ".
> I didn't change anything!
> Help is much appreciated!
>
> Thanks,
> Josh Seward
> [EMAIL PROTECTED]
>
>
>
>
> -|.gOp.|Pr0fessi0nal
>
>
> _________________________________________________________________
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
I have a line of code that is supposed to get the current status / track from Winamp
passthru("C:/htdocs/lib/winampinfo.exe");
the output when it is run from command prompt is
<b>Status:</b> Winamp is rocking it!
<b>Time on Track:</b> 6 seconds
<b>Currently:</b> Injected - Faithless
but PHP only returns
Winamp is not running! :O
the error message thrown by the exception if a Winamp instance is not running.
This is the C# for the prog:
using System;
using System.Runtime.InteropServices;
using System.IO;
namespace WinampInfo
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class WinampControl
{
public WinampControl()
{
WINDOW_HANDLER = FindWindow("Winamp v1.x",null);
if(WINDOW_HANDLER == 0)
{
throw new Exception("Winamp is not running! :O");
}
}
private int WINDOW_HANDLER;
private const int WM_COMMAND = 0x111;
private const int WM_USER = 0x400;
public const int WINAMP_ISPLAYING = 104;
public const int WINAMP_TIMEGOING = 105;
public const int WINAMP_WRITE_POSITION = 120;
[DllImport("user32.dll",EntryPoint="SendMessage")]
private static extern int SendMessage(int _WindowHandler, int _WM_USER, int _data,
int _id);
[DllImport("user32.dll",EntryPoint="FindWindow")]
private static extern int FindWindow(string _ClassName, string _WindowName);
public void SendCommands()
{
int intRetWINAMP_ISPLAYING = 0;
int intRetWINAMP_TIMEGOING = 0;
int intRetWINAMP_WRITE_POSITION = 0;
intRetWINAMP_ISPLAYING = SendMessage(WINDOW_HANDLER,WM_USER,0,WINAMP_ISPLAYING);
string strPlayStatus = null;
string strPlayTime = null;
string strPlaySong = null;
switch (intRetWINAMP_ISPLAYING)
{
case (1):
strPlayStatus = "Winamp is rocking it!";
break;
case (3):
strPlayStatus = "Winamp is paused.";
break;
default:
strPlayStatus = "Winamp is stopped.";
break;
}
intRetWINAMP_TIMEGOING = SendMessage(WINDOW_HANDLER,WM_USER,0,WINAMP_TIMEGOING);
long lngRetWINAMP_TIMEGOING = intRetWINAMP_TIMEGOING;
if (lngRetWINAMP_TIMEGOING >= 60000)
{
if ((lngRetWINAMP_TIMEGOING / 60000.0) == Math.Floor(lngRetWINAMP_TIMEGOING /
60000))
{
if ((lngRetWINAMP_TIMEGOING / 60000) == 1)
{
strPlayTime = "1 minute";
}
else
{
strPlayTime = (lngRetWINAMP_TIMEGOING / 60000).ToString() + " minutes";
}
}
else
{
if ((lngRetWINAMP_TIMEGOING / 60000) == 1)
{
strPlayTime = "1 minute";
}
else
{
strPlayTime = (lngRetWINAMP_TIMEGOING / 60000).ToString() + " minutes";
}
if (((intRetWINAMP_TIMEGOING % 60000) / 1000) == 1)
{
strPlayTime += " and 1 second";
}
else
{
if (((intRetWINAMP_TIMEGOING / 1000) % 60) != 0)
{
strPlayTime += " and " + ((lngRetWINAMP_TIMEGOING / 1000) -
(lngRetWINAMP_TIMEGOING / 60000) * 60).ToString() + " seconds";
}
}
}
}
else
{
if ((lngRetWINAMP_TIMEGOING / 1000) == 1)
{
strPlayTime = "1 second";
}
else
{
strPlayTime = (lngRetWINAMP_TIMEGOING / 1000).ToString() + " seconds";
}
}
intRetWINAMP_WRITE_POSITION =
SendMessage(WINDOW_HANDLER,WM_USER,0,WINAMP_WRITE_POSITION);
string strPlaylistFile = "C:/program files/winamp/winamp.m3u";
if (!File.Exists(strPlaylistFile)) strPlaySong = "Unable to open the playlist for
parsing.";
StreamReader sr = File.OpenText(strPlaylistFile);
string strInput;
int intCntr = 0;
int intLine2Read = intRetWINAMP_WRITE_POSITION * 2 + 1;
for (intCntr = 0; intCntr <= intLine2Read; intCntr++)
{
strInput=sr.ReadLine();
if ((intCntr == intLine2Read) && (strInput != null))
{
string[] strInfo = strInput.Split(new Char[] {','},2);
strPlaySong = strInfo[1];
}
}
Console.WriteLine("<b>Status:</b> " + strPlayStatus);
Console.WriteLine("<b>Time on Track:</b> " + strPlayTime);
Console.WriteLine("<b>Currently:</b> " + strPlaySong);
}
}
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
WinampControl myControl = new WinampControl();
myControl.SendCommands();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
Console.WriteLine("<!-- Made with Visual Studio .NET by Devon Knowles -->");
}
}
}
}
If anyone has any idea why this isn't working, I'd appreciate the help. I really don't
want to have to output to a text file and then have to read it again in my script.
- Devon Knowles
[EMAIL PROTECTED]
--- End Message ---