Products

Affiliate Manager

Posted on
Affiliate Manager

In today’s business and ecommerce world, you need a powerful tool to increase your e-commerce value. Affiliate Nation is a professional PHP affiliate software which has features to build a professional network of webmasters selling your products, goodd, membership subscription, or services.

Blog/Reviews

Restricted; A package that restricts usage of protected username

Posted on
Restricted; A package that restricts usage of protected username

Most of the time people want a username which is personal, and means something to them.

As developer, an admin or manager of any website, you would agree that sometimes, it’s important to be able to reserve certain names that you consider official. A good use case here is Twitter. No account names can contain Twitter or Admin unless they are official Twitter accounts.

Imagine you’re building an application that requires a dedicated URL like myapp.com/tailor, but then, a user signups with a username ‘tailor’. This would result in conflict as the system could malfunction trying to determine which URL request to respond to. It becomes even more complicated when a user signs up on your application using words such as; Admin, User, Reset, etc as their usernames while creating a profile on your application.

Why don’t we secure these important words by preventing it users from being able to use them in the first place? In response to this, we created a package – Laravel Restricted which tells the application to index all the application’s route segments and restrict users from choosing them as a username.

How to setup

Install via composer
composer require codulab/restricted

Add the following service provider to the array in: config/app.php

Codulab\Restricted\RestrictedServiceProvider::class,

Publish the config

php artisan vendor:publish --tag=restricted_config

Now, you can simply add ‘restricted’ to your validations in the controller like so:

$this->validate($request, [
'name' => 'required|string|min:5',
'username' => 'required|restricted' // You’re restricting the username field.
]);

You can also add a new validation message:

To view all the words you have ‘Restricted’, navigate to ‘public/restricted-usernames.txt’ file.

You should see this:

Now when you try to use one of the ‘Restricted’ usernames, you should see something similar to this:

    As far as your application requires a registration process, this package is a simple security measure to protect your website.

If you like Laravel Restricted, please STAR it, SHARE it with your friends, USE it and CONTRIBUTE to it.

Blog

Setting up Laravel 5.1 on a Shared Hosting Server

Posted on
Setting up Laravel 5.1 on a Shared Hosting Server

In the course of building products. You will encounter a situation where some of your users are hosting your product on a shared server. So here is how to do it if you encounter such problem.

First, let say in your shared hosting, you have current www or public_html directory, which is accessible publicly via web domain

Let say your laravel project is named laravel50 with the following folder structure:

After you have copied all the files to your www or public_html folder of your shared hosting. Create a folder and name it protected. You can call it any other name that you like. Then move all the files and folders to this new folder you created except the public folder. So you new folder structure would be

|--public_html
|--protected |--app
|--bootstrap
|--config
|--database
|--resources
|--storage
|--tests
|--vendor
|--.env
|--.env.example
|--.gitattributes
|--.gitignore
|--artisan
|--composer.json
|--composer.lock
|--gulpfile.js
|--package.jso
|--phpspec.yml
|--phpunit.xml
|--readme.md
|--server.php
|--public

Then after that, move all the content in the public folder into the main www or public_html folder. Your final folder structure would then be like this

|--public_html
|--protected bind('path.public', function() {
return __DIR__;
});

$kernel = $app->make('Illuminate\Contracts\Http\Kernel');

$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);
?>

After that open server.php in the protected folder and line 21 to something like this

*/

$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'../'.$uri))
{
return false;
}

require_once __DIR__.'../index.php';

And that’s it.

I would also recommend using the same folder structure during your development so that you can experience the whole process of deployment before you upload to your hosting server.

Hope this helps!

Blog

Dynamically output Javascript/CSS with a Laravel Route and Controller

Posted on
Dynamically output Javascript/CSS with a Laravel Route and Controller

I was working on an application and I needed to output a dynamic javascript file for inclusion from external websites with the [script src=””] tag. Also I needed to pass some variables to the view which is using the Blade engine.

For a quick solution to serving up a Javascript or CSS file using Laravel routes, i.e. http://www.example.com/js-file, take a look at the following snippet.

public function serve_js()
{
$contents = View::make('javascript.client-js', [ 'data' => $data //If you are passing extra data ]);
$response = Response::make($contents, 200);
$response->header('Content-Type', 'application/javascript');
return $response;
}

A file exists in app/views/javascript/ folder named client-js.blade.php. This file only contains the javascript needed to be served. E.g

$(function(){
$('#geoamplify-popup').dialogBox({
width: 500,
height: 300,
autoSize: true,
autoHide: false,
time: 3000,
effect: 'fall',
type: 'correct',
title: '',
hasClose: true,
content: '{{ $content }}' });
})

This code can be adapted to serve CSS as well, just change Content-Type to be text/css.