Click here to Skip to main content
15,891,033 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Looking for Website Host Provider (PHP/MYSQL/Wordpress) Pin
cyrossis17-Oct-09 1:01
cyrossis17-Oct-09 1:01 
QuestionOverwhelmed website mockup Pin
devboycpp7-Oct-09 7:47
devboycpp7-Oct-09 7:47 
AnswerRe: Overwhelmed website mockup Pin
Marc Firth7-Oct-09 22:17
Marc Firth7-Oct-09 22:17 
GeneralRe: Overwhelmed website mockup Pin
devboycpp8-Oct-09 7:35
devboycpp8-Oct-09 7:35 
GeneralRe: Overwhelmed website mockup Pin
Marc Firth8-Oct-09 21:53
Marc Firth8-Oct-09 21:53 
GeneralRe: Overwhelmed website mockup Pin
Richard MacCutchan8-Oct-09 23:01
mveRichard MacCutchan8-Oct-09 23:01 
Questionremove toolbars from browser window that's open or how to close parent window if remove toolbars requires two windows be open [modified] Pin
Diana Rhoades7-Oct-09 5:45
Diana Rhoades7-Oct-09 5:45 
QuestionNeed Memory Leak Help Pin
AsianMike7-Oct-09 4:23
AsianMike7-Oct-09 4:23 
I have a php page that is leaking pretty bad. I'm not sure if this belongs in this forum or the php one but I don't think it's the php that giving me problems. I've tried to use tools like drip and sieve to help narrow the problem down, but I'm not exactly sure how to fix it. I've tried nulling and deleting variables to clean stuff up but it's still not helping. Can someone give me a hand at cleaning my code up? I'm fairly new at the mem leak stuff. Thanks.

Sorry for the large amount of code. Sigh | :sigh:

<?php
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/header.php";
include_once $_SERVER["DOCUMENT_ROOT"] . "/include/dbfunctions.php";
header("Cache-Control: no-cache"); //needed because IE likes to cache stuff
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
<meta http-equiv="refresh" content="3600">
<html xmlns:"http://www.w3.org/1999/xhtml">

<head>
<? include_once $_SERVER["DOCUMENT_ROOT"] . "/include/scripts.php"; ?>   
<script type="text/javascript" src="/scripts/sortabletables.js"></script>
<script type="text/javascript" src="/scripts/reverse.js"></script>

<script type="text/javascript">

var updateTopObj;
var day = $.getUrlParameter("day");
var page = $.getUrlParameter("page");

$(document).ready(function(){         
  
  updateTopObj = new UpdatablePage({
           updateFunction: updateTop,
           interval: 4000,
           dataType: "xml",
           url: "/resources/Events.xml"
  });                                      
      
  updateTopObj.update();
  updateTopObj.start();
 
  $('#EventsTable').styleTable({});
  $('.table-sortable').click(function(){
    $('tr','#EventsTable').removeClass("odd").removeClass("even");
    $('#EventsTable').styleTable({});
    parent.OMC.pause(frameId);
  });

}); // end $(document).ready 

function updateTop(xml){

  var $xml = $(xml);
  var $root = $('eventsInfoTable', $xml);
  var $numDays = $('eventRec', $root).length; // alert($numDays);
  
  var $dayMenuTable = $('#DayMenuTable');
  var $dayMenuBody = $('tbody',$dayMenuTable).empty();
  var $newDayRow = $('<tr></tr>').appendTo($dayMenuBody);
  
  var $date_xml = $('date',$root);
  var $index_xml = $('dayIndex', $root);
  var $pages_xml = $('numPages', $root);
  var $records_xml = $('numRecords', $root);
  var date_arr = [];
  var index_arr = [];
  var page_arr = [];
  var records_arr = [];
  
  $('eventRec',$root).each(function(i){
    $date_xml = $('date',this).text().substring(0,5); // only show dd/mm
    date_arr[i] = $date_xml; 
    $index_xml = $('dayIndex',this).text();
    index_arr[i] = $index_xml; 
    $page_xml = $('numPages',this).text();
    page_arr[i] = $page_xml; 
    $records_xml = $('numRecords',this).text();
    records_arr[i] = $records_xml; 
  });

  for(i=0; i<date_arr.length; i++){
    if(date_arr[i] != "00/00"){
      $dayParam = index_arr[i];
    }
  }

  if(!day){ day = $dayParam;}
  for(i=date_arr.length-1; i>=0; i--){
    if(date_arr[i] != "00/00") { // don't display 00/00 dates
      $topPageNum = parseInt(page_arr[i])-1;
      //alert(index_arr[i]+" : "+day);
      if(index_arr[i] == day){ 
        if(!page){page = page_arr[i]-1;}
        $cell = $('<td width=45><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + $topPageNum + '" class="submenuSelected" onclick="parent.OMC.play(frameId);">' + date_arr[i] + '</a></td>').appendTo($newDayRow);
        $('#dayTitle').empty().append(date_arr[i]+' Events Log');
      } else $cell = $('<td width=45><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + $topPageNum + '"  class="submenuNormal" onclick="parent.OMC.play(frameId);">' + date_arr[i] + '</a></td>').appendTo($newDayRow);
    } //end if date != 00/00
  }
  
  //alert("DAY"+day+"_PG"+page);
  $cell = $('<td><form action="CSV.php" target="_blank" method="GET"><input type="submit" class="genCSVLink" value="View Weekly CSV"/></form></td>').appendTo($newDayRow);
  
  var $pageMenuTable = $('#PageMenuTable');
  var $pageMenuBody = $('tbody',$pageMenuTable).empty();
  var $newPageRow = $('<tr></tr>').appendTo($pageMenuBody);
  
  for(i=date_arr.length-1; i>=0; i--){
      if(index_arr[i] == day){ 
        $totalPages = parseInt(page_arr[i]);
        $pageInc = 20;
        $totalInc = parseInt(($totalPages-1)/$pageInc)+1; // $totalPages -1 for incase there are 20 pages exactly
        //$currentPage = parseInt(page_arr[i])-parseInt(page);
        $currentPage = parseInt(page)+1;
        $currentInc = parseInt(($currentPage-1)/$pageInc) + 1; // $currentPages -1 for incase there are 20 pages exactly
        if($currentInc != 1){
          $prevPage = ($currentInc-1)*$pageInc-1;
          $cell = $('<td width=20><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + $prevPage + '" class="submenuNormal" onclick="parent.OMC.play(frameId);">Prev</a></td>').appendTo($newPageRow);
        }
        for(j=0; j<=page_arr[i]-1; j++){
          $pageNum = parseInt(j)+1;
          //$pageNum = $totalPages - parseInt(j);
          if(($pageNum >= ($currentInc*$pageInc)-$pageInc+1) && ($pageNum <= ($currentInc*$pageInc))){
            if($pageNum == $currentPage){
              $cell = $('<td width=20><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + j + '" class="submenuSelected" onclick="parent.OMC.play(frameId);">' + $pageNum + '</a></td>').appendTo($newPageRow);
            } else{
              $cell = $('<td width=20><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + j + '" class="submenuNormal" onclick="parent.OMC.play(frameId);">' + $pageNum + '</a></td>').appendTo($newPageRow);  
              
            }
          }  
        }
        if($currentInc != $totalInc){
          $nextPage = ($currentInc*$pageInc);
          $cell = $('<td width=20><a href="/webpage/events.php?day=' + index_arr[i] + '&page=' + $nextPage + '" class="submenuNormal" onclick="parent.OMC.play(frameId);">Next</a></td>').appendTo($newPageRow);
        }
        if($currentPage == $totalPages){
          if(records_arr[i] == 0){
            var $startRecord = 0;
            var $endRecord = 0; 
          } else{
            var $startRecord = ($currentPage-1)*100+1;
            var $endRecord = records_arr[i];
          }
        } else if($totalPages == 0){
          var $startRecord = 0;
          var $endRecord = 0;
        }
        else{
          var $startRecord = ($currentPage-1)*100+1;
          var $endRecord = ($currentPage)*100;
        }
        $('#RecordsMenuTable').empty().append('Displaying records ' + $startRecord + ' to ' + $endRecord + ' of ' + records_arr[i]);
      }
  }
    
  // make events table
  $.ajax({ 
     type: "GET",
     url: "/resources/DAY"+day+"_PG"+page+".xml",
     dataType: "xml",
     success: function(xml){
         var $eventsXml = $(xml);
         var $eventsRoot = $('eventsTable', $eventsXml);
         var eventsBody = document.getElementById('EventsBody');
         var numNewRows = $('eventRec', $eventsRoot).length;

         var $currentRows = $('tr', $(eventsBody));
         var numRows = $currentRows.length; 
         
         $('th', $('#EventsTable')).removeClass("table-sorted-asc").removeClass("table-sorted-desc");
         var docFragment = document.createDocumentFragment();

         var newTable = false;
         //alert(numNewRows+" : "+numRows);

         //If we have more rows to append than exist, re-create the entire table
         if(numNewRows != numRows){
           $(eventsBody).empty();
           newTable = true;
           //alert("need new table");
         }
         //else{alert("don't need new table");}

         var trElem, tdElem;

         $('eventRec', $eventsRoot).reverse();

         if(newTable) {
           $('eventRec', $eventsRoot).each(function(i){
             $record = $(this);
             //alert($(this).text());
             trElem = document.createElement('tr');
             docFragment.appendChild(trElem);
             $record.children('dateTime').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('type').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('source').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('eventId').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('assAlrm').each(function(i) { 
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('username').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               tdElem.innerHTML = $(this).text();  
             });
             $record.children('desc').each(function(i) {
               tdElem = document.createElement('td');
               trElem.appendChild(tdElem);
               var cellText = $(this).text();
               $('bullet', $(this)).each(function(i){
                 tempText = $(this).text();
                 cellText = cellText.replace($(this).text(),"<br>&bull;"+tempText);
               });
               tdElem.innerHTML = cellText;
             });
             eventsBody.appendChild(docFragment);
           });
         }

         if(newTable) {
           eventsBody.appendChild(docFragment);
           $('#EventsTable').styleTable({header:false, title:false});
         } else {}

		 trElem = null;
         delete trElem;
		 tdElem = null;
         delete tdElem;
		 numNewRows = null;
         delete numNewRows;
		 numRows = null;
         delete numRows;
		 newTable = null;
		 delete newTable;
		 cellText = null;
		 delete cellText;
		 $eventsRoot = null;
		 delete $eventsRoot;
		 $eventsXml = null;
		 delete $eventsXml;
		 eventsBody = null;
		 delete eventsBody;
		 $record = null;
		 delete $record;
		 cellText = null;
		 delete cellText;
     }
  });  

$xml = null;
delete $xml;
$root = null;
delete $root;
$numDays = null;
delete $numDays;

$dayMenuTable = null;
delete $dayMenuTable;
$dayMenuBody = null;
delete $dayMenuBody;
$newDayRow = null;
delete $newDayRow;

$date_xml = null;
delete $date_xml;
$index_xml = null;
delete $index_xml;
$page_xml = null;
delete $page_xml;
$records_xml = null;
delete records_xml;

date_arr = null;
delete date_arr;
index_arr = null;
delete index_arr;
page_arr = null;
delete page_arr;
records_arr = null;
delete records_arr;

dayParam = null;
delete dayParam;
topPageNum = null;
delete topPageNum;
i = null;
delete i;

$pageMenuTable = null;
delete $pageMenuTable;
$pageMenuBody = null;
delete pageMenuBody;
$newPageRow = null;
delete newPageRow;

$totalPages = null;
delete $totalPages;
$pageInc = null;
delete $pageInc;
$totalInc = null;
delete $totalInc;
$currentPage = null;
delete $currentPage;
$currentInc = null;
delete $currentInc;
$prevPage = null;
delete $prevPage;
j = null;
delete j;
$pageNum = null;
delete $pageNum;
$cell = null;
delete $cell;
$nextPage = null;
delete $nextPage;
$startRecord = null;
delete $startRecord;
$endRecord = null;
delete $endRecord;

} // end of updateTop

function cleanup() {
  delete updateTopObj;
  delete day;
  delete page;
}

</script>


<title>Events</title>
</head>
<body onUnload="cleanup();">
<div class="whiteSubmenu"><table id="DayMenuTable" border="0"><tbody></tbody></table> </div>
<div class="tableSpacer"></div>
<div class="whiteSubmenu"><table id="PageMenuTable" border="0"><tbody></tbody></table> </div>
<div id="RecordsMenuTable" border="0"></div>
<hr>
<div id="dayTitle" style="color:#191970;font-size:12pt"></div>
<table id="EventsTable" title="" class="mainView table-autosort">
   <thead>
      <tr>
      <th class="table-autosort table-sortable:default" style="cursor:pointer">Timestamp</th>
      <th class="table-autosort table-sortable:default" style="cursor:pointer">Type</th>
      <th class="table-sortable:default" style="cursor:pointer">Source</th>
      <th class="table-sortable:default" style="cursor:pointer">ID</th>
      <th class="table-sortable:default" style="cursor:pointer">Associated Alarm</th>
      <th class="table-sortable:default" style="cursor:pointer">Username</th>
      <th>Description</th>
      </tr>
   </thead>
   <tbody id="EventsBody">
   </tbody>
</table>

</body>

</html>

Questionabout ffmpeg upload large video file Pin
SHINOJK7-Oct-09 3:49
SHINOJK7-Oct-09 3:49 
AnswerRe: about ffmpeg upload large video file Pin
Marc Firth7-Oct-09 22:20
Marc Firth7-Oct-09 22:20 
QuestionHow to upload large video files using php in less time [modified] Pin
SHINOJK6-Oct-09 23:33
SHINOJK6-Oct-09 23:33 
AnswerRe: How to upload large video files using php in less time Pin
Aman Bhullar7-Oct-09 0:11
Aman Bhullar7-Oct-09 0:11 
GeneralRe: How to upload large video files using php in less time Pin
SHINOJK7-Oct-09 0:51
SHINOJK7-Oct-09 0:51 
GeneralRe: How to upload large video files using php in less time Pin
Aman Bhullar7-Oct-09 3:09
Aman Bhullar7-Oct-09 3:09 
QuestionHow to implement Signature Pad ? Pin
That's Aragon6-Oct-09 23:04
That's Aragon6-Oct-09 23:04 
AnswerRe: How to implement Signature Pad ? Pin
Richard MacCutchan6-Oct-09 23:45
mveRichard MacCutchan6-Oct-09 23:45 
GeneralRe: How to implement Signature Pad ? Pin
cousinduck15-Oct-09 11:15
cousinduck15-Oct-09 11:15 
AnswerRe: How to implement Signature Pad ? Pin
cousinduck15-Oct-09 11:22
cousinduck15-Oct-09 11:22 
GeneralRe: How to implement Signature Pad ? Pin
mjessop1216-Dec-09 5:09
mjessop1216-Dec-09 5:09 
QuestionMultiple Checkbox validation Pin
llibin6-Oct-09 21:03
llibin6-Oct-09 21:03 
AnswerRe: Multiple Checkbox validation Pin
Marc Firth6-Oct-09 21:57
Marc Firth6-Oct-09 21:57 
AnswerRe: Multiple Checkbox validation Pin
Reelix7-Oct-09 23:39
Reelix7-Oct-09 23:39 
QuestionWebsite to track Diseases Pin
BrianElley6-Oct-09 11:49
BrianElley6-Oct-09 11:49 
AnswerRe: Website to track Diseases Pin
Christian Graus6-Oct-09 12:31
protectorChristian Graus6-Oct-09 12:31 
GeneralRe: Website to track Diseases Pin
BrianElley6-Oct-09 12:41
BrianElley6-Oct-09 12:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.