How to make Custom 404 err page without .htaccess file [duplicate] - html

I want to show the 404 page when user enters unknown address like on the above image.
I can control the unknown address after index.php but don't know how to do this for the part before the index.php part.
I wrote this code to control what user enters after index.php
<?php
$pageName = 'places';
if (isset($_GET['page'])) {
$pageName = $_GET['page'];
}
$pageList = array(
'places',
'places_info',
'save'
);
if (!in_array($pageName, $pageList)) {
$pageName = '404';
}
?>

It looks like you have apache on your development machine.
The way to have custom error pages is
Create/Edit the file in C:\xampp\htdocs\blit\.htaccess
Insert a line ErrorDocument 404 /blit/404.shtml
Create the file C:\xampp\htdocs\blit\404.shtml
Put whatever html you want in it.
Repeat for other errors.
If you type in localhost/blit/xxy and xxy.php and xxy.html do not exist then the error page will be shown.

Related

Get current directory address as localhost

This is continuation of question asked here (Provide link to iframe via js) as a second part. Here I am opening my iframe link. The iframe link opens up a PDF. I am currently running the code in localhost server which is why the address is http://127.0.0.1:5500. But when I upload it to the main server, this will be changed. My question is, since the link of the PDF is stored in the same directory as the index.html page. How do I automatically generate http://127.0.0.1:5500 or any other address depending on the hosting server. Such that it could be www.myhostingserver.come/myID/PDFIni.pdf and I do not have to manually enter the hosting address, rather just give : hostingaddress+"/PDFIni.pdf"?
<script>
...
...
let myIframe = document.getElementById("iframe");
if(myIframe.src != "http://127.0.0.1:5500/PDFIni.pdf")
{
console.log(myIframe.src);
myIframe.src = "http://127.0.0.1:5500/PDFIni.pdf";
}
Try to use document.location.hostname. For example:
var str = 'https://' + document.location.hostname + '/PDFIni.pdf';
if(myIframe.src != str) {
console.log(myIframe.src);
myIframe.src = str;
}

Magento Front End 404 Error

I am a newbie to magento, I have installed and put a few products, but then later I was getting Error:404 page not found in the front end. Backend is all OK, I am able to access everything but all of a sudden I don't know how this happened. I tried all the solutions like Flush Cache, replacing .htaccess, is_active field in database etc but all proved futile. Then lately I have put in system->Configuration->Web Base_url as http://sportiva.no/index.php/ (Previously it was http://sportiva.no/) and all is completely changed all the styles went away and I am not able to save anything. Please help, I am ready to give backend credentails.
Please help
Go to System > Configuration > Web > Default Pages and check "CMS Home Page" field value. If it is "404 Not Found", then change it to any of the CMS page available on the drop-down and save the configuration.
Refere to this link by Alan Storm,
http://magento-quickies.alanstorm.com/post/6462298634/404-debugging
excerpt from it,
Put this code in function _validateControllerClassName
<?php
#File: app/code/core/Mage/Core/Controller/Varien/Router/Standard.php
/**
* Generating and validating class file name,
* class and if evrything ok do include if needed and return of class name
*
* #return mixed
*/
protected function _validateControllerClassName($realModule, $controller)
{
$controllerFileName = $this->getControllerFileName($realModule, $controller);
if (!$this->validateControllerFileName($controllerFileName)) {
var_dump($controllerFileName);
return false;
}
$controllerClassName = $this->getControllerClassName($realModule, $controller);
if (!$controllerClassName) {
var_dump($controllerClassName);
return false;
}
// include controller file if needed
if (!$this->_includeControllerClass($controllerFileName, $controllerClassName)) {
var_dump($controllerFileName . '----' . $controllerClassName);
return false;
}
return $controllerClassName;
}

How can I use html5 cache manifest with CakePHP?

I want to use the html5 cache manifest technology with CakePHP,
but I don't know where to place the cache manifest in CakePHP,
I've searched for a solution, but I do not found anything.
Can you help me?
The best and easiest way to access one manifest file in all views is to look at your layouts, for example
View/Layouts/default.ctp
and replace <html> with
<?php echo "<html manifest='".$this->webroot."manifest.php'>"; ?>
in which manifest.php is located in
app/webroot/manifest.php
and looks something like this:
<?php
header('Content-Type: text/cache-manifest');
echo "CACHE MANIFEST\n";
echo "\n\nNETWORK:\n";
echo "*\n";
echo "\n\nCACHE:\n";
echo "# Version: 1\n";
?>
So the manifest.php is only needed once and can be used for all views.
HINT:
For a dynamic manifest-file you can use a code snippet from here:
http://nial.me/2010/01/using-the-html5-cache-manifest-with-dynamic-files/
I tried this solution, putting the manifest in default.ctp, but it causes some problems, all my pages was cached... i think it's discribed in the spec "...the page that referenced the manifest is automatically cached even if it isn't explicitly mentioned".
...couse this all my pages was being cached, manifest is checked in each page. And when another user logs in they see the last user homepage and other pages.
The final solution: create a redirect/loading page
1 - create the redirect page:
I had create the Pages/redirect.ctp file and the function redirect(){} in the Pages controller. A simple page, just with a hello message and a loading bar based on the applicationCache progress event:
var appCache = window.applicationCache;
appCache.addEventListener('progress', function(event) {
console.log(event.loaded + " of " + event.total + " files...");
//make some changes in the page' loading bar
}, false);
2 - Load manifest only in the redirect page:
In the View/Layouts/default.ctp I filtered the tag to show the manifest only in the redirect page:
<? if($this->request->params['controller']=='pages' &&
$this->request->params['action']=='redirect'): ?><html
manifest="<?=$this->webroot?>manifest.php">
<? else: ?>
<html >
<?
endif; ?>
3 - Use the redirect page in the auth component to lead my user
to redirect page after login:
In the appController a setted auth component like this
public $components = array (
'Session',
'Auth' => array (
'authError' => "user or password invalid",
'unauthorizedRedirect' => "/pages/redirect?err=login",
'loginRedirect' => "/pages/redirect",
'logoutRedirect' => "/",
'loginAction' => "/user/login",
'authorize' => array ('Controller')
)
);
now only the elements putted in the manifest will be cached. The redirect page is cached (according the spec) but the applicationCache event updates the page torning this "dinamic".
If you mean the manifest file it should go into /app/webroot, the directory that your vhost should also use for the site. besides this there is nothing really related to CakePHP with this.
Have a look at this: http://www.html5rocks.com/en/tutorials/appcache/beginner/

Unknown path components using PHP to post

I adapted the Social Cafe PHP to post news as read everytime a user access to an article.
Everytime I access the page, it presents this error:
Unknown path components: /mv-news:read
The code is this:
try {
$urlartigo = get_permalink();
$story_id = $facebook->api('/me/mv-news:read?article='.$urlartigo.'','POST');
} catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
}
mv-news is a correct namespace.
EDIT: I've just tried to use news.reads?article= and still get the same error. This is driving me crazy, as I've searched throughout the whole internet and haven't found a solution.
EDIT2: I've just changed the $story_id line of code to:
$story_id = $facebook->api('/me/mv-news:news.reads','post', array('article' => $urlartigo));
But it still outputs the same error.
enter code here

denied due to lack of policy file permissions

I can't get my Yahoo! Application Platform to run I keep getting denied access even though their policy file accepts requests from any domain.
OK: Policy file accepted: http://social.yahooapis.com/crossdomain.xml
Error: Request for resource at http://social.yahooapis.com/v1/user/<user id>/profile?oauth_signature_method=HMAC-SHA1&lang=en-US&oauth_consumer_key=<key>&oauth_token=<long ass token>&oauth_version=1.0&format=json&oauth_nonce=<blah blah>&oauth_timestamp=1262846353&region=US&oauth_signature=<foo bar> by requestor from http://<my domain>/YOSSimple.swf is denied due to lack of policy file permissions.
The url works btw, I editted some stuff out since it has my keys and stuff.
Links to the stuff I'm trying to do
http://developer.yahoo.com/flash/yos/
http://developer.yahoo.com/flash/yos/examples/simple/YOSSimple.fla
YOSSimple properly creates the url actually since if I type it in my browser I'm prompted if I want to download the file that contains information regarding my profile.
But it just wont open it in Flash.
I'm guessing that it's not loading the policy file automatically. You should try using
Security.loadPolicyFile("http://social.yahooapis.com/crossdomain.xml");
Do you have a webproxy installed with which you can monitor what files exactly are loaded? My favorite is Charles but there are also free FF plugins like Httpfox
EDIT:
I think I know what's going wrong. It's going wrong the other way around, the swf from yahoo is trying to access your swf, but doesn't have the correct permissions. Would you try
Security.allowDomain( 'http://social.yahooapis.com/' );
http://www.ieinspector.com/httpanalyzer/
use HTTP analyzer to see whats happening?
also check your not missmatching http://www. with http:// because flash treats them as different domains
also are you running the code locally on your machine. It could be your local security settings
A simple WebProxy will fix this:
<?php
// PHP Proxy
// Loads a XML from any location. Used with Flash/Flex apps to bypass security restrictions
// usage: proxy.php?url=http://mysite.com/myxml.xml
$session = curl_init($_GET['url']); // Open the Curl session
curl_setopt($session, CURLOPT_HEADER, false); // Don't return HTTP headers
curl_setopt($session, CURLOPT_RETURNTRANSFER, true); // Do return the contents of the call
$xml = curl_exec($session); // Make the call
header("Content-Type: text/xml"); // Set the content type appropriately
echo $xml; // Spit out the xml
curl_close($session); // And close the session
?>
Modify the web proxy example above to support multiple options as follows:
$sOptions = "";
foreach($_GET as $sIndex => $sValue) {
if ($sIndex == 'url') {
$url = $sValue;
}
else {
if (strlen($sIndex) > 0) {
$sOptions .= "&" . $sIndex;
}
if (strlen($sValue) > 0) {
$sOptions .= "=" . $sValue;
}
}
}
$url .= $sOptions;
$session = curl_init($url); // Open the Curl session