Jump to content

buildakicker

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by buildakicker

  1. Ok, did a little change.. .but this works. Thanks to the web! Added input names like so: name="request['+fields+'][Full Path of folder to change access:]" Added a number to them each time the user wanted to add a new field... Then processed them like so: $a=$_REQUEST['request']; foreach ($a as $value1) { foreach ($value1 as $k => $value2) { $note.= $k; $note.= $value2; } } Example ---- $k returns: Full Path of folder to change access: $value2 returns user input
  2. I ran into an interesting issues... this foreach will return the first added field correctly, however it will not add a 2nd or 3rd field with the data from the addQues(); For example: First Result: Full Path of folder to change access: t:\this-drive User Permission Group to be changed: dv group Additional users requiring read access: jfla Additional users requiring author access: azann Users to be removed from access: dlint Data Steward, Program Manager, Project Lead, or Supervisor who can authorize access changes: gpone Phone number of approving official: 888-888-7777 Second: i:\new i group urusa mmalone jjon yokis 888-999-555 Third: u:\ u group phammer midnite bmarley gdead 777-444-2222 ect... Any suggestions?
  3. this worked thanks... $addQues = array( "Full Path of folder to change access:", "User Permission Group to be changed:", "Additional users requiring read access:", "Additional users requiring author access:", "Users to be removed from access:", "Data Steward, Program Manager, Project Lead, or Supervisor who can authorize access changes:", "Phone number of approving official:", ); foreach($a as $k => $value) { echo "$addQues[$k] $value <br />"; }
  4. Hi, thanks for the response. They already have name: name="addfield[]" I get them in the array no problem, my issue is putting text before each of the results I am echoing out. Thanks
  5. I have a form: <fieldset> <legend>Request Access Change(s) To Exisiting Folder</legend> <div class="topinfo"> <p><span class="required">* Required Fields</span></p> </div> <label for="fullpath"><span class="required">*Full Path of folder to change access:</span></label> <input name="fullpath" id="it10" type="text" size="50" maxlength="50" /> <br /> <small>Example: j://this/is/my/folder</small><br /> <div class="bgdiff"> <label for="userpermissiongroup">User Permission Group to be changed:</label> <input name="userpermissiongroup" type="text" id="it11" size="50" maxlength="50" /> <small>If Known...</small></div> <br /> <label for="addreadaccess">Additional users requiring read access:</label> <input name="addreadaccess" type="text" id="it12" size="15" maxlength="15" /> <br /> <small>AD Username</small><br /> <div class="bgdiff"> <label for="addauthoraccess">Additional users requiring author access:</label> <input name="addauthoraccess" type="text" id="it13" size="12" maxlength="12" /> <br /> <small>AD Username</small></div> <br /> <label for="removeaccess">Users to be removed from access:</label> <input name="removeaccess" type="text" id="it14" size="12" maxlength="12" /> <br /> <small>AD Username</small><br /> <div class="bgdiff"> <label for="supervisor"><span class="required">*Data Steward, Program Manager, Project Lead, or Supervisor who can authorize access changes:</span></label> <input name="supervisor" type="text" id="it15" size="30" maxlength="30" /> <br /> <small>AD Username</small></div> <br/> <label for="phoneapprover"><span class="required">*Phone number of approving official: </span></label> <input name="phoneapprover" type="text" id="it16" size="30" maxlength="30" /> <br /> <small>999-999-9999</small><br /> <!-- id to adding more fields on demand to ---> <div id="addmore"></div> <input type="button" onClick="addInput()" name="add" value="Add More Requests" /> </fieldset> On Submit, this form calls a php script that just takes all these fields and echos them out for me to see for now. I would like to add the ability to add this whole fieldset again, if the user would like on click. I have a javascript "addInput()" function that just adds all these fields again: var fields = 0; function addInput() { /*if (addfields != 5) {*/ document.getElementById('addmore').innerHTML += '<hr /><p align="center" class="redtext" id="top'+fields+'">------------ ADD NEXT ACCESS CHANGE REQUEST BELOW ------------</p>'; document.getElementById('addmore').innerHTML += '<label for="fullpath" id="fauxtop"><span class="required">*Full Path of folder to change access:</span></label><input name="addfield[]" id="it10-' + fields + '" type="text" size="50" maxlength="50" /><br /><small>Example: j:\\this\\new\\folder\\</small><br />'; document.getElementById('addmore').innerHTML += '<div class="bgdiff"><label for="userpermissiongroup">User Permission Group to be changed:</label><input name="addfield[]" id="it11-' + fields + '" type="text" size="50" maxlength="50" /><small>If Known...</small></div><br />'; document.getElementById('addmore').innerHTML += '<label for="addreadaccess">Additional users requiring read access:</label><input name="addfield[]" id="it12-' + fields + '" type="text" size="15" maxlength="15" /><br /><small>AD Username</small><br />'; document.getElementById('addmore').innerHTML += '<div class="bgdiff"><label for="addauthoraccess">Additional users requiring author access:</label><input name="addfield[]" id="it13-' + fields + '" type="text" size="12" maxlength="12" /><br /><small>AD Username</small></div><br />'; document.getElementById('addmore').innerHTML += '<label for="removeaccess">Users to be removed from access:</label><input name="addfield[]" id="it14-' + fields + '" type="text" size="12" maxlength="12" /><br /><small>AD Username</small><br />'; document.getElementById('addmore').innerHTML += '<div class="bgdiff"><label for="supervisor"><span class="required">*Data Steward, Program Manager, Project Lead, or Supervisor who can authorize access changes:</span></label><input name="addfield[]" id="it15-' + fields + '" type="text" size="30" maxlength="30" /><br /><small>AD Username</small></div><br/>'; document.getElementById('addmore').innerHTML += '<label for="phoneapprover"><span class="required">*Phone number of approving official: </span></label><input name="addfield[]" id="it16-' + fields + '" type="text" size="30" maxlength="30" /><br /><small>999-999-9999</small><br />'; fields += 1; } I have been using a foreach loop to display the form inputs: foreach($_REQUEST['addfield'] as $value) { echo "$value <br />"; } I would like to have each of the fields display the $value and have information before each like so: Full Path of folder to change access: $value; User Permission Group to be changed: $value; That is where my problem is... seems simple, but I am not getting it to work. Thanks for any help!
  6. hi all, i am trying to just get a couple things from this RSS feed: http://www.sierraavalanchecenter.org/bottomline-rss.php I would like to grab the danger rose image on the left, the text that tells of the Avalanche danger ie... "Avalanche Danger Remains LOW..." and the date. I have tried using a few things like: $html = 'http://www.sierraavalanchecenter.org/bottomline-rss.php'; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $res = $xpath->query('//div[@id=dangericon]'); if ($res->item(0) !== NULL) { $test = $res->item(0)->nodeValue; } ...without any luck. Anyone have some advice for me? thanks!
  7. Hi all, I have a strange issue going on. It may be server related, but I don't know what to look for. I have a .php page with a few Virtual Includes: <?php virtual ("nav.shtml"); ?> ...throughout it. I have also a parser that is displaying XML data in a table form. The parser works with the standard: <?php include ('parser.php'); ?> ...however, if I have the Virtual above the include, the parser doesn't work. Or at least it will not "find the file" however, the file is there and it works ABOVE the virtual, displaying it fine... For example, this works: <?php include ('parser.php'); ?> <?php virtual ('file.shtml'); ?> This doesn't: <?php virtual ('file.shtml'); ?> <?php include ('parser.php'); ?> Any thoughts?
  8. Hi, I have echoed out the results and they show just fine. When the XLS file comes up, all I get is the geo_area field and 45 rows with 1-45 numbers in it. However, there should be multiple columns and rows...
  9. I have a simple question I thought... but I am not able to get it to work. I have an oracle select statement: select geo_area, oct_projects, oct_work_perf from metrics_parea_geo_trends Order by geo_area It works fine with SLQ+, so I know it's a good statement. When I try to export it to an excel spreadsheet using Spreadsheet_Excel_Writer() I get only the first field, geo_area and the total rows returned in the first column. This was working no problem on php4, however, we moved to php5 and now there is this issue. $select ="select ".$spiece." from metrics_parea_geo_trends Order by geo_area"; //THIS WORKS in SQL PLUS: select geo_area, oct_projects, oct_work_perf from metrics_parea_geo_trends Order by geo_area; $trends = $DB->select($con,$select); $DB->logOff($con); $fname = tempnam("/tmp", "Geographic_Area_Trend.xls"); $xls = & new Spreadsheet_Excel_Writer($fname); $xls->send("Geographic_Area_Trend.xls"); $sheet = & $xls->addWorksheet('Binary Count'); // Write some numbers for ( $i=0;$i<11;$i++ ) { // Use PHP's decbin() function to convert integer to binary $sheet->write($i,0,decbin($i)); } // Finish the spreadsheet, dumping it to the browser $xls->close(); I have tried other simple export to xls, but nothing is working. I am stumped! Any clues?
  10. There is something wrong with the tables in the db.
  11. Hi all, I am moving an app from php4 to 5 and have this query: $queryR = "Select u.unit_name, o.contact_name, o.contact_area, o.contact_number, o.contact_email, u.web_url, o.offering_desc from eum_offerings v o, eum_units u where o.offering = '".$offering."' and o.eu = u.eu order by u.unit_name"; where offering could = a few things, such as bridges. Does that look correct? SQL Plus is giving me a command not properly ended error.
  12. I was just reading up on this post: I guess this might have a lot to do with this script I am looking at...
  13. Hi thanks for the reply. This was written before I arrived at my current position. The person who wrote the PHP Parsing script, Adam Flynn, has been very helpful. He replied to me about passing Strings into the check_not_empty function. Which has worked to a certain extent. I am no longer getting errors, however, the XML isn't rendering in the page correctly yet. So, this error is solved in all reality.
  14. Hello all, I have an application that I am moving from php4 to php5 that I get some errors in. Namely: Line 497 has the: return (isset($s) && strlen($s)); // var is set and not an empty string '' of this function: function check_not_empty($s, $include_whitespace = false) { if ($include_whitespace) { // make it so strings containing white space are treated as empty too $s = trim($s); } return (isset($s) && strlen($s)); // var is set and not an empty string '' } I cannot figure out why it is doing this... It works fine on the php4 server. Here is the code for the file that is throwing this error: <?php //ERROR REPORTING ini_set('display_errors',1); error_reporting(E_ALL); /////////// include 'parser_php5.php'; include 'db.php'; include 'dbconnect.php'; // It's probably best to put this file in a non web-accessible folder for security $configFile = '../documents/WEBRIndex.xml'; $fileContents = file_get_contents($configFile); $indexXML = new XMLParser($fileContents); //Work the magic... $indexXML->Parse(); // ------------------------------------------------------------------ // Associate the users requested view with a document view mapping $docType = $_GET["doc"]; //$action = $_GET["act"]; if(check_not_empty($docType) == FALSE) { echo "No document type specified"; exit; } // Find the XML mapping that corresponds with this type.. the ->document->document reference is because // there is an embedded ->document attached automatically by the XML Parser... the second ->document // reference is part of our document $viewXMLFile = null; $viewMapping = null; foreach($indexXML->document->document as $doc) { if(strcmp($doc->documentkey[0]->tagData, $docType) == 0) { $viewMapping = $doc; $viewXMLFile = $doc->viewxml[0]->tagData; break; } } // Make sure we found our XML view mapping if($viewMapping == null) { echo "No mapping found"; exit; } // Now load the actual view XML file into memory $viewFile = '../documents/'.$viewXMLFile; $fileContents = file_get_contents($viewFile); $viewXML = new XMLParser($fileContents); //Work the magic... $viewXML->Parse(); // Find the XML mapping that corresponds with this type (because there can be multiple definitions per view XML file) // so we need to do this a second time, (the first was for the index file) $viewMapping = null; foreach($viewXML->document->documentview as $view) { if(strcmp($view->documentkey[0]->tagData, $docType) == 0) { $viewMapping = $view; break; } } // Make sure we found our XML view mapping if($viewMapping == null) { echo "No mapping found"; exit; } // --------------------------------------------------------------- // Extract the header and group data from the view template $includeScripts = $viewMapping->includescript; $customScript = $viewMapping->customscript; $headerBlock = $viewMapping->header[0]; $bodyBlock = $viewMapping->body[0]; $documentType = $viewMapping->documenttype[0]->tagData; if(check_not_empty($headerBlock) == FALSE || check_not_empty($bodyBlock) == FALSE || check_not_empty($documentType) == FALSE) { echo " Malformed document view - ".check_not_empty($headerBlock)." - ".check_not_empty($bodyBlock)." - ".check_not_empty($documentType); exit; } // ------------------------------------------------------------------------------------------------ // Grab any final screen variables... The home button returns the user back to the WEBR index page // the add button reloads the page for another document entry. The final screen message $completionMessage = ""; $homeButtonMsg = null; $addButtonMsg = null; if(count($viewMapping->submitmessage) > 0) { $finalScreenMsg = $viewMapping->submitmessage[0]->tagData; } if(count($viewMapping->homebutton) > 0) { $homeButtonMsg = $viewMapping->homebutton[0]->tagData; } if(count($viewMapping->completionmessage) > 0) { $completionMessage = $viewMapping->completionmessage[0]->tagData; } $DB = new DB($dbUser, $dbPassword, $dbServer); if ( $DB->error ) { echo $DB->errorToString(); exit("No database"); } // ------------------------------------------------------------------------------------ // The various case types are provided to add abstraction between the control column // and the provided drop-down data function provideDynamicData($viewMapping, $element, $type, $selected = null) { global $DB; $outText = ""; switch($type) { case "CURRENTDATE": return Date("m/d/Y"); break; case "CURRENTTIME": return Date("Hi"); break; case "EUNAMES": $outText .= getHTMLOptionsFromDB($viewMapping, $element, $selected); break; } return $outText; } // ------------------------------------------------------------------------------------ function getHTMLOptionsFromDB($viewMapping, $element, $selected) { global $DB; $outText = ""; $table = $viewMapping->defaulttable[0]->tagData; $column = $element->control[0]->column[0]->tagData; $sql = "SELECT distinct ".$column." from ".$table; $DB->query($sql); if ( $DB->error ) { echo $DB->errorToString(); exit("No database"); } $result = $DB->getSensibleStatement(); for($i=0; $i<count($result); $i++) { $value = $result[$i][$column]; if($selected == null) { $outText .= "<option value='".$value."'>".$value."</option>"; } else { if(strcmp($value, $selected) == 0) $outText .= "<option value='".$value."' selected>".$value."</option>"; else $outText .= "<option value='".$value."'>".$value."</option>"; } } return $outText; } // ------------------------------------------------------------------------------------ function returnConnection() { global $dbUser, $dbPassword, $dbServer; $con = OCILogon($dbUser, $dbPassword, $dbServer); if ( ! $con ) { echo "Unable to connect: " . var_dump( OCIError() ); exit; } return $con; } function executeSQL($sql) { global $statusXML, $errorMsg, $errorXML, $dbUser, $dbPassword, $dbServer; $con = OCILogon($dbUser, $dbPassword, $dbServer); if ( ! $con ) { $errorMsg = "Unable to connect: " . var_dump( OCIError() ); return FALSE; } $stmt = OCIParse($con, $sql); OCIExecute($stmt, OCI_DEFAULT); $error = OCIError ($stmt); if ($error["offset"]) { $errorMsg = substr ($error["sqltext"], 0, $error["offset"]).'*'.substr ($error["sqltext"], $error["offset"]); return FALSE; } // Commit to save changes... OCICommit($con); // Logoff from Oracle... OCILogoff($con); } // ------------------------------------------------------------------------------------ function generateControlHTML($viewMapping, $element, $isHeader) { $ctlHTML = ""; // Write out the question description $title = $element->description[0]->tagData; $helpPageURL = $element->helppageurl[0]->tagData; $nolinebreak = $element->nolinebreak; $validationScript = $element->validationscript; $noSubmit = $element->nosubmit; if(count($element->noheaderdatacarryover) > 0) $noDataCarryOver = TRUE; else $noDataCarryOver = FALSE; if(check_not_empty($title) == TRUE) { $ctlHTML .= "<p style='font-weight:bold;font-size:100%;'"; if(count($nolinebreak) == 1) { $ctlHTML .= " style='padding-right:10px;display:inline;' "; } $ctlHTML .= "><label onfocus='blur();' "; if(count($element->control) > 0) $ctlHTML .= " for='".$element->control[0]->column[0]->tagData."' "; $ctlHTML .= ">".$title; if(check_not_empty($helpPageURL) == TRUE) { $ctlHTML .= " <span style='cursor:hand' onclick=\"window.open('".$helpPageURL."', 'help', 'width=350,height=420,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1');\"> [ ? ] </span> "; } $ctlHTML .= "</label></p>\n"; } // See if this element contains an inline document if(count($element->inlinedocument) > 0 && count($element->inlinedocument[0]->documentkey) > 0 && count($element->inlinedocument[0]->source) > 0) { $ctlHTML .= "<div id='".$element->inlinedocument[0]->documentkey[0]->tagData."' style='margin:0px;padding:0px;width:100%;background:#ffffff;' >"; // Add a javascript variable identifying this inline documents content $ctlHTML .= "<script type='text/javascript'>\n<!--\n var inlineDocumentContext = '".$element->inlinedocument[0]->documentkey[0]->tagData."'; \n --></script>\n\n"; // Inject the inline document into the div $inlineDoc = $element->inlinedocument[0]->source[0]->tagData; $ctlHTML .= file_get_contents($inlineDoc); $ctlHTML .= "</div>\n"; } // Scan through all each of the control blocks in this element for($i=0; $i<count($element->control); $i++) { $ctlType = $element->control[$i]->type[0]->tagData; $posttext = $element->control[$i]->posttext[0]->tagData; $pretext = $element->control[$i]->pretext[0]->tagData; $column = $element->control[$i]->column[0]->tagData; $data = $element->control[$i]->data[0]->tagData; $limit = $element->control[$i]->limit[0]->tagData; $rows = $element->control[$i]->rows[0]->tagData; $cols = $element->control[$i]->cols[0]->tagData; $nolinebreak = $element->control[$i]->nolinebreak; $controlSize = $element->control[$i]->controlsize[0]->tagData; $defaultValue = $element->control[$i]->defaultvalue[0]->tagData; $onSubmitScript = $element->control[$i]->onsubmitscript; // The column names are uppercased and trimmed $column = trim(strtoupper($column)); // Write out any text coming before this element if(check_not_empty($pretext) == TRUE) { $ctlHTML .= "<label class='small' style='margin-right:8px;'>".$pretext."</label>"; } switch($ctlType) { case "NEWDROPDOWN": $ctlHTML .= "<select id='".$column."' name='".$column."' style='font-family:monospace;font-size:9pt;'>"; for($k=0; $k<count($element->control[$i]->option); $k++) { $ctlHTML .= "<option value='".$element->control[$i]->option[$k]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n"; } // Get the dynamic data if its requested for this control if(check_not_empty($data) == TRUE) { if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE) $ctlHTML .= provideDynamicData($viewMapping, $element, $data, $_SESSION[$column]); else $ctlHTML .= provideDynamicData($viewMapping, $element, $data); } $ctlHTML .= "</select><input type='button' value='New' id='".$column."-NEWBTN' onclick='newDropDownValue(\"$column\");' />\n"; $ctlHTML .= "<input type='text' class='specialforminput2' value='new value' id='".$column."-NEW' name='".$column."-NEW' style='display:none' "; if(check_not_empty($limit) == TRUE && check_not_empty($controlSize) == FALSE) { $ctlHTML .= "maxLength='".$limit."' size='".$limit."' "; } if(check_not_empty($controlSize) == TRUE) { $ctlHTML .= "size='".$controlSize."' maxlength='".$limit."' "; } $ctlHTML .= " /><br/>"; $ctlHTML .= "<input type='button' value='Select Previous' id='".$column."-selbtn' onclick='previousDropDownValue(\"$column\");' style='display:none' />\n"; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= " <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"font-size:50%;display:none\" ></span>'); \n --></script>"; } break; case "DROPDOWN": $ctlHTML .= "<select id='".$column."' name='".$column."' style='font-family:monospace;font-size:9pt;' "; if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; } if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onchange='sendSingleValue(\"".$column."\", \"".$column."\", \"DROPDOWN\", this.options[this.selectedIndex].value);' "; } else { $ctlHTML .= " onChange='convertToUpperCase(this);' "; } $ctlHTML .= ">"; for($k=0; $k<count($element->control[$i]->option); $k++) { if(count($element->control[$i]->option[$k]->value) > 0) $ctlHTML .= "<option value='".$element->control[$i]->option[$k]->value[0]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n"; else $ctlHTML .= "<option value='".$element->control[$i]->option[$k]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n"; } // Get the dynamic data if its requested for this control if(check_not_empty($data) == TRUE) { if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE) $ctlHTML .= provideDynamicData($viewMapping, $element, $data, $_SESSION[$column]); else $ctlHTML .= provideDynamicData($viewMapping, $element, $data); } $ctlHTML .= "</select>\n"; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= " <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"display:none\" ></span>'); \n --></script>"; } break; case "TEXTFIELD": $ctlHTML .= "<input class='specialforminput2' type='text' id='".$column."' name='".$column."' "; if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; } if($isHeader == FALSE) { $ctlHTML .= " onchange='"; if(count($onSubmitScript) > 0) { $ctlHTML .= " ".$onSubmitScript[0]->tagData." "; } if(count($validationScript) > 0) { $ctlHTML .= " ".$validationScript[0]->tagData." "; } if(count($noSubmit) == 0) { $ctlHTML .= " sendSingleValue(\"".$column."\", \"".$column."\", \"TEXTFIELD\", this.value); "; } $ctlHTML .= "' "; } else { $ctlHTML .= " onChange='convertToUpperCase(this);' "; } // If there was a previous header-value entered, then display it in this field if($isHeader == TRUE && $noDataCarryOver == FALSE && isset($_SESSION[$column]) == TRUE ) { $ctlHTML .= "value='".$_SESSION[$column]."' "; } else { if(check_not_empty($defaultValue) == TRUE) { $ctlHTML .= "value='".$defaultValue."' "; } } if(check_not_empty($limit) == TRUE && check_not_empty($controlSize) == FALSE) { $ctlHTML .= "maxLength='".$limit."' size='".$limit."' "; } if(check_not_empty($controlSize) == TRUE) { $ctlHTML .= "size='".$controlSize."' maxlength='".$limit."' "; } if(check_not_empty($data) == TRUE) { $ctlHTML .= " value='".provideDynamicData($viewMapping, $element, $data)."' "; } $ctlHTML .= " />\n "; if($element->control[$i]->displaylimit) $ctlHTML .= "<br/><label class='small'> ".$limit." characters max </label>\n"; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= " <script type='text/javascript'>\n<!--\n document.writeln('<div id=\"".$column."-status\" style=\"display:none\" >*</div>'); \n --></script>"; } break; case "TEXTAREA": if(check_not_empty($rows) == FALSE) { $rows = 6; } if(check_not_empty($cols) == FALSE) { $cols = 50; } $ctlHTML .= "<textarea name='".$column."' id='".$column."' cols='".$cols."' rows='".$rows."' "; if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; } if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onchange='if(checkLength(".$limit.", \"".$column."\") == true) { sendSingleValue(\"".$column."\", \"".$column."\", \"TEXTAREA\", this.value); }' "; } $ctlHTML .= ">"; if(check_not_empty($data) == TRUE) { $ctlHTML .= provideDynamicData($data); } $ctlHTML .= "</textarea>\n"; if($element->control[$i]->displaylimit) $ctlHTML .= "<br/><label> ".$limit." characters max </label>\n"; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= " <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"display:none\" >*</span>'); \n --></script>"; } break; case "RADIO": for($k=0; $k<count($element->control[$i]->option); $k++) { // See if the mapping specifies a custom value of this radio button... use this in the value="" attribute // If there is no value specified in the XML, then use the option text as the value $id = "".$column."-".$k; $radioValue = $element->control[$i]->option[$k]->tagData; if(count($element->control[$i]->option[$k]->value) > 0) $radioValue = $element->control[$i]->option[$k]->value[0]->tagData; // Build the HTML for this control $ctlHTML .= "<input type='radio' name='".$column."' id='$id' "; if($isHeader == FALSE) { $ctlHTML .= " onFocus='selectCTL(\"$id\");' "; } if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onclick='sendSingleValue(\"".$column."\", \"$id\", \"RADIO\", this.value);' "; } $ctlHTML .= " value=\"".$radioValue."\" "; if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE && strcmp($_SESSION[$column], $element->control[$i]->option[$k]->tagData) == 0 ) { $ctlHTML .= " checked='yes' "; } $ctlHTML .= " />"; $ctlHTML .= "<label for='$id'>".$element->control[$i]->option[$k]->tagData."</label>\n"; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= "<script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-".$k."-status\" style=\"display:none\" >*</span>'); \n --></script>"; } if(count($nolinebreak) == 0) { $ctlHTML .= "<br/>"; } else { $ctlHTML .= " "; } } break; case "CHECKBOXES": $ctlHTML .= "<div style='text-align:left;'>"; for($k=0; $k<count($element->control[$i]->checkbox); $k++) { $ctl = $element->control[$i]->checkbox[$k]; // Generate a hidden status field ONLY if the browser supports javascript if($isHeader == FALSE) { $ctlHTML .= "<script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$ctl->column[0]->tagData."-status\" style=\"display:none\" >*</span>'); \n --></script>"; } $ctlHTML .= "<input type='checkbox' name='".$ctl->column[0]->tagData."' id='".$ctl->column[0]->tagData."'"; if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onclick='selectCTL(\"".$ctl->column[0]->tagData."\"); sendSingleValue(\"".$ctl->column[0]->tagData."\", \"".$ctl->column[0]->tagData."\", \"CHECKBOX\", this.checked);' "; } $ctlHTML .= "\>\n"; $ctlHTML .= "<label for='".$ctl->column[0]->tagData."'>".$ctl->title[0]->tagData." </label><br/>\n"; } $ctlHTML .= "</div>"; break; } // Write out any text coming before this element if(check_not_empty($posttext) == TRUE) { $ctlHTML .= " <label class='small' style='margin-right:8px;'>".$posttext."</label>"; } if(count($nolinebreak) == 0) { $ctlHTML .= "<br/>\n"; } } return $ctlHTML; } // ------------------------------------------------------------------------------------ function check_not_empty($s, $include_whitespace = false) { if ($include_whitespace) { // make it so strings containing white space are treated as empty too $s = trim($s); } return (isset($s) && strlen($s)); // var is set and not an empty string '' } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Expires" content="Tue, 01 Jan 2000 12:12:12 GMT" /> <meta http-equiv="Pragma" content="no-cache" /> <title>WebR On-line customer response form</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="WebR - on-line customer response form" /> <link href="../local-resources/styles/webr.css" rel="stylesheet" type="text/css" /> <!--[if IE]> <style type="text/css"> /* place css fixes for all versions of IE in this conditional comment */ #sidebar1 { padding-top: 30px; } #mainContent { zoom: 1; padding-top: 15px; } /* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */ </style> <![endif]--> <script type='text/javascript' src='../libs/sarissa.js'></script> <script type='text/javascript' src='../libs/mootools-1.2-core-yc.js'></script> <script language="JavaScript" type="text/JavaScript"> <!-- // ==================================================================================== var activeCTL = null; var documentKey = null; // ==================================================================================== function convertToUpperCase(fieldObject) { fieldObject.value = fieldObject.value.toUpperCase() } function checkLength(strlimit, column) { var field = document.getElementById(column); if(field.value.length > strlimit) { alert("This field has exceeded it's maximum length by " + (field.value.length - strlimit) + " characters"); field.style.background = '#ffaaaa'; return false; } return true; } // ==================================================================================== function sendSingleValue(column, id, type, value) { // Set the wait icon var saveText = "<label> Saving... <img src='../local-resources/images/ajaxwait.gif' /> </label>"; document.getElementById(id + '-status').innerHTML = saveText; // The javascript urlencode method treats plus signs like spaces, so we need to convert them // into a unicode value before putting it through the js encoding if(type == "TEXTAREA" || type == "TEXTFIELD" || type == "RADIO") { var testVal = value; value = ""; for(var i=0; i<testVal.length; i++) { if(testVal.charAt(i) == '+') { value += "%2B"; continue; } if(testVal.charAt(i) == "'") { value += "''"; continue; } value += testVal.charAt(i); } } // Build a url containing the value to be updated var URL = 'WEBRController.php?act=add1&doctype=<?php echo $docType;?>&key=' + documentKey + '&' + column + "=" + escape(value); var xmlhttp = new XMLHttpRequest(); //alert("URL Query: " + URL); xmlhttp.open("GET", URL, true); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4) { var xmlDOC = Sarissa.getDomDocument(); xmlDOC = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml"); // Change the colors of the control based on the server response var errorXML = xmlDOC.getElementsByTagName("Error"); if(errorXML.length > 0) { document.getElementById(id).style.background = '#ffaaaa'; alert(errorXML[0].text); document.getElementById(id + '-status').innerHTML = 'Error'; } else { if(xmlDOC.getElementsByTagName("Success").length > 0) { document.getElementById(id).style.background = '#aaffaa'; document.getElementById(id + '-status').innerHTML = "<label><b>Saved</b> </label>"; // Fade out the save message setTimeout(function() { $(id + '-status').fade('out'); }, 1500); setTimeout(function() { $(id + '-status').style.display='none'; }, 2200); } } } }; xmlhttp.send(''); } // ==================================================================================== function sendHeader() { var headerForm = document.getElementById('headerform'); var inputFields = headerForm.getElementsByTagName("input"); for(var i=0; i<inputFields.length; i++) { if(inputFields[i].type == 'text') inputFields[i].style.background = '#ffffff'; } var headerForm = document.getElementById('headerform'); var query = Sarissa.formToQueryString(headerForm); var queryURL = 'WEBRController.php?' + query; //alert("Header Query: " + queryURL); var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", queryURL, true); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4) { var xmlDOC = Sarissa.getDomDocument(); xmlDOC = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml"); // Change the colors of the control based on the server response var errorXML = xmlDOC.getElementsByTagName("Error"); if(errorXML.length > 0) { alert("Error: " + errorXML[0].text); // See if its a specific validation error if(xmlDOC.getElementsByTagName("ValidationError").length > 0) { var controlid = xmlDOC.getElementsByTagName("Column")[0].text; document.getElementById(controlid).style.background = '#ffaaaa'; } alert("Error: " + errorXML[0].text); } else { // The header was sent and accepted, grab the document key to use var dockeyary = xmlDOC.getElementsByTagName("DocumentKey"); if(dockeyary.length > 0) { documentKey = dockeyary[0].text; //alert("documentKey: " + documentKey); openBody(); } else { alert("Response: " + xmlhttp.responseText); } } } } xmlhttp.send(''); } // ==================================================================================== function selectCTL(column) { if(column != null) { if(activeCTL != null && activeCTL != (column+"-status")) { var ctlName = activeCTL + "-status"; if($(ctlName).innerHTML == '*') { document.getElementById(ctlName).style.display = 'none'; } } $(column + '-status').fade('show'); document.getElementById(column).style.background = '#ffffff'; document.getElementById(column + '-status').innerHTML = '*'; document.getElementById(column + '-status').style.display = 'inline'; activeCTL = column; } } // ==================================================================================== function previousDropDownValue(column) { var dropdown = document.getElementById(column); var newTextField = document.getElementById(column + "-NEW"); var newbutton = document.getElementById(column + "-NEWBTN"); var selbutton = document.getElementById(column + "-SELBTN"); // reset whatever the user previously input newTextField.value = "new value"; dropdown.style.display = 'inline'; newbutton.style.display = 'inline'; newTextField.style.display = 'none'; selbutton.style.display = 'none'; } // ==================================================================================== function newDropDownValue(column) { var dropdown = document.getElementById(column); var newTextField = document.getElementById(column + "-NEW"); var newbutton = document.getElementById(column + "-NEWBTN"); var selbutton = document.getElementById(column + "-SELBTN"); dropdown.style.display = 'none'; newbutton.style.display = 'none'; newTextField.style.display = 'inline'; selbutton.style.display = 'inline'; newTextField.focus(); newTextField.select(); } // ==================================================================================== function openBody() { var dropdowns = $('headerDIV').getElementsByTagName("select"); for(var i=0; i<dropdowns.length; i++) { dropdowns[i].style.display = 'none'; } $('headerDIV').fade('out'); $('SubmitHeaderBtn').fade('out'); $('headerText').fade('out'); setTimeout("$('SubmitHeaderBtn').style.display='none';", 800); setTimeout("$('headerDIV').tween('height', 0);", 500); setTimeout("$('headerDIV').style.display='none';", 1000); setTimeout("$('headerText').style.display='none';", 1000); $('bodyDIV').fade('hide'); document.getElementById('bodyDIV').style.display = 'block'; $('bodyDIV').fade('in'); } // ==================================================================================== function displayFinishedScreen() { $('bodyDIV').style.display = 'none'; $('FinalScreen').style.display = 'block'; window.scroll(0,0); } // ==================================================================================== function resize(iframedom) { try { var oBody = iframedom.document.documentElement; var oframe = iframedom; alert(iframedom.document.documentElement.clientHeight); alert(oBody.offsetHeight); alert(oBody.clientHeight); alert(oBody.scrollHeight); var calcheight = (oBody.offsetHeight - oBody.clientHeight); if(oBody.scrollHeight != null) { calcheight += oBody.scrollHeight; } oframe.style.height = calcheight; } catch(e) { window.status = 'Error: ' + e.number + '; ' + e.description; } } <?php // If this document specified any custom javascript in the VIEW XML then include it here if(count($customScript) > 0) { echo $customScript[0]->tagData; } ?> // --> </script> <?php // If the document includes and custom javascript libraries, then do it here if(count($includeScripts) > 0) { for($i=0; $i<count($includeScripts); $i++) { echo "<script type='text/javascript' src='../libs/".$includeScripts[$i]->tagData."'></script>"; } } ?> </head> <body> <!-- start #container --> <div id="container"> <!-- start #header --> <div id="header"> </div> <!-- end #header --> <?php include_once("topbar.php"); ?> <!-- start #mainContent --> <div id="mainContent"> <h2><?php echo $documentType; ?></h2> <!-- Write out the form header --> <div style="text-align:center;"> <span id="headerText">Please complete this section before continuing...<br /></span> <div id="headerDIV" class="list-box"> <form action="WEBRController.php" method="post" id='headerform' onsubmit="return false;"> <fieldset> <input type='hidden' name='act' value='addheader' /> <input type='hidden' name='doctype' value='<?php echo $docType ?>' /> <div class="list-left" style="text-align:left;"> <?php $breakPoint = FALSE; for($i=0; $i<count($headerBlock->element); $i++) { $headerElement = $headerBlock->element[$i]; echo generateControlHTML($viewMapping, $headerElement, TRUE); if($i >= ((count($headerBlock->element)/2)-1) && $breakPoint == FALSE) { $breakPoint = TRUE; echo "</div><div class='list-right'>"; } } ?> </div> </fieldset> <input type='button' onClick='sendHeader();' id='SubmitHeaderBtn' value='Start Survey' class='Submit' /> </form> </div> </div> <!-- Write out the body --> <div id="bodyDIV" style="display:none"> <script type='text/javascript'> <!-- document.writeln("<div style='text-align:center;'><div style='text-align:left;'><small class='surveyheadertext'>After answering a question, tab or click off the answer box to automatically save that entry. The field will turn green to represent a successful save. An asterisk mark indicates the currently selected field. </small></div></div>"); --> </script> <noscript> Your information will not save until you click the "Submit Entire Form" button </noscript> <?php for($i=0; $i<count($bodyBlock->group); $i++) { $groupBlock = $bodyBlock->group[$i]; $groupTitle = $groupBlock->title[0]->tagData; echo "<fieldset>"; echo "<legend>".$groupTitle."</legend>"; for($k=0; $k<count($groupBlock->element); $k++) { $groupElement = $groupBlock->element[$k]; if(($k % 2) == 1) { echo "<div class='altform-g'>"; } echo generateControlHTML($viewMapping, $groupElement, FALSE); if(($k % 2) == 1) { echo "</div>"; } } echo "</fieldset>"; } ?> <div style="text-align:center;"> <br /> <input type="button" id='FinalSubmitBTN' class='Submit' onClick='displayFinishedScreen(); return false;' value="Finish Survey" /> </div> </div> </fieldset> </div> <!-- ************************************************************************************************ FINAL SCREENS - The final screen contains the thank you message and optional "Enter Another ... " button, and optional "Go to WEBR Home" button. All of these values including button text are specified in the document level of the View XML. ************************************************************************************************ --> <div style='display:none' id='FinalScreen'> <div style="text-align:center;"><strong><?php echo $completionMessage; ?></strong> <br /><br /> <?php if($addButtonMsg != null) { echo "<input type='button' value='".$addButtonMsg."' onClick='window.open(\"WEBRView.php?doc=".$docType."\", \"_self\");'>"; } if($homeButtonMsg != null) { echo "<input type='button' value='".$homeButtonMsg."' onClick='window.open(\"WEBRView.php?doc=".$docType."\", \"_self\");'>"; } ?> <br /><br /> </div> </div> <?php include_once ("footer.php"); ?> </div> </body> </html> The php5 parser is located here: http://www.criticaldevelopment.net/xml/parser_php5.phps WebIndex.xml looks like this: <?xml version="1.0"?> <WEBRIndex> <Document> <DocumentKey>EP2010</DocumentKey> <Title>2010 Enterprise Program Customer Survey</Title> <ViewXML>ep2010-views.xml</ViewXML> <MappingXML>ep2010-mappings.xml</MappingXML> </Document> </WEBRIndex>
  15. I am going to close this topic and open a new one with less confusion I hope
  16. I commented out line 40, 96 and 97 and got only 1 error at 498. Catchable fatal error: Object of class XMLTag could not be converted to string in /srv/www/htdocs/webr/app/WEBRView.php on line 498 Line 498: function check_not_empty($s, $include_whitespace = false) { if ($include_whitespace) { // make it so strings containing white space are treated as empty too $s = trim($s); } return (isset($s) && strlen($s)); // var is set and not an empty string '' } I think this is an issue with the XMLTag Class... in the http://www.criticaldevelopment.net/xml/parser_php5.phps script maybe...
  17. line 40: $action = $_GET["act"]; // as far as I can see it's not doing anything... line 96: $includeScripts = $viewMapping->includescript; line 97: $customScript = $viewMapping->customscript;
  18. php error log says: Notice: Undefined index: act in /srv/www/htdocs/webr/app/WEBRView.php on line 40 Notice: Undefined property: XMLTag::$includescript in /srv/www/htdocs/webr/app/WEBRView.php on line 96 Notice: Undefined property: XMLTag::$customscript in /srv/www/htdocs/webr/app/WEBRView.php on line 97 Catchable fatal error: Object of class XMLTag could not be converted to string in /srv/www/htdocs/webr/app/WEBRView.php on line 498
  19. Yeah, sorry. It's a big chunk of code. I have been trying to get it to work in php5 from a server with 4 on and I am just not sure where this thing is failing. The parser is from: http://www.criticaldevelopment.net/xml/doc.php I switched to the php5 version as an includes, and it still didn't work. So I have been going through the code trying to find what is up... Besides that parser being included, this is the code: // It's probably best to put this file in a non web-accessible folder for security $configFile = '../documents/WEBRIndex.xml'; $fileContents = file_get_contents($configFile); $indexXML = new XMLParser($fileContents); //Work the magic... $indexXML->Parse(); // ------------------------------------------------------------------ // Associate the users requested view with a document view mapping $docType = $_GET["doc"]; $action = $_GET["act"]; if(check_not_empty($docType) == FALSE) { echo "No document type specified"; exit; } // Find the XML mapping that corresponds with this type.. the ->document->document reference is because // there is an embedded ->document attached automatically by the XML Parser... the second ->document // reference is part of our document $viewXMLFile = null; $viewMapping = null; foreach($indexXML->document->document as $doc) { if(strcmp($doc->documentkey[0]->tagData, $docType) == 0) { $viewMapping = $doc; $viewXMLFile = $doc->viewxml[0]->tagData; break; } } // Make sure we found our XML view mapping if($viewMapping == null) { echo "No mapping found"; exit; } // Now load the actual view XML file into memory //this file contains the <header><body> etc... $viewFile = '../documents/'.$viewXMLFile; $fileContents = file_get_contents($viewFile); $viewXML = new XMLParser($fileContents); //Work the magic... $viewXML->Parse(); // Find the XML mapping that corresponds with this type (because there can be multiple definitions per view XML file) // so we need to do this a second time, (the first was for the index file) $viewMapping = null; foreach($viewXML->document->documentview as $view) { if(strcmp($view->documentkey[0]->tagData, $docType) == 0) { $viewMapping = $view; break; } } // Make sure we found our XML view mapping if($viewMapping == null) { echo "No mapping found"; exit; } function check_not_empty($s, $include_whitespace = false) { if ($include_whitespace) { // make it so strings containing white space are treated as empty too $s = trim($s); } return (isset($s) && strlen($s)); // var is set and not an empty string '' } // --------------------------------------------------------------- // Extract the header and group data from the view template $includeScripts = $viewMapping->includescript; $customScript = $viewMapping->customscript; $headerBlock = $viewMapping->header[0]; $bodyBlock = $viewMapping->body[0]; $documentType = $viewMapping->documenttype[0]->tagData; if(check_not_empty($headerBlock) == FALSE || check_not_empty($bodyBlock) == FALSE || check_not_empty($documentType) == FALSE) { echo " Malformed document view - ".check_not_empty($headerBlock)." - ".check_not_empty($bodyBlock)." - ".check_not_empty($documentType); exit; } Thanks for a look if you have some time !
  20. Thanks for the replies! So if nothing is getting returned at $foo, then there is something wrong elsewhere then since $foo has array spot 1 data correct? I am trying to get data from an XML file. Certain tags that is... for example $foo = $foobar->header[0]; where <header> has info in the xml file. <Header> <Element> <Description>Select one per Survey</Description> </Element> </Header>
  21. For example, how does this statement work: $foo = $foobar->header[0]; I am a bit lost on it... Thanks!
  22. Hi, sorry, yes it is looping through data. The one part I don't get is the: foreach($indexXML->document->document as $doc) { if(strcmp($doc->documentkey[0]->tagData, $docType) == 0) { $viewMapping = $doc; $viewXMLFile = $doc->viewxml[0]->tagData; break; } }
  23. foreach($indexXML->document->document as $doc) { if(strcmp($doc->DocumentKey[0]->tagData, $docType) == 0) { $viewMapping = $doc; $viewXMLFile = $doc->ViewXML[0]->tagData; break; }
  24. Thanks for the reply. I increased the memory. However, I find that images that are 3000px X 3000px don't work with that either. I noticed 2000px X 200px 6mb files will work... weird. Is there anything other than the php.ini memory doing this? Thanks!
×
×
  • 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.