Untitled Document
NewCJ PHP

NewCJ C

Main

NewCJ C Documentation
pdf documentation download
word documentation download


NewCJ Trading system
in.cgi / in.fcgi
Description
Incoming traffic tracker cgi for the website. When the user approaches to your site, his/her connection is being recorded by the in.cgi regarding the visitor status.
The status is determined by the user’s tracker cookie existence and validness.
The following status types used in the context of NewCJ:
Unique visitor: The incoming user’s first visit for the website.
Reloading visitor: The incoming user already visited the webpage at least once.
Clicking visitor: The incoming user is approached at least once to the website and clicking on one of the links where the in.cgi or out.cgi is activated.

In the next phase, the user’s connection is checked for proxy usage.
The commonly used HTTP header information set by the proxy server indicates proxy usage.

The user’s IP address is stored for late country lookups done by the postprocessor (newcj_pp) in every hour. The background country processing dispatches the expensive lookup mechanism to the newcj_pp, therefore the visitor using the in.cgi will not suffer any lag or long response time caused by system overload. When all the necessary information is collected, the status is accounted to the NewCJ’s database and the user’s tracker cookie is updated.
Usage
The in.cgi must be included from the site’s entry point, mostly in the index.html or index.php file. Calling the in.cgi is possible with PHP code or with Server Side Includes (SSI).

The following line should be added to the desired web page’s first line:
PHP:
<?php virtual ("/cgi-bin/newcj/in.cgi"); ?>
SSI:
<!--#include virtual="/cgi-bin/newcj/in.cgi" -->

Please consider, that the include URL could be differ if the NewCJ is reachable from different URL location on your site. In those case the include URL (“/cgi-bin/newcj/in.cgi”) should be set respectively.

If your webserver supports FastCGI, the URL should be changed to reflect the in.fcgi executable:
PHP:
<?php virtual ("/cgi-bin/newcj/in.fcgi"); ?>
SSI:
<!--#include virtual="/cgi-bin/newcj/in.fcgi" -->

out.cgi / out.fcgi
Description
This application provides the statistics based trading for the outgoing hits.

Whenever the visitor is clicking on the linked out.cgi, the trading mechanism is being activated and the user’s destination page is determined. The destination page is chosen from the active trading partner list if trading is necessary to keep the trading plan matching with the actual statistics.
If no trading is necessary or no active trade partners exist the visitor will be redirected to the specified URL in the parameter list.

The trading plan is defined per site in the web interface using the various constraints:
1.Global skim and country skim percentages
2.One time and hourly forces
3.Minimal and maximal outgoing percentages, ratios and hits

Please take particular note on, the above mentioned trading constraint list is in priority order.

The NewCJ is continuously monitors the incoming statistics and the constraints to set up internal weighted distribution for the partner sites to meet/correct the trading plan set. Possible trading corrections made by evaluating the last 24 hours statistics to avoid the under or oversized return traffic if the partner’s incoming hits per time is changing.
By analyzing the partners’ trends the optimal number of return visitors could be sent to keep the trade and production optimally grow.

The global skim (set on the administration page or by command line parameter) specifies how many percent of the visitors will be sent to partner sites. The country skim percentage defines the percent of the visitors coming from the various countries to be sent to trade.
The one time and hourly forces sets either one-off (continuously decreasing to zero) or hourly (continuously decreasing to zero in every hour) visitor number send for trade.

Minimal and maximal constraints used to cap the return traffic based on the partner sites’ actual incoming hits.

If trading in action, click is counted for the partner site and the visitor will be redirected to the partner site’s URL set with the administration interface.

Parameter nameParameter aliasesDescription
urluOriginal destination URL, where the user will be redirected if no trading in action.
NewCJ supports URL encoding, the existence of the URI specification (i.e. http://) is optional.
url_bu_bOriginal destination URL in base64 encoding. For the format see the url parameter’s description.
firstf, click, cNo trade for the first N clicks. If set, the user will be not redirected in his/her first specified number of clicks.
percentagepThe skim percentage of the traffic to be traded.
If 0 is specified, no trade will be done for the hit. If 100 is specified, all the hits will be traded.
linklLink associated with the hit. Setting this value will generate sub-site statistics about the appearing links in the outgoing hits. This feature enables separate (i.e. gallery by type) hit counting.
trade The given value for this parameter will be used in the redirect phase. Useful to count the toplist hits as clicks.


Usage
The out.cgi should be called with the desired parameters from the webpage or gallery on the site by simply linking by the html or php pages.

If FastCGI is available on the system, the out.fcgi should be called to reach the optimal performance.

admin.cgi / admin.fcgi
Description
This web application provides the administrative interface for the NewCJ Environment. The various system and trade partner related settings and statistic information could be set or viewed using web browser on the administrator side.
Initially the administrator information is:
Username: admin
Password: adminAfter the successful installation the password should be changed to avoid access for unauthorized persons.

As mentioned in the in.cgi and out.cgi sections, for optimal performance FastCGI operation should be preferred.
Usage
The administration interface is reachable by loading the admin interface’s URL to the web browser. In common installation the admin.cgi takes place in the cgi-bin/newcj/admin.cgi on the server.


Views
The administration tasks, settings and trading statistics can be reached by using the upper menu bar on each of the pages.

The actual view could be saved in Microsoft© Word or Excel using the Open in Word or Open in Excel links at the bottom of the page.

Add and Edit trade
New partner could be added by selecting the Add Trade from the upper menu bar. On the Refresh and Trade stats view (see section 4.3.3.2) the existing trade partner settings can be edited by clicking on the Edit in the partner’s row. Shortcut for the enable/disable state switch also placed to the Trade stats view in every row.

The following trader specific information could be set in these views:
Site URL
The partner’s webpage, where the incoming traffic will come and the outgoing trades will go to.
Site Name
Name for the partner site. The specified name will appear in the Last 50 Incoming and Outgoing hit (see section 4.3.3.6) views.
Site Description
Textual description for the partner site.
Webmaster Email
The contact webmaster’s email address.
Webmaster ICQ UIN
The contact webmaster’s ICQ Number.
ICQ Nick
The contact webmaster’s ICQ Nickname.
Webmaster name
The contact webmaster’s name.
Hourly Force
Hourly force set for this page (see section 4.2.1). The hourly forces used to prioritize the return number of visitors send besides the normal trade. Setting this option for the partner site, the NewCJ will try to force the specified number of visitors in every hour. If the desired number of return force is reached, the NewCJ will continue to work in normal trading operation mode.
One time force
As hourly forces, defines prioritized traffic sending for the partner site. The one time forces are not repeating like the hourly force does, once the desired number of visitor is sent to the partner normal trading operation will be used.
Minimum % of return traffic
The minimal percentage of the return traffic to be sent back for the partner site in 24 hours. Setting to 100, NewCJ will try to send back as much visitors as the partner page sent.
Maximum % of return traffic
The maximal percentage of the return traffic to be sent back for the partner site in 24 hours. Setting this option capes the trading to the desired percentage. Setting to 200 means, that twice as much visitor will be sent back maximum than the partner sent.
Ratio
The minimal ratio of the return traffic to be sent back for the partner site in 24 hours. Same as the Minimum % of return traffic, except the metric.
Maximize the return traffic
Switch to activate the Maximum number of visitors to send hourly option below.
Maximum number of visitors to send hourly
The upper cap for the sent visitor to the partner hourly. Only active if the Maximize the return traffic switch is enabled.
State
State of the trading for this partner. Could be either enabled or disabled. If set to disabled, only the incoming hits from this partner will be accounted, but no return traffic will be generated.
Visible on toplist
Controls the visibility on the toplist. If set to disabled, the site will not appear on the generated toplist (see section 4.3.3.7).
Enable Auto-Disable function
Switch to enable or disable the automatic disable settings for this partner. If enabled the trade partner’s state (enabled or disabled) will be set automatically if the incoming traffic from the site reaches the limits defined in this section.
Maximum percentage of proxy hits
The maximal percent of the proxy hits from the incoming hits before the trade partner status set to disabled (if Auto-Disable function is enabled).
Minimum percentage of productivity
The minimal percentage of productivity generated by the incoming hits before the trade partner status set to disabled (if Auto-Disable function is enabled).
Maximum percentage of productivity
The maximal percentage of productivity generated by the incoming hits before the trade partner status set to disabled (if Auto-Disable function is enabled).


Refresh, Trading stats and Daily
In the refresh, trading stats and daily views the various generated statistics could be seen. Refresh and Trading stats provides per site statistics with the following columns:
R.In: Raw In, accumulated value for the Reloads and Unique hits
U.In: Unique In hits
Out: Number of visitor sent back
Clicks: Number of clicks by visitors
Prod: Production, calculated with Clicks / U.In
Return: The percentage of the return traffic, calculated with Out / U.In
Force: The remaining one time and hourly force
Links: The links passed to the Out’s link parameter (see section 4.2.2)
IP Log: IP Address based events for the incoming hits.
Country: Distribution of the visitors sent by the partner site based on their country, if country lookups are enabled (see section 4.3.3, Country Lookups).
Referers: Full links with the referring URLs.In the Refresh and Trading stats view four special accumulated statistics shown at the bottom of the table:
Bookmark: Bookmarking user statistics, which use direct links for the NewCJ site.
Unknown: Traffic comes from unknown (not yet added) partner site.
Search Engines: The referrer of the hits is one of the Search Engine specified in the SE list.
Total: Aggregate value which represents the overall site statistics.The Daily view provides the aggregated total statistics in per day basis with the following fields:
R.In: Raw In, accumulated value for the Reloads and Unique hits
U.In: Unique In hits
Clicks: Number of clicks by visitors
Out: Number of visitor sent back
Return %: The percentage of the return traffic, calculated with Out / U.In
Productivity %: Production, calculated with Clicks / U.In

Settings
The following site specific settings could be set in this view:
Site Domain (read-only)
Domain name for the site where the NewCJ being used.
Site URL
URL for the site, where the incoming traffic will come.
Site Name
Textual description for the site.
Your Email
Email address of the NewCJ Administrator.
Your ICQ UIN
ICQ Number of the NewCJ Administrator.
Minimum hits In to start trade
The minimal number of hits needed to start the trade.
Rules
Rules for the site.
Max Trades partner
Maximal number of trade partner to work with. If the specified number is reached, the webmaster.cgi will not accept new trades (see section 4.4)
Default Global Skim
The default global skim percentage used for the out if no value specified in the out’s parameter list. See section 4.2, Parameter percentage.
New Trade
Status for the trades added by the webmaster.cgi. If set to enabled, all the freshly registered trades will get return traffic from the out.cgi.
Trade Status
Defines the trade status for the webmaster.cgi. If set to enabled, new site registrations is accepted by the webmaster.cgi interface.
Proxy check
Proxy checking for the visitors. If set to enabled, all the visitors proxy usage state will be determined by the in.cgi and out.cgi.
Enable Country Ratios
Country ratio check for the visitors. If set to enabled, the visitor’s country will be taken into account in the trading mechanism. See section 4.3.3.5.
Reset Client’s Visited Page list
Sets the visitors’ cookie expire behavior. If enabled, the returning users’ cookies for the visited pages will be reset after all the trading partners in the NewCJ are visited. Setting this switch to disabled will cause that the returning users’ visited page cookie will expire in twelve hours. Please note, if all the partner pages are visited by the user, no trade will be done for this user until the cookie not expires.

The default settings (max return %, min return %, etc.) sets the default values for the trades added after those options are changed (see section 4.3.3.2).

Cheat, Blacklist, Proxy and SE

The NewCJ environment provides extensible features for handling Blacklist, Proxylist and Search Engines (SE). In each individual view for those list operations additional hosts could be set either as proxies or blacklisted sites.
If the trade partner site is on blacklist, the visitors sent by this site will be not traded to the active partners to avoid the NewCJ to be placed in the blacklist as well. For each of the blacklist sites the domain name and textual reason for blacklisting should be given.
On the Cheat view sites could be placed to the blacklist directly by clicking on the Blacklist button in the partner’s row.

Proxies and Search Engines used to indicate proxy or search engine hits by the visitor. To support mass-insert to these lists, one domain per row should be placed to the textbox.

Countries
In the Countries view the per country trade skim percentage could be set.

To enable the country based skim trading feature, you have to activate the Enable Country Ratios feature in the Settings view (see section 4.3.3.3, Enable country ratios).

The NewCJ is able to lookup the visitor’s country in the trading phase (out.cgi processing). Each of the percentages set for the countries defines the percentage of the traffic to be traded from this country.
If 0 is specified, no trade will be done for the hit.
If 100 is specified, all the hits will be traded.

Last 50 In and Last 50 Out
The Last 50 Incoming and Outgoing hits could be seen in this view.

Last 50 In fields:
Date: The timestamp of the incoming hit
From: The partner site’s name, who sent the incoming visitor.
Type: Unique indicates the visitor type.
IP: IP address of the sent visitor.
Country: The country of the visitor. The entries with POSTPROCESS country name refer to the unprocessed connections. For these fields the country will be resolved in the upcoming hour.
Is Proxy: The proxy usage for this hit.

Last 50 Out fields:
Date: The timestamp of the outgoing hit.
Redirected to: The partner site where the visitor sent.

Toplist
Template based toplist generator functionality could be used for the NewCJ partner sites statistics. The toplist generator service is capable to generate statistics based on Click hits or Unique hits for the toplist-visible (see section 4.3.3.1, Visible on Toplist field) partners.
In the web administrator interface the template and the generated files accessible under the Toplist Templates section. The files placed to the toplists/ with the `.templ` suffix is used as basis in the hourly postprocessor task to generate the HTML files. In the installation the NewCJ recognizes the directory used for toplists and sets the Toplist directories. The default settings can be changed in the Specify Toplist Directories section.

Special template procedures used inside the toplist files:
Ordering rules:
Order by click:
To order the toplist by click count from the partner pages, the following line should be placed to the toplist temlate file’s first line:
<!-- order: click -->
Order by unique hit:
For ordering on partner page by unique hits, the following line should be placed to the toplist template file’s first line:
<!-- order: uniq -->

Toplist variables:
Site domain: Domain name of the partner site (see section 4.3.3.1, Site Domain).
Variable name: ${sitedomain[n]}
Site name: The name of the partner site (see section 4.3.3.1, Site name).
Variable name: ${sitename[n]}
Site descr.: Description of the partner site (see section 4.3.3.1, Site description).
Variable name: ${sitedesc[n]}
Short URL: URL for the partner site (see section 4.3.3.1, Site URL)
Variable name: ${siteurl[n]}
Where n represents the rank in the toplist.

As an example, please take the default toplists given by the NewCJ release in the newcj/toplist directory.Manage Users and Change Pass view
This view is used to manage the Users’ privileges.
The NewCJ distinguishes between two user types in the system:
Administrator: Full access granted to all of the views and services
If the actual user is Administrator, Manage Users link will appear on the top menu bar. The Manage Users view gives the full control for the access user management: create and delete users, change passwords

Guest: Read only access for the trade statistics.
If the actual user is Guest, Change Password link will appear on the top menu bar.
The guest’s Change Password view is only capable to change the actually logged in user’s password.

Security

The event viewer service is reachable under this view. The various security for login, logout and user credential changes shown in time descending order.

The administrative messages stored in the newcj/newcj.log file, it can be cleaned by removing the file from the directory.


webmaster.cgi / webmaster.fcgi
Description
The webmaster.cgi is provided for webmaster signups if the trades in the NewCJ are open (see section: 4.3.3 New Trade, Trade Status and Max trades partner options). Direct linking to this application from the webpage allows the new webmasters to sign in to your site automatically.


newcj_pp
Description

newcj_pp is the background statistics and plan generator used by the NewCJ Environment. To dispatch the extensive country lookup and statistic generation for the admin.cgi and the trading plan, this standalone shell application is used as a cronjob. This application is started in every five minutes to perform the five minute, hourly and bi-daily administrative tasks.
To verify the cronjob existence on the system, the
crontab –l
command should be used with the installation user (web server) privileges.
The following entry should appear for each of the installed NewCJs:
# newcj:/path/newcj
*/5 * * * * cd /path/newcj && ./newcj_pp 2>&1 > /dev/null