Jump to content

skillednerd

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Posts posted by skillednerd

  1. Thanks I got it to work off your sample code. I finally got it working correctly thanks very much!!

     

    $lines = file('access.00.log');
    //$opt = array();
    foreach($lines as $line){
    if(!preg_match("/^#/", $line)){
    
            $thisx = htmlspecialchars($line);
    
            $thisx = preg_replace("/\s+/", ", ", $thisx);
    
           //removed the extra white space and comma on the end
            $thisx = substr_replace($thisx ,"",-2);
    
    
    
            $pC = explode(",", $thisx);
    
            echo "Value1 = $pC[0]<br />";
    
    
    
    
    }
    
    
    
    
    }

  2. Well I want to have the values separated by comma. I thought I needed the 'value' but don't just comma separated.

     

    Like

     

    app-stop, application, 2011-04-19, 00:02:10   

     

    The problem come with the comments in the file with the # before it so it comes at the beginning of file and every so many results there

    is another #field list. I do have comma separated working its just the blank lines formed when trying to remove all the lines starting with #

     

    The problem is when using:

    $patternx = '/^.*\#.*\R$/';

    $newx = '';

    $new_hold = preg_replace($patternx, $newx, $thisx);

     

    It doesn't get rid of the lines it creates a blank line with return in it. So results look like

    Blank Line

    Blank Line

    Blank Line

    Blank Line

    server-stop, server, 2011-04-19

     

    And in the middle of results where field list (# field, field, field .. .) the blank lines are there.

     

    And when I use explode to create an array from it messes all that up.

     

     

  3. Ok no problem.

     

    code

     

    $lines = file('access.00.log');
    
    
    
    foreach ($lines as $line_num => $line) {
    
    $thisx = htmlspecialchars($line);
    
    
    
    
    $patternx = '/\#(.*)\n/i';
    $newx = '';
    
    $new_hold = preg_replace($patternx, "", $thisx);
    
    
    $patterny = '/ /';
    $newy = ',';
    
    $new_hold2 = preg_replace("/\s+/", ", '", $new_hold);
    
    
    
    $new_hold3 = preg_replace("/,/", "',", $new_hold2);

     

    And flash media log I am working with

     

    #Version: 1.0
    #Start-Date: 2011-04-19 00:02:10
    #Software: Adobe Flash Media Server 4.0.0 r1121 x86
    #Date: 2011-04-19
    #Fields: x-event        x-category      date    time    tz      x-ctx   s-ip    x-pid   x-cpu-load      x-mem-load      x-adaptor       x-vhost x-app   x-appinst       x-duration      x-status        c-ip    c-proto c-proto-ver     s-uri   cs-uri-stem     cs-uri-query    c-referrer      c-user-agent    c-client-id     cs-bytes        sc-bytes        c-connect-type  x-sname x-sname-query   x-suri-query    x-suri-stem     x-suri  x-file-name     x-file-ext      x-file-size     x-file-length   x-spos  c-spos  cs-stream-bytes sc-stream-bytes x-service-name  x-sc-qos-bytes  x-comment       x-eid   x-sid   x-trans-sname   x-trans-sname-query     x-trans-file-ext        x-trans-mode    x-soffset       x-codec-type    x-codec x-plugin        x-page-url      x-smax-rec-size x-smax-rec-duration     x-forwarded-for
    app-stop        application     2011-04-19      00:02:10        EDT     45fdkfjwdj      -       12607   -       -       _defaultRoot_   mobile.chatcadet.com    45fdkfjwdj      _definst_       -       -       -       -       -       -       -       -       -       -       -       3073    3376    -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -
    app-start       application     2011-04-19      00:02:14        EDT     45fdkfjwdj      -       12607   -       -       _defaultRoot_   mobile.test.com    45fdkfjwdj      _definst_       -       -       -       -       -       -       -       -       -       -       -       0       0       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -
    connect-pending session 2011-04-19      00:02:20        EDT     192.168.1.1   192.168.1.1    12607   0       1       _defaultRoot_   mobile.test.com    45fdkfjwdj      _definst_       0       100     76.25.101.105   rtmp    -       rtmp://mobile.test.com/45fdkfjwdj  rtmp://mobile.test.com/45fdkfjwdj  -       rtmp://mobile.test.com/45fdkfjwdj  FMLE/3.0 (compatible; FMSc/1.0) 4702111235045409135     3073    3073    normal  -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -
    connect session 2011-04-19      00:02:20        EDT     192.168.1.1   192.168.1.1    12607   0       1       _defaultRoot_   mobile.test.com    45fdkfjwdj      _definst_       0       200     76.25.101.105   rtmp    -       rtmp://mobile.test.com/45fdkfjwdj  rtmp://mobile.testt.com/45fdkfjwdj  -       rtmp://mobile.test.com/45fdkfjwdj  FMLE/3.0 (compatible; FMSc/1.0) 4702111235045409135     3073    3073    normal  -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -
    disconnect      session 2011-04-19      00:04:27        EDT     192.168.1.1   192.168.1.1    12607   0       1       _defaultRoot_   mobile.chatcadet.com    45fdkfjwdj      _definst_       127     200     192.168.1.1   rtmp    -       rtmp://mobile.chatcadet.com/45fdkfjwdj  rtmp://mobile.chatcadet.com/45fdkfjwdj  -       rtmp://mobile.test.com/45fdkfjwdj  FMLE/3.0 (compatible; FMSc/1.0) 4702111235045409135     3073    3376    normal  -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -       -

               

  4. I have stats log file I want to parse lines from. The lines I want to get are:

     

    GET /xxxx/xxxx/xxxx/xxxx/xxx HTTP

     

    I am trying to get those lines and the regex works to get them but I cant figure out how to process the results I want to print

    out each match to the browser.

     

    Here is the php file I am using and the output it outputs is: Array ( )

     

    <?php
    
    $url = "filex";
    
    $filepointer = fopen($url,"r");
    
    if($filepointer){
    
    while(!feof($filepointer)){
    
    $buffer = fgets($filepointer,4096);
    
    $file .= $buffer;
    
    }
    
    fclose($filepointer);
    
    } else {
    
    die("Could not open file");
    
    }
    
    
    $regexname = "/^GET(.*)HTTP/i";
    preg_match_all('/^GET(.*)HTTP/i',$file,$match);
    $result = $match[1];
    print_r($result) ;
    
    ?>

     

    Thanks in advance!

  5. I have a db with db with date and the format for the date is 1975-12-22 and I want them to appear as 1975-DEC-22

    I don't mind changing the date from date to varchar to make this happen maybe pulling each record and using find and replace or something. What would be the best way to make this happen.

     

    thanks in advance.

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