> Main > Products and Services > Purchase > Company
English / Russian

CNCat

The application for web-resources catalogue creation

Current Version

CNCat 4.4.2

CNCat Frequently Asked Questions

Design

How to Modify Directory Design?

The instructions on how to modify design see in «Design Modification» manual.

How to Insert PHP-Code onto the Page?

  1. You can create files _top.php and _bottom.php in the directory root folder. These files will be executed and enabled in the beginning and in the end of all directory user pages.

  2. Or you can use the way PHP-code is inserted for banners (file /cncat_config/banners.php) see section «Banners».

How to Organize Filters in Columns (starting with v4.3)?

To do this, you will need to modify templates. common.tpl file, filt* templates. There is a {$CNCAT[filtval][_number]} variable in filtval template. It contains filter value number (starting with 1). Thus, to output filter values line by line (two values per line), use the example:

{TEMPLATE filtval (FILTVAL[id,title])}
	<input type="checkbox" name="f{$CNCAT[filtval][id]}" 
	value="1" id="f{$CNCAT[filtval][id]}" onclick="form.submit()" 
	{if $CNCAT[filtval][_checked]}checked="checked"{endif} /> 
	<label for="f{$CNCAT[filtval][id]}">{$CNCAT[filtval][title]}</label>

	{IF $CNCAT[filtval][_number]%2==0}
		<br>
	{ENDIF}
{/TEMPLATE}
<br> will be placed after each second filter value.

Banners

Managing Banners via Administrator Interface

In CNCat v4.1.1, we have implemented the ability to manage banners via web-interface. To enable, add, change banners, and manage their location, go to Administration - Directory Elements - Banners (see user manual).

Managing Banners via PHP-File

You can also manage banners in a separate PHP-file. The instructions are given below.

How to Enable Banners?

First, enable the option «Display banners» (Settings – Directory – General Setting).

Then, find banners.default.php in /cncat_config/ folder and copy it into the banners.php.

Go to the catalogue and check the enabled banners.

How to Modify Banner Code?

The code for banners is defined in /cncat_config/banners.php file.

Each banner is described in the following way:

$CNCAT["banner"]["banner ID"] =<<<CNCAT_40_BANNER

banner code

CNCAT_40_BANNER;

Also you can change the code for the banners you need and delete it for useless banners.

By default, there are seven banners which ID's are listed below:

Banner code can contain any HTML-text except for the string «CNCAT_40_BANNER».

Also, you can define the banner code as a simple string, for example:

$CNCAT["banner"]["banner_identifier"] = "banner code";

In this case, you need to place symbol «\» before the double quotes, for example:

$CNCAT["banner"]["page_top"] = "Ltd \"Directory-Construct\" – constructing directories.";

How to Add New Banner?

In case none of the default locations of the standard banners suites you, you can either change the location of one of seven banners, or add your own banner.

To add new banner, create the identifier for it, for example, «my_banner». Then describe this banner code in the same way as a standard one.

After that, add the banner into the desired place in the design theme, for example:

{$CNCAT[banner][my_banner]}

How to Swap Banners According to Current Category?

In the banners.php file, you can insert arbitrary PHP-code, which will display banners depending on the current category.

The identifier of each category is displayed in the section «Categories Management» of the administrator interface.

To get the identifier of the current category, use:

$cid = $CNCAT["page"]["cid"];

Then, display banner depending on the category, for example:

if ($cid==10)

{

$CNCAT["banner"]["banner_identifier"] =<<<CNCAT_40_BANNER

banner code for the category 10

CNCAT_40_BANNER;

}

else

{

$CNCAT["banner"]["banner_identifier"] =<<<CNCAT_40_BANNER

banner code for other categories

CNCAT_40_BANNER;

}

See also «How to Get Information on Current Category?».

API

How to Get Information on Current Category?

Information on current category is stored in the array $CNCAT[“page”][“cat”]. The values of the array elements are the following:

id

Category identifier. Also availabe using variable $CNCAT[“page”][“cid”]

id_full

Parent categories and current category identifiers, separated by the symbol «/», for example: «311/69/206» (311 – root, 206 – current category).

parent_id

Parent category identifier. It is equal to «-1» for the root category

child_id_list

The list of child categories identifiers (in one line separated by commas), for example: «15,23,53»

title

Category name

path

The part of the path to the current category, for example: «business» (without «/» in the beginning and in the end of line)

path_full

Full path to the current category, for example: «auto/business» (without «/» in the beginning and in the end of line)

url

Path of the current category, for example: «/cncat/auto/business/»

item_count

The number of links within the category

item_count_full

The number of links within the category, including the links within the child categories

is_link

Shows whether the category is the link or not

image_mime

MIME-code for the category image. Empty line if there is no image

meta_keywords

Keywords for META keywords tag

meta_descr

Description for META description tag



General Questions

How to use RECAPTCHA when adding links and articles?

To add reCaptcha

  1. Download archive here.
  2. Copy recaptchalib.php file into the directory root.
  3. Register your domain at the reCaptcha web-site https://www.google.com/recaptcha/admin/create.
  4. Replace the file cncat_code.php contents by the specified code.

    <?php
    /******************************************************************************/
    /*                         <c) CN-Software CNCat                              */
    /*                                                                            */
    /*  Do not change this file if you want to easily upgrade                     */
    /*  to newer versions of CNCat. To change appearance set up files: _top.php,  */
    /* _bottom.php and config.php                                                 */
    /*                                                                            */
    /******************************************************************************/
    
    
    require_once<'recaptchalib.php');
    
    function recaptcha_valid<)
    {
      $privatekey = "YOUR PRIVATE KEY";
      # the response from reCAPTCHA
      $resp = null;
      # the error code from reCAPTCHA, if any
      $error = null;
    
      # was there a reCAPTCHA response?
      if <$_POST["recaptcha_response_field"]) {
          $resp = recaptcha_check_answer ($privatekey,
                                          $_SERVER["REMOTE_ADDR"],
                                          $_POST["recaptcha_challenge_field"],
                                          $_POST["recaptcha_response_field"]);
    
          if ($resp->is_valid)
                  return "DONE";
          return $resp->error;
      }
      return false;
    }
    function get_recaptcha_html($error = null)
    {
        $publickey = "YOUR PUBLIC KEY";
        return recaptcha_get_html($publickey, $error);
    } 
    


    Make sure you have submitted public key and private key obtained during the registration.
  5. Apply changes to the add.tpl template.
    Find:

    {TEMPLATE form}
        {IF $CNCAT[config][add_show_message] == 1}{$CNCAT[config][add_message]}{ENDIF}
        
            {DISPLAY ERRORS}
        
        {IF $CNCAT[config][add_accept_to_add] == 1}{$CNCAT[lang][accept_work]}{ENDIF}
        {IF $CNCAT[config][add_accept_to_add] == 2}{$CNCAT[lang][accept_work_with_back]}{ENDIF}
        {IF $CNCAT[config][add_check_link]}{$CNCAT[lang][first_check_link]}{ENDIF}
        {DISPLAY BACKLINKS}
        
    {INCLUDE field_link_url} {INCLUDE field_back_link} {INCLUDE field_site_title} {INCLUDE field_cats} {INCLUDE field_email} {INCLUDE field_author} {INCLUDE field_descr} {INCLUDE field_descr_full} {INCLUDE field_meta_keywords} {INCLUDE field_meta_descr} {DISPLAY FILTERS} {DISPLAY EXTFIELDS} {INCLUDE field_captcha} {INCLUDE field_submit}
    {/TEMPLATE}


    Replace it with:

    {TEMPLATE form}
        {IF $CNCAT[config][add_show_message] == 1}{$CNCAT[config][add_message]}{ENDIF}
        
            {DISPLAY ERRORS}
        
        {IF $CNCAT[config][add_accept_to_add] == 1}{$CNCAT[lang][accept_work]}{ENDIF}
        {IF $CNCAT[config][add_accept_to_add] == 2}{$CNCAT[lang][accept_work_with_back]}{ENDIF}
        {IF $CNCAT[config][add_check_link]}{$CNCAT[lang][first_check_link]}{ENDIF}
        {DISPLAY BACKLINKS}
        
        
    {INCLUDE field_link_url} {INCLUDE field_back_link} {INCLUDE field_site_title} {INCLUDE field_cats} {INCLUDE field_email} {INCLUDE field_author} {INCLUDE field_descr} {INCLUDE field_descr_full} {INCLUDE field_meta_keywords} {INCLUDE field_meta_descr} {DISPLAY FILTERS} {DISPLAY EXTFIELDS} {INCLUDE field_captcha} {INCLUDE field_submit}
    {/TEMPLATE}


    Then, find

    {TEMPLATE field_captcha}
            {IF $CNCAT[config][add_use_captcha]}
            <tr><td colspan="2" class="name">{$CNCAT[lang][input_image_code]}:</td></tr>
            <tr>
                <td class="name"><img src="cncat_code.php?{$CNCAT[add][rand]}" alt="" onclick="this.src='cncat_code.php?'+Math.random();" /></td>
                <td class="field"><input type="text" class="text" name="captcha_code" value="{cn_str($CNCAT[add][captcha_code])}" /></td>
            </tr>
            {ENDIF}
    {/TEMPLATE}
    


    And replace it with

    {TEMPLATE field_captcha}
            {IF $CNCAT[config][add_use_captcha]}
            {$CNCAT[lang][input_image_code]}:
            
                
                {$CNCAT[page][recaptcha]}
                
            
            {ENDIF}
    {/TEMPLATE}
    

  6. Change the CAPTCHA check in cncat_add.php file.
    Find PHP code:

    require_once dirname(__FILE__) . "/cncat_init.php";
    


    Add below

    require_once $CNCAT["system"]["dir_root"] . "/cncat_code.php"; 
    


    Find

    if (!isset($_POST["next"])) {
            if ($CNCAT["config"]["add_use_captcha"]) {
                $CNCAT["add"]["rand"] = time();
    
                srand(((int)((double)microtime() * 1000003))); 
                $_SESSION["secret_number"] = rand(1000, 9999);
                
                $CNCAT['page']['recaptcha'] = get_recaptcha_html();
            }
        }   
    


    Replace it with

    // if (!isset($_POST["next"])) {
            if ($CNCAT["config"]["add_use_captcha"]) {
                $CNCAT["add"]["rand"] = time();
    
                srand(((int)((double)microtime() * 1000003))); 
                $_SESSION["secret_number"] = rand(1000, 9999);
                
                $CNCAT['page']['recaptcha'] = get_recaptcha_html();
            }
       // }   
    


    Then find

    if ($CNCAT["config"]["add_use_captcha"]) {
                    $captcha_code = $_POST["captcha_code"];
    
                    if ((int)$captcha_code != (int)$_SESSION["secret_number"]) {
                        $errors[] = $CNCAT["lang"]["wrong_image_code"];
                    }
                }     
    


    Replace it with

    if ($CNCAT["config"]["add_use_captcha"]) {
                    $captcha_code = $_POST["captcha_code"];
                    $resp = recaptcha_valid();
                    if ($resp != "DONE") {
                        $errors[] = $CNCAT["lang"]["wrong_image_code"];
                    }
                }     
    

After all changes are applied, reCaptcha will be used when adding new links. The same algorithm is used for adding reCaptcha in case of articles.

How to Change Admin Password?

  1. In the file cncat_config/config.php, select the string $CNCAT["config"]["apassword"] = "...";

  2. Replace it with $CNCAT["config"]["apassword"] = md5("newpassword");

How to change files prefix "cncat_"?

You can change the prefix of the files and folders in cncat_init.php file (the cncat_init.php file prefix cannot be changed).

To change prefix:

  1. Rename files and folders by defining new prefix.
  2. In cncat_init.php file find: $CNCAT["system"]["dir_prefix"] = "cncat_";
    and paste your new prefix instead of "cncat_".
  3. After you changed the prefix, you should manually change the prefix in mod_rewrite conditions in .htaccess file.

You can also change only folders names. To modify the folders names, find and define the following values in the cncat_init.php file:

     $CNCAT["system"]["dir_admin"]  = 
		$CNCAT["system"]["dir_prefix"]."admin/";
     $CNCAT["system"]["dir_engine"]  = 
		$CNCAT["system"]["dir_prefix"]."engine/";
     $CNCAT["system"]["dir_product"] = 
		$CNCAT["system"]["dir_prefix"]."links/";
     $CNCAT["system"]["dir_config"]  = 
		$CNCAT["system"]["dir_prefix"]."config/";
     $CNCAT["system"]["dir_export"]  = 
		$CNCAT["system"]["dir_prefix"]."export/";
     $CNCAT["system"]["dir_manual"]  = 
		$CNCAT["system"]["dir_prefix"]."manual/";