====== Hints ====== Practical tips and best practices (some are reminders of common knowledge, but worth repeating). ===== Includes in PHP files ===== I've encountered constructions like include('http://otherdomain/1.html'); or virtual('/scj/top/top.html'); Having even a few of these—especially 10 per template—significantly impacts performance. **Why this matters:** PHP processes includes before the page is sent to the browser. Remote includes cause page delivery delays. If the remote server slows down, your site slows down too. Even on the same server, virtual('/scj/top/top.html') creates overhead. For 1 user request, you get multiple server requests: 1 to your domain + 1 per include. With 10 includes, that's 11 total requests for 1 visitor—dramatically increasing server load. **The right approach:** Always use local includes with absolute file paths: include('/home/user/domain/scj/top/top.html'); If you need to include a file from another domain on the same server, use a different path. If it's on another server, ask your admin to set up a cron job to sync the file locally, then include it. **Similar issue:** readfile('http://domain/1.html') has the same performance problems as include(). **Passing parameters to includes:** Most banner rotators use JavaScript includes, but some require PHP includes. Avoid remote includes with parameters: Instead, set parameters locally and include the file: This approach passes parameters and keeps the include local rather than remote. ===== Deny access for certain countries ===== Use .htaccess: RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(RU|CN)$ [NC] RewriteRule ^$ http://google.com [R,L] ===== Rotate pages for returning visitors ===== When the same visitor returns to your niche site from different sources, you can show them different page designs. For example, show design 1 to first-time visitors and designs 2, 3, etc. to repeat visitors. Configure this in Settings > CJ Pages by adding multiple design paths, one per line: /home/user/domain/design1.html /home/user/domain/design2.html /home/user/domain/design3.html On the visitor's first visit, they see design1; on their second visit, design2, and so on. If you use internal rotation, you have two options: **Option 1: Automatic rotation in Rotation > Tube > Tube Settings** Enable the option to rotate pages for repeat visitors. The system works as follows: - When a returning visitor (one who came from within your site) visits the index, they see the 2nd page design - If they've seen the 2nd, they see the 3rd, and so on - For categories: if they arrive directly and have already seen that category page, they see the next design Note: This rule only applies if the referrer is your own domain. This ensures that when a visitor clicks from the homepage to a category thumbnail, they see that design on the category page. **Option 2: Create separate page files** Create multiple PHP files like: domain/1.php and set CJPages to: /home/user/domain/1.php /home/user/domain/2.php (and so on) ===== Direct links for topsites ===== If you link directly to traders instead of using out.php, you can still count clicks using AJAX. Here's an example topsite template: test This renders as: test The links are direct. To count these clicks, add AJAX code to track them: Key points: - Replace YOUR_FOLDER with your actual folder path - Each link has class='domain_css' and a trader='somedomain.com' attribute - A click event is attached to this class: $('.domain_css').each(function(){ ===== Page tracking ===== You can track which pages receive traffic and how visitors move through your site. In Trade > Statistics > Page Track, you'll see two columns: - **Inbound Views:** Traffic from outside your site (external referrer) - **Local Views:** Traffic from within your site (internal referrer) You can track pages in two ways: **Option 1: URL parameter** Add &page_track=... to your links **Option 2: Template tags** Use template tags in your HTML: