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




How Convert Http:// Text To Real Hyperlink?


I have some texts in MySQL databases. When I show this texts in webpages using PHP, I need to convert every ocurrence of

http://blablabla.com

to

<a href='http://blablabla.com'>http://blablabla.com</a>

, so my text will really became 'active'. The people who wrote the texts don't know HTML tags so I can't ask them to write explicity <a...> </a> commands. The problem is the same with text that contains the @ charactere, as

name@mailserver.com

. I have to change this to

<a href='mailto:name@mailserver.com'>name@mailserver.com</a>.

Please, I don't know how to use regular expression. I think It can make this replacemments very easy..




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Real Audio Http Streaming Without .ram File
I wanted a way to (http) stream Real Audio files without the need to use
..ram files. In case there are others interested in this, the following is
the solution that worked for me:

<?php
Header("Content-Type: audio/x-pn-realaudio");
echo "http://www.domain.com/audiofolder/track1.rm";
?>

URL Text To Hyperlink
here is what i have

   $threadx = preg_replace("/((ht|f)tp://[^s&]+)/", "<a href="$1">$1[/url]", $threadx);
   $threadx = preg_replace("/(S+@S+.w+)/", "<a href="mailto:$1">$1[/url]", $threadx);

can someone tell me how to make it better,
this one completly screws up existing hyperlinks and <img src=""> tags...
need to fix it somehow..

Extractng Text From Hyperlink
I need to extract the text within anchor tags for use in building another hyperlink.  In other words, if I have something like this:

<a href="http://www.something.php?id=12">Blah blah blah</a>

I need to get the 'Blah blah blah' part.  I'm thinking that a regular expression is the way to go, but I'm having difficulty seeing how to deal with the stuff in the href attribute.

Hyperlink In Text Area
I have a basic CMS system and the client would like to insert some links in the text area. What would you recommend the best way to do this in a textarea box? There may be several hyperlinks in 1 textarea and some may have none at all.

I assume this would be some sort of javascript code or is there an easier way.

Dynamically Genetrate RAM (Real Media) Text Files
I am working on a record company's site.  They offer a selection of track snippets for stream/download. I would like to be able to dynamically generate the RAM (text File) to save manual input in the DB. 

Currently each RAM file has to be uploaded everytime a new track is added....but I'd like to have this created on the fly when a user is browsing the site.

user selects track...is forwarded to the dynamically generated RAM file...which in turn selects the appropriate media.

I can't think how i'd get this to work as I am trying to create a text file that is parsed rather than a peice of HTML that is read by a user.  Perhaps on the server I'd have to add PHP Parsing to the RAM mime type?

Conditional Email Text To Hyperlink
I am trying to write a content management section for a web site.

I have managed so far to use htmlarea to give users a basic, but user
friendly interface by which to edit the page content.

The user can add emails by symply typing john@example.com - IE automatically
converts this to a hyperlink. The trouble is sometimes the users use plain
text. I have been using the following line to convert plain text to a
hyperlink:

$pagetext=ereg_replace('[A-Za-z0-9_]([-._]?[A-Za-z0-9])*@[A-Za-z0-9]([-.]?[A-Za-z0-9])*.[A-Za-z]+',
'<a href="mailto:?subject=Email%20from%20web%20site"></a> ',
$pagetext);

This works well - BUT it completely screws up any existing hyperlinks. Is
there a way to convert the plain text email address in to a hyperlink only
if it is NOT part of a hyperlink.

Basically I need some way of checking
* If it's plain text > convert to a hyperlink
* If it's already an email hyperlink leave it alone.

I have tried looking up and testing everything I can think of - but am
finally asking around before I go mad.

Changing An Image For Text/hyperlink
I have the following piece of code, which uses an image as a button. I want to remove the image and just have some text/hyperlink which has the same effect when clicked? Would someone please help and advise what needs to be changed...

<?php echo tep_image_submit('button_wishlist.gif', 'Add to Wishlist', 'name="wishlist" value="wishlist"');?> ....

Convert HTTP Header Last Modification Date To Integer
snoopy class can retrieve the specific page's lat modification date in
String but is there any way to get into the integer or long?

<?php
include( "Snoopy.class.php" );
$request = new Snoopy;
$request->fetch( "http://www.mysite.com" );

if( ! $request -error ){
while( list( $key, $val ) = each( $request -headers ) ) {
echo $key.": ".$val."<br>
";
}
}
?>

A Real Challenge For Real PHP Programmers
<?php
/*
A challenge to every PHP programmer.The one who's gonna solve this
problem would be deemed as

PSP(PHP Supreme Programmer).The problem is this : You have to write a
script that displays a list of

categories and subcategorieslike this one:

<select name="category">
<option value="1">Main</option>
<option value="2">Main > Computers</option>
<option value="4">Main > Computers > Hardware </option>
<option value="8">Main > Computers > Hardware > PC</option>
<option value="7">Main > Computers > Hardware > Mac</option>
<option value="9">Main > Computers > Hardware > Atari</option>
<option value="11">Main > Computers > Hardware > PC > History of
Pc</option>
<option value="">etc...</option>
</select>

The categories and subcategories details are stored in these two
tables in a MySQL database.
-categories : the categories names and ids.
-cat_relations : the relations between categories.It shows which
subcategory belongs to which category.
The belongings between categories can go very deep and the number of
categories is unlimited. This script will create the two tables and
fill them with sample data. All you need to do is to change the four
variables below. You can send the script back to this email :
yasbergy@yahoo.com.
*/

//Here starts the script. Please change the values of these variables
to fit your settings
$user = "prospective_PSP";
$database = "db";
$server = "localhost" ;
$pwd = "" ;
//Connection to the database that you created
mysql_connect($server,$user,$pwd) ;
mysql_select_db($database);
//Creation of the two tables : categories and cat_relations
$categories = " CREATE TABLE `categories` (`id` INT not null
AUTO_INCREMENT, `name` VARCHAR(100) not null , PRIMARY KEY (`id`),
INDEX (`id`), UNIQUE (`id`)) comment = 'The categories details' ";
mysql_query($categories) ;
$cat_relations = "CREATE TABLE `cat_relations` (`id` INT not null
AUTO_INCREMENT, `daughter_id` INT not null, `mother_id` INT not null ,
PRIMARY KEY (`id`), INDEX (`id`), UNIQUE (`id`)) comment = 'Which
category is the daughter of which category'";
mysql_query($cat_relations) ;

//Filling the two tables with sample data
$cats = array('Main','Computers','Countries','Hardware','S oftware','Programming
languages','Mac','PC','Atari','Winamp','History of the
PC','IBM','Components','High
level','USA','NYC','LA','Manhattan','India','Winzi p');
for ($i=0;$i<count($cats);$i++){
$sql = mysql_query("insert into categories (name)
values('".$cats[$i]."')");
}
mysql_query("insert into cat_relations (daughter_id,mother_id) values
(2,1),(3,1),(4,2),(5,2),(6,2),(7,4),(8,4),(9,4),(1 1,8),(12,8),(13,8),(10,5),(20,5),(14,6),(15,3),(16

,15),(17,15),(18,16),(19,3)");
//Now you can have a look on them through phpMyAdmin
?>

Convert Text
I have a text like this: "Thuy&#7873;n Và Bi&#7875;n"
How to convert it to: "Thuyá»n VÃ* Biển"

How To Convert Any Text To Unicode?
How can I convert any text to unicode please help me

Convert Text To A Percent
Im making a useless little program that takes 2 peoples names and tests their love compatibility as a percentage. I dont want a random number generator because I want to make it so when you enter the same name twice you get the same result.

Any ideas how to put the to strings together to get a varying percentage. I have tried a few things. One i converted both the strings to md5 and then did similar_text() to compare... however the percentages were always low... I want a mixed result.

How To Convert Ascii To Text
I replace some user input with their ascii equivalent so they display
on the webpage properly:

$entry = preg_replace ( "/'+/" , '&#39' , $entry);
$entry = preg_replace ( "/,+/" , '&#44' , $entry);

I then need to email the data, however in email the ascii code is
displayed, not the text.

Is there an easier way to convert the ascii back to the text without
another preg_replace?

Convert Word-to-Text On Linux
How can I read a Word document and convert it to text (just in memory
is fine) on a Linux machine where there is no Word installed?

Convert MS Word / Rtf / ... To Plain Text
i'm looking for standalone libraries that convert documents to plain text so i can let people edit the text in a textarea after uploading. One thing to notice is that i can not use COM because i can't configure the webserver.

Does anyone has interesting classes that are able to do this. I found a PHP class for ms word documents at http://obninsk.name/obninsk_doc/ but that doesn't work at all for my word documents.

Convert Php Data Into Text File?
I have a php file that gathers data from a specific website. I am then using that data (numbers) in a different application. The only problem is the html formatting. I just need the numbers, but I'm getting all the html tags with the data. Is there a way for me to have the php file output in to a seperate plain text file?

Convert Text From Database For HTML
I'm pulling text from a database (MySQL) and I'm using the nl2br () function to convert the line breaks

DESCRIPTION="<?php echo nl2br($row_rsttheJobResults['description']); ?>"

This creates the following example

"A new line will be created soon < 'br' >
and here it is."

However the website that receives this cannot accept the characters < and >
So I want to convert this "< br >" into this "&lt;p&gt;"

Could anybody help me add to the nl2br () function to convert the < br > tags?

* the spaces between the < and br are there because they won't show in the message otherwise

Convert Numerical To Text For Check Writing
Does anyone know of/have an open source class that will compose the text
version of a dollar amount? For instance, convert $525.62 to "Five hundred
twenty five and 62/100 dollars".

I'm trying to write a quick accounts payable app and I really do not want
to have to write this part from scratch!!

PHP/pear Http Put Method And Text/xml?
I have a problem with the HTTP implementation of the PEAR package:
I try to PUT an XML instance to an XML database (eXist), but it always
puts a binary:

<?php
require_once "HTTP/Request.php";

$URL = 'http://ap34.ifi.informatik.uni-goettingen.de:8081/exist/servlet/db/may/hamlet.xml'

$req =& new HTTP_Request("");
$req->setBasicAuth($user, $passwd);
$req->setURL($URL);
$req->setMethod("PUT");
$req->addHeader("Content-Type", "text/xml");
$req->addFile("hamlet.xml","/home/may/public_html/PHP/hamlet.xml", "text/xml");

$response = $req->sendRequest();
?>

When looking into the database, there is also not the XML file, but
there is a complete HTTP request:

***
--HTTP_Request_f42cc34621bc820ecd46b8f6ef61eb7e
Content-Disposition: form-data; name="hamlet.xml"; filename="hamlet.xml"
Content-Type: text/xml

<?xml version="1.0"?>
<!DOCTYPE PLAY SYSTEM "play.dtd">

<PLAY>
<TITLE>The Tragedy of Hamlet, Prince of Denmark</TITLE>
etc.
****

It seems not ot be a problem of the database, since it works well when doing
the same with python (a sample that is included into the documentation of eXist),
i.e., tha database work correctly when it receives a correct PUT.
Can anybody give me an example how HTTP PUT is applied correctly with PEAR?

Warning: Fopen(http://localhost/.. ?HTTP Wrapper Does Not Support Writeable Conn
I am able to create a pdf using php and ezpdf, its works fine, and display the pdf document in the current server page.

But here are two things i wish to do, first store the pdf and than open, if possible in a new popup window?

When i tried this function below, it gives me an error

Error:
Warning: fopen(http://localhost/pdf/files/tmp1/yasmina.pdf) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections. in C:Program FilesxampphtdocspdfpdfClassesAndFonts_009ecertificate.php on line 139
Could not open file to save PDF. Code:

Server HTTP Sends Or Streaming HTTP?
I was wondering if you guys had any ideas to constantly
stream a webpage in case an announcement was posted
or possibly pushing onto the browser information.

What I basically want is for a user browsing my website
to be notified of any new announcements. I thought
about checking everytime he changes pages but then
I realized that I want them to be notified as long as
they have the page open even if it's minimized. So it
would at best be a method to use php force send a msg
after someone posts an announcement.

Questions About HTTP Headers Sent With PHP In HTTP Authentication
Here is an example from the PHP Manual

<?php

if ((!isset($_SERVER['PHP_AUTH_USER'])) || (1==1)) {
header('WWW-Authenticate: Basic realm="My Realm"');
header('HTTP/1.0 401 Unauthorized');
echo 'Text to send if user hits Cancel button'
exit;
} else {
echo "<p>Hello {$_SERVER['PHP_AUTH_USER']}.</p>";
echo "<p>You entered {$_SERVER['PHP_AUTH_PW']} as your password.</
p>";
}
?>

Questions.

1. This is a status code not a header, right? = header('HTTP/
1.0 401 Unauthorized');

2. According to the change log in the PHP manual, starting with 4.4.2
and 5.1.2 the header function now prevents more than one header to be
sent at once as a protection against header injection attacks. Does
this mean if I make multiple header calls the headers will be sent in
multiple response messages to the browser? Is this allowed? Can a
server send multiple response messages to one request?]

3. If you hit the "cancel" button on the browser user name/password
request dialog (as alluded to in the code snippet above), what message
does the browser send to the server.

Trapping A File Error: Failed To Open Stream: HTTP Request Failed! HTTP/1.1 404 Not Foundin
php
Warning: file(http://shop1.outpost.com/product/5053975)
[function.file]: failed to open stream: HTTP request failed! HTTP/1.1
404 Not Foundin

I am just trying to put some code around this to trap it.

Real Ip Behind A Proxy
is there any way to know the real ip, for people behind a proxy?

Getting The REAL Directory?
Is there any way to get the directory/path of the file running the script, not the directory you're inside (Via dir())? I'm allowing the user to navigate through directories, and that part works great - but whenever I attempt to used getcwd(), it returns the directory the user is in - not the directory of the php file - is there any way to get the directory of the .php file the user is using?

Real-time Output?
I'm a relative PHP newbie, so I apologize if this is a simple question.

Anyway, here's my problem. I'm using a PHP script to pre-render a bunchload of insert files for an HTML page. Right now there's about 1,600, but that number could get much, much higher when the site goes live.

I'll only need to re-render the whole batch once or twice a year (if that) but it's still something I'd like to be able to do in case I have to move the site to a different server, or there's a hard drive crash or etc.

Basically what the script does is grab a whole bunch of information from a database and write the insert file. It does this for every single one.

The problem of course, is that PHP by default does all this server-side, and then sends it to the browser. Because this process takes like ten or twenty minutes to do, the browser times out long before it's finished.

Is there a way to get progressive output with PHP? Or do I need to re-do this in another language like Perl?

Real Length Of Arrays
Sometimes, I want to know how many elements are really in an array (php3).

The count() and sizeof() functions apparently return the number of non-empty array elements, and if you do a while loop checking for empty will stop on the first empty element.

I have been using the following function:
function truecount($theArray) {
if (is_array($theArray)) {
end($theArray);
return key($theArray);
}
}
but if the key is non-numeric, won't that trip me up?
Anyone have a better solution?

Md5 / Sha1 - Any Real Difference?
I use md5 hash with some of my cookies and occassionally a hidden form
field - I know the physical data on my network is insecure (unless being
served via https) but I was wondering if there are any advantages to using
md5 over sha1 or versa vicea... I know md5 gives me a unique 32bit hash
while sha1 I've read is 'secure' (?) and gives a 40bit hash... Since The
technical webpage on sha1 is lengthy and for the most part over my head...
and other than today, I've never heard of it before... I was wondering if
anyone could offer any comments on it...

Real Time Chat
There's anyone out there that can give me a light on real time chat using sockets. I've seen some using push technics but they all hang up after an elapsed amount of time.

Htmlspecialchars/real Escape
I'm creating a BBCode parser, and everything's working but one thing; I need code tags, but I will need to real_escape/htmlspecialchars the post to make sure it isn't malicious. The only problem is if I real_escape with code tags that contain php, the php will be removed. If I specialchars the post with php, I can't have syntax highlighting (or, not easily). How do I get round this?

Real IP Address From Behind Proxy Or NAT
How to get the real IP address of a user, not that of their proxy server or the external NAT address. I was quite sure that this wasn't possible without some kind of process getting the address on the client machine.

I have suggested that these sites could be using Java to get the real IP address, however, I could be wrong and for me the script that I found always returns 127.0.0.1 . This suggests to me that any script attempting to obtain the hosts real IP address infarct rely s on the HTTP-X-FORWARDED-FOR header sent by the proxy server...

Real Audio Download Limiter
i'm running a site with .ra and .ram files, when some visitor download or stream all these files at the same time it causes an huge bandwidth consumption.

so i'd like to limit the download per each IP to a certain number of .ra and .ram files at time.

i wonder if i can use some php script with cookies session but i'm new to this and i don't know where to start.

Real Time Echo'ing Of Var In A Loop
i have a big loop, and rather then waiting until its done for me too see what happened, every time it runs, how can i get the browser to echo the result, and proceed to keep running the loop.

basically this loop takes a long time to finish, and i had to set my max runtime past 30 seconds. i guess incorporating a refresh of some sort like this would eliminate the need for the time extension too?

PHP Template Redirecting To Real Video
I've developed a RealVideo content management system w/ PHP and MySQL. On the back end is a form that sends a Real Video file (.rm) and writes the filename to a database. On the front end is a PHP template that pulls the filename from the database and outputs a string that is read in by a Flash movie. The Flash movie reads in the file location and places HTML-encoded text inside a text field that says "Launch Video."

All works fine -- the Flash movie launches the Real Video file, and the file plays correctly. There's only one problem: the Real Video doesn't stream.

In order for a Real Server to stream a Real Video file, a "stub" file with the extension .ram needs to be placed in the root directory. The only content in these .ram files is a URL pointing to the actual .rm file, and it's written in this format: pnm://ra.domainName.com/realvideoFile.rm

My problem: The form is sending a Real Video file and the receiving page is copying it to the server as well as inserting a record into my database, but it can't write a .ram file to the root directory because to do so I'd have to adjust permissions accordingly (PHP is part of group Apache). That's unacceptable; I won't adjust permissions on the root directory. My solution was to create a redirector that acts as the stub file:
PHP Code:

Real World Singleton Class Example?
Anybody can show me real world singleton class example?
Something that works (is implemented) as part of working solution.
Does it make sense to create database handler class that way?

Is Gmail Homepage Real Ajax?
I saw gmail's storage size on mail.google.com. It was counting size like "Over 2728.845439 megabytes". then increasing... but my dialup connection disconnected I don't understand howto count storage size, when my pc disconnected internet. is it real 2728.845439 MB? or only text?

Stripping Commas From Real Numbers
I have an HTML form in a PHP script which queries the user for a dollar amount of sales.
If a user enters "1,000,000" rather than "1000000" for 1 million, PHP (or MySQL?) treats the commas as a decimal and "1" is entered in the database.

A simple work-around is to simply advise the user "Please enter numbers only, no commas or $'s" but this seems awkward. Is there a built in function or another easy way to have commas and currency signs stripped out of form-entered data?

Can Curl Pretend As Real Browser?
Is curl can pretend to real browser when it get content and how set the browser that it pretend to?

Exploding At Real Breaks Not Wraps
I am working on reading my  pop3 email , and I am trying to return the header data using the function, I get this fine. The question I have is since there is no consistency to the rows, I want to take each row of data, not a wrap of a long line, any idea beyond checking if it has a : in it???

Hyperlink
Im making a select statement and the outputs are in a table but i want the entry of a column to be hyperlink to take to another page Code:

Checking If Email Address Is Live And Real?
There's all kinds of ways to validate an email address to make sure
it's well formed and whatnot, but what about checking to see if it's a
valid e-mail account?
Like how you can use checkdnsrr() to check to see if a URL is valid.

I know finger used to be used at one time, no? But server block finger
requests, and I'm not sure many e-mail accounts out there are even
fingerable type accounts anyway.

MySQL Result To Real Array In Function
I'd like to create a function which input is the result of a mySQL
query.
The output should be exactly the same, only not a mySQL result array,
but a 'real' array.
So it should also get the fieldnames returned by mySQL and use those as
keys.

I can't get things to work properly: it should return a
multidimensional array,
like

$result_array[1] = array(
[field1] => field1 value,
[field2] => field2 value,
etc.
)

somehow my result is (with code below)

$result_array[1] = array(
[0] => field1 value,
[field1] => field1 value,
[1] => field2 value,
[field2] => field2 value,
etc.
)

+++++ code ++++++

$get_res= mysql_query(QUERY);

if( $res = mysql_fetch_array( $get_res ) )
{

do{

$result[] = $res;

}while( $res = mysql_fetch_array( $get_res ) );

};

foreach( $result as $key => $value ){

print_r($value);

};

Real Good Content Management System ?
I'm getting somewhat annoyed about how many cms's
there are in PHP/MySQL while so few are really good.
Yesterday I started to like ezPublish, until I decided
the template language is ugly and the process for creating
a maintenance template for a content class is not logical.

I'm starting to think I should write my own cms, but that
will increase the leadtime for my site enormously.
So I would like to know from you if you know a cms that ..

- Is free and open source
- Is PHP/MySQL based ( usable with just about any host )
- Doesn't enforce site/navigation structure
- Has a WYSIWYG editor or one can easily be plugged in
- Has a forum module
- Is also an application framework with good
separation of content, code and layout.
- Does not have its own insane template language
- Supports a moderation process for content
- Has an intuitive process for creating maintenance forms
for posting and maintaining content.

I think Zope comes close, but that's Python :-(

Displaying A Hyperlink
I pull a string out of MySQL and display it in an html page using PHP. It automatically becomes a hyperlink but if it is a link to a document (www.web.com/test.doc) it won't translate it into a hyperlink. Does anybody know how I might do this?

Hyperlink Query
I have the following line that prints out a record with a link, when you
click the link you get more column
information in the record. I want to add another field (State) so that I can
narrow down the results. How can I pass both the hcounty as I'm doing now,
along with state? to the state7.php file?

print " <td><bgcolor=#000000><font color=#000000 font color=#000000
face=Tahoma size=2 ><A href='state7.php?searchid=$line[hcounty]'><img
src='buttondetail.gif' border=&#390;'></img></td>
";

Replacing Www... With Hyperlink
i want to replace all entries of beginning with 'www.' and
ending with ' ' with a hyperlink to that substring such as:

www.google.com := <a href="www.google.com">www.google.com</>

can anyone tell me the easiest way to do this?

HyperLink Validatation
I am wondering what approach I could used to validate links. I am building a simple portal type index and I would like to be able to check for broken links weekly. The Database already has a field for link status. I would like to create a script that checks for broken links and changes the status so a human can follow up on it.

I am also wondering about how one would “limit” this program. I mean I don’t care if it takes 2 hours just as long as it does run rampant and cause issues with my host. Any thoughts…? I am not looking for a complete solution just a point in the right direction.

Hyperlink Per Mail
can anybody tell me how to sen a hyperlink using the php mail function.
If I send a <a ref ...> it just turns up in plain text. Whats the trick

Hyperlink With Parameters
Is this how you print a hyperlink passing parameter action , id, qty to another php script? And printing HTML inside php? I giving three sample code in my program.


I use quotation around HTML TAG and code so can read by php print command.

1. Hyperlink with parameter to pass

print "<a href = "cart.php?action=Add&id=" . $column['SKU'] . "&qty=1">Add Item</a></font></td></tr>";

2. Printing HTML tag with PHP print command

print "<TR><TH>Title</TH><Price</TH><TH>Description</TH><TH>Add Item</TD></TR>";

3. Here I try to print a drop down list with Javascript onChange event. Notice that I use concatenation between HTML TAG and PHP code. I use to respesent quoatation mark.

// print the drop down that will update the qty instantly using Javascript onChange event
// the following syntax will look like this in regular HTML code
// <select name = "$column['SKU']" onChange = "upDateQty(this)"><option
Selected>i</option></select>

print "<tr width = 15% height = 25><td width = 15% height = 25><font face = verdana size = 1 color = black>";
print "<select name = "" . $column['SKU'] . ""onChange = "updateQty(this)"";

for ($i = 0; $i <= 20; $i++)
{
print "<option";
if ($rows['QTY'] == $i)
{
print "SELECTED";
}
print ">" . $i . "</option>";
}
print "</select></font></td>";


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