Jump to content

Trying to Add Content to Page from a text file


dotnet69

Recommended Posts

Is there a function that i can pull specific information from a text file, and trying to put that variable into a table, that refreshs every specific period of time. 

 

What is the commands that i would use to pull that info from a txt file and put it into a PHP automatically and how to you select what text in the text file to correspond where you want the information to display in PHP

 

What is the coding for this

 

Anyone?

 

 

Link to comment
Share on other sites

ok here is what i need help with

I am trying to create a a display that shows information dumped avaya into a tex file, now i have most of the PHP setup, however, i cannot find how to reference the text from that one file (specific area of text in the text file) and link it to a PHP script.  what i want to know is how to link that in formation from the text file to the PHP script.  so that when the information updates (text file) it will link it to the specific reference in the PHP document

 

Hopefully that is a little more clearer

Link to comment
Share on other sites

its dumped into a text file from an application

 

Darn!  I was afraid you would say that because it sounded like a DB would have been better for you.  I haven't worked with text files a whole lot in PHP.  You can't really point to certain spot in a txt file to retrieve info from.  Thats pretty much why DB's were invented to solve this issue.  So basically you will need create a script that will read your txt files and peel away all the garbage you don't want.  Depending on the text file this will probably be a nightmare.  Might not be so bad if the data in the file is delimited some how.  Maybe post an example of the text file and maybe I could steer you in a better direction.

Link to comment
Share on other sites

If yer data is in csv format, than ur in luck

fgetscsv

CSV isn't hard to break down, if u know what each field header is. even if u dunno each one, just the ones that are important to you.

(fopen/fgetscsv/fclose)

 

if it's not a text file, there is no tips and tricks for it.

you will most likely view it thru a hex editor looking for patterns in the data, than with pencil in hand write down offset / length and what kind of data it is.

once you are able to figure out the pattern, u can use fopen in binary mode, to extrapulate the data. (fopen/fread/fseek/fclose)

Link to comment
Share on other sites

This is the script

 

The info i need from the Txt files is the

SLA

AHT

Calls Waiting

Agents Available

 

<?

$name = "vdn.txt";

$file = fopen ($name, "r");

//register_global($new_aht);

 

############################## Get SLA and AHT data from vdn.txt ####################

 

#read up to line needed

for($i = 1; $i <= 5; $i++) {

$line = fgets ($file);

};

 

//print "\n******************************\n$line\n******************************\n\n";

 

#parse line of data

$dataLine = split("[ ]", $line);

 

$AHT = substr($dataLine[6], 0);

$AHTColor = (substr($AHT, 0) < 11) ? "green" : "red";

 

$new = explode(".", $AHT);

$new[1]=(($new[1]/100)*60);

$new[1] = round($new[1]);

 

$SLA = $dataLine[15];

$SLAColor = ($SLA < 70) ? "red" : "green";

 

 

//print "<BR>AHT: $AHT\n";

//print "<BR>SLA: $SLA\n";

 

############################## Get CW and AA data from core.txt ####################

$file_core_name = "core.txt";

$file_core = fopen ($file_core_name, "r");

 

# read up to 2nd line.

for($i = 1; $i <= 2; $i++) {

$line = fgets ($file_core);

}

 

//print "<BR>\n******************************\n$line\n******************************\n\n";

 

#parse line of data

$dataLine = split("[ ]", $line);

 

$CW = $dataLine[1];

$CWColor = ($CW > 0) ? "red" : "green";

//print "<BR>CW: $CW\n";

 

# read down one more line

#for($i = 1; $i <= 1; $i++) {

$line = fgets ($file_core);

#};

 

#parse line of data

$dataLine = split("[ ]", $line);

 

$AA = $dataLine[3];

$AAColor = ($AA <= 0) ? "red" : "green";

//print "<BR>AA: $AA\n";

 

$red = "red";

$blank = "";

 

function getLastModified($file) {

 

$lastmodified = date("d-m-y g:ia", filemtime($file) );

 

return $lastmodified;

}

 

$title = "| CW=$CW | AA=$AA";

?>

 

<HTML>

<HEAD>

<TITLE>  <? echo $title;?></TITLE>

 

<link rel="stylesheet" type="text/css" href="stats_styles.css">

<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<META http-equiv=Refresh content="60">

 

<SCRIPT language=JavaScript>

<!--

 

//Disable right mouse click Script

//By Maximus (maximus@nsimail.com) w/ mods by DynamicDrive

//For full source code, visit http://www.dynamicdrive.com

 

var message="Function Disabled!";

 

///////////////////////////////////

function clickIE4(){

if (event.button==2){

//alert(message);

return false;

}

}

 

function clickNS4(e){

if (document.layers||document.getElementById&&!document.all){

if (e.which==2||e.which==3){

//alert(message);

return false;

}

}

}

 

if (document.layers){

document.captureEvents(Event.MOUSEDOWN);

document.onmousedown=clickNS4;

}

else if (document.all&&!document.getElementById){

document.onmousedown=clickIE4;

}

 

document.oncontextmenu=new Function("return false")

 

// -->

</SCRIPT>

 

 

<SCRIPT>

 

var repeat=1 //enter 0 to not repeat scrolling after 1 run, othersise, enter 1

var title=document.title

var leng=title.length

var start=1

function titlemove() {

  titl=title.substring(start, leng) + title.substring(0, start)

  document.title=titl

  start++

  if (start==leng+1) {

    start=0

    if (repeat==0)

    return

  }

  setTimeout("titlemove()",215)

}

if (document.title)

titlemove()

 

</SCRIPT>

 

<SCRIPT type="text/javascript">

//Capture CTRL+N

document.onkeydown = funDown;

var lastKeyDown;

         

function funDown()

{

    if(window.event && window.event.keyCode == 17) 

    { // Capture and remap ctrl

      window.event.keyCode = 555;

  lastKeyDown = "Ctrl";

      return false;

    }

           

    if(window.event && window.event.keyCode == 78) 

    { // Capture and remap N

  if(lastKeyDown == "Ctrl") {

      window.event.keyCode = 555;  

      return false;

  }

    }

 

if(window.event && window.event.keyCode != 78 && window.event.keyCode != 17) 

{

lastKeyDown="Not Ctrl or N";

}

}

 

 

function right(str, n)

{

    if (n <= 0)

      return "";

    else if (n > String(str).length)

      return str;

    else {

      var iLen = String(str).length;

      return String(str).substring(iLen, iLen - n);

    }

}

 

//alert(window.parent.document.title)

//= "<? //echo $title;?>";

 

</SCRIPT>

<LINK rel="stylesheet" href="/rr/_inc/styles.css">

<LINK rel="stylesheet" type="text/css" href="stats_styles.css">

<STYLE type="text/css">

<!--

.style2 {

color: #990000;

font-weight: bold;

}

.style4 {font-size: 12px}

.style5 {

font-family: Verdana, Arial, Helvetica, sans-serif;

font-weight: bold;

color: #FFFFFF;

}

.style6 {

font-family: Verdana, Arial, Helvetica, sans-serif;

color: #000000;

}

body {

background-color: #006699;

}

-->

</STYLE>

<BODY onLoad="javascript: //opener.close();" leftmargin="0" bottommargin="0" style="margin-top:15;">

<CENTER>

  <TABLE width="290" border="1" align="center" cellpadding="1" cellspacing="1" style="background-color:#000000; color:#FFFFFF">

    <TR>

      <TD colspan="3" align="center" nowrap class="main" style="background-color: rgb(64, 64, 255);"> </TD>

    </TR>

    <TR>

      <TD colspan="3" align="center" class="cell style6" style="background-color: rgb(161, 193, 233);">Current Stats</TD>

    </TR>

  </TABLE>

<TABLE width="290" border="1" align="center" cellpadding="1" cellspacing="1" style="background-color:#003399; color:#FFFFFF">

<tr>

<td>

<TABLE width="270" border="0" align="center" cellpadding="1" cellspacing="1" style="background-color:#003399; color:#FFFFFF">

    <TR>

      <TD colspan="2" nowrap > </TD>

      <TD nowrap class="lastmod"><DIV align="center"><STRONG>last updated</STRONG></DIV></TD>

    </TR>

    <TR>

      <TD width="49%" nowrap class="stat"><DIV align="right">

 

           SLA:</DIV></TD>

      <TD width="7%"  nowrap class="value"><DIV align="right" class="<? echo $SLAColor; ?>" id="sla" style="visibility:visible"><? echo $SLA; ?>%</DIV></TD>

      <TD width="44%" nowrap class="lastmod"><? echo getLastModified("vdn.txt"); ?></TD>

    </TR>

<TR>

      <TD nowrap class="stat"><DIV align="right">AHT:</DIV></TD>

      <TD nowrap class="value"><DIV align="left" class="<? echo $AHTColor; ?>"><?

 

//echo $AHT;

echo $new[0];

echo ":";

if ($new[1] < 10) echo "0";

echo $new[1];

 

 

?></DIV></TD>

      <TD width="44%" nowrap class="lastmod"><? echo getLastModified("vdn.txt"); ?></TD>

    </TR>

<TR>

      <TD nowrap class="stat"><DIV align="right">Calls Waiting (CW):</DIV></TD>

      <TD nowrap class="value"><DIV align="left" class="<? echo $CWColor; ?>" id="calls" style="visibility:visible"><? echo $CW; ?></DIV></TD>

      <TD width="44%" nowrap class="lastmod"><? echo getLastModified("core.txt"); ?></TD>

    </TR>

    <TR>

      <TD nowrap class="stat"><DIV align="right">Agents Available (AA):</DIV></TD>

      <TD nowrap class="value"><DIV align="left" class="<? echo $AAColor; ?>"><? echo $AA; ?></DIV></TD>

      <TD width="44%" nowrap class="lastmod"><? echo getLastModified("core.txt"); ?></TD>

    </TR>

    <TR>

      <TD align="center"></TD>

      <TD align="center"></TD>

      <TD align="center"> </TD>

    </TR>

    <TR>

      <TD colspan="3" class="lastmod"><DIV align="center"><STRONG>last

          refresh</STRONG>:

  <script type="text/javascript">

<!--

var currentTime = new Date()

var month = currentTime.getMonth() + 1

var day = currentTime.getDate()

var year = currentTime.getFullYear()

var hours = currentTime.getHours()

var minutes = currentTime.getMinutes()

if (minutes < 10)

minutes = "0" + minutes

 

document.write(month + "/" + day + "/" + year + " ")

document.write(hours + ":" + minutes + " ")

if(hours > 11){

document.write("PM")

} else {

document.write("AM")

}

//-->

</script>

 

<BR>

        </DIV></TD>

      <!-- <td colspan="3" class="main" nowrap><script language="Javascript"> document.write("<b>Last refresh: "+ document.lastModified +"</b>");</script></td> -->

    </TR>

  </TABLE>

  </td>

  </tr>

  </TABLE>

 

</CENTER>

 

</BODY>

</HTML>

Link to comment
Share on other sites

what ya ask for yer script already does in the first portion

up to the:

?>

 

<HTML>

 

this is where ya want it to display the variables

$AHT, $SLA, $CW, and $AA

 

just design yer new page, with tables

and when u need one of the above variables, add <?=$AHT;?> (keep the stuff in bold just change the variable.

 

 

 

 

Link to comment
Share on other sites

correct, but the thing is how to pull that information from the text file to link up with the variable

 

Post a sample of the text file!  Nobody can really tell you how to go about it till they know a little bit about the structure of the file.

Link to comment
Share on other sites

correct, but the thing is how to pull that information from the text file to link up with the variable

 

Post a sample of the text file!  Nobody can really tell you how to go about it till they know a little bit about the structure of the file.

 

Agreed, please post the files. Also, please use the code or quote buttons on the toolbar when posting large blocks of text.

Link to comment
Share on other sites

These are the three tables i need to pull info from

 

<quote>

Date: 2/1/2008

Split/Skill:

Start Time Service Level ASA Calls Offered Calls Answered AHT Aban Calls % Aban % Occ. % Avail % AUX Staffed Time Avail Time Aux Time Avg Talk Time Avg Hold Time Avg ACW Time APS Max Delay

Totals 99 :03 298 298 12:14 0 .00 61 27 12 117:25:15 32:02:51 14:26:02 12:35 :42 :37 - :52

7:30 AM 0 0 0 0 0 0 0 0 46 54 :20:28 :09:19 :11:09 0 0 0 1 :00

8:00 AM 100 :03 25 25 7:45 0 .00 52 41 7 8:44:51 3:36:41 :36:26 10:30 :08 :13 17 :03

8:30 AM 100 :03 28 28 11:56 0 .00 58 33 9 13:05:28 4:16:28 1:13:17 15:15 :07 :40 26 :03

9:00 AM 100 :03 39 39 10:45 0 .00 59 36 6 18:58:33 6:45:56 1:05:03 14:41 :38 :35 38 :03

9:30 AM 100 :03 50 50 14:59 0 .00 56 30 14 23:15:43 7:00:40 3:13:15 13:48 :53 :49 47 :03

10:00 AM 97 :04 71 71 12:24 0 .00 66 15 19 25:14:31 3:49:30 4:51:16 11:37 :46 :44 50 :33

10:30 AM 100 :03 85 85 12:36 0 .00 65 23 12 27:45:41 6:24:17 3:15:36 11:26 :56 :33 56 :07

 

 

Split/Skill: Skill State: NORMAL

Calls Waiting: 0 Agents Staffed: 62

Oldest Call Waiting: :00 Agents Avail: 26

Direct Agent Calls Waiting: 0 Agents Ringing: 0

% Within Service Level: 100 Agents in ACW: 3

Service Level: 30 Agents on ACD Calls: 31

ACD Calls: 28 Agents in AUX: 2

Aban Calls: 0 Agents in Other: 0

 

 

1/30/2008

 

Totals .00 9 11.75 .06 0 .00 0 0 16 3.77 9.23 100.00 1.7 5

12:00AM - 12:30AM 0 0 .00 0 0 0 .00 1.0 0

12:30AM - 1:00AM 0 0 .00 0 0 0 .00 1.0 0

1:00AM - 1:30AM 0 0 .00 0 0 0 .00 1.0 0

1:30AM - 2:00AM 0 0 .00 0 0 0 .00 1.0 0

2:00AM - 2:30AM 0 0 .00 0 0 0 .00 1.0 0

2:30AM - 3:00AM 0 0 .00 0 0 0 .00 1.0 0

3:00AM - 3:30AM 0 0 .00 0 0 0 .00 1.0 0

3:30AM - 4:00AM 0 0 .00 0 0 0 .00 1.0 0

4:00AM - 4:30AM 0 0 .00 0 0 0 .00 1.0 0

4:30AM - 5:00AM 0 0 .00 0 0 0 .00 1.0 0

5:00AM - 5:30AM 0 0 .00 0 0 0 .00 1.0 0

5:30AM - 6:00AM 0 0 .00 0 0 0 .00 1.0 0

6:00AM - 6:30AM 0 0 .00 0 0 0 .00 1.0 0

6:30AM - 7:00AM 0 0 .00 0 0 0 .00 1.0 0

7:00AM - 7:30AM 0 0 .00 0 0 0 .00 1.0 0

7:30AM - 8:00AM 0 0 .00 0 0 0 .00 1.0 0

8:00AM - 8:30AM 0 0 .00 0 0 0 .00 2.2 0

8:30AM - 9:00AM 0 0 .00 0 0 2 10.53 3.06 2.0 0

9:00AM - 9:30AM 0 0 .00 0 0 3 1.83 3.83 2.0 0

9:30AM - 10:00AM 0 0 .00 0 0 0 20.94 2.0 0

10:00AM - 10:30AM .00 3 9.11 .00 0 .00 0 0 4 2.55 24.61 100.00 2.0 2

10:30AM - 11:00AM .00 1 4.62 .53 0 .00 0 0 0 8.55 100.00 2.0 0

11:00AM - 11:30AM 0 0 .00 0 0 0 .00 3.0 0

11:30AM - 12:00PM 0 0 .00 0 0 3 5.37 .00 2.9 0

12:00PM - 12:30PM .00 2 9.52 .00 0 .00 0 0 0 47.17 100.00 3.0 1

12:30PM - 1:00PM .00 2 24.41 .00 0 .00 0 0 3 2.32 39.60 100.00 2.5 1

1:00PM - 1:30PM .00 1 5.90 .00 0 .00 0 0 0 1.14 100.00 3.9 0

1:30PM - 2:00PM 0 0 .00 0 0 1 .53 20.48 3.0 0

</quote>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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