Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Problem with installing link exchange script

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-18-2008, 08:08 AM
 
Pilnik Pilnik is offline
 

Member
  
Join Date: Jul 2007
Posts: 18
 

Default Problem with installing link exchange script

Hi all,
I'm not sure whether this is good question here, but I'll give it a try.

I'm trying to install script that handles link exchange.
Instalation seems to be pretty easy...for somebody who knows smarty and php. Unfortunatelly, I'm not that person...

What they say needs to be done is:
Installation for PHP pages

1. Add the following code to .php pages of your website:

ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
include_once ('linkor.php');

2. Put the following code in the place where you want links to be displayed:

linkor_wyswietl_poz();

I have two questions.

- In which .php files should I add the code, so that it would be displayed on each page of my shop

- I want to display code where copyright.tpl is. What form "linkor_wyswietl_poz();" should have to make it work properly.

I spent a lot of time trying to solve this problem, but at the end of the day I gave up.

Thanks for any help.
Regards,

Maciej
__________________
X-Cart 4.1.8

africanartstall.com - an online store for african art
Reply With Quote
  #2  
Old 06-19-2008, 05:39 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Problem with installing link exchange script

Quote:
Originally Posted by Pilnik
Hi all,
.........

Maciej

Try to do so:
1. In the end of the file "auth.php" add next lines:

PHP Code:
ini_set ("include_path"ini_get ("include_path") . ':../:../../:../../../:../../../../'); 
include_once (
'linkor.php'); 

$link_change =  linkor_wyswietl_poz();

$smarty->assign("link_change"$link_change); 


2. Add the code in the template for the output links (for. exmpl in the end of the file "skin1/bottom.tpl" - links will appear at the bottom of the site):
PHP Code:
{$link_change
Reply With Quote
  #3  
Old 06-19-2008, 06:18 AM
 
Pilnik Pilnik is offline
 

Member
  
Join Date: Jul 2007
Posts: 18
 

Default Re: Problem with installing link exchange script

Thanks for your help, but still there's something not working properly. Links are displayed always at the top of page no matter to which .tpl file I put the second bit of code.
Some of the page formatting is changed as well.
Regards,
Maciej
__________________
X-Cart 4.1.8

africanartstall.com - an online store for african art
Reply With Quote
  #4  
Old 06-19-2008, 06:20 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Problem with installing link exchange script

Quote:
Originally Posted by Pilnik
Thanks for your help, but still there's something not working properly. Links are displayed always at the top of page no matter to which .tpl file I put the second bit of code.
Some of the page formatting is changed as well.
Regards,
Maciej


Need source file linkor.php...
The problem there.
Reply With Quote
  #5  
Old 06-19-2008, 06:26 AM
 
Pilnik Pilnik is offline
 

Member
  
Join Date: Jul 2007
Posts: 18
 

Default Re: Problem with installing link exchange script

I hope it's not too long:


$now = time();
$t24h = 60 * 60 * 24;
$lfname = "linkor.txt";
$refferer = $_SERVER['HTTP_HOST'];
$VER = "1.7.5 STATIC";
$p_linkor = '';

while(!is_file($p_linkor . 'linkor.txt') && $catd < 20) {
$p_linkor .= '../';
$catd++;
}

$lfname = $p_linkor . $lfname;

if(@file_exists($lfname)) {
if((filemtime($lfname) + $t24h < $now) || (filesize($lfname) == 0)) {
if(is_writable($lfname))
{
$newlinks = getpage ("http://get.linkor.pl/download_links.php?linkor=".
urlencode($lfname).
"&VER=".urlencode($VER).
"&referer=".urlencode($refferer), $refferer) ;

if ($newlinks) {

} else {
$newlinks = '';
for ($i = 0; $i < 10; $i++) {
$newlinks .= '<a id="L'. $i .'" href="#" title="#'. $i .'" >Linkor.pl</a> 1130882242' . "\n";
}
}

$lp = @fopen($lfname,'r+');
@flock($lp, LOCK_EX|LOCK_NB);
@fwrite($lp, $newlinks);
@ftruncate($lp, @ftell($lp));
@fclose($lp);
}
else
{
// Blad zapisu do pliku
$linkor_links[0][0] = "WE";
$linkor_links[1][0] = "WE";
$linkor_links[2][0] = "WE";
$linkor_links[3][0] = "WE";
$linkor_links[4][0] = "WE";
}
}
else
{

}

}
else
{
// Nie odnaleziono pliku linkor.txt
$linkor_links[0][0] = "FnF";
$linkor_links[1][0] = "FnF";
$linkor_links[2][0] = "FnF";
$linkor_links[3][0] = "FnF";
$linkor_links[4][0] = "FnF";
}

if (is_file($lfname)) {
if (is_readable($lfname)) {
$alllinks = file($lfname);
$i = 0;
$linkor_links = array();

while( $i < 3) {
$numlinks = count($alllinks)-1;
//$rand = mt_rand(0, ($numlinks)) ;
$rand = lnk_Rand($numlinks);
$newlink = explode("\t", trim($alllinks[$rand]) );

if ($utf8 == 1) {
$newlink = ISO88592_2_UTF8($newlink);
}

if ($noweokno == 1) {
$newlink = str_replace(' >', " target=\"_blank\" >", $newlink);
}

if ($css != "") {
$newlink = str_replace(' >', " class=\"$css\" >", $newlink);
}

$linkor_links[] = $newlink;

unset($alllinks[$rand]);
foreach ($alllinks as $onelink) {
$newalllinks[] = $onelink;
}

$alllinks = $newalllinks;
$i++;
}

$i = 0;

while( $i < 2) {
$numlinks = count($alllinks)-1;
$rand = mt_rand(0, ($numlinks)) ;
$newlink = explode("\t", trim($alllinks[$rand]) );

if ($utf8 == 1) {
$newlink = ISO88592_2_UTF8($newlink);
}

if ($noweokno == 1) {
$newlink = str_replace(' >', " target=\"_blank\" >", $newlink);
}

if ($css != "") {
$newlink = str_replace(' >', " class=\"$css\" >", $newlink);
}

$linkor_links[] = $newlink;

unset($alllinks[$rand]);
foreach ($alllinks as $onelink) {
$newalllinks[] = $onelink;
}

$alllinks = $newalllinks;
$i++;
}
}
}

function getpage ($pageSpec, $refferer)
{
$pageSpec = urldecode($pageSpec);

if (function_exists('curl_init')) {
if (!$agent) $agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

$ch = curl_init($pageSpec);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, $refferer);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
$tmp = curl_exec ($ch);
curl_close ($ch);
unset($ch);
}
else
{
$tmp = @file_get_contents($pageSpec);
}

return $tmp;
}

if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
if (!$handle)
{
return 0;
}
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}

function linkor_wyswietl_poz($separator=' ')
{
global $linkor_links;

echo $linkor_links[0][0] . $separator .
$linkor_links[1][0] . $separator .
$linkor_links[2][0] . $separator .
$linkor_links[3][0] . $separator .
$linkor_links[4][0];
}

function linkor_wyswietl_pion()
{
global $linkor_links;

echo $linkor_links[0][0]."<br>".
$linkor_links[1][0]."<br>".
$linkor_links[2][0]."<br>".
$linkor_links[3][0]."<br>".
$linkor_links[4][0];
}

function iso2utf()
{
$tabela = Array(
"\xb1" => "\xc4\x85", "\xa1" => "\xc4\x84", "\xe6" => "\xc4\x87", "\xc6" => "\xc4\x86",
"\xea" => "\xc4\x99", "\xca" => "\xc4\x98", "\xb3" => "\xc5\x82", "\xa3" => "\xc5\x81",
"\xf3" => "\xc3\xb3", "\xd3" => "\xc3\x93", "\xb6" => "\xc5\x9b", "\xa6" => "\xc5\x9a",
"\xbc" => "\xc5\xbc", "\xac" => "\xc5\xbb", "\xbf" => "\xc5\xba", "\xaf" => "\xc5\xb9",
"\xf1" => "\xc5\x84", "\xd1" => "\xc5\x83");

return $tabela;
}

function ISO88592_2_UTF8($tekst) {
return strtr($tekst, iso2utf());
}

function lnk_Rand($numlinks)
{
$lnk_UserUrl = $_SERVER['REQUEST_URI'];
if ($lnk_UserUrl == "")
{
$lnk_UserUrl = $_SERVER['SCRIPT_NAME'];
if (!$_SERVER['QUERY_STRING'] == "")
{
$lnk_UserUrl = $lnk_UserUrl . "?" . $_SERVER['QUERY_STRING'];
}
}

$lnk_Seed = hexdec(substr(md5($lnk_UserUrl), -) & 0x7fffffff;
srand($lnk_Seed);
$lnk_RandStart = rand(0, $numlinks);

return $lnk_RandStart;
}


?>
__________________
X-Cart 4.1.8

africanartstall.com - an online store for african art
Reply With Quote
  #6  
Old 06-19-2008, 06:34 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Problem with installing link exchange script

Quote:
Originally Posted by Pilnik
I hope it's not too long:



?>


Change next code in this file:

PHP Code:
function linkor_wyswietl_poz($separator=' ')
{
global 
$linkor_links;

echo 
$linkor_links[0][0] . $separator .
$linkor_links[1][0] . $separator .
$linkor_links[2][0] . $separator .
$linkor_links[3][0] . $separator .
$linkor_links[4][0];


by this
PHP Code:
function linkor_wyswietl_poz($separator=' ')
{
global 
$linkor_links;

$a=$linkor_links[0][0].$separator.$linkor_links[1][0].$separator.$linkor_links[2][0].$separator.$linkor_links[3][0].$separator.$linkor_links[4][0];
return 
$a;

Reply With Quote
  #7  
Old 06-22-2008, 05:25 AM
 
Pilnik Pilnik is offline
 

Member
  
Join Date: Jul 2007
Posts: 18
 

Default Re: Problem with installing link exchange script

Thank you very much!!!
You've helped me a lot.
__________________
X-Cart 4.1.8

africanartstall.com - an online store for african art
Reply With Quote
  #8  
Old 06-26-2008, 12:24 AM
  Yurij's Avatar 
Yurij Yurij is offline
Banned
 

X-Adept
  
Join Date: Jan 2008
Posts: 486
 

Default Re: Problem with installing link exchange script

Quote:
Originally Posted by Pilnik
Thank you very much!!!
You've helped me a lot.

What links exchange service you use?

I creat a new topic with this decision, it may be someone will need in the future.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 01:25 PM.

   

 
X-Cart forums © 2001-2020