<?php
$url = "http://subdomain.domain.com/sample/url";
$host = parse_url($url, PHP_URL_HOST);
$host = array_reverse(explode('.', $host));
$host = $host[1].'.'.$host[0];
echo "$host";
?>
You should know your purpose in life, make a difference, and believe in yourself. Always think positive, take the risk and move forward. Do that, then before you know it, you're already the man you always wanted. Cheers!!
<?php
$url = "http://subdomain.domain.com/sample/url";
$host = parse_url($url, PHP_URL_HOST);
$host = array_reverse(explode('.', $host));
$host = $host[1].'.'.$host[0];
echo "$host";
?>
<?php
$cachefile = "cache/yourpage.html";
$cachetime = 30 * 60; // 30 minutes
// validate and check for existing cache file
if (file_exists($cachefile) && (time() - $cachetime < filemtime($cachefile))) {
include($cachefile);
exit;
}
// start the output stream
ob_start();
?>
<html>your page here to put into cache</html>
<?php
// save the contents to cache file
$fp = fopen($cachefile, 'w');
fwrite($fp, ob_get_contents());
fclose($fp);
// end the output stream
ob_end_flush();
?>
<VirtualHost>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ^([a-z0-9][-a-z0-9]+)\.domain\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1 -d
RewriteRule ^(.*) %1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]
<html>
<head>
<title>Progress Bar</title>
<style type="text/css">
#progressWrap
{
margin: 0px 0px 0px 5px;
background: #FFF;
height: 11px;
width: 200px;
}
#progressWrap #progressBar
{
height: 11px;
position:absolute;
background-color: #000;
}
#progressWrap #progressNum {
text-align:center;
width:100%;
color:#515151;
font-size:9px;
font-weight:bold;
}
</style>
</head>
<body>
<div id="progressWrap">
<div id="progressBar" style="width:50px"></div>
<div id="progressNum">25%</div>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function() {
var percent = 25;
var width = percent * parseInt($('#progressWrap').css('width')) / 100;
$('#progressNum').html(percent+'%');
$('#progressBar').css('width', width+'px');
});
</script>
<html>
<head>
<title>Progress Bar</title>
<style type="text/css">
#progressWrap
{
margin: 0px 0px 0px 5px;
background: #FFF;
height: 11px;
width: 300px;
}
#progressWrap #progressBar
{
height: 11px;
position:absolute;
background-color: #000;
}
#progressWrap #progressNum {
text-align:center;
width:100%;
color:#515151;
font-size:9px;
font-weight:bold;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="progressWrap">
<div id="progressBar"></div>
<div id="progressNum"></div>
</div>
</body>
</html>
<script type="text/javascript">
$(document).ready(function() {
var percent = 25;
var width = percent * parseInt($('#progressWrap').css('width')) / 100;
$('#progressNum').html(percent+'%');
$('#progressBar').css('width', width+'px');
});
</script>
<html>
<head>
<title>File Upload</title>
<style type="text/css">
div.inputContainer {
position: relative;
}
div.inputStyled {
position: absolute;
top: 0px;
left: 0px;
z-index: 1;
}
input.inputHide {
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 2;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#docufile').change(function() {
var vals = $(this).val();
val = vals.length ? vals.split('\\').pop() : '';
$('#document').val(val);
});
$('#btnSubmit').click(function() {
$('#frmAdd').submit();
});
});
</script>
</head>
<body>
<form id="frmAdd" name="frmAdd" action="upload.php" method="post" enctype="multipart/form-data" encoding="multipart/form-data">
<div class="inputContainer">
<div class="inputStyled">
<input name="document" id="document" type="text">
<input name="button" type="button">
</div>
<input type="file" class="inputHide" name="docufile" id="docufile"/>
</div>
<input type="submit" value="submit" id="btnSubmit"/>
</form>
</body>
</html>
<?php
$docufile = '';
if (@$_FILES['docufile']['tmp_name']) {
$docufile = upload_file($_FILES['docufile']);
}
echo $docufile;
function upload_file($docu=null) {
$upload_dir = "files/";
$docu_file='';
if (!$docu['error'] == 0) return '';
if (!@is_uploaded_file($docu['tmp_name'])) return '';
$filename = preg_replace("/\s+/", "", $docu['name']);
if (!file_exists($upload_dir.$filename)) {
$docu_file = $filename;
} else {
$rand = 1;
while(file_exists($upload_dir.$rand."-".$filename)) {
$rand ++;
}
$docu_file = $rand."-".$filename;
}
$upload_file = $upload_dir.$docu_file;
if (!@move_uploaded_file($docu['tmp_name'], $upload_file)) {
return '';
}
return $docu_file;
}
?>
Quote for the day:
If you want to reach your potential, you need to add a strong work ethic to your talent. If you want something out of your day, you must put something in it. Your talent is what God put in before you were born. Your skills are what you put in yesterday. Commitment is what you just put in today in order to make today your masterpiece and make tomorrow a success. - john m.