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






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Using Preg_match_all To Locate HTML Anchor Link BUT Only If The Link Is A .pdf File


The subject line describes what I'm trying to do, (and after thinking about it for a day or so and trying different things; searching around for similar questions on the board,) but I still haven't found a proper regular expression.

I am trying to use preg_match_all to locate HTML Anchor link BUT only if the link is a .pdf file within text from a database table. It actually was working just fine until I recently made a change regarding new lines () and (<br />) in the text that is to be searched. But after making changes regarding the new lines and things, my previous regexp doesn't work correctly. Here is the regexp I am trying to use:

preg_match_all('/<a href="(.*)">(.*)</a>/U', $entry->Record['e_entry'], $res_output, PREG_PATTERN_ORDER);

That regexp does find each occurance of an <a href="">something here</a> link... but I need it to only find occurances of an anchor link if it is a PDF file link (ex: <a href="../something.pdf">something</a>). So I tried changing the regexp to something like this:

preg_match_all('/<a href="(.*).pdf">(.*)</a>/U', $entry->Record['e_entry'], $res_output, PREG_PATTERN_ORDER);

But in the preg_match_all results array ($res_output) a regular <a href="">something here</a> link is ALSO found as well as the .pdf links... I am trying to only find links that contain .pdf at the end of the file name. Sorry that this is written kind of strangely, if you need more info let me know. Does anyone know what I need to change in the regexp to ONLY find HTML anchor links that contain .pdf at the end of the HREF?




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Want To Make A Link Anchor Call A Script
In a certain PHP document at my site, I have a link to a Word version of the
same document. If the user downloads it, I want to log that s/he has done this.
Data logging isn't the issue. Calling a PHP script is.

So what I have is something like:

<a href=http://my-web-site.com/documents/mydoc.doc>Click here</a> to
download a Word version of this document.

Of course the <a> anchor exists only on the client side and the PHP script
exists only on the server. But since clicking the anchor sends a message to the
server, there ought to be a linkage that can be exploited to enable a PHP call.
I just can't think of one.

View Replies !   View Related
Dynamic Download Link - Not Direct File Link
I'm posting a podcast feed that makes reference to audio files for download. Instead of linking to the files directly (e.g. www.mywebsite.com/podcast.mp3), I want to link to the file as get variables so that I can track number of listeners (e.g. www.mywebsite.com/?audio=podcast.mp3). Where would I look to get something like this to work? How do I start sending audio data to the user using a link like this?

View Replies !   View Related
Search Each Html File For Every Occurrence Of A Link
I am looking to transfer content of hundreds of html files into a database. I need to search each html file for every occurrence of a link, image if there is one present, alt text and anchor text. It should then be placed in several variables $link, $src, $alt, $anchor and placed into a csv file so I can import it into a database. The only thing that I have done so far is read the contents of the html file into a string.

<a href="link.htm" target="_blank"><img border="0" src="example.jpg" alt="This is an example"><br>This is an example</a></td>

So in this example, I need to retrieve link.htm, example.jpg, 'This is an example', and 'This is an example'.

View Replies !   View Related
Html Link For Local File Not Working
I tried a simple example for html link inside php file
I have a file called file1.txt inside C:

I put the following lines in a file and named it .html

<html>
<a href='C:file1.txt'> open file</a>
</html>
here the link works and the file opens upon clicking

if the same file I named it .php and tried to run it using apache localhost
here when you click the link, nothing happen and the file didn't open

why??

knowing that if we put any website link it works , but if we put any file inside our computer it doesn't work.

View Replies !   View Related
How Do You Link To An External PHP Script In An HTML File?
I installed XAMPP, so everything should be configured properly. However, I'm still having problems. So, here are some of the questions I have. If anyone could help me out on any of them, that would be great.

1. What is a web server? How is it helping me write PHP?

2. When I open my PHP files in my browser, they are still not read properly. Any known reason why?

3. How do you link to an external PHP script in an HTML file? Is there a such thing, or am I totally clueless?

View Replies !   View Related
How To Get My Upload File To Automaticaly Post A Link To A Html Web Page
Can some one direct me to a good tutorial that can teach me how to get my upload file to automaticaly post a link to a html web page on a web site.

View Replies !   View Related
Find A Link - Link Exchange Script
I am currently writing a link exchange script. Is it possible to have the script detect if the link is/is not present on the page it is supposed to be?

I have this:
reciprocalcheck.php:
<?php

$webpage = file_get_contents("http://localhost/ee/admin/reciprocaltest.html");

$find = '<a href="http://www.domain.com/enter.php?refer=1">'
//<a href="http://www.domain.com/enter.php?refer=1">
$offset = strpos($webpage,$find);

if($offset != 0)
{
echo "link found";
}
else
{
echo "link NOT found";
}
?>

This works but it also works even if the page it is searching only has http:// on. So how can I get it to search for that exact peice of code? ....

View Replies !   View Related
HTML Link
The select options include each of the products which are coded by an ID number. To create a link in the outgoing mail by PHP page. I have a var coming from a Select Option $productid. It is written as

<OPTION VALUE="23532">

What I need to do is have this provide a complete link and name of the product. I would like to parse the databse of the store so that if the ID number is provided, on the resulting php page that sends the mail and displays the results on the screen, I want to read from the data base to complete the link that goes on to the screen and into the mail

Thus pulling
$product_name
$product_description
$product_thumbnail

and composing it into a preformatted HTML email message.

<P ALIGN="CENTER"><IMG SRC="$imagelink" width="100" height="120"><BR>
<A HREF="http://www.foobar.com/products.php?productid="$productid"> $product name</A> $product_description</P>

View Replies !   View Related
Url Html Link
Rather than make my own function Im just wondering if there is a predefined one or one you guys know of I want to have something that will turn a link someone has entered (www.website.com) and wrap it in html to make it a link so:

<a href="http://www.website.com" target="blank">www.website.com</a>

View Replies !   View Related
Create An Html Link
Is it possible to create an html link for in internal *.html file where $filename.html is posted from a form?

View Replies !   View Related
Html Link To Data
The site I am building needs several html links, from images, to variouse categories. There are two foreign keys in the table so there is no need for a join. I simply wish to search those fields and gather all the relevant numbers to display on the results page. The method is a link with the correct variable. The query:

<?php require_once('Connections/sports_connect.php'); ?>
<?php
mysql_select_db($database_sports_connect, $sports_connect);
$query_qLinks = "SELECT department_id, cat_id, advert FROM entry";
$qLinks = mysql_query($query_qLinks, $sports_connect) or die(mysql_error());
$row_qLinks = mysql_fetch_assoc($qLinks);
$totalRows_qLinks = mysql_num_rows($qLinks);
?>

I am trying to get a "detail" link modified to send to the results page to where the data will be recieved. search_result.php?department_send=<?php echo $row_qLinks['department_id']; ?>

View Replies !   View Related
From Html Form To A Sitengine Link
My problem is this. I want a code, that would allow the phrase that i type in my html/php form, to be automatically put into a link in a search engine. I know how to do this with frames using variables, but how could i do that with opening new pages? How I would like it to go:

View Replies !   View Related
Make It Link To Another Html Page
How to retrive feild from table and make it clickable and link to another html page.

View Replies !   View Related
Grabbing A Link Out Of A Line Of HTML
I currently have a huge function that will crawl a page of a site and grab all the links off the page. There seems to be a problem though by grabbing the link text. I was curious how I can improve my function.

So I was curious if anyone knows how I can make a function that will grab "info@test.com" out of this line:

Just some text. <a href="mailto:info@test.com">Contact Us.</a>.

The main problem I come up with is sometimes it will grab the "Contact Us" or it screws up when they have additional values in the <a href> tag.

View Replies !   View Related
Can I Inser Value From Mypage.html?src=[value] Into A Link?
Let's say I have an incoming link going to

www.mydomain.com/page.html?src=[value]

where the value is the id of an ad or whatever. Is it possible to insert this value in to an outbound link on www.mydomam.com/page.html, i.e. is it possible to create a link that will automatically pass on this value to a different page?

View Replies !   View Related
Pass Variable With Html Link
how can I pass a php varialbe with an onClick= event handler?

View Replies !   View Related
Determine If User Came From Inner Link Or An Outside Link
any php method or function to determine if a user came from within the website or from an outside website. I have a page that I want to display in different manners depends on how did the user arrive at my site.

I know about the HTTP_REFERER function. but don't really know how to use it. I know this is the syntax:

<?php
echo $_SERVER['HTTP_REFERER'];
?>

but when i entered the code in the php page. for instance test.php, there is nothing coming up. So my questions:

1. is there any other method?
2. could any of you maybe specify a bit more details about this function and how to use it.

View Replies !   View Related
Regalar Expression To Extract An Html Link From A Page
I have a regalar expression to extract an html link from a page:

href=(["']?)([^>1]*.html)1(?: [^>]*)?>

It looks after the "href" for an optional quote and then looks for something
that is not the quote or the endarrow.

The problematic part is [^>1]*. It should exclude anything with the quote,
but somehow that doesn't work. Maybe 1 is not allowed inside brackets?
I would like some advice on how to handle this.

View Replies !   View Related
Html Page Link Prints Path 3 Times In Header
I have a website with html pages and a php page (a form). I just put in links on the html pages to the php page. When I click them I go to the php page and as bonus the path of the html page is printed at the top three times. (The text in the php page changes depending on which page I have hit the link from.) For example:

Quote: http://mysite.com/sitefolder/previouspage.htmlhttp://mysite.com/sitefolder/previouspage.htmlhttp://mysite.com/sitefolder/previouspage.htmlhttp

If I highlight and then delete this text in Navigator or Explore both browsers return me to the page written out three times at the top of the page. Here is the code that is giving me this result. Code:

View Replies !   View Related
A Web Development QUICK LINK PAGE (QLP) - HTML, Perl, PHP, JavaScript, AJAX, CGI, Etc.
I've recently organized and even color-coded many of my favorite
bookmarks on WEB DEVELOPMENT (and a few other favorite subjects too)
into what I call QUICK LINK PAGES. These are very condensed, compact
(no graphics), fast-loading pages with a 100+ links to some of my
favorite web sites on a particular subject. I hope you'll give them a
try...

Here's the link...

The easy-to-remember link above gets you to one of the Quick Link Pages
(QLP). The current categories (DIVERSIONS, INVESTING, JAZZ, MACINTOSH,
OPERA, PHYSICS (with ASTRONOMY and MATHEMATICS), SPORTS, WEB
DEVELOPMENT, and WINDOWS) are color-coded on the top of every page.
Just click your favorite category. I hope you'll find a lot to enjoy.
If you find any errors, or have suggestions for additional links or
categories,

View Replies !   View Related
How Do I Exit An Html Frameset As I Have A Link Which Has To Redirect Back To The Index Page?
I was just wondering in how do I exit an html frameset as I have a link which has to redirect back to the index page as shown below, which should not have the frames. header("location:index.php");

View Replies !   View Related
File With No Link
I have a link on my web page. When clicked, opens up a pdf file that is
stored on my server. Every file is specific to a user's user name and I
don't want users to see each other's files.
For example:
When User1 clicks on the link, it opens up
http://mydomain.com/files/user1.pdf
and when User2 clicks on the link, it opens up
http://mydomain.com/files/user2.pdf.

So, if User1 knows about User2, he can see User2's pdf file.

How can I make the file open up in a different window without the file
path in the address bar?

View Replies !   View Related
Specify A Link To A PDF File
How do I specify a link to a PDF file in a local subfolder such as pdf/order_form_print.pdf? The lines below are my quesswork so far. The HREF line causes a parse error in a PHP syntax checker.

<?php
define('NAVBAR_TITLE', 'Printable Order Form');
define('HEADING_TITLE', 'Printable Order Form');

define('TEXT_INFORMATION', 'If you prefer to order by surface mail, click the link below to display a printable order form.');

<a href="<?php echo tep_href_link('pdf/order_form_print.pdf'); ?>" target=_blank>Printable Order Form</a>

?>

View Replies !   View Related
Creating Link To File Or Temp File For User Download
I am designing a document management system (DMS). The files are stored
in a directory on the webserver. The filenames for the documents are
stored in a MySQL database. The DMS will track revisions from the
initial version through the updates. We must have strict permissions
set so only authorized personnel can access some documents. All of the
documents when uploaded are given totally random names such as
"114723fb5422c6bd5ed18f6.doc". Is there a way, without the webserver
creating a new file name "document_specs_ver2.doc" to have the file
download named "document_specs_ver2.doc".

If I must physically create a new file, how do I know when the
webserver would be allowed to delete it? Notes: The files will be in
several different file formats, not just "doc".

View Replies !   View Related
Log Url Link Throughs To File
I'm putting an advert onto my company website and the client has requested to know the amount of traffic the advert attracts (a click through).

How can I incorporate php to log all click throughs to a file on the server for the client? Can I use something like this?   http://www.dynamicdrive.com/forums/archive/index.php/t-5341.html

View Replies !   View Related
Play MP3 File Through Link
I have the following code, that uploads files to a "Upload" directory on the server, and stores the files path in a database. Code:

View Replies !   View Related
How To Add A Download Link For A PDF File?
I'm wondering if someone might be willing to walk me through this?

I see in my database where all my files are stored in a directory called www. Now, if I were to add a new page to my site would I need to go into that www directory and click Upload File, Add Directory or Add File?

I have a page where it has a WYSIWYG editor. What I'm wanting to do is duplicate that page with the editor on it, rename it and also add a link to point to it. But I'm not sure how to do that. One other thing I want to do with this page is be able to put a PDF file on there with a button people can download it.

That comes to my second dilema, I guess I would need to add somewhere in my CMS (admin) area where I can upload the PDF file so it will show up on the site.

Any idea's for me?? Remember I'm a complete newbie. Have no idea how to write code/scripts, but do think I could copy/paste *grin* if someone walked me through it.

View Replies !   View Related
Add XML File Download Link
I have created a simple PHP script which generates an XML document. I have added a link so that the user can view the XML file. Is it possible to create a file download link so that when the user clicks it, the file download dialogue window opens so that the user can save the file to their own computer?I know the user can do a right click and save target as but that isnt very user friendly.

View Replies !   View Related
Downloading A File From The Server Via A Php Link
If a user is is downloading a file from the server via a php
link...there are 2 ways I can do it..

1. Create a symlink to the file and .. redirect user to it and delete
the symlink later

OR

2. Just send appropriate headers to the browser and read the file to
it.

I was wondering which of these 2 approaches will take more resources.
Is there a way to benchmark this?


View Replies !   View Related
Unlinking File After Click On Link
I run a script that zips some files, after it's been zipped the client get the link to the file so that he can download it.

I want to unlink the zipped file after the client has clicked on the link. This sounds easy but I don't know how to perform an action from a link ie. <a href = ../path_to_zipped_file/zipped_file.zip>download here</a>

After they click that link I want to unlink ../path_to_zipped_file/zipped_file.zip
any ideas?

View Replies !   View Related
Flat File Link Counter (PHP)
For a small site I would like to add a simple flat text file based counter of the # of times a link has been clicked. I found some php scripts on the net, but they all count per grand total, and not with a daily statistic.

would you know where I can find a simple php script that counts the clicks and write it down in a simple txt file with the option to view daily and grand total # of clicks?

View Replies !   View Related
Secure Downloads - How To Link To File?
I use a download script to allow users to download files that are not in a
publicly accessible directory. The files should only be downloadable from a
secure page which only authenticated users have access to. But how do I
prevent someone from running the download script?

The hyperlinks in the
secure page point to the download script which is in a public directory. If
the script is not in a public directory, the links fail. Code:

View Replies !   View Related
Downloading File Via Curl When Url Not A Direct Link?
I am trying to use CURL to log into a site, download a file, and send the results. So far I have gotten it to log-in and send results (based on sample data), but I cannot get the file to download.

For example, the url is in a format similar to the link below When you click it, it redirects somewhere and provides REPORTS.ZIP (note the bolded area of the example link).

http://www.example.com/file.php?date=2006/01/18&date2=2006/01/19&file=REPORTS&info=all

The problem is that the url is not a direct link and when clicked, it prompts any (standard) browser to download the (zip) file. When I tried using wget, it downloads file.php which does no good.

What do I need to do for it to download and write the file to my local directory?

View Replies !   View Related
Read Off An Uploaded File Name To Create A Link?
I want to read an uploaded filename, say "mypic.jpg" to create a link to this image without having to ask the users to enter the filename "mypic.jpg" when uploading it.  My upload code works file but it's not on the same page. 

I'm working on my "index.php" page and included the upload.php page "<?php include("upload.php"); ?>" in it.  Here's the sample of my code in the upload.php page (the code for the form is separate and not included here): Code:

View Replies !   View Related
Download File - Display The Path As A Link
The following code, uploads an MP3 file to a folder located in the root directory of the server, whilst adding the files path to a database.

For each record in the database, how do I display the path as a link and upon a link being clicked, download the file? Code:

View Replies !   View Related
Simple Add Link To File Path Script?
I am trying to build a simple PHP script that will append links to video files on a simple PHP page. The page already has video links posted, but the admin (idealy) will have to open a page that has a "name of video" field, "description of video field" then a path of file field. This would the add a link to the path file in addition to the rest of the file links...the simpler, the better. Code:

View Replies !   View Related
Use Download Manager If File Link: File.php?file=something.zip
I have a piece of code:

<?php
    $path = "/home/surfall/secret";
    $mainpath = "$path$file";
    header("Cache-Control: ");# leave blank to avoid IE errors
    header("Pragma: ");# leave blank to avoid IE errors
    header("Content-type: application/octet-stream");
    header("Content-Disposition: attachment; filename="".$file.""");
    header("Content-length:".(string)(filesize($mainpath)));
    sleep(1);
    readfile("$mainpath");
?>


However I can't seem to get download manager to work with it? So that I can download the file in pieces, thus the download will be faster. (I use Flashget as the download manager)

View Replies !   View Related
PHP-generated Link To Local File Doesn't Work When Clicked On. Why?
I'm running an Apache server on my own computer (Windows XP Pro).

I wrote a simple PHP script (called test3.php) that I'm running by
putting the following URL in the address bar of the browser (Firefox)
....

http://localhost/test3.php

The script generates the following link using the echo statement ...

<a href="file:///C:/pictures/xyz.jpg"> Picture </a>

("C:/pictures/xyz.jpg", as you can guess by now, is an image file on
my harddrive, but it's not in the document root).

When I clicked on the link, nothing happened. However, if I
RIGHT-click on it and select "Copy link location" (which copies the
URL to the clipboard) and then paste the URL into the address bar of
the browser, the picture then displays correctly.

Why did it not work when I clicked on the link the first time, but it
only worked when I pasted the link to the address bar?

Is there some special notation/syntax that I need to use to get this
to work properly?

View Replies !   View Related
Set A Cookie That Change The Visitor's File Extension Upon Click On A Link
I'm trying to do this for some days now but still not getting somewhere. I want to set a cookie that change the visitor's file extension upon click on a link, ex.

Link1: index.1.php
Link2: index.2.php
Link3: index.3.php
...

Now lets say that you are click on Link1 and the cookie is placed, and then click on a second link, lets say default.php; now i want the default file get the extension .1.php rather than .php, and so on. When a cookie is set all the following files get the specified extension.

View Replies !   View Related
Eregi (html Anchor Tags)
I need to get all the html anchor tags from a string. heres my eregi line: PHP Code:

View Replies !   View Related
Page Redirection - Link Index.html Page To A .php Pag
I have an index.html page with a link to a .php page This is the complete code of the .php page Code:

View Replies !   View Related
Locate A String In A File
I need a script that can locate a string in a file (same line/position in every file) copy it and replace another string in the same file with the copied string. open a pointer to a page. grab the text from <td>Text to copy</td> replace zzz with "Text to copy" close the pointer .

View Replies !   View Related
How To - File Download Link File.php?file=something.zip
I'm trying to get/make a code that will make it possible to download from urls like "file.php?file=something.zip"

I've made one, but the problem is that I can't seem to get download manager working with it, and this is a big problem.

As you all probably know, with the download manager I can download the file in pieces and pause, start the download process. I use "Flashget" as my download manager. But if someone else knows one that would work with the url, let me know! Code:

View Replies !   View Related
<link:page.html,xxx> => <a Href="page.html?id=xxx">
I want to transform this code <link:page.html,xxx> to

<a href="page.html?id=xxx"> dynamically.

I tried out alot of preg_replace stuff, but I didn't get to manage it.

View Replies !   View Related
Preg_match_all , Pulling Content From Html Page
This is what I have:

preg_match_all("/<tr class="*tdshade.*>(.*)</tr>/U", $result, $matches);

$result is a string of HTML like so: Code:

View Replies !   View Related
Getting File Type From A String Into Anchor
I'm pulling out links from a database, some of them are images, some are movies, some are URLs and some are just download files. I need a way to differentiate each of the to be printed in the anchor tag this is what I'm doing: Code:

View Replies !   View Related
Preg_match_all Pattern, Find URLs In A File
I'm trying to find URLs in a file, but I need to include the target="blank" to the pattern matching. I tried this: PHP Code:

preg_match_all('/<as+.*?href=["']?([^"' >]*)["'?[^>]*?target="_blank">(.*?)</a>/i', $s,$matches,PREG_SET_ORDER))

View Replies !   View Related
Give The User A "Browse" Button To Locate The File On His System
I want to give the user a "Browse" button to locate the file on his system
that he wants to upload to the server. Where is a good example of how to do
this?

View Replies !   View Related
Link?=ID#
I am wondering if there is a script/code somewhere to find that hides my actuall links from browsing users, no database related. For example. My links on a webpage


link 1 = http://mysite.com/hello.php
link2 = http://mysite.com/byebye.php

I want to hide theese links and for the outsidebrowsers to look like this:

link1 = http://mysite.com/redirect.php?ID=12
same for link 2 but with a different ID

hope ypu understand .Please note : NO MYSQL support.

View Replies !   View Related
Using An As A Link
Now I am able to practice php on my pc, thanks to previous replies to a
post in this forum, here the first of many questions.

I want to be able to use an image as a link. So in html I would use:

<a href="http://www.somepage.com">
<img src="someimage.jpg">
</a>

I have written the php code below (which I am proud of !!):

<?php

// Switch statement based off server time
switch (date('H i D'))
{
case &#3922; 33 Sat':
print '<img src="michelle.jpg" border="2" height="170"
width="227" />'
break;

case &#3922; 34 Sat':
print '<img src="sunset.jpg" border="2" height="170"
width="227" />'
break;

default:
print 'Cases not met'

}

?>

Now the code above does what I want it to do but if I add the line
below i get a parse error:

case &#3922; 35 Sat':
print '<a href="http://www.somepage.com"><img
src="someimage.jpg"></a>'
break;

So how do I create a link from the images in my code?

View Replies !   View Related
Getting 404 Link
Thanks to my apache .htaccess file, all the 404 errors are redirected to my
404.php file.

I'd like to get the following infos :
- the page address from which the 404 error come from (I get it with
$_SERVER["HTTP_REFERER"]),
- the exact link that provoqued a 404 error.

How can I get the 2 piece of info ?

View Replies !   View Related
Link In If
if i have the following how do i make the new chat message a link?

<? $numbernow=($chat[0])?>
<? if ($stat[chatnow] < $numbernow) {
       print "NEW CHAT MESSAGES";
}
?>

View Replies !   View Related

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