php-windows Digest 26 May 2010 14:20:58 -0000 Issue 3818
Topics (messages 30122 through 30125):
Re: @EXEC command not work :(
30122 by: Richard Quadling
30123 by: Sascha Meyer
30124 by: Sascha Meyer
Help needed in searching a sentence in the code
30125 by: nagendra prasad
Administrivia:
To subscribe to the digest, e-mail:
php-windows-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-windows-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-wind...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On 24 May 2010 19:35, loki <loki5100-newsgr...@yahoo.fr> wrote:
> Hello,
>
> PHP is installed in c:\program files\php
> the PHP script are in network drive \\xxx.xxx.xxx.xxx\scriptdir\
> in the PHP script, we try to launch the command @exec(...) with a executable
> located in c:\program files\ourexecutable\
>
> it's not work :(
>
> but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> to c:\scriptdir\ then it's work !!
>
> everything work good EXCEPT the @EXEC command ...
>
> Safe mode in PHP is OFF ...
>
> Thanks by advance for you help
> stephane
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Can you show the exact exec() call please?
Most likely you are falling foul of the spaces in "Program Files".
Windows needs you to put spaces around any path that has spaces in it.
e.g.
"C:\Program Files\PHP\php.exe"
You can try this at the command prompt!
If you type ...
C:\Program Files\PHP\php.exe -v
you get ...
'C:\program' is not recognized as an internal or external command,
operable program or batch file.
Wrapping it in quotes will show you the PHP version.
There is a gotcha.
In the event that the program name (C:\Program Files\PHP\php.exe)
_AND_ a parameter to the program have spaces in, then you would
normally expect something like this ...
"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"
to work.
And it does from the command line.
But not when passed to the shell via the exec() method.
This was fixed in PHP about 2 years ago
(http://svn.php.net/viewvc?view=revision&revision=260429), so if you
are using a newer release of PHP, you can safely ...
exec('"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"');
If not, then use ...
exec('""C:\Program Files\PHP\php.exe" -f "C:\Program
Files\Scripts\script.php""');
That is
exec('
"
"C:\Program Files\PHP\php.exe" -f "C:\Program Files\Scripts\script.php"
"
'
);
Richard.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling
--- End Message ---
--- Begin Message ---
Hello Stephane,
Hi Niel,
> > ...
> > but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> > to c:\scriptdir\ then it's work !!
> ...
> Is this operating in a CLI or web-server environment? If it is
> web-server then it is probably a permissions issue. By default
> Apache/PHP do NOT have permissions to access network resources. You must
> create a user to run Apache and give that user the permissions needed.
> This of course assumes you're using Apache, but I would guess similar
> problem would happen with IIS.
I ran into similar problems some years ago and I assume you run into comparable
problems as I did:
---------------
Problem source:
---------------
* if you access a remote share interactively (i.e. through Windows Explorer),
your stored user account information is validated on the remote computer and if
the logged in user is allowed to access the share, you won't even know that an
authentication happened.
* if the webserver (running under the localsystem account) tries to load or
execute a remote script, the same authentication method happens but the
localsystem accounts on the two computers (local web server and remote file
server) are not the same, authentication fails causing exec() to fail too.
-----------------
Access debugging:
-----------------
* if the remote file server is a Windows 2000 and newer system, activate object
access logging (through MMC, snap-in "Local Computer Policy" -> Computer
Configuration -> Windows Settings -> Security Settings -> Local Policies ->
Audit Policy, option "Audit object access"
> after activating object access, rightclick one of the scripts that will be
> executed by the web server and set the object access options under
> "properties" -> "Advanced" -> "Auditing", add everyone and both successes and
> failures
Now execute the script on the web server and then check your file server's
event log, security node if there are any failures logged.
-----------------------
How to solve the issue:
-----------------------
* add a user account with the same passwords on both the local web server and
remote file server, change the service owner for Apache2/IIS to use the new
account. If you are on a domain, it's even better to add a domain user with the
same SID and use this one. Restart the service and check if the web server
behaves normally, then retry the test.
* use the PSTools from Sysinternal to execute remote scripts. The tool PSExec
takes a user name and password when calling remote script and first
authenticates on the remote system before executing scripts (see
http://technet.microsoft.com/de-de/sysinternals/bb897553.aspx)
Hope this helps!
Regards, Sascha
--
Freundliche Grüße / Kind regards,
Sascha Meyer
--------------------------------------------------
EE: http://www.experts-exchange.com/M_761556.html
ZCE: http://www.zend.com/en/yellow-pages#show-ClientCandidateID=ZEND011290
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
--- End Message ---
--- Begin Message ---
Hello Stephane,
Hi Niel,
> > ...
> > but if we move the PHP script from \\xxx.xxx.xxx.xxx\scriptdir\
> > to c:\scriptdir\ then it's work !!
> ...
> Is this operating in a CLI or web-server environment? If it is
> web-server then it is probably a permissions issue. By default
> Apache/PHP do NOT have permissions to access network resources. You must
> create a user to run Apache and give that user the permissions needed.
> This of course assumes you're using Apache, but I would guess similar
> problem would happen with IIS.
I ran into similar problems some years ago and I assume you run into comparable
problems as I did:
---------------
Problem source:
---------------
* if you access a remote share interactively (i.e. through Windows Explorer),
your stored user account information is validated on the remote computer and if
the logged in user is allowed to access the share, you won't even know that an
authentication happened.
* if the webserver (running under the localsystem account) tries to load or
execute a remote script, the same authentication method happens but the
localsystem accounts on the two computers (local web server and remote file
server) are not the same, authentication fails causing exec() to fail too.
-----------------
Access debugging:
-----------------
* if the remote file server is a Windows 2000 and newer system, activate object
access logging (through MMC, snap-in "Local Computer Policy" -> Computer
Configuration -> Windows Settings -> Security Settings -> Local Policies ->
Audit Policy, option "Audit object access"
> after activating object access, rightclick one of the scripts that will be
> executed by the web server and set the object access options under
> "properties" -> "Advanced" -> "Auditing", add everyone and both successes and
> failures
Now execute the script on the web server and then check your file server's
event log, security node if there are any failures logged.
-----------------------
How to solve the issue:
-----------------------
* add a user account with the same passwords on both the local web server and
remote file server, change the service owner for Apache2/IIS to use the new
account. If you are on a domain, it's even better to add a domain user with the
same SID and use this one. Restart the service and check if the web server
behaves normally, then retry the test.
* use the PSTools from Sysinternal to execute remote scripts. The tool PSExec
takes a user name and password when calling remote script and first
authenticates on the remote system before executing scripts (see
http://technet.microsoft.com/de-de/sysinternals/bb897553.aspx)
Hope this helps!
Regards, Sascha
--
Freundliche Grüße / Kind regards,
Sascha Meyer
--------------------------------------------------
EE: http://www.experts-exchange.com/M_761556.html
ZCE: http://www.zend.com/en/yellow-pages#show-ClientCandidateID=ZEND011290
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
--- End Message ---
--- Begin Message ---
Hi All,
I have this code where user can search a song or the entire song title. It
looks like when a user search a single word its searching and giving the
proper results. However if the user wants to search the entire sentence its
not giving the proper results. For example let say I have searched for the
MJ's song "Earth Song", its giving me the proper results. However if I am
searching for the MJ's " Why You Wanna Trip On Me", its not giving me the
proper results. Below is the code:
<?php
//get data
$button = $_GET['submit'];
$search = $_GET['search'];
$s = 0;
$s = $_GET['s'];
if (!$s)
$s = 0;
$i = 0;
$e = 30; // Just change to how many results you want per page
$next = $s + $e;
$prev = $s - $e;
if (strlen($search)<=2)
echo "<br><table align='center'><tr><td><sup>†</sup><font
face='sana-serif' size='6'><font color='blue'><b><sup><a href='
http://localhost/searchengine/' style='text-decoration:
none'>MP3dom</a></sup></b></b></font><font face='sana-serif'
size='3'><sup>™</sup></td><td><sup><form action='search.php'
method='GET'><input type='text' onclick=value='' size='50' name='search'
value='$search'> <input type='submit' name='submit'
value='Search'></form></td></tr></table> <table bgcolor='#0000FF'
width='100%' height='1px'><br /></table><table bgcolor='#f0f7f9'
width='100%' height='10px'><tr><td><div align='right'><b>Must be greater
then 3 chars</b></div></td></tr></table><p></sup>";
else
{
echo "<br><table align='center'><tr><td>†<font face='sana-serif'
size='6'><font color='blue'><b><a href='http://localhost/searchengine/'
style='text-decoration: none'>MP3dom</a></b></b></font><font
face='sana-serif' size='3'><sup>™</sup></td><td><sub><form
action='search.php' method='GET'><input type='text' onclick=value=''
size='50' name='search' value='$search'><input type='submit' name='submit'
value='Search'></form></td></tr></table></sub>";
//connect to database
mysql_connect("localhost","root","");
mysql_select_db("mp3");
//explode out search term
$search_exploded = explode(" ",$search);
foreach($search_exploded as $search_each)
{
//construct query
$x++;
if ($x==1)
$construct .= "name LIKE '%$search_each%'";
else
$construct .= " OR name LIKE '%$search_each%'";
}
//echo outconstruct
$constructx = "SELECT * FROM data WHERE $construct";
$construct = "SELECT * FROM data WHERE $construct LIMIT $s,$e ";
$run = mysql_query($constructx);
$foundnum = mysql_num_rows($run);
$run_two = mysql_query("$construct");
if ($foundnum==0)
echo "<table bgcolor='#F1EDC2' width='100%' height='1px'><br
/></table><table bgcolor='#f0f7f9' width='100%' height='10px'><tr><td><div
align='right'>No results found for
<b>$search</b></div></td></tr></table><p>";
else
{
echo "<table bgcolor='#F1EDC2' width='100%' height='1px'><br
/></table><table bgcolor='#f0f7f9' width='100%' height='10px'><tr><td><div
align='right'>Showing 1-30 of <b>$foundnum</b> results found for
<b>$search.</b></div></td></tr></table><p>";
print '<table bgcolor="#F1EDC2" width="700" height="30" border="0"
align="center" >';
print '<tr>';
print '<td width="100" nowrap="nowrap"><strong>Artist</strong></td>';
print '<td width="250" nowrap="nowrap"><strong>Song
Name</strong></td>';
print '<td width="50" nowrap="nowrap"><strong>Movie
Date</strong></td>';
print '<td width="50" nowrap="nowrap"><strong>Size</strong></td>';
print '</tr>';
while ($runrows = mysql_fetch_assoc($run_two))
{
//get data
$type = $runrows['artist'];
$date = $runrows['date'];
$name = $runrows['name'];
$size = $runrows['size'];
foreach ($runrows as $row)
{
if ($i % 2 != 0) # An odd row
$rowColor = "#EBECE4";
else # An even row
$rowColor = "#FEF1E9";
print '<table width="700" height="30" border="0" align="center">';
}
print '<?php do { ?>';
print '<tr bgcolor="' . $rowColor . '">';
print '<td nowrap="nowrap" width="100">'.'<font color=:blue"
size=2>'."$type".'</td>';
//print '<td nowrap="nowrap" width="250">'.'<font size=2>'."<a
herf='$url'>$name".'</td>';
print '<td nowrap="nowrap" width="250">'.'<font color="blue"
size=2>'."<a href='download.php?url=$url'>$name".'</font></td>';
print '<td nowrap="nowrap" width="100" align="center">'.'<font
size=2>'."$date ".'</td>';
print '<td nowrap="nowrap" width="50">'.'<font size=2>'."$size
".'</td>';
print '<td nowrap="nowrap" width="25">'.'<font size=2>'."$se
".'</td>';
print '<td nowrap="nowrap" width="25">'.'<font size=2>'."$le
".'</td>';
print '</tr>';
print '</table>';
print '</body>';
print '</html>';
}
?>
<table width='100%'>
<tr>
<td>
<div align="center">
<br><br>
<?php
if (!$s<=0)
echo "<a href='search.php?search=$search&s=$prev'>Prev</a>";
$i =1;
for ($x=0;$x<$foundnum;$x=$x+$e)
{
echo " <a href='search.php?search=$search&s=$x'>$i</a> ";
$i++;
}
if ($s<$foundnum-$e)
echo "<a href='search.php?search=$search&s=$next'>Next</a>";
}
}
?>
</div>
</td>
</tr>
</table>
***************************************************************************************************
Also, the above code is giving me the below errors:
*Notice*: Undefined index: s in *C:\wamp\www\searchengine\search.php* on
line *11
**Notice*: Undefined variable: x in *C:\wamp\www\searchengine\search.php* on
line *46*
*Notice*: Undefined variable: construct in *
C:\wamp\www\searchengine\search.php* on line *48
******************************************************************************************************************
Please help me with this.
Best,
Guru.
*
--- End Message ---