Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Evaluating Php Tags/documents Outside Of Web Server?


I need to generate and send multiple xml documents over a socket.

Is it feasible to use php as a templating language for these? How would
i go about that?

I figure i _could_ make them into 'normal pages' and fetch the contents
using some http library, but that doesn't sound too elegant. There has
to be a better way?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Evaluating Strings...
In php, I have an array called "q". The elements are:

$q[0] = 2
$q[1] = 4
$q[2] = 5
$q[3] = 3

I'd like to be able to loop through this array via a While loop, and
echo the contents of these array elements back to the screen.

When I try something like:

for($i = 0; $i < 4; $i++) {
echo $q[i];
echo eval("$q[i]");
echo eval("$q[" . i . "]");
}

I get the "String" instead of the "Contents". For example, the output
is $q[0] instead of 2, $q[1] instead of 4, etc.

Evaluating A Concatenated Variable
I have a form with 10 select boxes. The boxes are named "select1", "select2", ..., "select10". On the action page, I would like to be able to use a "for" statement to loop through all 10, since the action taken on each is identical. However, I am unsure how I can evaluate the each variable dynamically. It's probably easier to show.

Page 1:
<form>
<select name="select1">
<option value="blah1">blah1
</select>
<select name="select2">
<option value="blah2">blah2
</select>
etc. etc. etc.
</form>

Action Page:
<?
for ($i=1;$i<=10;$i++) {
$tmpValue = $select . $i; <---- This is the question
}?>

In this case, for i=1, tmpValue becomes "select1", not the evaluation of this variable, or "blah1". How can I assign the value of the variable select1 into tmpValue while using this for loop?

Evaluating Array And Skipping Certain Results
I'm having a brain freeze on this. I have a script where I am reading
the contents of a file into an array. I have that up and working with no
problem. Then I'm exploding the array using

while ($line = fgets($fd, 4096))
{
$arrayData = explode("-", trim($line));
}

Works fine. But what I want to do now is evaluate arrayData[2] to see if
it contains the integers "00" (that's zero zero) and if it does, I want
it to skip that entry. I know I need to set it up with
if arrayData[2] == "00" {

But I'm drawing a blank on how to get it to skip this entire line in the
final results. There may be multiple instances of this happening in each
file and I want to skip them all.

Coding To Detect Number Of Students That Evaluating A Person
i really in need of a php script that can ensure SYSTEM able to trace the number of people that log in into the system and evaluating person A and detect that number so that we will know whether person A has been evaluated by all her students?. This is to restrict the number of people evaluating a single person to the exact number of students only.

eg: person A teaches 10 students and when all her students evaluate her teaching, the system actually detects the number of student under her that already evaluate her; and if the number exceed, the system will detect 'has exceed the number of students'.

what if there are person A till Z? while, the number of students for each person is different?

My problem is, is there is a php code to detect the number of people that evaluating the same person (indicate as A) and already fill the quota for evaluating that person?

Generating .pdf Documents On The Fly...
Does anyone know if it's possible to generate pdf documents from content held in a database? The idea is to use a template to dynamically generate pdf documents on the fly based on what the data a user has selected on a site. Is this possible with PHP/ ASP?

MS Word Documents
I've been asked to write a script to upload Microsoft Word documents and then convert them into 'printer friendly' pages. The uploading part I've got no problem with, but I can't find anything about reading MS word docs into PHP. Does anyone know anything about this?

I hope it's not as difficult as excel documents - which I'm still trying to get working on and off without any real success.

Word (or Other Documents) To PDF On The Fly?
Is there an option to convert any (or mosts file types) a user might upload to PDF format upon upload? I'd like users to be able to upload Word, Excel, Text and other documents, then have our upload script convert the document to PDF on the fly. Then viewing users would simply need the acrobat reader to view files, not all these other office products. Is this possible with just PHP and pdflib for example? If not, what are the options?

Creating XML Documents
I'm trying to get myself to grips with XML and PHP, I've been through the XML parsing tutorials here and they are very good.

However, what is the best way of doing the reverse, i.e. actually dynamically creating XML documents in PHP as opposed to parsing them? Is there a library for doing this, or is it best just to do it from scratch?

Printing Documents
I have a web page that displays CVs submitted by users (in DOC, PDF or RTF format). CVs are stored in a folder for e.g. user_cv Admin can select the CVs to be printed and then click on Print button. This should send all documents to printer for printing. How do I do that in PHP?

Getting A File Via Http Or Evaluating A Php File And Getting Its Output
I need to somehow merge two separate web programs written in php
together (from the user's perspective). This solution won't be
perminant, I just need something done quickly. I was thinking of two
different approches.

One would be to download a processed version (modified so it will
create validating html with the page it's being embeded in) of one of
the programs with the other, then just use print to embed it in the
page. I couldn't find out how to get a file via http here
(http://us2.php.net/manual/en/index.php). Sorry if I missed this in
the docs.

The other would be to process the other program and get it's command
line output, and print that.

If there's a better way to this, I'd be glad to hear it :)

Also, I've never written any php before; so sorry if I missed
something obvious to someone who has.

SSI And Perl Within .php3 Documents
Im new to PHP. I want to know if you can use ssi within .php3 documents and call php3 funtions in a .pl scritp.
That is if you want to use the useful perl scripts you find on the web and combine them with php.

Compare Two Word Documents Using Php
In my system I want to compare two word documents ,but my server is a
Linux one and thats y I cant create COM object .

Any othermethods to find this one .I think to connect PHP to some
other mightt be useful for this.....

Phplib Creating Pdf Documents
I can load a font, set a font, load an image, draw a line, output text in a box, output text on a line, create a pdf, open a pdf, add a page, close a page, close a pdf but I can not set a font to bold or italic or underlined.

I currently use a function which moves the text position slightly and re outputs it for bold and I simply draw line for underlined text but now I need to do italicized and I am stuck.

I found little on font styles anywhere when using the pdf commands on php.net I can see the list of commands but everything is deprecated and the new commands don't have clear documentation on how to use them:

pdf_setfont($pdf, $times, 9);
pdf_setcolor($pdf,"both","rgb",0,0,0);
pdf_set_parameter($pdf,"fontstyle","italic");

the first line sets the font to be times roman and size 9 the second change the color to black I though the last line would set the font to be italic but it is not correct Any ideas?

Parsing Existing PDF Documents
I have an existing PDF document; "myfile.pdf". I want to be able to seek through that document for particular strings. The thing is, I can't find a way to open the file as something that's legible/readable.

I've tried using PDFLib aswell as using fopen/fgets (among many other things) to open the file and display the content. The only content I get is a little mark-up and a bunch of garbbled text.

I'm assuming that when a PDF is created it has some form of character encoding passed over it, or it's encrypted in some way. I've looked at a few classes around, but none show ways of opening a PDF document up.

How To Upload Documents In Mysql
I'm a beginner and will like to know how to upload documents in mysql. These documents will be cited on the intranet and a user will have to search for a particular document using either date, title etc.

Downloading Secure Documents
i'm building a site which will have a secure section (still haven't decided between cookies and sessions), but anyhow, after the login screen, there will be links to a bunch of word documents that the user can download or view. I'm thinking anyone who knows the path to those documents can view them without logging in.. is there a way to prevent this? or am I just wrong?

Tutorials/Articles/Documents Script?
I was looking for a script that could let me manage tutorials, articles or documents in my website. There should be categories and they are not for download but to be displayed right on the page, extra functions like rating, comments would be nice but not required.

I'm currently using Tutorials Manager (http://scripts.phpwiz.net/tb2/) but the script is in beta state and is quite buggy. If anyone knows about any others scripts, please let me know all of them so I can choose one. Free ones or under the GPL only.

PDF Generation - Making Large Documents
I am trying to generate a large PDF using PDFLib. Specifically, I have a database of University researchers (perhaps 300-400) and I need to generate a printed report with a table of contents - all of the entries are stored in a MySQL database.

There can be several researchers / page and I want to avoid a researcher's entry spanning two pages.

I think PDFLib would be a good solution for me, but all the examples / tutorials I have seen using it have been quite trivial.

I wonder if anyone has some tips / tricks for using PDFLib for text spanning several pages or if you can think of a better way to generate this larger document for print - keeping in mind that I must keep track of page numbers.

Reading EXCEL (XLS) Documents With Other Charactersets
(the other code i cannot post due weird carakters!)

I've been searching over the internet for days but havent found why! i've tried alot of scripts (both free or wich i need to pay for) but only a pricy script (like 80$) would show the carakters in ROW C correctly. If i convert the script to a HTML document i get the carakters with &# and a four digit number... that's what i like to extract from the excel sheet.

The script i wrote is.

Code:
<?php
$excel = new COM("excel.application") or die("Unable to instanciate excel");

//bring it to front
$excel->Visible = 1;//NOT
//dont want alerts ... run silent
$excel->DisplayAlerts = 1;

//open document
$excel->Workbooks->Open("d:/excel.xls");

for ($h = 1; $h <= 3; $h++)
{
$book = $excel->Workbooks(1);
$sheet = $book->Worksheets($h);

echo "<table>
";
//Wtite row
for ($i = 1; $i <= 150; $i++)
{
echo "<tr>
";
//write colom
for ($j = 1; $j <= 5; $j++)
{
$cell = $sheet->Cells($i, $j); // #Select the cell (Row Column number)
$cell->activate; // #Activate the cell

if($cell->value == &#390;')
{
$td = "";
}
else
{
$td = $cell->value;
}

echo "<td>" . $td . "</td>
"; // #write the cell
}
echo "</tr>
";
}
echo "</table>
";
}

//closing excel
$excel->Quit();
?>

Extract Text From Word Documents
Is there a way to extract the text of a word document with php? And perhaps some of the formatting (like break lines, bold, italic,...)?

Algorithm For Detecting/highlighting Changes In Documents
Anyone knows a good algorithm for detecting difference between two
pieces of text? I'm working on a content management system and would
like to add the ability to highlight changes made between versions. I
don't think diff is suitable here, since I want word level detection.
Besides, I'll need to handle a large number of relatively short
strings. Spawning an process for each would be too time consuming.

AFAIK, PHP doesn't have a build-in function. If necessary, I can build
a wrapper extension.

Automatically Download Documents Onload
i have another problem with regards to documents. The thing is, when a user registers, they upload a document right, and we store the document's link and the date it was loaded on the database, but now i would like this to happen, that when i log in and there has been a dcument uploaded, it takes the date now and compares it with the date that the document was loaded, like this: Code:

Multiple Forms, Different PHP Documents, Same Page?
In a PHP file 'main.php' I have

<?php
include 'header.php';
include 'login.php';
include 'body.php';
include 'footer.php';?>

Login.php has a form on it to allow the user to log in to the site.

Body.php has a form on it to allow a user to post a message.

What I'm finding is that the 'submit' button on 'body.php' actually calls the form from 'login.php'. Does PHP have issues when there are 2 separate forms doing 2 saperate things displayed on the same page - is there anything I need to look out for?

Uploading Documents To Multiple Servers At Once
I have two servers: Server X and Server Y.  I'm looking for a solution so that when users upload their documents to server X, they also upload to server Y to the same folder and directory.  This way, if server X is down, we can still access the uploaded documents through server Y.

Secure Login Area For Documents
I built a login area with a document manager.  It works great and all and all the pages are secure.  My question though if the pages are protected by php and you can't get to them, how do you keep someone from linking to the document directly.  Since the document is not going to process the php and check for credentials when they put in the direct link to the document.

Reading Microsoft Office Documents?
I need to be able to upload a Microsoft office document and then show the contents to the visitor, in addition i need to be able to  write documents on the fly.

Is there a way of doing this, or will i have to spend days researching and programming my own classes to handle it?

Trouble With Counting New Documents With Complex Query
width formulating the most
effective (in terms of processing time)
SQL query to count all the "new"
documents in the repository, where "new" is
defined as "from 00:00:01 up to 23:59:59
today". My current query does not give me
satisfactory results, it creates a visible
delay in rendering of the main page of one of
the departments (Drugs) :8[[[
(at least I, for now, think it's the culprit).
It's for the <url: https://hyperreal.info >
site, see for yourself, notice the delay
<url: https://hyperreal.info/drugs/go.to/index >.

Currently I ask MySQL to (offending
PHP fragment follows, I hope it is self-
explanatory)....

Unexpected Behavior When Creating Xhtml Documents
The following has been posted before (2 years ago) but no response was
added. Therefor again, the following code for creating xhtml file:

<?php

error_reporting(6143);

$xmlns = "http://www.w3.org/1999/xhtml";
$lang = "en";

$xhtml_1_strict = new DomImplementation();

$dtd_xhtml_1_strict = $xhtml_1_strict->createDocumentType("html", "-//
W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/
xhtml1-strict.dtd");

$xhtml_1_strict_document = $xhtml_1_strict->createDocument("", "",
$dtd_xhtml_1_strict);
$xhtml_1_strict_document->encoding = "UTF-8";
$xhtml_1_strict_document->standalone = "no";


Can I Convert MySQL Db Records Into Microsoft Word Documents?
i found the solution to export
file from mysql db into *.csv. but is there anyway to convert the
contents into *.doc and save in my webserver and providing a link for
the end users to download the word file?

FYI, the database records are obtained by end users submitting the
forms themselve and i saved it in my db...

Div Tags With PHP
I cant seem to get CSS to work with my PHP code. An example is this:

<?php if (isset($_GET['addstory'])): // If the user wants to add a
story
?>

<div id="storyform">

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>Type your story here:<br />
<textarea name="storytext" rows="10" cols="40">
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</form>

</div>

<?php elseif (isset($_GET['addcomment'])): // If the user wants to add
a comment
?>

<div id="commentform">

<form action="<?php echo $_SERVER['PHP_SELF'].'?comment='.
($_GET['addcomment']); ?>" method="post">
<label>Type your comment here:<br />
<textarea name="commenttext" rows="10" cols="40">
</textarea></label><br />
<input type="submit" value="SUBMIT" />
</form>

</div>

The CSS for this is:

#storyform{
position: absolute
top: 200px
left:300px
width:724px
height: 500px

}

#commentform{
position: absolute
top: 200px
left:300px
width:724px
height: 500px

}........

Mp3 Tags
Just out of curiosity,

Can PHP read MP3 Tags?

ID3 Tags
I have written some code that grabs any any and all ID3 tags in a file. It works fine unless the file includes the tag "APIC" which holds an encoded image. The problem is that the bytes that I read the size from show less than half of what the actual size of that tag is.

For example, the tag will say the size is 7415, but if I count the characters in the tag, there are 14978, or so. On the ID3 website they explain synchronization briefly, but what I get from it doesn't seem to make sense. It says to replace all occurances of %11111111 00000000 111xxxxx with %11111111 111xxxxx and all occurances of $FF 00 00 with $FF 00. I used some regex to do this and it found and replaced two occurance. Since that only lowered the size by two bytes, I don't think this is correct, since it obviously didn't fix anything anyway.

I guess this really isn't a PHP question, but I really would appreciate it if someone could point me to somewhere that could help me. An example of unsynchronization, if that is what the problem is, would be great.

Print Between XML-tags
I need to print file contents between the existing XML-tags <archve> </archive> like this:

<?xml version="1.0" encoding="ISO8859-1"?>
<archive>
//HERE SHOULD THE NEW FILE CONTENT COME

</archive>

Any help is much appreciated!

Implementing [PHP] Tags
I was able to do is using string posistions, suprisied myself there. But how can I do it with regular expression? I have regex that looks like: PHP Code:

Parsing XML Tags
Is there a function or otherwise some way to pull out the target text
within an XML tag?

For example, in the XML tag below, I want to pull out 'CALIFORNIA'.

<txtNameUSState>CALIFORNIA</txtNameUSState>

Does PHP Read MP3 Tags?
I was wondering has been successful in reading mp3 tags out of file. Tags being Artist, Track Title, etc... I tried using fpassthru() on a file, but I was only successful in outputting a ton of binary data. Any thoughts?

Form Tags?
I know that there is a meta tag function to get all meta tags from a url.
I am searching for a similar function that would get all values of a form.

something like :

<form>
<input type="text" name="name" size="10">
<input type="text" name="url" size="40">
</form>

it would return 'name', 'url'...

Finding H-tags
I am trying to build a script whic will convert html pages, to php, and formatting them to fit the php file's setup... i am trying to also improve navigation - which is where i am stuck.

I need to find all information located between any number of <h2> </h2> tags, and place the contents into an array, which i can then print of, and link to that section i just need to find a method to find the information, and then put it into an array.

Spacing For <UL> Tags
Can anyone tell me if there is a way to set the default tabbing for the <UL> tag? For instance, if I display this.. Code:

<ul>
OPTION 1
<ul>OPTION 1a</ul>
<ul>OPTION 1b</ul>
OPTION 2
<ul>OPTION 2a</ul>
<ul>OPTION 2b</ul>
</ul>

It puts all the options quite spaced apart (like a tab size). Any way of sorting this using CSS?

Troubles With The {} Tags
I have moved a script to my new server and am having troubles with the {} tags showing up all over a script (viewable at http://halterhorsestallions.com/index.php) and am wondering what I've done wrong, in that photos aren't being linked, there's extra tags all over, so database information isn't showing up properly (hope I'm explaining myself).

At first I was getting errors on line 131, then got it fixed (hopefully) and then line 261 showed up with a problem, so I changed some tags and now more database info is showing up, but still not properly. Here's an excerpt of line 131 (starting with 125) and line 261 (before & after) respectively: Code:

How To Access Mp3 Id3-tags
Have anyone seen/got functions that can read id3-tags from mp3-files...?

Meta Tags
I was read PHP manual, but i'm not sure yet. Here is my meta tags in html:

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-2">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-store, no-cache,
must-revalidate, max-age=0, post-check=0, pre-check=0">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<META NAME="title" CONTENT="test">
<META NAME="description" CONTENT="Test description.">
<META NAME="keywords" CONTENT="a b c">
<META NAME="robots" CONTENT="All">
<META NAME="copyright" CONTENT="x y z ">
<META NAME="author" content="x y z">

and here is in PHP:

// META TAGS CONFIGURATION
// Cache deactivate
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always
modified

// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

header("Content-Type: text/html;charset=ISO-8859-2">;
header("Title: test");
header("Content-Description: Test description.");
header("Keywords: a b c");
header("Robots: All");
header("Copyright: xyz");
header("Author: xyz");

Is PHP code correct?

Replacing Tags?
i have a string (very large str) that i need to parse, i have a number of different custom tags in the str and they are all diffferent. I need to parse the str and replace the custom tags with functions.

The problem is that i have not a clue how to do that. I tried using explode but that only removes the custom tags and not replaces them. I tried ereg_replace but that only replaces one instance and not all the different tags. I tried using ereg_replace multiple times but that only gets me the page being displayed over and over.

The string is a HTML page called from a database (MySQL) and parsed for these custom tags (<-MAIN->, <-LINK->, and so on) so that when the page is displayed the custom tags are replaced with the functions. Giving you a site that is basically totally pulled from a database.

Custom Tags
through JSP and Coldfusion ive seen it is possible to create custom tags. Is this possible with PHP in any way?

Reg Exp For HTML Tags
I'm have trouble with my regular expressions trying to grab the contents of html tags. Lets say i'm tyring to get what is between all my <td> tags. I wish to put all matches in an arry but its just not working for me. Well, I'm sure its working fine, i'm just not doing it right. I was trying this PHP Code:

Strip Tags
I am trying to take external content (text description) that could either be raw text, or HTML content - and assign it to a field that will be displayed on my website.

Since I want to present the data on my website, I want to strip the majaority of HTML tags, that control is font, colour, size, underlines etc.

I know that PHP provides strip_tags for this purpose.  The thing is, I want it to keep the carriage returns/newlines, and if possible bullet points - does anyone know how I can achieve this?

HTML Tags...
Say if I wanted to allow people to use <strong> <em> <a href etc. when posting a comment on my story would PHP know that it's HTML and parse it or would I need to tell it somehow that there may be HTML coming in from the form before it stores it in the database? And when I query the database do I need to let it know it might be returning some raw HTML?

Removing Img Tags With Eregi_replace
I'm trying to remove all image tags from a html document.

<H1>header</H1>
<P>foo<IMG src="asdf.jpg">
<BR>
foo...</P>

I want the "<IMG src="asdf.jpg">" to go away... (for display on an AvantoGo channel).

I suck at regexs...

$html = eregi_replace("<img.*.>", "", $html);

Nukes everything after the img tag (and the image tag)...

Stripping HTML Tags
I have the following code at the beginning of a php page:


Copyright © 2005-08 www.BigResource.com, All rights reserved