Установка кода трастлинк

MantroniX
На сайте с 17.05.2007
Offline
102
1411

Привествую, нужна небольшая помощь программистов

Хочу поставить код трастлинка на самописный двиг.

В шаблоне сайта пхп не исполняеться, при попыткевставки кода системы в файл где исполняется пхп(пардон незнаю как назвать, в программировании не силён) и инклуда в шаблон вывод ссылок сайт перстаёт работать. Видимо где-то допускаю ошибку, посмотрите пожалуйста что дела не верно?

файл webpage.php где исполняется пхп

<?php

class WebPage {
/* var $startTime, $endTime, $totalTime, $title, $sqlTime;*/
public $get, $post, $db, $httpHeaders, $config, $Page, $body, $head, $footer, $arrays, $values, $block, $block_get, $lang, $SiteAddress, $SiteName, $SupporteMail, $action, $last_link_vars, $cache_time;

function __construct ($block_get, $block_name, $db) {
error_reporting (E_ALL | E_STRICT);
$this->values['startTime'] = $this->getMicroTime();
global $langPath;
global $SiteName;
global $SiteAddress;
global $SupporteMail;
$this->cache_time = 0; //90*2592000; // = 30*86400;86400
$this->values ['ref'] = (isset ($_SERVER ['HTTP_REFERER'])) ? urlencode ($_SERVER ['HTTP_REFERER']) : '';
$this->SiteName = $SiteName;
$this->SiteAddress = $SiteAddress;
$this->SupporteMail = $SupporteMail;
$this->lang = $langPath;
$this->block = $block_name;
$this->block_get = $block_get;
$this->last_link_vars = array ();
$this->values['title'] = "spravka";
$this->db = $db;


if ($this->isCached ()) {
$content = $this->getCache ();
$this->Output($content);
$this->values ['endTime'] = $this->getMicroTime ();
$this->values ['totalTime'] = $this->values ['endTime'] - $this->values ['startTime'];
return;
}



$this->MakePage();
//$this->httpHeader = "Pragma: no-cache";
$this->MakeHead ();
$this->MakeFooter();
$this->values ['endTime'] = $this->getMicroTime ();
$this->values ['totalTime'] = $this->values ['endTime'] - $this->values ['startTime'];
if (!is_array ($this->head)) $this->head = array ();
if (!is_array ($this->body)) $this->body = array ();
if (!is_array ($this->footer)) $this->footer = array ();
$content = $this->head;
$content = array_merge ($content, $this->body);
$content = array_merge ($content, $this->footer);
//print "<pre>".htmlspecialchars (join ("",$content));
$this->Output($content);
$this->cache ($content);
/*
$this->Output ($this->head);
$this->Output ($this->body);
$this->Output ($this->footer);

$this->cache ($this->head + $this->body + $this->footer);
*/
//print $this->getMicroTime () - $this->values ['startTime'];


}

function __destruct () {
/*
$this ->values['endTime'] = $this->getMicroTime ();
$this->values['totalTime'] = $this->values['endTime'] - $this->values['startTime'];
$this->Output ($this->head);
$this->Output ($this->body);
$this->Output ($this->footer);
*/
//printf ("queries: %d, SQL Time: %5.6f<br />", $this->db->queries_number, $this->db->dbtime);
//printf ("Total time: %5.6f <br />", $this->values['totalTime']);
}
function getMicroTime () {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function MakePage () {
global $modules_get, $modules;
if (!empty ($_GET['module']) && in_array ($_GET['module'], $modules_get)) {
$module = $_GET['module'];
$entry = array_search ($module, $modules_get);
$module = $modules[$entry];
}
else {
$module = 'Main';
}
//print $module;
include "modules/".$module."/".$module.".php";
$this->Page = new $module($this, $_GET, $_POST);
}
function MakeHead () {
header ($this->httpHeaders);
$this->head = $this->Template ("header");
}
function MakeFooter () {
$this->values['endTime'] = $this->getMicroTime ();
$this->values['totalTime'] = sprintf ("%5.5f", $this->values['endTime'] - $this->values['startTime']);
$this->values['sqlTime'] = sprintf ("%5.5f", $this->db->dbtime);#substr ((string)$this->db->dbtime, 0, 6);
$this->values['queries'] = $this->db->queries_number;
$this->footer = $this->Template ("footer");
}
function Template ($file) {
global $host;
//global $langPath;
//if (!empty ($langPath)) {
if (file_exists ("./".$this->block."/templates/".$this->lang."/".$file.".tpl")) {
$path = "./".$this->block."/templates/".$this->lang."/".$file.".tpl";
}
else {
$path = "./".$this->block."/templates/default/".$file.".tpl";
}
//print $path. "<br>";
/*
}
else {
$path = "./".$this->block."/templates/".$file.".tpl";
}
*/
$out = file ($path);
//print_r ($out);
# подстановка данных из конфига
if (!empty ($this->config)) {
foreach ($this->config as $key => $value) {
$out = str_replace ("<<".$key.">>", $value, $out);
}
}
# обработка циклов внутри шаблона
$str_num = 0; // номер строки, добавляемой в массив
for ($i = 0; $i < count ($out); $i ++) {
if (substr ($out[$i], 0, 9) == "<cms for ") {
$for_prep = substr ($out[$i], 9);
//print $for_prop;
$for_prep = explode (" ", $for_prep);
$for_name = $for_prep [0];
$for_start = (int)$for_prep [1];
$for_end = (int)$for_prep [2];
$for_str = "";
for ($i = $i+1; $i < count ($out); $i ++) {
if (substr ($out[$i], 0, 9+1+strlen ($for_name)+1) == "</cms for $for_name>") {
break;
}
else {
$for_str .= $out[$i];
}
}
# теперь - обработка массивов
$for_arr = $this->arrays [$for_name];
$for_count = (count ($for_arr) > ($for_end-$for_start))? ($for_end-$for_start) : count ($for_arr);
# дозапись в вывод
for ($j = 0; $j < $for_count; $j ++) {
$for_string = $for_str; # временная переменная, которая позволяет заменять массивы
if (is_array ($for_arr)) {
foreach ($for_arr[$j] as $key => $value) {
$for_string = str_replace ("[[".$key."]]", $value, $for_string);
}
}
$for_string = str_replace ("[[id]]", (string) ($j+$for_start), $for_string);
$out_for [$str_num] = $for_string;
$str_num ++;
}
}
else {
$out_for[$str_num] = $out[$i];
$str_num ++;
}
}
if (isset ($out_for)) {
$out = $out_for;
}

# подстановка стандартных значений
if (!empty ($this->values)) {
foreach ($this->values as $key => $value) {
$out = str_replace ("{{".$key."}}", $value, $out);
}
}
# возврат массива с хтмл-содержимым

$centr_niz = 5;
$centr_verh = 5;
$left_banner = 5;
$links = 8;



# вывод переданного массива
function Output ($content) {
set_time_limit (6);
$content_count = count ($content);
for ($i = 0; $i < $content_count; $i ++) {
print $content [$i];
}
}

function ScriptDie ($str) {
//die ($str);
}

function RememberMyVisit () {
//print "<h1>Remember All</h1>";
/*
$query = "update users set last_visit = ".time ().", last_block = '".$this->block_get."', last_module = '".$this->module_get."', last_action = '".$this->action_get."' where id = ".$this->UserID;
$this->db->query ($query, __FILE__, __LINE__);
*/
}



function cache ($out_arr) {
if ($this->cache_time == 0) return false;
$path = $this->getCachePath ();
$ff = new FileFunctions ();
$path_dir = dirname ($path);
$ff->createDir ($path_dir);
$fp = fopen ($path, 'w');
foreach ($out_arr as $line) {
//$line = trim ($line). "\n";
$line .= "\r\n";
fputs ($fp, $line);
}
fclose ($fp);
return true;
}

function isCached () {
if ($this->cache_time == 0) return false;
if (!empty ($_POST)) return false;
$path = $this->getCachePath ();
if (!file_exists ($path)) return false;
$time = $_SERVER ['REQUEST_TIME'];
$new_after = $time - $this->cache_time;
if (filemtime ($path) > $new_after) {
return true;
}
return false;

}

function getCache () {
$path = $this->getCachePath ();
//print $path;
return array (file_get_contents ($path));
}

function getCachePath () {
global $host;
$path = 'cache/'.$host.'/html/';
$user_id = Security::getUserID ();
if (empty ($user_id)) $user_id = '0';
$path .= $user_id.'/'.urlencode ($_SERVER ['REQUEST_URI']);
return $path;
}
}

?>
Старый воин, мудрый воин!
MantroniX
На сайте с 17.05.2007
Offline
102
#1

код биржи

<?php

define('TRUSTLINK_USER',
'eff52d540fd7447777c2');
require_once($_SERVER['DOCUMENT_ROOT'].'/'.
TRUSTLINK_USER.'/trustlink.php');
$o['charset'] = 'cp1251';//кодировка сайта
$trustlink = new TrustlinkClient($o);
unset($o);
echo $trustlink->build_links();
?>

пробывал вставлять такой код в файл где исполняется пхп


# Код TrustLink

define('TRUSTLINK_USER', 'eff52d540fd7447777c2');
require_once($_SERVER['DOCUMENT_ROOT'].'/'.TRUSTLINK_USER.'/trustlink.php');
$o['force_show_code'] = false;
$o['host'] = $host;
$o['multi_site'] = true;
$trustlink = new TrustlinkClient($o);
if (false !== strpos(implode('', $out), '{{trustlink}}')){
$out = str_replace ("{{trustlink}}", $trustlink->build_links(), $out);
}

switch ($host) {
case 'orenburjec.ru':
$out = str_replace ("{orejec-trust}", $trustlink->build_links(), $out);

break;

default:
$out = str_replace ("{orenjec-trust}", $trustlink->build_links(), $out);

в шаблоне вставил метку {orejec-trust}

За ранее спасибо!

R
На сайте с 10.12.2010
Offline
2
#2

Ну и? метка спарсилась или нет? и не равно пишется вот так != а не !== если я правильно понял код

php+mysql+html Пишу парсеры. Продаю cms для сателитов, которая парсит новости и формирует готовый сайт за пару минут. icq:55-91-35 skype:r00we_home

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий