LinkFly Documentation | Version 1.0 |

LinkFly v.1.0

Documentation

##

##

##

##

##

## Table of Contents

Table of Contents

Introduction

Requirements

Support

Installing the Script

Uploading Files

Setting up the Database

Changing the Base URL

Accessing the Admin Account

Using the Administration Panel

Accessing the Admin Panel

Important Settings

Changing the Admin Password

Changing the Site Name/Logo/Timezone

Setting up a Payment Processor/Currency

Processing Withdrawal Requests

Making a Member an Admin

Using the Site

Shortening Links

Setting up Alternative Domains

Using the Publisher Dashboard

Using the Advertiser Dashboard

Basic Campaign Info

Rates & Percentages

Rates Pricing Reference

Modifying the Script

Script Structure

Custom Localization

Translation Files

Translating Pages

Creating your own Theme using Smarty

##

##

## Introduction

Thank you for purchasing this Scriptastic PHP template. This template allows you to build, run, maintain, and customize your own monetized link shortener, similar to sites like AdFly or Shorte.st.

This documentation is intended to be a guide for installing, customizing, maintaining, and supporting your own LinkFly installation. It will cover installation, using the administration panel, customizing aspects (such as developing your own theme), and more.

Please note that we do provide basic support for this script and your custom installation as long as it directly relates to your legally purchased copy of LinkFly and concerns bugs and/or other issues. We do not provide support for 3rd-party themes, plugins, or your own script customizations.

Our code is fully documented and accessible. We do not provide free template customizations.

## Requirements

- PHP 5.6+ with crypt_blowfish and GD Library with freetype support enabled
- MySQL version 4.0+ Database
- 10+ MB Free Space
- FTP Access
- Write/Read Access (CHMOD777/755)
- Apache Server with mod_rewrite enabled

## Support

Scriptastic PHP Support: http://scriptastic.co/support

Scriptastic PHP E-Mail Support: support@scriptastic.co

End User License Agreement: http://scriptastic.co/linkfly/eula

Please do not post technical questions regarding the script on the CodeCanyon comments page, since those will most likely get removed. To get in direct contact with a developer, please use our Support System or our Support E-Mail referenced above. You will be asked to provide your CodeCanyon or Scriptastic purchase code if you request support - more info on how to obtain your purchase code can be found on our support page.

Support is only provided to legally obtained copies of this script. If you have illegally obtained this script from an unknown source, a filesharing site, or sites that re-sell this script besides Scriptastic or an Envato marketplace, we will not provide support and reserve the right to blacklist you from purchasing our products.

## Installing the Script

The next few steps will guide you through the installation process of LinkFly. Please note that the software used in this documentation to install the script may vary from your setup.

### Uploading Files

1. Connect to your FTP server
2. Upload the contents of the ‘Upload’ folder onto your FTP server
3. Ensure that .htaccess file is properly uploaded
4. To test that everything is working and you can access the uploaded files, visit http://yourdomain.com/index.php - even if you’re greeted with errors, the script is correctly uploaded!

### Setting up the Database

1. Create a new database for your LinkFly installation in your hosting solution (e.g. cPanel) or manually (if installed on a VPS or dedicated server). Preferably, name it ‘linkfly’ or similar.
2. In the ‘Installation’ folder, make sure that ‘LinkFly_vXX.sql’ exists, where ‘XX’ is the current LinkFly version (will look like ‘LinkFly_v1.0.sql’ or similar).
3. In your MySQL administration panel (most likely phpMyAdmin), import the SQL file mentioned in Step #2. You can do this by directly selecting the file from the ‘Browse file…’ dialog under the ‘Import’ tab in phpMyAdmin and pressing ‘Go’, or you can manually copy-paste the SQL code from the file and paste it into the ‘SQL’ tab in phpMyAdmin or the mysql command line.
4. The following tables should now be installed (as of v.1.0):

1. As of the final release of v1.0, table 'plugins' is deprecated and is not necessary for the script to function properly

5. Your MySQL database is now ready. Next, you will need to connect your LinkFly installation to the database.
6. Make sure you have access to the following information related to your database:

1. Database Host (most likely localhost)
2. Database Username
3. Database Password
4. Database Name

7. In your uploaded LinkFly files, find the file ‘db.configs.php’ located in the ‘includes/configs’ directory and ensure you can edit it.
8. Starting at Line 16, replace ‘root’ & etc with your correct database info acquired in Step #6 and save the file on your server.
9. Visit your site again. You should not receive a ‘Connection to database failed’ error.

### Changing the Base URL

1. The next step is critical for your LinkFly installation to function properly.
2. Access your database using your preferred MySQL administration tool and find the ‘settings_values’ table.
3. In the ‘settings_values’ table, find the setting named ‘Base URL’ with the slug ‘base_url’.
4. Change the ‘settings_value’ column to your base URL and ensure it is saved properly.

1. Your base URL is the full path in which the index.php is located. For example, if you have installed LinkFly in the root directory of www.yourdomain.com, the base URL would be http://yourdomain.com/
2. Make sure that the base URL ends with a forward slash (/)!

5. You should no longer see errors when visiting your site, and LinkFly is now correctly installed!

### Accessing the Admin Account

1. You can log into the default admin account using the following credentials:

1. Username: admin
2. Password: password

1. It is recommended you change this password after logging in for the first time!

2. The default login page can be accessed at http://yourdomain.com/login

## Using the Administration Panel

## Accessing the Admin Panel

1. The admin panel can be accessed only by users that are admins. The link to the admin panel is http://yourdomain.com/admin and can also be found in the top right corner of the ‘default’ LinkFly template for users that are admins.
2. The admin panel allows you to change settings related to your LinkFly installation, and view/edit/delete members, links, campaigns, withdrawals, and more.

### Important Settings

#### Changing the Admin Password

1. It is recommended you change the admin password from ‘password’ to something a lot more secure. You can do this by visiting http://yourdomain.com/my_account while logged into the main admin account (username: admin).

#### Changing the Site Name/Logo/Timezone

1. One of the first things you might want to do is to change the name of the site to a name of your liking. The site name appears often in the default template, and it is recommended that the name be short, e.g. similar to adf.ly.
2. You can change the Site Name on the ‘General’ page in the admin panel. Make sure that you hit ‘Save’ on the bottom of the page after making changes.
3. There are different ways to change the site logo and alternative logo:

1. If you’re using the default template, you can simply replace the logo.png located in templates/default/img/logo.png with your custom image.
2. You can also manually upload your image to the server or to a 3rd party host and then link to the image in the ‘Logo URL’ field in the ‘General’ settings page.

4. On the same page, ensure to change the timezone to the timezone where the server is located in. Refer to the following site for timezone codes: http://php.net/manual/en/timezones.php

#### Setting up a Payment Processor/Currency

1. Currently, the only supported payment processor for LinkFly is PayPal.
2. To setup PayPal, ensure that you have a PayPal account.
3. In the admin panel, go to ‘General’, then the ‘Payment’ tab.
4. Ensure that ‘Use PayPal’ is checked.
5. Next, enter your PayPal E-Mail in the ‘PayPal E-Mail’ field towards the bottom of the page. Make sure to hit ‘Save’ after making changes.
6. This is also the part where you might want to select a currency for your site. The default is US Dollar, but if you are located somewhere else, you can change that. Please note if you change this setting in the future, any monetary values in the database will not be converted. Only the label (e.g. ‘$’ and ‘USD’) will be changed accordingly.
7. You can also change the appearance of monetary value on the site. See the ‘Currency Code Position’, ‘Currency Symbol Position’, and ‘Currency Symbol’ options for that.

#### Processing Withdrawal Requests

1. Processing withdrawals is a major aspect of a monetized link shortener. Please note that this script does not automatically process withdrawals. However, it makes it as easy as possible to manually process withdrawals.

1. It is always a good idea to double-check withdrawals and check the validity of withdrawal requests before actually visiting PayPal.
2. If your PayPal account has MassPay enabled, you can export MassPay files by going to ‘Withdrawals’, then ‘MassPay’.

2. Whenever a user requests a valid withdrawal, it will show up in the administration panel. Visit the administration panel and navigate to the ‘Withdrawals’ tab.
3. On the withdrawals page, you will see the most recently requested withdrawals. The table presents all the information necessary to check the validity of withdrawals and change the withdrawal status.
4. Once you have checked the withdrawal request, you can then manually send the funds to the given PayPal e-mail through PayPal (e.g. the ‘Send Money’ option on Paypal.com).
5. Lastly, ensure to mark the withdrawal as ‘Processed’ or as needed. This will let the withdrawal user know that the withdrawal is processed and that the funds have been delivered. If anything is incorrect, this will also allow the user to double check their request and try again.

1. Changing the status of a request will also notify the user through e-mail. You can edit the withdrawal e-mail templates located in ‘templates/admin_default/email’.

#### Making a Member an Admin

1. Admins are useful for maintaining the site, providing support, checking for spam, and processing withdrawals.
2. To make a normal member an admin, navigate to the admin panel and click on ‘Members’.
3. In the table, search for the member you want to make an admin (most likely by username).
4. Click the ‘Edit’ button on the right side in the member row.
5. For the field ‘Administrator?’, select ‘Yes’.
6. Make sure to assign Administrator permissions to the member. Assuming you have not renamed any permissions, select ‘Administrator’ for the ‘Permissions’ dropdown.
7. Hit ‘Update Member’ to apply these changes.

## Using the Site

### Shortening Links

The key aspect of any link shortener is to shorten links. LinkFly uses AJAX and jQuery as well as a small API backend to provide a fast and error-free link shortening experience. Links can be shortened on the home page or under the publisher dashboard. The template for the link shortening component is called ‘shorten_widget.tpl’ and contains the HTML and jQuery frontend. The backend for the link shortener is called api.php and is protected from unwanted API access.

To prevent users from spamming links, it is a good idea to turn on the 'Anonymous links require CAPTCHA verification’ option in the admin panel located under ‘Links’ and then ‘Settings’. This requires non-registered users to fill out a security code before being able to shorten links.

It is also a good idea to have a link posting ‘cooldown’ period. By default, it is 10 seconds for non-registered users, 5 seconds for registered members, and 0 seconds for any admins. To change this amount, visit ‘Members’ and then ‘Permissions’. Pick the permission you’d like to change and hit the ‘Edit’ button in its row. A new page should open. For the ‘Spam Waiting Time’ enter the time period in seconds the user has to wait between shortening links. If you do not want a cooldown period, simply type in ‘0’. Make sure to save these changes by hitting ‘Update Permission’.

The link shortener allows for advanced settings as well. As of 1.0, these settings include ‘Custom Alias’, ‘Ad Type’, and ‘Domain’.

‘Custom Alias’ allows users to give their shortened links a custom name, e.g. alias instead of having a random string of letters and numbers for their shortened URL. You can turn off ‘Custom Alias’ for certain permissions in the admin panel under the ‘Members’ and then ‘Permissions Edit’ page (for example, only registered members can use a custom alias - this could be an incentive to get users to sign up for your site). You can change the minimum allowed length and the maximum allowed length of the custom alias under ‘Links’, then ‘Settings’. The length of the automatically generated suffix can be changed on the same settings page as well.

‘Ad Type’ changes the type of ad that will be displayed once a user clicks on the shortened link. Users can choose between Interstitial, Banner, or No Ads. Interstitial Ads are full page advertisement, banner ads are smaller, and no ads simply redirects to the intended link. This can be turned off in the permissions for certain groups as well.

Users also have the option of selecting different domains if the default domain of the site isn’t fitting or they simply want something different. This can be turned off in the permissions for certain groups as well. See below on how to add alternative domains to LinkFly. Please note that if you do not have any alternative domains, the ‘Domain’ drop down will not appear in the shortener.

#### Setting up Alternative Domains

Setting up shortened domains is not difficult. You do not require a hosting plan with the alternative domain.

1. In your domain provider's administration panel, setup a redirect to your main domain (where LinkFly is hosted on). For example, if your main domain is http://linksho.rt, and your alternative domain is http://short.url, make sure that http://short.url redirects to http://linksho.rt.

1. You also have to ensure it is a WILDCARD REDIRECT (see screenshot below). Otherwise, the suffix will not be redirected to your main domain.

1. Most domain providers have this function visible and available.

2. In the admin panel under ‘Links’, ‘Domains’, click on ‘Add Domain’ and enter the new alternative domain. Ensure it ends with a forward slash (/)!

This is what it would look like on JustHost.com:

### Using the Publisher Dashboard

The publisher dashboard allows publishers to create, manage, and view their shortened links and see how well they are doing.

The dashboard allows members to directly shorten links without visiting the home page. It also presents account information like username, account balance, and e-mail.

1. Total Earnings: Shows the total profit from all links
2. Total Views: Shows the total amount of views that each link received combined
3. Links: Shows the amount of links this member has shortened
4. Average CPM: Shows the average CPM (Cost Per Mille) that the member would earn per thousand views
5. Average View: Shows the cost an average view
6. Monthly Views: Shows the line bar graph (#10)
7. Top Countries: Top Ten list of the top ten countries where viewers are from
8. Top Referrals: Top Ten list of the top ten referral sites
9. Date Filter: Allows the member to filter the graph to a certain month and year
10. Line Graph: Shows a line graph based on the month and year selected in #9 with the total amount of views each day

1. Showing entries: Allows the member to change the amount of entries on the table
2. Search: Allows the member to search for specific links
3. Short URL: Shows the shortened URL in the table
4. Full URL: Shows the full URL in the table
5. Ad Type: Shows the type of ad (either interstitial, banner, or no ad) in the table
6. Views: Shows the total amount of views the link has received in the table
7. Profit: Shows the total amount of money the link has generated for the user
8. Statistics: Redirects to the statistics page
9. Delete: Allows the user to delete the link. Funds will not be lost.

Clicking on Statistics will present the same information as the ‘Statistics’ panel in the Dashboard, but for an individual link.

### Using the Advertiser Dashboard

1. Monthly Views: Shows the monthly views line graph (#6)
2. Top Countries: Top Ten list of top ten countries viewers of all the member’s campaigns are from
3. Top Referrals: Top Ten list of top ten referrals to the campaign
4. Top Devices: Top Ten list of top ten devices used to view the campaign
5. Date Filter: Allows the advertiser to filter the graph to a certain month and year (#6)
6. Line Graph: Line graph that summarizes the amount of views that all of the campaigns have received in a certain month and year

1. Showing entries: Allows the member to change the amount of entries on the table
2. Search: Allows the member to search for specific links
3. Name: Shows the name of the campaign
4. Website: Shows the name of the campaign’s website and the URL
5. Current Budget: The current budget is equal to the actual price paid minus the amount used up for displaying the campaign
6. Daily Budget: The budget for a single day. If this runs out for a day, the campaign won’t be displayed anymore that day. This ensures that the duration of the campaign is equally spread out.
7. Used Today: How much of the daily budget was used today
8. Started: Date and Time when the campaign was purchased
9. Rate: The rate the advertiser purchased
10. Ordered Views: The amount of views the advertiser ordered
11. Delivered Views: The amount of views that are delivered
12. Edit: Allows the advertiser to edit the campaign. If turned on in the settings, an update to a campaign requires re-approval by an admin.
13. Delete: Deletes this campaign (no refunds)
14. Ended Legend: Shows up when campaign has ended

### Basic Campaign Info

There are two types of campaigns:

- Interstitial
- Banner

In order for a campaign to be displayed, the following requirements have to be met:

- The campaign's status is set to 'Running' and is approved (if this is turned on in the settings)
- The campaign is successfully paid for
- The 'Budget Used Today' does not exceed 'Daily Budget'
- The 'Current Budget' is not zero
- The amount of delivered views is smaller than the amount of ordered views
- The user viewing the campaign is on the device specified (mobile, desktop, or both)
- The user viewing the campaign is in the country specified in the purchased rate

If no campaign is found, no ads will be shown and the user will be immediately redirected to the link.

### Rates & Percentages

Rates define different prices and locations that advertisers can purchase. For example, one rate named ‘US Package’ could be priced at 1.00 USD CPM with location ‘US’. This means, that if an advertiser purchases this rate, they have to pay 1 USD for every thousand views their campaign receives. Also, the campaign is then only displayed to visitors from the United States.

You can view, create, and delete rates in the administration panel under ‘Campaigns’, then ‘Rates’.

In the admin panel under ‘Campaigns’, then ‘Settings’, you can change the following percentages:

1. Interstitial Ad Percentage (80% default)
2. Banner Ad Percentage (75% default)
3. No Ad Percentage (0% default)

Your share of profit from each valid view would then be:

100% - Publisher Percentage = Your Profit

### Rates Pricing Reference

Here is an example for competitively priced rates that have proven to be effective:

Name | CPM (USD) | Location
Worldwide | $1.00 | Anywhere (Empty)
United States | $4.00 | United States
United Kingdom | $5.00 | United Kingdom
Germany | $3.00 | Germany
Austria | $3.00 | Austria
France | $4.50 | France
Sweden | $2.00 | Sweden
Norway | $2.00 | Norway
Denmark | $2.00 | Denmark
New Zealand | $3.00 | New Zealand
Australia | $3.00 | Australia

## Modifying the Script

### Script Structure

This is the main folder structure for the script:

- admin: Contains PHP code for the admin panel
- cache: Contains the template cache for the main site template
- includes: Contains core logic and functions for the script as well as global definitions

- configs: Contains basic config files for the database
- functions: Contains core functions that powers the site
- libraries: Contains 3rd party libraries (e.g. AdoDB, securimage, more)

- langs: Contains the language files
- templates: Contains templates and admin templates

- default: Default template

- css: Contains CSS
- img: Contains images used on the site and by the template
- js: Contains core JavaScript as well as libraries (e.g. jQuery and Bootstrap.js)
- email: Contains e-mail templates

- admin_default: Default admin template

### Custom Localization

You can change the global site language under ‘General’ in the admin panel. You can turn off the language picker by unchecking ‘Show language picker’ and saving the changes. Languages are automatically discovered - simply place them in the ‘langs’ folder and ensure the filename ends with ‘.lang.php’.

#### Translation Files

In order to translate the whole main website (not the admin panel), LinkFly uses PHP language files. These files simply contain an array with the translations that are then used by the template and some core functions.

As of version 1.0, LinkFly is prepackaged with an english translation file. Use this file as a template for further translations.

In order to add a new translation, simply copy the ‘english.lang.php’ file located in the ‘langs’ folder. Then, rename the file to ‘new_language.lang.php’, where new_language is the language of the new translation (e.g. ‘german.lang.php’ or ‘swedish.lang.php’). Please note that the name of the language in the file name is also the name that will be displayed in the language picker and the admin panel.

In your new language file, simply start translating by replacing the text in the quotes after each array item with the new translation.

For example, this is what it might look like for an English-German translation:

Original ‘english.lang.php’:

$langs[0] = 'Earn money by sharing links.';

$langs[1] = 'Get paid to share your links on the Internet!';

$langs[2] = 'Your link will be immediately shortened. Want to earn money while you are at it? ';

$langs[3] = 'Make money with links';

…

New ‘german.lang.php’:

$langs[0] = 'Verdiene Geld bei dem Du Links verteilst.';

$langs[1] = 'Werde bezahlt Deine Links im Internet zu verteilen!';

$langs[2] = 'Ihr Link wirdt sofort gekuerzt. Willst du Geld damit verdienen?';

$langs[3] = 'Verdiene Geld mit Links';

...

#### Translating Pages

Since pages are not stored in the language files but in the database, you have to translate them through the admin panel. If the language is different than the language that the page is stored as, the page will not be found. However, you can have translated pages with the same slug in order for the translated pages to appear when a different language is set.

For example, to translate the ‘about’ page, simply add a new page under ‘Pages’ in the admin panel. You can then translate the title and content, but make sure that for slug you put ‘about’, since this is the translation for the about page. For the language field, put the language of the translated page.

### Creating your own Theme using Smarty

Creating your own theme requires knowledge of Smarty, a PHP templating engine. To get started, it is a good idea to copy the ‘default’ template folder and start from there. Refer to the Smarty Documentation to learn more.

Scriptastic Software --- http://www.scriptastic.co --- http://codecanyon.net/user/scriptastic