php-general Digest 25 May 2010 13:56:07 -0000 Issue 6763

Topics (messages 305494 through 305503):

Re: editing a file
        305494 by: Rene Veerman
        305495 by: Andres Gonzalez
        305496 by: Ryan Sun
        305497 by: shiplu

Re: Remove blank lines from a file
        305498 by: tedd

Re: Dynamic Menus in a PHP Form Issue
        305499 by: tedd
        305500 by: Arno Kuhl

COM/DCOM
        305501 by: Mayer, Jonathan

Re: exec in different directory where PHP is Installed
        305502 by: loki

determining time difference between two timestamp fields.
        305503 by: Bruce Gilbert

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On Mon, May 24, 2010 at 11:16 PM, Andres Gonzalez
<and...@packetstorm.com> wrote:
> I have a large C source file that is generated by a separate
> source-generating program. When the generated src file is compiled, it
> produces tons of warnings. I want to edit the generated src file and delete
> the offending lines.
>
> What is the easiest way using a PHP script to read in a file, search for a
> particular signature, and delete a couple of lines? Seems like this would be
> very easy in PHP.

file_get_contents() to get the file into a $string.

preg_match_all(,,$matches) to get to what you need,

str_replace() to replace $matches with your chosen replacements

and there you are :)

file_put_contents() to save the results..

>
> Thanks,
>
> -Andres
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
---------------------------------
Greetings from Rene7705,

My free open source webcomponents:
  http://code.google.com/u/rene7705/
  http://mediabeez.ws/downloads (and demos)

http://www.facebook.com/rene7705
---------------------------------

--- End Message ---
--- Begin Message ---
thank you Rene, that is the start I needed.

-Andres


Rene Veerman wrote:
On Mon, May 24, 2010 at 11:16 PM, Andres Gonzalez
<and...@packetstorm.com> wrote:
I have a large C source file that is generated by a separate
source-generating program. When the generated src file is compiled, it
produces tons of warnings. I want to edit the generated src file and delete
the offending lines.

What is the easiest way using a PHP script to read in a file, search for a
particular signature, and delete a couple of lines? Seems like this would be
very easy in PHP.

file_get_contents() to get the file into a $string.

preg_match_all(,,$matches) to get to what you need,

str_replace() to replace $matches with your chosen replacements

and there you are :)

file_put_contents() to save the results..

Thanks,

-Andres

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--- End Message ---
--- Begin Message ---
yea, file_get_contents and file_put_contents are the easiest, but play
with caution when dealing with large files, 'cause it loads the whole
file into memory, fopen() fread() fwrite() can be used for large
files.

On Mon, May 24, 2010 at 5:56 PM, Rene Veerman <rene7...@gmail.com> wrote:
> On Mon, May 24, 2010 at 11:16 PM, Andres Gonzalez
> <and...@packetstorm.com> wrote:
>> I have a large C source file that is generated by a separate
>> source-generating program. When the generated src file is compiled, it
>> produces tons of warnings. I want to edit the generated src file and delete
>> the offending lines.
>>
>> What is the easiest way using a PHP script to read in a file, search for a
>> particular signature, and delete a couple of lines? Seems like this would be
>> very easy in PHP.
>
> file_get_contents() to get the file into a $string.
>
> preg_match_all(,,$matches) to get to what you need,
>
> str_replace() to replace $matches with your chosen replacements
>
> and there you are :)
>
> file_put_contents() to save the results..
>
>>
>> Thanks,
>>
>> -Andres
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>
> --
> ---------------------------------
> Greetings from Rene7705,
>
> My free open source webcomponents:
>  http://code.google.com/u/rene7705/
>  http://mediabeez.ws/downloads (and demos)
>
> http://www.facebook.com/rene7705
> ---------------------------------
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
You can use shell commands.
Like sed, replace etc ..


Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
Follow me, http://twitter.com/shiplu
SUST Programmers, http://groups.google.com/group/p2psust
Innovation distinguishes bet ... ... (ask Steve Jobs the rest)

--- End Message ---
--- Begin Message ---
At 2:39 PM -0400 5/24/10, Robert Cummings wrote:
-snip- It highlighting the conceptual differences between different people in the production chain and how the client pretty mich didn't get what he wanted :)

Cheers,
Rob.

Rob:

Any guy called "pretty mich" probably doesn't get what he wants anyway.  :-)

The point is -- we all make mistakes.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
At 11:38 AM -0400 5/24/10, tedd wrote:
At 10:46 AM -0400 5/24/10, Alice Wei wrote:
Hi, I have a snippet as in the following: <ul> <li>Select the type of your starting point of interest:<br/> <div id="start_menu"><form action="" name="form1" method="post"> <span><input type="radio" value="Apartment" name="start" onclick="alert(document.form1.start)"/> Apartment </span> </form></div></li> </ul>If I tried to put this at the top of a file where I save as PHP with other PHP execution statements, looks like the form does not do anything, and yet when I save the page as in HTML with out the other PHP execution, it works. I am trying to create a page where I have dynamic drop down menu lists so users can egenerate dynamic content based on their preference. Is it possible that I can save the entire file as a PHP and still keep the functionality, including generating dynamic menus, writing the proper entries to the database and printing out the proper output?

Thanks for your help.

Alice

Alice:

I'm not sure as to what it is that you are asking, but php runs on the server and is done by time anyone looks at a select control.

If you want a dynamic select, then there are two basic types: 1) dynamically generated on the server based upon what the user indicted via a previous submit; 2) dynamically generated on the client-side based upon what the user indicted via a javascript trigger.

Now, please describe which type you want?

Cheers,

tedd
--


Re the above, I meant indicated and not indicted -- sorry.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Alice Wei [mailto:aj...@alumni.iu.edu] 
Sent: 24 May 2010 04:47 PM
To: php-gene...@lists.php.net
Subject: [PHP] Dynamic Menus in a PHP Form Issue

Hi,    I have a snippet as in the following:                   <ul>
<li>Select the type of your starting point of interest:<br/>
<div id="start_menu"><form action="" name="form1" method="post">
<span><input type="radio" value="Apartment" name="start"
onclick="alert(document.form1.start)"/> Apartment </span>
</form></div></li>            </ul>If I tried to put this at the top of a
file where I save as PHP with other PHP execution statements, looks like the
form does not do anything, and yet when I save the page as in HTML with out
the other PHP execution, it works. I am trying to create a page where I have
dynamic drop down menu lists so users can egenerate dynamic content based on
their preference. Is it possible that I can save the entire file as a PHP
and still keep the functionality, including generating dynamic menus,
writing the proper entries to the database and printing out the proper
output?

Thanks for your help. 

Alice                                     
_________________________________________________________________

The reason it works in html is because it is "executed" in the browser. If
you want this html to get to the browser you must either echo it to the
output buffer that is sent to the browser, or end your php section with "?>"
so that these lines are interpreted as part of the output that is sent to
the browser.

If your php script is running without error then I presume you're already
doing this. If that's the case then maybe it's not being put into the output
buffer the way you're expecting (e.g. maybe the quotes don't match). You can
look at the source code in the browser and compare it against the working
html code to see where the difference is.

Cheers
Arno



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

 

I'm trying to write a few scripts to help automate some Windows
administration tasks. One of these is to add people to groups on
different networked machines.

 

I've written something like the following:

 

<?php

$computer = "TestComputer";

$groupName = "TestGroup";

$server_config = array('Server' => TestComputer' , 'Username' =>
'TestUser' , 'Password' => 'TestPass');

// list all current group members

$domainObject = new
COM("WinNT://".$computer."/".$groupName.",group",$server_config) or
die("Cannot create COM object");

foreach ($domainObject->Members as $var)

{

          echo $var->Name."<br>";

}

// add person to group

$usertoadd = "APerson";

$domainUser = new
COM("WinNT://DOMAIN/".$usertoadd.",user",$server_config) or die("Cannot
create COM object ");

$domainObject->Add($domainUser->ADsPath);

 

?>

 

TestUser is a local administrative account on TestComputer.

 

If I run apache using the standard local system account, the code lists
the members of the group but refuses to add APerson. If I run apache
with a domain administrator account it works fine, but I don't want to
do this - I want to be able to pass the username and password of an
account on the target machine that has permissions set up for this
purpose.

 

I've tried making changes using dcomcnfg on the target machine, but no
luck so far. 

 

Does anyone have any experience in using COM functions and can spot
anything I'm doing wrong or a misunderstanding in how it works?

 

Thanks,

Jon

 

---------

This e-mail does not reflect the views or opinions of Travellers Tales
(UK) Ltd or any other related TT Games group company.

 


--- End Message ---
--- Begin Message ---
I have a begin of explanation

When PHP is run as CGI it's work but with this header message :

'\\xxx.xxx.xxx.xxx\scriptdir'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported.  Defaulting to Windows directory.
Status: 200 OK
X-Powered-By: PHP/5.2.8
Content-type: text/html

@exec function work well


Now when PHP is run as a FAST-CGI then it's not work at
ALL (ie: just the @exec function not work, the other work ok!)


is it a normal behavior ?

thanks you by advance
stephane



On 5/24/2010 11:42 PM, Bob McConnell wrote:
From: loki

On 5/24/2010 11:31 PM, Bob McConnell wrote:
From: loki

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 ...

Is 'C:\Program Files\PHP' in your PATH? You may need to add that
manually.

no ? but why i would need to add C:\Program Files\PHP in my path ?
why it's explain that it's work when the php script are located in any

directory under c: and not under \\xxx.xxx.xxx.xxx\scriptdir\ ??

What is the exact error message you get when it doesn't work?

Bob McConnell


--- End Message ---
--- Begin Message ---
Here is the situation. I have a form which sets a timestamp when a
user logs in using UPDATE in SQL. The field is called
'login_timestamp' and is in a table called 'Candidates'. I have
another timestamp which is set when a user submits the form data into
the DB and it is called 'submit_timestamp' . What I want to do is
determine the amount of time the user takes to complete the form by
subtracting the 'login_timestamp' time form the 'submit_timestamp'
time. I am using SQL to extract the data here.

$sql = "SELECT Responses.name,Answers,submit_timestamp,login_timestamp
           FROM Responses LEFT JOIN Candidates USING (user_id)";

and then to display the timestamp in readable form.

echo "<tr><th>Completion Time:</th></tr><tr><td>" . date('F j, Y
g:i:sa', strtotime($row["login_timestamp"])) . "</td></tr>";

so I need to know how to subtract from two timestamp fields, two
different tables and come up with the difference in minutes.


thanks.

-- 
::Bruce::

--- End Message ---

Reply via email to