Skip to content
Jun 29 16

Laravel 5.2 Post: TokenMismatchException in VerifyCsrfToken.php line 67:

by php friend

// Route::post($uri, $callback);
Route::post('/eyeglasses', function () {
echo 'post';
});

When running the code under postman, the errors are:

Whoops, looks like something went wrong.

1/1
TokenMismatchException in VerifyCsrfToken.php line 67:
in VerifyCsrfToken.php line 67
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54

Laravel set CSRF on as default, how to disable CSRF then?
Open app\Http\Kernel.php, and search ‘App\Http\Middleware\VerifyCsrfToken’, and remark it or delete this link.

Jun 26 16

How to Install Symfony 2.8 under Ubuntu 16.04?

by php friend

$ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$ sudo chmod a+x /usr/local/bin/symfony

This will create a global symfony command in your system.

$ symfony new my_project_name // $ symfony new blog

use the most recent version in any Symfony branch
$ symfony new my_project_name 2.8
$ symfony new my_project_name 3.1

use a specific Symfony version
$ symfony new my_project_name 2.8.1
$ symfony new my_project_name 3.0.2


The installer also supports a special version called lts which installs the most recent Symfony LTS version available:

$ symfony new my_project_name lts

——–

Symfony 2.8.7 was successfully installed but your system doesn’t meet its
technical requirements! Fix the following issues before executing
your Symfony application:

* simplexml_import_dom() must be available
> Install and enable the SimpleXML extension.

After fixing these issues, re-check Symfony requirements executing this command:

php blog/app/check.php

Then, you can:

* Change your current directory to /home/ubunto/blog

* Configure your application in app/config/parameters.yml file.

* Run your application:
1. Execute the php app/console server:run command.
2. Browse to the http://localhost:8000 URL.

Solveing this issue:

sudo apt-get install php-xml

“sudo apt-get install php-xml” worked for my PHP 7 on Ubuntu 16.04 LTS.

or try:

sudo apt-get install php7.0-xml

This reinstalled/re-enabled SimpleXML and everything is working as intended.


[OK]
Your system is ready to run Symfony projects

Optional recommendations to improve your setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* intl extension should be available
> Install and enable the intl extension (used for validators).

Note The command console could use a different php.ini file
~~~~ than the one used with your web server. To be on the
safe side, please check the requirements from your web
server using the web/config.php script.

Solving:
sudo apt-get install php7.0-intl
=============

Running the Symfony Application

$ cd my_project_name/ // cd blog/
$ php app/console server:run

// Quit the server with CONTROL-C.

Then, open your browser and access the http://localhost:8000/ URL to see the Welcome Page of Symfony

Jun 24 16

How to Install Symfony 3 under Window 10?

by php friend

Use composter to install symphony:
Install Composer: download composer at https://getcomposer.org/ and setup it.

First install wamp at your computer, say you have installed wamp at D:/wamp, and have run it.

Create a fold, named symfony, and install symfony under it, run windows command cmd, and run:
composer create-project symfony/framework-standard-edition my_project_name

After you have successfully installed symfony, and run:

cd my_project_name/
php bin/console server:run

Then, open your browser and access the http://localhost:8000/ URL to see the Welcome Page of Symfony!

http://symfony.com/doc/current/book/installation.html

Jan 22 16

HostGator Page Not Found for Zen-Cart

by php friend

We all know that HostGator has set custom 404 error page for all hosted websites, the visitor leaves your website and reaches to HostGator website. It is really very bad for your site, and SEO. Can we keep the visitor on our site even after 404 error comes?

The answer is Yes! How to create our own 404 error page, and disable Hostgator 404 error ads then?

First, create our own custom 404 page, say the file name is nofound.html, we can use dreamweaver or other txt editors to modify this html file, and put it under the root of your site.

Second, add the following line at your .htaccess file:
ErrorDocument 404 /notfound.html

Done!

How about Zen-Cart shop? We all know that Zen-Cart has already add a 404 error page for us: page_not_found.php, the file is just under the root of the shop. We can add either the line to .htaccess file:
ErrorDocument 404 /page_not_found.php
or
ErrorDocument 404 /index.php?main_page=page_not_found
Both method will work!

Nov 5 15

How to let X-cart redirect to product page directly?

by php friend

At www.loupesusa.com ,  several categories only have one product. The default category will only display one product, that make the category looks very ugly, I think if a category only has one product, we can hide the category, when a visitor click the category, the category url will redirect the detailed product page directly. How to then?

Try to insert this to the /light_responsive/customer/home.tpl right after the opening <body> tag.

{if $main eq 'catalog' and $cat_products|@count eq 1}
  <script type="text/javascript">
    window.location.href = "{$cat_products[0].page_url}";
  </script>
{/if}
Nov 2 15

How to display 3 latest articles at homepage of x-cart v4.7.4?

by php friend

First step, edit postauth.php which is under root folder. Find

$pages_menu = func_query(“SELECT * FROM ” . $sql_tbl[‘pages’] . ” WHERE language='” . $store_language . “‘ AND active=’Y’ AND level=’E’ AND show_in_menu=’Y’ ORDER BY orderby, title”);
$smarty->assign(‘pages_menu’, $pages_menu);
Add the following codes below them:
//dental loupes faq begin
$pulled_articles= func_query(“SELECT * FROM ” . $sql_tbl[‘pages’] . ” WHERE language='” . $store_language . “‘ AND active=’Y’ AND level=’E’ ORDER BY orderby DESC LIMIT 3”);
$loupe_articles = array();
foreach ($pulled_articles as $article){
    $pages_dir = $xcart_dir . $smarty_skin_dir . ‘/pages/’ . $article[‘language’] . “/”;
    $filename = $pages_dir.$article[‘filename’];
    $page_content = func_file_get($filename, true);
    $article[‘page_content’] = $page_content;
    $loupe_articles[] = $article;
}
$smarty->assign(‘loupe_articles’, $loupe_articles);
//dental loupes faq end
Second step, go to skin/light_responsive/customer/main/, and edit welcome.tpl, find:
    {include file=”customer/main/featured.tpl”}
Under it add the following codes:
    <div>
<div>
<h2>{$lng.lbl_articles}</h2>
</div>
{foreach from=$loupe_articles item=p name=loupe_articles}
<div>
<h3><a href=”pages.php?pageid={$p.pageid}”>{$p.title|amp}</a></h3>
<div>
{$p.page_content|truncate:250|strip_tags:false}
</div>
</div>
{/foreach}
</div>
Last step, login admin panel,  go to content–>language, and find Add new entry:
Add new entry
Select topic: Labels
Variable: lbl_articles
Value: Dental Loupes FAQs
Done!
Apr 7 15

Add Different Resource for EmpireCMS

by php friend

Sometimes it is very difficut for us to publish an article if all the articles have 2 or more different articles resources from other sites. In this cases, we can not copy directly. We can use PHP code: read more…

Nov 16 14

How to generate all strings with 3 lowercases

by php friend

In order to let you understand my php code easily on how to generate all strings with 3 lowercases, I will share the code with you on how to generate all 26 single letter from a to z; next generate all strings with 2 lowercases, ie, aa, aj, gz; finally i will tell you the code to generate all stings with 3 lowercases: read more…

Jun 3 14

PHP code for wordpress breadcrumb navigation

by php friend

We all know that breadcrumb navigation is very important for seo, how to add this for our wordpress blogs then?

First, add the following code at the end of functions.php: read more…

Jan 18 14

Urgent help!!! Error after upgrading to vB4.2.2: “Warning: date() [function.date]: It is not safe…”

by php friend

after updating my installation from vbulletin version 4.2.1 to version 4.2.2 I can not access the forum. I can not access the control panel. When I try to access any page of the forum or admin panel, I find the following errors:

Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for 'BST/1.0/DST' instead in ..../includes/functions.php on line 4912 read more…