Web Catalog | PHP Script - Documentation

Web Catalog

Thank you for purchasing web catalog 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!

 

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

Database Settings

This application is build on Yii framework.
So, The main Web application configuration file located in ~/root/protected/config/main.php
Open this file and let's begin with configure database settings. Find following lines and set your own mysql settings
'db'=>array(

// Mysql with host: localhost and databse name catalog
'connectionString' => 'mysql:host=localhost;dbname=catalog',


// whether to turn on prepare emulation
'emulatePrepare' => true,


// db username
'username' => 'root',


// db password
'password' => '',


// default cahrset
'charset' => 'utf8',


// table prefix
'tablePrefix' => 'directory_',


// cache time to reduce SHOW CREATE TABLE * queries
'schemaCachingDuration' => 60 * 60 * 24 * 30,

),

SMTP Mail server

SMTP mail server is an important part of the application, beacuse it's used for different notifications, contact form and etc.
See below how to setup settings. The same config file:
 
// Mailer extension
'mailer' => array(

'SMTPAuth' => true,

// smtp server's port
'Port' => 25,

// server's host
'Host' => 'mail.your-host.com',

// username
'Username' => 'username',

// password
'Password' => 'password',

// letter's charset
'CharSet' => 'UTF-8',
),




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 key. For exemaple:
'encryptionKey' => 'my-very-very-secret-key',



URLs

If none of your URLs do not work, it seems that Web server doesn't allows for configuration overrides using .htaccess
In this way you need to set:
'showScriptName'=>true,
in main config file.
 
 

Cron jobs

This app very closely linked with cron jobs, because it has to generate sitemap and check external dofollow links.
You have possibility to do this in two different ways: via command line or using 3rd party services to run command via browser.
1. Let's begin with command line:
Firstly, open: ~/root/protected/config/console.php file and configure it.
...
// your website name: 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 : /catalog
'baseUrl' => '',
...
Next you need is to add following lines into your cron job shedule:
 
0 0 * * * /usr/bin/php /path/to/web/root/protected/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 number go to: ~/root/protected/commands/SitemapCommand.php and set any number of $urlCount property.
0 0 * * * /usr/bin/php /path/to/web/root/protected/premiumchecker.php >/dev/null 2>&1
0 0 * * * /usr/bin/php /path/to/web/root/protected/linkcalculator.php >/dev/null 2>&1
 
0 0 * * * Time and date for your task. In our case cron will be executed every day
/usr/bin/php path to php command
/path/to/web/root/protected/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 is a lot of 3rd party services you can find, which will send requests to defined URL every X time.
 
Open main config file and find following line:
'cronKey'=>false,
Set up your sicret key (ex. "abc")
'clearKey' => 'abc',
Now, to generate sitemap or check external dofollow links you need request this URL:
http://your.domain/index.php?r=cron/sitemap&key=abc
http://your.domain/index.php?r=cron/premiumchecker&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
 
Note. You can generate sitemap in admin panel. Go to admin panel -> tools -> generate sitemap
 
Remains only register this URL in your 3rd party service.
 

Admin Panel

 
Once you configured main settings, it's time access admin panel. Go to:
http://your.domain/admin
or(if you set 'showScriptName'=>true)
http://your.domain/index.php/admin
 
By default, username and password equals "admin". Of course you must change them. Log in and click on your name(Administrator) on the right top. Select "change password" from dropdown menu and fill up the form. Do the same thing to change name, login. 
 
NOTE! If you forgot your password, then you can reset login and password with default values(admin, admin). Run this query in database to reset password and login.

UPDATE `directory_user` 
SET 
`password`='8a23307a0c66a9441025ba2c3e959906',
`login`='admin',
`salt`='77c10f8a4b497c0a0ea2cb821ceba17b'
WHERE id = 1;
 
Now you need to create root categories (for each language). Go to: admin panel -> manage roots -> create tree.
After creation you need to populate each tree with new categories.
Click on "manage tree". The interface is friendly, so I think you will not have any difficulties.
 
NOTE! After creating/updating/moving categories you need to clear cache. To do this go to admin panel -> tools -> clear cache
 

How to

Question: How to calculate how much URLs contains each category?
Answer: Since this process require a lot of calculation and queries to database, it can be done in 2 ways: via admin panel or by setting it as cron job.
1. Via admin panel: Go to admin panel -> tools -> Calculate how much URLs contains each category
2. As cron (command): 0 0 * * * /usr/bin/php /path/to/web/root/protected/linkcalculator.php >/dev/null 2>&1


Question. I've done a lot of changes in admin panel. Approved some URLs, added new categories or updated existing ones, but don't see any changes on the front-end version. What to do?
Answer: This To increase maximum performance the app is very closely linked with caching. To flush it go to: admin panel -> tools -> clear cache

 

Banners

To get dofollow backlink, user must set up text-link or banner. All banners stored in ~/root/banners/ directory. Replace existing ones with your own.
Supported formats:  .jpg  .jpeg  .gif  .png  .bmp

Localization

To see the list of available languages find this line:

...
'languages'=>array('ru'=>'Русский', 'en'=>'English'),
...

Set up default app language.

...
'language'=>'en',
...
You can setup as as many languages as you want. For example, let's translate application to German.
First of all, create directory with chosen language. In our case language ID will be de.
~/root/protected/messages/de/
 
Copy all files from ~/root/protected/messages/en/ to ~/root/protected/messages/de/
Next, open and translate them :)
 
Note. Each file contains an array, so you only need to translate only values. Leave keys as is.

Then add new key=>value pair into config file

...
'languages'=>array('ru'=>'Русский', 'en'=>'English', 'de'=>'Deutsch'),
...


Next you need to add alphabet for newly created language. To do this open ~root/protected/extensions/ealphabet/alphabet.php and append array with new key value pair.


Go ahead, now we need to translate country names. Go to ~root/protected/extensions/ecountry/countrylist/ directory. Create new file. The name must be in following format: {Language_ID}.php. For instance: fr.php Next, copy content from en.php file, paste into newly created file and begin translation.


And the final step is to create new root category in admin panel. To do this, go to:
admin panel -> manage roots -> create tree

Template and Theme

This app has template system based on themes. It mean that you can create your own or modify already existing theme.
Admin theme location:
~/root/themes/admin
Public theme location:
~/root/themes/public
This directories contains folders with available themes. By default admin and public sections have classic theme.
 
How to create your own custom theme.
Below listed steps how to create custom admin theme. You can use same algorithm for public section.
  1. Create folder in ~/root/themes/admin/metalic
  2. Copy all files from ~/root/themes/admin/classic into newly created directory.
  3. Modify HTML/CSS/Images as you want
  4. Switch theme name in config file
'themes' => array(
'admin' => 'metalic',
'public' => 'classic',
),

Application options

Some useful options you need to know.
 
'name'=>'Web Catalog', // Brand name. Not translatable

'language' => 'en', // Default app language

"enableSystemLogging"=>true, // whether to log every action in admin panel

'default_timezone' => 'Europe/Vilnius', // Default app timezone. More: http://www.php.net/manual/en/timezones.php

'badLoginCount' => 3, // When you three times filled up authorization form with invalid credentials, next time you will need to enter captcha as well

"checkPremiumLink" => 2, /* This value used for external dofollow link checking (remeber we already set cron in previous section). It has been made not to check manually all premium links.For example. You have approved http://php5developer.com link as premium link. By the rules, this webpage should refer back to your catalog.
So, if script  2 times will not find dofollow back link, then it will change type from premium to regular.*/

"backURL"=>false, /* Here you can change text and banner backlink. By default this value equals false which mean that backlink is absolute path of installed script. For example: http://catalog.php5developer.com
or if installed in subdirectory:
http://php5developer.com/catalog
*/

'searchUrlPerPage' => 10, // Number of found URLs per page

'searchCatPerPage' => 20, // Number of found categories per page

'minUrlSearchLength' => 3, // Minimum character length for URL searching

'minCatSearchLength' => 2, // Minimum character length for category searching

'catCacheTime' => 3600 * 5, // Time in seconds. Nested categories.

'contactEmail' => 'contact-form@mail.com', // Email which will receive all messages from contact form

'notificationEmail' => 'no-reply@mail.com', /* Email which will send automatic notifications.For example. When user submit url for approval and etc.*/

'notificationName' => 'No-reply',

v 1.2 - 2014.02.09

  1. Fixed issue with cyrillic symbols in URL
  2. The correct translation of the phrase
Following files has been modified
themes/public/classic/views/url/view.php
protected/config/main.php

v 1.1 - 2014.01.21

New features

Added/Modified files
  1. ~/root/protected/config/main.php
    new options added into "params" array:
        "countryColumns" => 3,
        "urlCountryPerPage"=>10,
    new language added into "languages" array
        'de' => 'Deutsch',
    new key added into "import" array
        'application.extensions.ealphabet.EAlphabet',
    Changed URL patterns and options in "urlManager" array
  2. Modified ~/root/protected/extensions/ecountrylist/ECountryList.php
  3. Modified ~/root/protected/extensions/ecountrylist/countries.en.php
  4. Added files: ~/root/protected/extensions/ecountrylist/countries/(ru|de).php
  5. Modified: ~/root/protected/models/Website.php
  6. Modified: ~/root/protected/controllers/admin/UserController.php
  7. Modified: ~/root/protected/controllers/UrlController.php
  8. Modified: ~/root/protected/forms/SubmitForm.php
  9. Modified:
        ~/root/protected/messages/(en|ru)/permissions.php
        ~/root/protected/messages/(en|ru)/system_log.php
        ~/root/protected/messages/(en|ru)/site.php
  10. Modified: ~/root/themes/public/classic/views/layouts/main.php
  11. Added new extension: ~/root/protected/extensions/ealphabet
  12. Added new controller: ~/root/protected/controllers/CountryController.php
  13. Added new view files: ~/root/themes/public/classic/views/country/
  14. Added new cronjob file: ~/root/protected/linkcalculator.php
  15. Added new command: ~/root/protected/commands/UrlCalculatorCommand.php
  16. Added new model: ~/root/protected/models/UrlCounter.php
  17. Modified ~/root/themes/admin/classic/views/url/index.php
  18. Modified ~/root/themes/admin/classic/views/tools/index.php
  19. Modified ~/root/protected/controllers/admin/ToolsController.php
  20. Modified ~/root/themes/admin/classic/views/category/children.php
  21. Modified ~/root/protected/controllers/CategoryController.php
SQL Changes
  1. Added new index into `directory_website` table
ALTER TABLE `directory_website` ADD INDEX `ix_country_status_lang_created` (`country_id`, `status`, `lang_id`, `created_at`);

       2. Added new table `directory_category_count`

CREATE TABLE IF NOT EXISTS `directory_category_count` (
`category_id` int(10) unsigned NOT NULL,
`website_count` int(10) unsigned NOT NULL,
PRIMARY KEY (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

      3. Added new permission into `directory_authitem` table

INSERT INTO `directory_authitem` (`name`, `type`, `description`, `bizrule`, `data`) VALUES ('admin_tools_generatewebsitecount', 0, 'admin_tools_generatewebsitecount', NULL, 'N;';

v 1.0 Initial - 2014.01.14