Images display directory in php file - php

i have a maintenance page 503.php. I tried to get the images to be displayed but it did not show. I tried path and html img way, but it did not work. Below are the codes and also anyone helps me explain how to included images in php file?
My website images directory is like this:
on server: pulic_html/website/images
on local: website/images
php file dir: website/503.php
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>
<?php
header("HTTP/1.1 503 Service Temporarily Unavailable");
header("Status: 503 Service Temporarily Unavailable");
header("Retry-After: 3600");
?>
</title>
<style type="text/css">
body {
background-image: url("../images/black-brick-wall-texture.jpg");
}
</style>
</head>
<body>
<div>
<div>
<p style="text-alignment: middle"><img src="../images/still-under-construction.gif" width="306" height="350" alt="dang duoc bao tri" />" </p>
</div>
<div style="text-align: center; font-size: 24px; color: #FFF;">
<p>BSeveryday.vn hiện <span style="color: #F00">under maintenance</span>, please come back later <span style="color: #F00">30p - 2 giở</span>.</p>
<p>if you have any problem, please send me a message at: <span style="color: #00F">vandekhac#bseveryday.vn</span></p>
</div>
</div>
<p><img src="../images/under_construction.gif" alt="under maintenance" width="350" height="299" align="right" />" </p>
</body>
</html>

In the .htaccess file in the website's root directory insert the following line before your RewriteRule line::
RewriteCond %{REQUEST_FILENAME} !.(gif|jpe?g|png)$
You may need to add css or js to that list of filetypes, depending on your holding page’s needs.
It may solve your problem.

Related

Getting Error Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0

I am new to php but have done a lot of development in other languages. I have inherited a system created by another developer. The code should display a standardized form that is formatted with CSS. It should display a navigation menu on the right with a masthead containing text which changes dynamically, then shows a page and then some content. It works fine running locally on a Mac. I've migrated the project to a PC. When I try to run it's index.php page I get the following errors:
( ! ) Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
( ! ) Fatal error: Unknown: Failed opening required 'C:/wamp/www/styleguide/index.php' (include_path='.;C:\wamp\bin\php\php5.5.12\pear') in Unknown on line 0
After looking through similar errors in the forum I have checked the file permissions and all of the files give me full access and are not read only. I tested Pear, it appears to work fine. Phpinfo shows I have the correct include_path. Other php code I've written runs fine on the PC and can do require_once. The error log shows this same message so I can't determine which files are causing a problem.
I'm running Wampserver 2.5 with Apache v2.4.9 and php v5.5.12 with PEAR Release version 1.9.5 on a Windows 7 64-bit machine. Any suggestions would be appreciated.
Here are the contents of Index.php
<?require_once('includes/header.html');
head("Style Guide | Welcome!");
?>
<body id="welcome">
<div class="scroller"></div>
<div class="midcontent">
<?php include("includes/welcome-msthd.html"); ?>
<?php include("includes/welcome-content.html"); ?>
</div>
<div class="holderbox">
<?php include("includes/navs.html"); ?>
</div>
</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
Here are the contents of includes/header.html
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
<link rel="shortcut icon" href="http://www.allmysons.com/images/amsfav.ico" type="image/x-icon" />
<link href="css/css3.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Waiting+for+the+Sunrise' rel='stylesheet' type='text/css'>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<META NAME="GOOGLEBOT" CONTENT="NOARCHIVE">
<!--Bookmark Code -->
<script type="text/javascript">
function bookmarksite(title,url){
if (window.sidebar) // firefox
window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
var elem = document.createElement('a');
elem.setAttribute('href',url);
elem.setAttribute('title',title);
elem.setAttribute('rel','sidebar');
elem.click();
}
else if(document.all)// ie
window.external.AddFavorite(url, title);
}
</script>
<!--Remember to add new IDs for new pages below! -->
<style type="text/css">
#welcome li#welcomelink a,
#generalrulesoverview li#generalrulesoverviewlink a,
#employeeuniform li#employeeuniformlink a,
#generalrulessocialmedia li#generalrulessocialmedialink a,
#logodownloads li#logodownloadslink a,
#logodosanddonts li#logodosanddontslink a,
#logocolors li#logocolorslink a,
#logousageandfonts li#logousageandfontslink a,
#emailtemplate li#emailtemplatelink a,
#emailsignatures li#emailsignatureslink a,
#businesscardoverview li#businesscardoverviewlink a,
#orderabusinesscard li#orderabusinesscardlink a,
#brochureordoorhangeroverview li#brochureordoorhangeroverviewlink a,
#thankyoucards li#thankyoucardslink a,
#orderabrochureordoorhanger li#orderabrochureordoorhangerlink a,
#billboards li#billboardslink a,
#changeofaddressform li#changeofaddressformlink a,
#tshirts2 li#tshirtslink a,
#managershirts li#managershirtslink a,
#otherapparel li#otherapparellink a,
#orderapparel li#orderapparellink a,
#taglines li#taglineslink a,
#truckart li#truckartlink a,
#content-submission li#content-submission-link a,
#orderestimatorfolder li#orderestimatorfolderlink a
{ color: #fff; }
a:link {color: #ccc; text-decoration: none;}
a:visited {text-decoration: none;color: #ccc;}
a:hover {text-decoration: none;color: #fff;}
a:active {text-decoration: none;color: #ccc;}
</style>
<!--Code below dynamically inserts page title (from page) -->
<?php
function head($title){
if(!$title){
$title="Default page title";
}
?>
<title><?php print $title; ?></title>
</head>
<?php } ?>
Here are the contents of includes/welcome-msthd.html
!--Masthead -->
<div class="versiondate">Version 2.0 | 4-20-12</div>
<div class="header">My Company Name</div>
<div class="header2">Company Style Guide and Resources</div>
<div class="header3">Welcome!</div>
<!--Masthead -->
<div class="versiondate">Version 2.0 | <?php include("includes/updated.html"); ?></div>
<div class="header">All My Sons Moving & Storage</div>
<div class="header2">Company Style Guide and Resources</div>
<div class="header3">Order Estimator Folders</div>
Here are the contents of includes/welcome-content.html
<!--Content -->
<div class="content">
<strong>Some content welcoming the user </strong><br /><br />This is some welcome text <a style="color:#3a7124; text-decoration:underline;" href="mailto:myemail#mycompany.com?subject=Style Guide Help Request">contact us</a> for help.
<div>
<?php include("includes/footer.html"); ?>
</div>
</div>
<!--Content -->

preg_match not giving output

i am trying to filter data using preg_match it seems to be correct and matching on view source code but when i run the code it gives no match found
here is my pattern
/\<p\>(.*)\<center\>/
string is
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<small>Photo courtesy of hortongrou </small>
</div>
<p>I have developed theasional thriller.<br />
<code> </code><br />
<li><strong>Beginning Ubuntu Linux<img style="border:none !important; margin:0px !important;" src="" border="0" alt="" width="1" height="1" />, by Keir Thomas and Jaime Sicam.</strong> For those who like to transition from Windows to Linux, install Ubuntu Linux on one of yoto you.</li>
</ol>
<p class="alert">For more Linux books that I recommend, browse <a rel="nofollow" href="http://astore.amazon.com/thgest-20">The Geek Stuff bookstore at Amazon.</a></p>
<p>There are several hundreds of books on Linux. <strong>What is your favorite Linux book that is not on this list?</strong><br />
<code> </code><br />
<em>If you like this article, please bookmark it on <strong>delicious and Stumble it</strong>.</em></p>
<center>
<div style="margin-left:2px; margin-top:10px; margin-bottom:10px; ">
<!-- AD BLOCK -->
</body>
By default . doesn’t match new lines. Try adding DOTALL (s) modifier like this /<p>(.*)<center>/s.

what does a "0" at the end of a raw http header mean (header("Location: http://www.sitename.com/0");)

The index.php file in the html document root of a web server contains:
<?php
header("Location: http://www.sitename.com/0");
exit();
?>
...
(see below for full listing but I think nothing gets done b/c the exit())
There is no file or directory in the document root named "0"
Can anyone tell me what it's doing / why it would be used?
When I enter http:/www.sitename.com/ in my browser address bar, the site loads and the address bar displays:
www.sitename.com/0
if I click on a button, a new page loads and the address bar displays something like:
www.sitename.com/0/index.php?toDo=sometext
and it I type in a file name that doesn't exist like this:
www.sitename.com/0/file_not_there.php
it doesn't complain, it just goes too the main page (and leaves www.sitename.com/0/file_not_there.php displaying in the address bar).
Any assistance you can give in helping me understand what's going on is appreciated.
full listing of public_html/index.php:
<?php
header("Location: http://www.sitename.com/0");
exit();
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Site Name</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>
<body>
<div align="center">
<p> </p>
<p><img src="/somedir/images/logo.png" /></p>
<p class="style1"><strong>Welcome</strong><br />
</p>
</div>
</body>
</html>

How to properly include a header file in a webpage

So I have a header file:
<html>
<head>
<link href="/design_header.css" rel="stylesheet" type="text/css" />
</head>
<body>
content
</body>
</html>
And I want to place this header in my file
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
The problem is now I have regular <html>, <head>, <body> tags inside the <body> tag of my webpage. In the html validator I receive errors like
Stray start tag html.
Stray end tag head.
An body start tag seen but an element of th
e same type was already open.
How to do it properly? Btw. I also place a footer to the bottom of the webpage the same way.
Your header file should only contain the HTML text you want for the header.
As it will be inserted into another webpage, it should not be a full HTML document.
Having only HTML for Header in Header
One option is to instead include in your header file only the HTML that is for the header (used by all pages that include it). However this has the downside that your not following the recommendation to have CSS loading before is rendered.
See: https://stackoverflow.com/a/1642259/1688441
Header File
<link href="/design_header.css" rel="stylesheet" type="text/css" />
content
Other files
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
Having only HTML for Header in HeaderFile and Separate HeadFile
You could have have a separate global_head_include.html (or txt, php, etc) file and put your CSS code there.
Header File (for include)
Header content
File with CSS includes (for include)
<link href="/design_header.css" rel="stylesheet" type="text/css" />
Whatever else is global...
Other files
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
<?php include 'global_head_include.php'; ?>
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
This is how I set out my headers and footers in my current PHP site:
header.php:
<!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">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>James Wright - Young Software Developer</title>
<link rel="stylesheet" href="style.css" />
<meta name="description" content="The online home of a young web designer and software developer." />
<link rel="icon" type="image/png" href="/img/ico.png" />
</head>
<body>
<div id="holder">
<div id="menu"></div>
<div id="mainContent">
footer.php:
</div>
<div id="mainReflect"></div>
<p class="footer">© James Wright <?php echo date("Y"); ?>. Minimum resolution: 1024x768 <a href="http://validator.w3.org/check?uri=referer" target="_blank"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" style="vertical-align: middle;"/></a>
<a href='http://www.powermapper.com/products/sortsite/'><img src='http://www.powermapper.com/images/badge-v1/sortsite-badge-small-5.png' width="80" height="15" alt='Broken link checker and accessibility checker top 5% - SortSite' style='vertical-align: middle;'/></a>
</p>
</div>
</body>
</html>
Then whenever I create a new page, all I need to do is this:
<?php include("header.php"); ?>
<p>Main body content!</p>
<?php include("footer.php"); ?>

Like Button Alignment woes

I'm currently re-designing the layout of my site and am trying to position my Facebook like button on the bottom of my page, next to my 'Tweet' button... However there seems to be a five pixel difference between the top and bottom of each button, knocking them out of alignment... I've tried setting the padding and the margin of the div to 0 but this hasn't worked either...
The page can be seen here: http://www.jameshenry.info/test/video.php?video=14
Any ideas on why the tops of each button are not aligned?
Try the following
<div class="bottombar">
<div style="float:left">
<iframe class="twitter-share-button ......
</div>
<div class="float:left">
<fb:like ........
</div>
<div style="clear:both;"></div>
</div>
Unfortunately there isn't much that can be done, the size seems to vary along with the padding and margin across every browser. You can set a container to a specific size and overflow to hidden but then it will cut parts of the button off in one browser but not another.
Not much help, I know, but I wouldn't waste too much time on it.
One approach I've taken is to create a nice share button and have them both appear in a tooltip on hover. At least then the ugliness is hidden until needed!
Hope that helps :)
try this
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>
Azari & III - James Henry
</title>
<link href="scripts/page.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class = 'rightbar'>
<div class = 'videobox'>
<iframe src="http://player.vimeo.com/video/28767067?title=0&byline=0&portrait=0&color=ffffff&amp" width="640" height="360" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe><BR><div class='video-title'>Azari & III</div><div class='video-subtitle'>Manic (Directors Cut)</div><BR><div class='back'>«back</div></div>
</div>
<div class ='bottombar'>
<div style="margin: 3px 3px 0px 3px; position: relative; float: left;">Tweet<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div>
<div style="margin: 3px 3px 0px 3px; position: relative; float: left;"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like show_faces="false" layout="box_count" width="75" padding="0" margin="0" font="lucida grande" !important ></fb:like></div>
<div>
</body>
</html>

Categories