dotnet69 Posted January 30, 2008 Share Posted January 30, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/ Share on other sites More sharing options...
dotnet69 Posted January 31, 2008 Author Share Posted January 31, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454096 Share on other sites More sharing options...
Azarian Posted January 31, 2008 Share Posted January 31, 2008 Where does this text file come from? Is it generated from another program? or is it user created? Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454123 Share on other sites More sharing options...
dotnet69 Posted January 31, 2008 Author Share Posted January 31, 2008 its dumped into a text file from an application Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454134 Share on other sites More sharing options...
Azarian Posted January 31, 2008 Share Posted January 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454138 Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 its not all that hard. but you will need to know how the file can be broken down. if you got this much you can do pretty much anything with the data. importing to a db, or making your own interface. again not all that hard but may take time. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454218 Share on other sites More sharing options...
dotnet69 Posted January 31, 2008 Author Share Posted January 31, 2008 is there any trick or tips that i can use to break the data down, and reference it to PHP? Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454368 Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 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) Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454377 Share on other sites More sharing options...
dotnet69 Posted January 31, 2008 Author Share Posted January 31, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454704 Share on other sites More sharing options...
laffin Posted January 31, 2008 Share Posted January 31, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454864 Share on other sites More sharing options...
dotnet69 Posted February 1, 2008 Author Share Posted February 1, 2008 correct, but the thing is how to pull that information from the text file to link up with the variable Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454883 Share on other sites More sharing options...
Azarian Posted February 1, 2008 Share Posted February 1, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-454896 Share on other sites More sharing options...
laffin Posted February 1, 2008 Share Posted February 1, 2008 The script u posted already pulls the variables from the text file. it's just designing yer html output page with those variables. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-455045 Share on other sites More sharing options...
dotnet69 Posted February 1, 2008 Author Share Posted February 1, 2008 what i want to know is how to pull the variables from that text file Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-455265 Share on other sites More sharing options...
rhodesa Posted February 1, 2008 Share Posted February 1, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-455272 Share on other sites More sharing options...
dotnet69 Posted February 1, 2008 Author Share Posted February 1, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-455390 Share on other sites More sharing options...
dotnet69 Posted February 2, 2008 Author Share Posted February 2, 2008 any assistance? i want to be able to pull info from those text files into PHP Is there a guide or tutorial in how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/88650-trying-to-add-content-to-page-from-a-text-file/#findComment-456397 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.