# Website Worth Calculator - PHP Script Documentation

- created: 03/10/2011
- latest update: 07/18/2014
- by: PHP5 Developer

Get Website Cost

Thank you for purchasing Website Worth Calculator PHP script. If you have any questions that are beyond the scope of this help file, please feel free to email roman.codecanyon@gmail.com. Thanks so much!

### Requirements

- PHP 5.3.0 or above
- PDO extension
- MySQL 5.0 or above
- CRON jobs
- cURL extension
- SMTP Mail Server
- Mcrypt Extension (MCRYPT_RIJNDAEL_256 ciphername)
- GD extension
- Multibyte String Functions
- Rewrite module (optional)
- DOMDocument (optional. For sitemap generation)
- ZipArchive (optional. For language translation import/export)

### Installation

- Upload files to your web server or hosting
- Make sure following directories are writable (chmod 755)
  ~/root/assets
  ~/root/sitemaxp.xml
  ~/root/sitemap/
  ~/root/protected/runtime
  ~/root/protected/runtime/cache
  ~/root/protected/runtime/translation
- Import sitecost.sql in MySQL
- Go to Customization Section

Note. You can view framework's requirements by accessing the requirement checker script via following URL: http://your-domain.com/requirements
Note. If you installed script not in web-root directory then you need to add RewriteBase /subdir/ into .htaccess after RewriteEngine on

### Customization

#### Database Settings

The main Web application configuration file located in ~/root/protected/config/main.php
Open this file and configure database settings. Find following lines and set up your own MySQL settings

    'db'=>array( // Mysql host: localhost and databse name catalog'connectionString' => 'mysql:host=localhost;dbname=sitecost', // whether to turn on prepare emulation'emulatePrepare' => true, // db username'username' => 'root', // db password'password' => '', // default cahrset'charset' => 'utf8', // table prefix'tablePrefix' => 'sc_', // cache time to reduce SHOW CREATE TABLE * queries'schemaCachingDuration' => 60 * 60 * 24 * 30, 'enableProfiling'=>true,'enableParamLogging' => true,),

#### SMTP Mail server

Next. You need set up SMTP account. This is an important part of the application, because mail server used for different notifications, contact form, user registration and etc. Once you have created your account, you should fill out config file with SMTP credentials.
Open config file (~/root/protected/config/main.php), find following lines and enter your credentials

    'mailer' => array( 'class' => 'ext.mailer.EMailer', // Mail server protocol'Mailer' => 'smtp', 'SMTPAuth' => true, // Mail server host'Host' => 'mail.exampl.com', // Mail server port'Port' => 25, // Username'Username' => 'no-reply@example.com', // Password'Password' => 'pass', // Encoding'CharSet' => 'UTF-8',),

Once the previous step has been done, you should set email which will receive messages from contact form, name and email of notifier

    'adminEmail'=>'webmaster@example.com', // This email will be receiving message sent by contact form'notificationEmail' => 'no-reply@php5developer.com', // Notifier email'notificationName' => 'GetWebsiteCost Team', // Notifier name

#### Security

While app is using cookie-based authorization, we need to encrypt cookies. The algorithm and encryption key is set in main config:

    'securityManager' => array( 'cryptAlgorithm'=>array('rijndael-256', '', 'ofb', ''), // More http://php.net/manual/en/function.mcrypt-module-open.php 'encryptionKey' => 'pnkRVLZC6Oj87H2G8qmsNN',),

I suggest to change only the encryptionKey. For exemaple:

    'encryptionKey' => 'my-very-very-secret-key',

#### Cron jobs

This app very closely linked with cron jobs, because it has to generate sitemap, check website which are on sale, remove expired data. You have possibility to do this in three different ways:

- Via command line
- Using 3rd party services to run commands via browser
- Via Admin Panel

## 1. Let's begin with command line:

When script being executed via command line, the web server has no idea what website host is. You must help him in this matter. Open ~/root/protected/config/console.php file and configure it.

    // your host name (With protocol): for example: http://your-domain.com'hostInfo' => 'http://your-domain.com', // if you installed script not in root directory, then you need to set baseUrl. For example : /sitecost'baseUrl' => '',),

Next you need is to add following lines into your cron job shedule:
0 0 * * * /usr/bin/php /path/to/web/root/protected/cron_sitemap.php >/dev/null 2>&1
NOTE! Script already support multiple sitemap generation. Each sitemap has maximum of 50 000 URLs. If you want to change this value, go to: ~/root/protected/commands/SitemapCommand.php and change $urlCount property.
0 0 * * * /usr/bin/php /path/to/web/root/protected/cron_onsalechecker.php >/dev/null 2>&1
0 0 * * 0 /usr/bin/php /path/to/web/root/protected/cron_garbagecollector.php >/dev/null 2>&1

0 0 * * * 0 0 * * 0 | Time and date for your task. 0 0 * * * - every day at midnight; 0 0 * * 0 - every Sunday at midnight
/usr/bin/php | path to php command
/path/to/web/root/protected/cron_sitemap.php | physical path to script
>/dev/null 2>&1 | this mean that all output from this command should be shoved into a black hole. I.e just do nothing with output.

## 2. Using 3rd paty service as cron job:

There are a lot of 3rd party services you can find, which will send requests to defined URLs every X time.
Open main config file and find following line:

    'cronKey'=>false,

Set up your sicret key (ex. "abc")

    'clearKey' => 'abc',

Now, to run cron job commands you need to request following URLs:

    http://your.domain/index.php?r=cron/sitemap&key=abchttp://your.domain/index.php?r=cron/garbagecollector&key=abchttp://your.domain/index.php?r=cron/onsalechecker&key=abc

Pay attention! GET variable "key" must be equal to what you have set in config file. In our case it's "abc"
Note. If you installed script in sub-direcotry, then URL should look like this: http://your.domain/subdir/index.php?r=cron/sitemap&key=abc

## 3. Via admin panel:

You can execute these commands via admin panel. Go to:

    Tools->Sitemap generationTools->Run widget checkerTools->Run garbage collector

How to Log in into Admin Panel read here:

#### Admin Panel

Once you configured main settings, it's time access admin panel. Go to: http://your.domain/admin
If you can't reach URL, then open main config file (~/root/protected/config/main.php) and set

    'showScriptName'=>true,

Now you're not depend on Rewrite module. To access admin panel go to http://your.domain/index.php/admin
By default root user has following credentials:
Email: admin@example.com
Password: admin
To change Email click on User icon and choose "Profile" from drop down menu.
To change password click on User icon and choose "Change password" from drop down menu.
That's all. Application has been set up and only you're able to access Admin Panel with root permissions. Read FAQ to find out more about app configuration.
Note! If you do not remember root login or password, the only way to recover is to run query:

    UPDATE sc_user SET role='root', password='4dec0c215ba6008a2da7072c1d5a34c0', salt='a3f61195aac72cba69f20b471b8fa319', email='admin@example.com' WHERE id=1;

### FAQ

#### I want to verify my website in Google webmaster panel and insert Google Analytics

You can put verification meta tag and analytics code in main template which is included on each page. You can find it here: ~/root/views/front/layouts/main.php

#### How to setup Google adsense?

There are two specially selected advertising space, which combined with website design. They are displayed at the top and at the bottom of document.
Note! Make sure your ads banners are adaptive.
So, you can place banner code in config file:

    'bannerTop'=>'', // Top banner source'bannerBottom'=>'', // Bottom banner source

Note! Pay attentions at quotes, not to cause a syntax error
The banners located in main layout file: ~/root/protected/views/front/layouts/main.php

#### How to creaty category?

Users are able to sell website only if there are categories. You can manage categories in admin panel. Go to Manage Categories section. Click on Create Category. Fill out the form and click on create. Next you need to translate category name. To do this click on Manage Categories, choose needed category and click on Manage translation. Click on Create Translation to translate into needed language.

#### How to translate application into new language?

There are 2 ways:

1. Go to Localization->Manage Languages. Click on Create Language. Fill out the form. If you want to copy translations from old language to new, then choose something from Make copy dropdown list. Next go to Localization->Manage Translations. For easy management, phrases are categorized. Click on Manage translation next to each category. You will see the list of phrases belonging to the selected category. Click on Translate Phrase. Fill out the form and click Translate Phrase. Do the same thing for each category and phrase inside it.
2. Go to Localization->Manage Languages->Export translation. Save file into your hard drive. Extract all CSV files, open and translate.
   Important notes! The delimiter is ,(comma) and enclosure is " (double quote).
   Then archive all translated CSV file into archive and go Localization->Manage Languages->Import. Select your archive and click Import.

After translation you must flush cache. To do this go to: Tools->flush cache
The final step is to translate config file which contains list of countries. Go to: ~root/protected/extensions/ecountrylist/countries create file and name it as you named new language's ID. For example: no.php (where no is new language id). Copy content from en.php into recently created file and translate country names.

#### I found phrase that has wrong translation. How to fix?

Go to Localization->Manage Translations->Find phrase/translation. Fill out the form and click on Search button. Next click on Translate phrase and set your own translation.

After translation you must flush cache. To do this go to: Tools->flush cache

#### I want to remove website. How to do this?

Go to Manage Websites, find website by domain and click on Trash Icon. Next re-generate sitemap by clicking on Tools->Sitemap generation

#### I do not see website location on google map.

Go to https://code.google.com/apis/console -> APIs, enable "Static Maps API". Next go to Credentials, copy API KEY and isnert it in config file

    'googleMapsAPIKey' => '', // Google maps API

#### I want that website worth would be displayed in euros, not in dollars.

Open main config file (~root/protected/config/main.php) and set:

    'currency'=>'&#128;','dollarRate'=>0.739300474,

If you want that the price should be displayed before currency sign then set:

    'pricePattern'=>'{price} {currency}',

#### How to re-calculate website estimate price?

On FrontEnd all results are being cached for 24h. You can change this value in config file:

    'webdataCache' => 60 * 60 * 24, // Cache estimate price for X seconds

On BackEnd click on Manage Websites, find needed website and click on re-calculate icon. There is no cache rule for BackEnd.

#### I do not see share button on website estimate page

There are a lot of free online sharing service. I choosed sharethis.com service. Select a style and get the code. Insert suggested HTML and JS code in config file:

    'shareHTML'=>"", // HTML for share buttons'shareJS'=>'', // JS for share buttons

Note! Pay attentions at quotes, not to cause a syntax error

#### I get the error, that website contains bad word. What to do?

This happens when BOT finds a stop words in website's HTML. The full list of these words you can find here: ~/root/protected/config/badwords.php
If you want to disable badword checker, then open config file and set:

    'checkForBadwords' => false,

#### How I can generate report without filing form?

You need to request following URL to generate report without filing form:

    http://domain.name/en/website/calculate?CalculationForm[domain]=php5developer.com&redirect=%2Fen%2Fcost%2F__DOMAIN__&instant=1

Where:
php5developer.com - domain which must be analyzed
en - language id
1 - whether to do instant redirect or no (if 0, then JSON object will be returned)

### Agreement

You can not run this script on a free web hosting, because their IPs banned on Google, Twitter, Facebook because of a spam.
Also, I am not responsible if your server's IP will be banned and script will not be able to get information from public API's.