Jump to content

Asheeown

Members
  • Posts

    471
  • Joined

  • Last visited

Posts posted by Asheeown

  1. You can do this:

     

    index.php?Page=Links

     

     

    index.php:

    <body>
    <?php
    if($_GET['Links']) {
    include("Links.php");
    }
    ?>
    </body>
    

     

     

    If you do multiple pages do NOT do

    <?php
    include($_GET['Page'] . ".php");
    ?>

     

    That leads to all types of injection and you don't want any part of that, if you get to use many more pages just use a switch statement and put all your possibilities in there.

  2. Okay I'll leave it with another question.

     

    If in the same script as executing the background script did I run a tasklist command that pulled an entire list of processes could I pull the PID from there?

    Meaning that once the script has executed the list command will run and php will grab the absolute last process called "php.exe" and get it's PID since processes are listed in order of executed on tasklist.

    Would this work or if someone executed at the same time as someone else could the PIDs get mixed up?  Please someone answer this question since it's based on pure logic and doesn't have anything to do with Windows or Linux OS.  Thank you.

  3. Sorry it took so long but no it didn't work, it printed

    com Object
    on the screen and the process still runs in the background.  If I print the command it returns a 0, probably 0 or 1 for telling php if it's waiting for execution to finish.
  4. Fatal error: Uncaught exception 'com_exception' with message 'Unable to lookup `ProcessId': Unknown name. ' in C:\xampp\htdocs\EGM\test.php:12 Stack trace: #0 C:\xampp\htdocs\EGM\test.php(12): unknown() #1 {main} thrown in C:\xampp\htdocs\EGM\test.php on line 12

     

    $dir = "C:/xampp/php";
    $php_path = "C:/xampp/php/php.exe";
    $file = "myscript.php";
    $cmd_options = "-t " . time();
    $wscript = new COM('WScript.Shell');
    $Command = $wscript->Run("$php_path $dir/$file", 0, false);
    $PID = $wscript->ProcessId;
    echo $PID;
    

     

    Everything works fine until I add the $PID = $wscript->ProcessId; in.

  5. Basically, I want to access one of the properties of the COM Object.

     

    Now, com_get would work fantastic, however it has been discontinued ever since php5, this is the note that comes along with the manual for COM_GET

     

    Note:  This function does not exist in PHP 5; instead, you should use the regular and more natural OO syntax to access properties or call methods.

     

    If anyone could point me in the direction of how to write an OO syntax for this situation it would be the most amazing thing ever.

  6. I need to get the process ID of a background process I'm executing and I can't seem to get it.

    OS: Windows

     

    $dir = "C:/xampp/php";
    $php_path = "C:/xampp/php/php.exe";
    $file = "myscript.php";
    $cmd_options = "-t " . time();
    $wscript = new COM('WScript.Shell');
    $Command = $wscript->Run("$php_path $dir/$file", 0, false);
    

     

    Any ideas?

  7. Success!  I got it working, OK one more question, the com_get to pull a property from a COM object has been deprecated in PHP5.  I need to pull the process ID from the execution I am running.

     

     

    $dir = "C:/xampp/php";
    $php_path = "C:/xampp/php/php.exe";
    $file = "myscript.php";
    $cmd_options = "-t " . time();
    $wscript = new COM('WScript.Shell');
    $Command = $wscript->Run("$php_path $dir/$file", 0, false);
    

  8. Well before I sign off tonight I figure I should post my new code, this code is working, but isn't working lol.

     

    <?php
    $dir = "C:/xampp/php";
    $php_path = "C:/xampp/php/php.exe";
    $file = "myscript.php";
    $cmd_options = "-t " . time();
    $wscript = new COM('WScript.Shell');
    echo $wscript->Run("cmd /K CD $php_path $dir/$file > output.txt  &  ", 0, false);
    ?>
    

     

    Replicated it completely in Windows and I get an Access is Denied read out.  Vista kills me but Windows Server 2008 does the same access bull**** so does anyone know how to setup permissions so that it won't require admin access?  Or any other hints perhaps?

  9. Yes

    It works for command prompt using the EXACT same execution as I use in the PHP.  Php has to have a way to not want any output or maybe an alternative way would do?  This is a user triggered script so when a user browses to this page it's going to start, I can't have it hung up in the background.

  10. Okay been a few days so I guess I'll bump it.

     

    The problem I am having is the page that is loading the background process is hanging at loading, it's trying to incorporate the background process in the page which I don't want to happen.

  11. Okay figured out why it's not starting, needed forward instead of backslashes.  However it sits at loading on the page, I need it to be completely in the background so that the web page is completely unaffected by the execution.

  12. Okay, primary goal here is this:

    User views a page that executes a background php script that continuously pulls data from a certain source and loads it into the database.

     

    Two things I am having problems with

    1. The script won't execute I am doing a simple script output to a text file and it doesn't show but works in command prompt

    2. I cannot seem to figure out how to get the PID of the php process running.

     

    Installation structure is xampp full installation so phhp is under the xampp folder, this is not the structure for my real server, is is a server 2008 server with fastcgi php installed.

     

    Here is the code I am using to execute the file

     

    <?php
    $Command = exec("C:\xampp\php\php.exe C:\xampp\php\myscript.php > output.txt");
    echo $Command;
    ?>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.