Консультация № 178490
19.05.2010, 05:01
0.00 руб.
0 3 0
Здравствуйте, Уважаемые Эксперты. Есть сайт на CMS ArticleMS 2.0 (анг. версия). После добавления кода биржи для вывода ссылок, на сайте выскакивает ошибка:
Parse error: syntax error, unexpected '<' in /home/mylogin/public_html/code/articlems.php(679) : eval()'d code on line 2
2010-05-19 01:08:31 (MSD) / 2 Warning Cannot modify header information - headers already sent by (output started at /home/mylogin/public_html/code/articlems.php(679) : eval()'d code:2) /home/mylogin/public_html/code/articlems.php 57
Пробовал смотреть articlems.php в Notepad – каких либо не завершённых символов не заметил.
Прошу Вас помочь решить данную проблему. В приложении выкладываю полный код articlems.php


Приложение:
<?php
if (!defined('ARTICLEMS')) {
header('HTTP/1.0 403 Forbidden');
die;
}
/**
* Main board view
*
**/

//---Placeholder Classes---
$Category = new baseclass();
$Comments = new baseclass();

$Blocks = new baseclass();
$Page = new baseclass();
$Search = new baseclass();
$Plugin = new baseclass();
//--------------

class articlems extends articlemscore{

function executeAdmin(){

if (!defined('ARTICLEMS_ADMIN')) {
header('HTTP/1.0 403 Forbidden');
die;
}
$plugin = $_GET['a'];

if (!$plugin){
$plugin = 'admincp_home';
}
$this->admin_module = &$this;

$this->admin_output = $this->execute();

require "admin/templates/admincp_php.php";
$admincp_template = $this->readUrl("templates/admincp.tpl");
$this->update_time_exec();
$result = eval($this->parse_template_string($admincp_template, 'admin', 'admincp'));
$this->print_output($result, 1);
exit;
}

function print_output($output, $force_do_not_cache=0){

$this->db->close_connection();

if ($this->db_settings['cache_output'] and !$force_do_not_cache and !defined('ARTICLEMS_ADMIN')){ //never cache admin side

$fp = @fopen($this->db_settings['cache_file'], 'w');
@fwrite($fp, $output);
@fclose($fp);
}

header($this->output_header); //default is 'Content-Type:text/html; charset=UTF-8'
if ($force_do_not_cache){
header("Expires: Mon, 26 Jul 2004 05:00:00 GMT"); // Leave date set in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
}
echo $output;
exit;
}

function update_time_exec(){

global $time_start;
$time_end = explode(' ', microtime());
$time_end = $time_end[1] + $time_end[0];
$this->time_execute = number_format($time_end - $time_start, 2, '.', '');
}

function doTemplates($templateset, $templatename, $pluginname=''){
global $Profile;
global $Member;
global $Items;
global $Article;
global $Category;
global $Search;
global $Searchresults;
global $Blocks;
global $Page;
global $Plugin;
global $Plugins;
global $Comment;
global $Comment_items;
global $time_start;

if ($templateset){

if ($templateset == 'feeds'){
$this->output_header = "Content-type: text/xml; charset=utf-8";
$this->bypass_cms = 1;
}

if ($templateset == 'standalone'){

$Blocks->$templatename = $this->get_block_output($templateset, '', $templatename, $pluginname,null,2);
$this->output = $Blocks->$templatename;
}
elseif($templateset == 'articleview'){

$Blocks->$templatename = $this->get_block_output($templateset, '', $templatename,$pluginname, null, 2);
$this->output = $Blocks->$templatename;
}
else{
$this->output = $this->get_block_output($templateset, '', $templatename, $pluginname, null, 2);
}
}

if ($this->bypass_cms == 1){
$this->print_output($this->output);
exit;
}

$this->relpath = $this->relpath_main;
if ($this->Sections[$this->section_id]->state == SECTION_STATE_INTEGRATED){
$this->load_section(1);
$this->load_skin(1);
}

$this->update_time_exec();
if ($this->bypass_cms == 2){
$main = $this->output;
}
else{
$main = $this->get_block_output('universal', '', 'main', '', null, 2);
}

if (($this->Sections[$this->section_id]->state == SECTION_STATE_INTEGRATED_UNIVERSAL) and ($this->bypass_cms != 2)){
$this->load_section(1);
$this->load_skin(1);

$this->output = $main;
$this->update_time_exec();
$main = $this->get_block_output('universal', '', 'main', '', null, 2);

}

$this->update_time_exec();
$header = $this->get_block_output('universal', '', 'header', '', null, 2);

$this->update_time_exec();
$footer = $this->get_block_output('universal', '', 'footer', '', null, 2);

$this->print_output($header.$main.$footer);
}

function parse_template_string($string, $templateset='', $templatename=''){
global $Profile;
global $Member;
global $Items;
global $Page;
global $Media;

global $Category;
global $Blocks;
global $Searchresults;
global $Search;
global $Comment;
global $Comment_items;
global $Plugins;
global $Items;
global $Article;

$template_output = array();
$template_output['html'] = $this->escape_templates($string);

preg_match_all('/\$Blocks\-\>([a-zA-Z0-9_]*)/', $template_output['html'], $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[1]); $i++) {

$Blocks->$result[1][$i] = $this->get_block_output($templateset, $templatename, $result[1][$i],'');
if ($Blocks->$result[1][$i] === false){
$Blocks->$result[1][$i] = $this->get_block_output('universal', '', $result[1][$i],'');
}
}

preg_match_all('/\$Plugins\-\>([a-zA-Z0-9_]*)\-\>(block_[a-zA-Z0-9_]*)/', $template_output['html'], $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[1]); $i++) {

$plugin_name = $result[1][0];
$block_name = $result[2][0];

if (!isset($Plugins->{$plugin_name})){

if (isset($this->plugins[$plugin_name]) and $this->plugins[$plugin_name]['installed'] and $this->plugins[$plugin_name]['active']){
$p = 'plugin_'.$plugin_name;
$Plugins->{$plugin_name} = new $p($this);
}
else{ //plugin not active
continue;
}

}
$Plugins->$plugin_name->{$block_name} = $this->get_block_output($templateset, $templatename, $block_name, $plugin_name);
if ($Plugins->$plugin_name->{$block_name} === false){
$Plugins->$plugin_name->{$block_name} = $this->get_block_output('universal', '', $block_name, $plugin_name);
}

}

$this->errors_template = array();
$this->errors_template['name'] = $templatename;
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = $templateset;
$this->errors_template['type'] = 'html';
return ($this->formattemplate($templatename, $template_output['html']));
$this->errors_template['type'] = '';

}

function executeBrowse($block_name){

global $Blocks;
global $Plugins;

$this->doTemplates('browse',$block_name);

}

function executeMediaEdit(){
global $Blocks;
global $Plugins;
global $Items;
global $Media;



$media_items = $this->getMedia("media_id = ".intval($this->get['id'])." AND media_user_id = {$this->User->id} AND media_state = 1", '', 1);
$Media = $media_items[0];

if (!$Media){
return $this->permission_denied();
}

if ((($Media->type == 'image') and (!$this->perms->auth('allow_image_upload', 'media'))) or
(($Media->type != 'image') and (!$this->perms->auth('allow_file_upload', 'media')))){
return $this->permission_denied();
}
$Media->result = 0;
if ($this->post['submit']){

$Media->result = 1;

$q = $this->db->query("UPDATE {$this->pre}media SET
media_title = '{$this->post['title']}',
media_caption = '{$this->post['caption']}' WHERE media_id = ".intval($Media->id)." LIMIT 1");

$Media->title = stripslashes($this->post['title']);
$Media->caption = stripslashes($this->post['caption']);

}

$this->doTemplates('media','media_edit');
}

function executeMediaLibrary(){

global $Blocks;
global $Plugins;
global $Items;
global $Media;

if ($this->get['type'] == 'files'){
if (!$this->perms->auth('allow_file_upload', 'media')){
return $this->permission_denied();
}
}
else{
if (!$this->perms->auth('allow_image_upload', 'media')){
return $this->permission_denied();
}
}

if ($this->get['id']){
return $this->executeMediaEdit();
}

$_blockresult = $this->db->query("SELECT block_name, block_html, block_php FROM {$this->pre}blocks
WHERE block_name = 'item' AND block_active = 1 AND block_type = 1 AND block_set = 'media' AND block_parent_name = 'media' AND block_owner = '{$this->skin}'");

$_blockrow = $this->db->nqfetch($_blockresult);

$comment_items = $Comment->Items;
$start = 0;
$num = 10;
if (isset($this->get['page'])){
$start = $num * max(0, intval($this->get['page']-1));
}
$Items->start = $start;
$Items->count = 0;

$type = 'image';
if ($this->get['type'] == 'files'){
$type = 'file';
}

$q_count = $this->db->fetch("SELECT COUNT(*) AS allcount FROM {$this->pre}media WHERE
media_type = '$type' AND media_user_id = {$this->User->id} AND media_state = 1");

$Items->count = $q_count['allcount'];
$endpage = floor(max(0,$Items->count-1)/$num +1);
$this->Pagination->page_count = $endpage;


$media_items = $this->getMedia(" media_type = '$type' AND media_user_id = {$this->User->id} AND media_state = 1", '', "$start, $num");

$Items = new baseclass();
$Items->output = '';
foreach ($media_items as $Media){

$this->errors_template = array();
$this->errors_template['name'] = $_blockrow['block_name'];
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = 'media';

$this->errors_template['type'] = 'php';
$this->execute_hooks("media.media.item.php");
eval ($_blockrow['block_php']);
$this->errors_template['type'] = '';

$this->errors_template['name'] = $_blockrow['block_name'];
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = 'media';
$this->errors_template['type'] = 'html';
$this->execute_hooks("$block_set.$block_parent_name.item.html");

$r = eval($this->parse_template_string($_blockrow['block_html'], 'media', 'media'));

$this->errors_template['type'] = '';

$Items->output .= $r;
}

//------Upload File------
$this->upload_result = 0;
$Media = new baseclass();

if ($this->get['type'] == 'files'){

if (isset($this->files['file']['name'])){ //New Image Uploaded

$do_validation = 1;
$data = array();
$data['error'] = $this->skin_settings['articles_invalid_file_message'];
$data['filename'] = '';
$data['msg'] = '';

if ($this->files['file']['name']){ //if there is something in the image box..

$ext = strtolower(end(explode('.', $this->files['file']['name'])));
$this->Url->images_rel = 'uploads/files/';
$media = array();
$media['title'] = $this->post['title'];
if (!$media['title']){
$media['title'] = $this->files['file']['name'];
}
$media['caption'] = $this->post['caption'];
if (!$media['caption']){
$media['caption'] = $this->files['file']['name'];
}
$result = $this->upload_file('file', $this->files['file']['name'], $this->settings['file_max_size'], explode(';', $this->settings['file_allowed_extensions']), $media);

if (!$result){

$this->add_error_message($this->_reason . $this->skin_settings['articles_invalid_file_message'], 'file');
$this->updateok = 0;
$this->updateresult = $result;
}
else{ //uploaded OK
$new_media_item = $this->getMedia("media_id = {$result}", '', 1);
$Media = $new_media_item[0];

$this->upload_result = 1;
}
}
}
//-----/Upload File------
}
else{

if (isset($this->files['image']['name'])){ //New Image Uploaded

$do_validation = 1;
$data = array();
$data['error'] = $this->skin_settings['articles_invalid_image_message'];
$data['filename'] = '';
$data['msg'] = '';

if ($this->files['image']['name']){ //if there is something in the image box..

$ext = strtolower(end(explode('.', $this->files['image']['name'])));
$this->Url->images_rel = 'uploads/images/';
$media = array();
$media['title'] = $this->post['title'];
if (!$media['title']){
$media['title'] = $this->files['image']['name'];
}
$media['caption'] = $this->post['caption'];
if (!$media['caption']){
$media['caption'] = $this->files['image']['name'];
}
$result = $this->upload_image('image', $this->files['image']['name'], $this->settings['image_max_size'], explode(';', $this->settings['image_allowed_extensions']), $media);

if (!$result){

$this->add_error_message($this->skin_settings['articles_invalid_image_message'], 'image');
$this->updateok = 0;
$this->updateresult = $result;
}
else{ //uploaded OK
$new_media_item = $this->getMedia("media_id = {$result}", '', 1);
$Media = $new_media_item[0];

$this->upload_result = 1;
}
}
}
}
//-----/Upload Images------

$this->doTemplates('media','media');
}

function get_browse_articles($whereq, $orderq='', $limit=-1, $return_all=0, $section_id=-1){

global $Profile;
global $Member;
global $Items;
global $Page;

global $Category;
global $Blocks;
global $Searchresults;
global $Search;
global $Comment;
global $Comment_items;
global $Plugins;
global $Items;
global $Article;

$num = $this->skin_settings['articles_per_page'];
if ($this->get['fmt'] == 'rss'){
$num = $this->skin_settings['articles_per_feed'];
}

if ($limit > 0){
$num = $limit;
}
if (!isset($Items)){
$Items = new baseclass();
}
$start = 0;
if (isset($this->get['page'])){
$start = $num * max(0, intval($this->get['page']-1));
}
$Items->start = $start;
$Items->count = 0;

$articles = $this->getArticles($whereq, $orderq, "$start, $num", $return_all, $section_id, 1);

$Items->Articles = $articles[0];
$Items->count = $articles[1];
$Items->output = '';

$endpage = floor(max(0,$Items->count-1)/$num +1);
$this->Pagination->page_count = $endpage;

}

function get_block_cache_output(&$block_row){
global $Article;

$cache_settings = unserialize($block_row['block_cache_settings']);
if (! (isset($cache_settings['use_cache']) and ($cache_settings['use_cache'])) ){
return false;
}

if (($cache_settings['cache_for'] == 'guests') and ($this->User->id > 1)){
return false;
}

$cache_url_hash = '';
switch ($cache_settings['cache_type']){
case 'single': $cache_url_hash = ''; break;
case 'article': $cache_url_hash = intval($Article->id); break;
case 'user': $cache_url_hash = $this->User->id; break;
case 'url': $cache_url_hash = $this->url; break;
case 'custom': $cache_url_hash = eval('return "'.$cache_settings['cache_type_custom'].'";');
break;
default: break;
}

$q = $this->db->query("SELECT * FROM {$this->pre}block_cache WHERE
cache_block_id = {$block_row['block_id']} AND
cache_url_hash = '".md5($cache_url_hash)."' LIMIT 1");

if ($row = $this->db->nqfetch($q)){

$use_cache = 1;
if ($cache_settings['cache_expires'] == 1){
$time_diff = time() - strtotime($row['cache_last_update']);
$use_cache = ($time_diff < $cache_settings['cache_expires_seconds']);
}

if ($use_cache){

$saved_fields = array();
if ($cache_settings['cache_saved_vars']){

$saved_vars = unserialize($row['cache_stored_vars']);
if (is_array($saved_vars)){
foreach ($saved_vars as $index=>$val){
$this->{$index} = $val;
}
}
}

if ($cache_settings['cache_php']){
eval($cache_settings['cache_php']);
}
return $row['cache_output'];
}
}

return false;
}



function return_and_cache_block(&$block_row, $output){

global $Article;

$cache_settings = unserialize($block_row['block_cache_settings']);
$save_cache = ( (isset($cache_settings['use_cache']) and ($cache_settings['use_cache'])) );

if ($save_cache){
if ( !(($cache_settings['cache_for'] == 'guests') and ($this->User->id > 1)) ){

$cache_url_hash = '';
switch ($cache_settings['cache_type']){
case 'single': $cache_url_hash = ''; break;
case 'article': $cache_url_hash = intval($Article->id); break;
case 'user': $cache_url_hash = $this->User->id; break;
case 'url': $cache_url_hash = $this->url; break;
case 'custom': $cache_url_hash = eval('return "'.$cache_settings['cache_type_custom'].'";');
break;
default: break;
}

$saved_fields = array();
if ($cache_settings['cache_saved_vars']){
$saved_vars = str_replace("\r\n",'', $cache_settings['cache_saved_vars']);
$saved_vars = str_replace("\n\r",'', $saved_vars);
$saved_vars = str_replace("\r","\n", $saved_vars);
$saved_vars = explode("\n", $saved_vars);

foreach ($saved_vars as $saved_var){
$saved_fields[$saved_var] = $this->{$saved_var};
}

}

$q = $this->db->query("REPLACE INTO {$this->pre}block_cache SET
cache_block_id = {$block_row['block_id']},
cache_expiration_type = ".intval($cache_settings['cache_expires']).",
cache_output = '".real_addslashes($output)."',
cache_last_update = NOW(),
cache_stored_vars = '".real_addslashes(serialize($saved_fields))."',
cache_url_hash = '".md5($cache_url_hash)."'");
}
}

return $output;
}

function get_block_output($parentset, $parentname, $blockname, $pluginname, $_blockresult=null, $block_type=0){
global $Profile;
global $Member;
global $Items;
global $Page;
global $Article;
global $Category;
global $Blocks;
global $Searchresults;
global $Search;
global $Comment;
global $Comment_items;
global $Plugins;
global $Media;

if (!$_blockresult){

if (!$pluginname){
if (($parentset == 'universal') and ($parentname == 'universal')){
$_blockresult = $this->db->query("SELECT * FROM {$this->pre}blocks
WHERE block_active = 1 AND (block_set = 'universal' OR block_set = 'standalone' OR block_set = 'browse')AND block_name = '$blockname' AND block_owner = '{$this->skin}'
ORDER BY block_set='universal' DESC, block_set='standalone' DESC, block_set='browse' DESC LIMIT 1");
}
else{

$_blockresult = $this->db->query("SELECT * FROM {$this->pre}blocks
WHERE block_active = 1 AND block_set = '$parentset' AND block_parent_name = '$parentname' AND block_name = '$blockname' AND block_owner = '{$this->skin}' LIMIT 1");
}
}
else{
if (($parentset == 'universal') and ($parentname == 'universal')){
$_blockresult = $this->db->query("SELECT * FROM {$this->pre}blocks
WHERE block_name = '$blockname' AND block_active = 1 AND (block_set = 'universal' OR block_set = 'standalone' OR block_set = 'browse') AND block_owner = '_plugin_s{$this->section_id}_{$pluginname}'
ORDER BY block_set='universal' DESC, block_set='standalone' DESC, block_set='browse' DESC LIMIT 1");

}
else{
$_blockresult = $this->db->query("SELECT * FROM {$this->pre}blocks
WHERE block_name = '$blockname' AND block_active = 1 AND block_set = '$parentset' AND block_parent_name = '$parentname' AND block_owner = '_plugin_s{$this->section_id}_{$pluginname}' LIMIT 1");
}
}
}

if ($_blockrow = $this->db->nqfetch($_blockresult)){

$real_parent_name = $_blockrow['block_parent_name'];
$parentset = $_blockrow['block_set'];
$parentname = $_blockrow['block_parent_name'];

$this->Block = new baseclass();
$block_settings = unserialize($_blockrow['block_settings']);
$custom_fields = $block_settings['custom_fields'];
$oldblock = null;
if ($custom_fields){
$customization = $block_settings['customization'];
$this->Block->custom_fields = $customization;
$this->get_custom_fields($custom_fields, $this->Block);

if(version_compare(phpversion(), '5.0') >= 0){
$oldblock = clone($this->Block);
}
else{
$oldblock = $this->Block;
}
}

$cache_settings = unserialize($_blockrow['block_cache_settings']);
if (isset($cache_settings['use_cache']) and ($cache_settings['use_cache'])){
$result = $this->get_block_cache_output($_blockrow);

if ($result !== false){
return $result;
}
}

if ($block_type == 2){
$parentname = $blockname;
}

if ($pluginname){
if (method_exists($Plugins->{$pluginname}, "exec_{$blockname}")){
$Plugins->{$pluginname}->{"exec_{$blockname}"}();
}
}
$this->errors_template = array();
$this->errors_template['name'] = $_blockrow['block_name'];
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = $_blockrow['block_parent_set'];

if ($real_parent_name){
$this->execute_hooks("$parentset.$parentname.$blockname.php"); //articles.submit.message.php
}
else{
$this->execute_hooks("$parentset.$blockname.php"); //articles.submit.php
}

$this->errors_template['type'] = 'php';
eval ($_blockrow['block_php']);
if (isset($this->_message)){
$temp = $this->_message;
unset($this->_message);
return $this->return_and_cache_block($_blockrow, $temp);
}
$this->errors_template['type'] = '';

if (($parentset == 'browse' or $parentset == 'search') and ($real_parent_name == '') and ($blockname != 'item')){

$this->items_loop($parentset, $blockname, $_blockrow['block_owner']);
}

if (($parentset == 'feeds' ) and ($parentname == 'comment_feed') and ($blockname != 'item')){
$this->comment_items_loop('feeds', 'comment_feed');
}
if ($parentname){
$this->execute_hooks("$parentset.$parentname.$blockname.html"); //articles.submit.ajaxupload.html
}
else{
$this->execute_hooks("$parentset.$blockname.html"); //articles.submit.html
}
$block_html = $this->escape_templates($_blockrow['block_html']);

preg_match_all('/\$Blocks\-\>([a-zA-Z0-9_]*)/', $block_html, $result, PREG_PATTERN_ORDER); //blocks within this block
for ($i = 0; $i < count($result[1]); $i++) {

if (isset($Blocks->$result[1][$i]) and $Blocks->$result[1][$i] == '__RECURSION__'){ //recursive inclusion
$Blocks->$result[1][$i] = '<b>TEMPLATE WARNING: RECURSIVE INCLUSION OF {$Blocks->'.htmlentities($result[1][$i], ENT_COMPAT, 'UTF-8').'} IN {$Blocks->'.htmlentities($_blockrow['block_name'], ENT_COMPAT, 'UTF-8').'}</b>';
}
else{
$Blocks->$result[1][$i] = '__RECURSION__'; //prevent recursive includes
$Blocks->$result[1][$i] = $this->get_block_output($parentset, $parentname, $result[1][$i],'');


if ($Blocks->$result[1][$i] === false){
$Blocks->$result[1][$i] = '__RECURSION__'; //prevent recursive includes
$Blocks->$result[1][$i] = $this->get_block_output('universal', 'universal', $result[1][$i],'');

if ($Blocks->$result[1][$i] === false){ //block not found
$Blocks->$result[1][$i] = '<!-- TEMPLATE NOTICE: {$Blocks->'.$result[1][$i].'} not found-->';
}
}
}

if ($this->bypass_parent){
$this->bypass_parent = 0;
return $this->return_and_cache_block($_blockrow, $Blocks->$result[1][$i]);
}
}

preg_match_all('/\$Plugins\-\>([a-zA-Z0-9_]*)\-\>([a-zA-Z0-9_]+)/', $block_html, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[1]); $i++) {

$plugin_name = $result[1][0];
$block_name = $result[2][0];

if (!isset($Plugins->{$plugin_name})){

if (isset($this->plugins[$plugin_name]) and $this->installed_plugins[$plugin_name] and $this->plugins[$plugin_name]){
$p = 'plugin_'.$plugin_name;
$Plugins->{$plugin_name} = new $p($this);
}
else{ //plugin not active
continue;
}

}

if (isset($Plugins->$plugin_name->$block_name) and $Plugins->$plugin_name->$block_name == '__RECURSION__'){ //recursive inclusion
$Plugins->$plugin_name->$block_name = '<b>TEMPLATE WARNING: RECURSIVE INCLUSION OF {$Plugins->'.htmlentities($plugin_name, ENT_COMPAT, 'UTF-8').htmlentities($block_name, ENT_COMPAT, 'UTF-8').'} IN '.htmlentities($_blockrow['block_name'], ENT_COMPAT, 'UTF-8').'}</b>';
}
else{
$Plugins->$plugin_name->$block_name = '__RECURSION__'; //prevent recursive includes

$Plugins->$plugin_name->$block_name = $this->get_block_output($parentset, $parentname, $block_name, $plugin_name);

if ($Plugins->$plugin_name->$block_name === false){

$Plugins->$plugin_name->$block_name = '__RECURSION__'; //prevent recursive includes
$Plugins->$plugin_name->$block_name = $this->get_block_output('universal', 'universal', $block_name, $plugin_name);
if ($Plugins->$plugin_name->$block_name === false){
$Plugins->$plugin_name->$block_name = '<!-- TEMPLATE NOTICE: {$Plugins->'.$plugin_name.'->'.$block_name.'} not found-->';
}
}
}

if ($this->bypass_parent){
$this->bypass_parent = 0;
return $this->return_and_cache_block($_blockrow, $Plugins->$plugin_name->$block_name);
}
}

if ($custom_fields){
$this->Block = &$oldblock;
}

$this->errors_template['name'] = $_blockrow['block_name'];
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = $_blockrow['block_parentset'];
$this->errors_template['type'] = 'html';

if ($real_parent_name){
$this->execute_hooks("$parentset.$parentname.$blockname.html"); //articles.submit.ajaxupload.php
}
else{
$this->execute_hooks("$parentset.$blockname.html"); //articles.submit.php
}
$r = eval($this->formattemplate('Block_'.$_blockrow['block_name'], $block_html));
$this->errors_template['type'] = '';
return $this->return_and_cache_block($_blockrow, $r);

}
else{
return false;
}
}

function executeDefault($a='home'){

$this->doTemplates('default',$a);
}

function executePage($page=''){

global $Blocks;
global $Page;
global $Comment;
global $Comment_items;
global $Plugins;

$result = $this->db->query("SELECT page_id, page_text FROM {$this->pre_section}pages
WHERE page_url = '".$this->get['p']."' AND page_active = 1");

if ($row = $this->db->nqfetch($result)){ //Module
$Page = $this->PageTree[$row['page_id']];
$Page->text = $row['page_text'];

$Comment->output = '';
if ($Page->allow_comments){
$this->executeComments($Page->id, 'pages');
}

if ($Page->sets['includeincms'] == '0'){ //Display Outside of CMS

$this->bypass_cms = 2;
}
}
else{ //page not found
$this->executeDefault('notfound');
return;
}

$this->doTemplates('default','page');
}

function executeInit(){
global $Profile;
global $Member;
global $Items;
global $Article;
global $Category;
global $Blocks;
global $Searchresults;
global $Search;
global $Comment;
global $Comment_items;
global $Plugins;

$this->errors_template = array();
$this->errors_template['name'] = 'init';
$this->errors_template['skin'] = $this->skin;
$this->errors_template['parentset'] = 'universal';

$this->errors_template['type'] = 'php';
$this->get_block_output('universal', '', 'init', '',null, 2);
$this->errors_template['type'] = '';
}

function executeLogin($a='login'){

$s = '';
if (isset($this->get['s'])){
$s = $this->get['s'];
}
$a = $this->do_login($s);

$this->doTemplates('login',$a);
}

function executePwreset(){

$this->pwreset_result = 0;
$this->pwreset_resultstring = '';

if ((isset($this->get['confirm'])) and ($this->get['confirm'] == 1)){

$q = $this->db->query("SELECT * FROM {$this->pre}users WHERE user_name = '{$this->get['username']}' AND user_id > 1 LIMIT 1");

if ($row = $this->db->nqfetch($q)){

if ( substr($row['user_password'], 0, 8) == stripslashes($this->get['pw'])){


$this->Recipient = new UserClass($this);
$this->_getUser($row, $this->Recipient);


$this->Recipient->url_password_reset = $this->settings['site_location'].$this->Url->pwreset.'?confirm=1&username='.urlencode($row['user_name']).'&pw='.urlencode(substr($row['user_password'], 0, 8));

$this->Recipient->password = substr(md5($row['user_password']),0,8);

$q = $this->db->query("UPDATE {$this->pre}users SET user_password = '".real_addslashes(md5($this->Recipient->password))."' WHERE user_id = '{$this->Recipient->id}' LIMIT 1");

$this->send_email('pwreset_done', $this->Recipient->email, 1); //force send now

$this->new_password = $this->Recipient->password;
$this->pwreset_result = 2;
$this->pwreset_resultstring = 'RESET_DONE';
}
else{
$this->pwreset_result = -2;
$this->pwreset_resultstring = 'RESET_INVALID_CODE';
}
}
else{
$this->pwreset_result = -2;
$this->pwreset_resultstring = 'RESET_INVALID_CODE';
}

}
else{
if ($this->post['submit'] and ($this->post['user_name'] or $this->post['user_email'])){

if ($this->post['user_name']){
$q = $this->db->query("SELECT * FROM {$this->pre}users WHERE user_name = '{$this->post['user_name']}' AND user_id > 1 LIMIT 1");
}
else{
$q = $this->db->query("SELECT * FROM {$this->pre}users WHERE user_email = '{$this->post['user_email']}' AND user_id > 1 LIMIT 1");
}

if ($row = $this->db->nqfetch($q)){

$this->Recipient = new UserClass($this);
$this->_getUser($row, $this->Recipient);

$this->Recipient->url_password_reset = $this->settings['site_location'].$this->Url->pwreset.'?confirm=1&username='.urlencode($row['user_name']).'&pw='.urlencode(substr($row['user_password'], 0, 8));

$this->send_email('pwreset_confirm', $this->Recipient->email, 1); //force send now

$this->pwreset_result = 1;
$this->pwreset_resultstring = 'RESET_CONFIRM';
}
else{
$this->pwreset_result = -1;
$this->pwreset_resultstring = 'RESET_NO_USER_FOUND';
}
}
}

$this->doTemplates('login','pwreset');
}

function executeProfile(){

global $Profile;
global $Plugins;
$Profile = new baseclass();
$s = $this->get['p'];

$match = array();
preg_match("/([0-9]+)$/i",$s, $match);

$Profile->id = intval($match[0]);

if ($Profile->id > 1){
$Profile->User = new baseclass();
$Profile->user = $this->db->fetch("SELECT * FROM {$this->pre}users WHERE user_id = '$Profile->id'");
$this->_getUser($Profile->user, $Profile->User);

$this->doTemplates('members','profile');

}
else{
$this->doTemplates('default','notfound');
}
}

function executeMemberList(){

global $Items;
global $Member;
global $Plugins;

$Member = new userclass($this);

$start = 0;
if (isset($this->get['start'])){
$start = max(intval($this->get['start']),0);
}
$num = $this->skin_settings['members_per_page'];
$start = 0;
if (isset($this->get['page'])){
$start = $num * max(0, intval($this->get['page']-1));
}

$orderq = 'user_id';
$orderdir = 'ASC';
if ( (isset($this->get['sort'])) and ($this->get['sort'] == 'article_count')){

$column = 'user_article_count';
if ($this->section_id > 1){
$column = 'user_article_count_s'.$this->section_id;
}

$orderq = $column;
$orderdir = 'DESC';
}
if ( (isset($this->get['sort'])) and ($this->get['sort'] == 'name')){
$orderq = 'user_name';
}

if ( (isset($this->get['dir'])) and ($this->get['dir'] == 'asc')){
$orderdir = 'ASC';
}
elseif ( (isset($this->get['dir'])) and ($this->get['dir'] == 'desc')){
$orderdir = 'DESC';
}

$listcount = $this->db->fetch("SELECT COUNT(*) AS allcount FROM {$this->pre}users WHERE user_amsgroup != 6");
$listq = $this->db->query("SELECT * FROM {$this->pre}users WHERE user_amsgroup != 6 AND user_id > 1 ORDER BY $orderq $orderdir LIMIT $start, {$this->skin_settings['members_per_page']}");

if (!isset($Items)){
$Items = new baseclass();
}
$Items->output = '';
$Items->count = $listcount['allcount']-1; //everyone except guest

$i = 0;
while ($row = $this->db->nqfetch($listq)){
$i++;
$user = $this->db->fetch("SELECT * FROM {$this->pre}users WHERE user_id = '{$row['user_id']}'");
$this->_getUser($user, $Member);

$Items->index = $i+$start;
$_blockrow = $this->db->fetch("SELECT block_name, block_html, block_php FROM {$this->pre}blocks
WHERE block_name = 'item' AND block_active = 1 AND block_type = 1 AND block_set = 'members' AND block_parent_name = 'members' AND block_owner = '{$this->skin}'");

$this->execute_hooks('members.members.item.php');
eval ($_blockrow['block_php']);
$this->execute_hooks('members.members.item.html');
$r = eval($this->parse_template_string($_blockrow['block_html'], 'members', 'members'));
$Items->output .= $r;
}

$this->Pagination->page_count = floor(max(0,$Items->count-1)/$this->skin_settings['members_per_page'] +1);

$this->doTemplates('members','members');

}

function executeVerification(){

$this->verification_result = 0;
if ( (isset($this->get['id'])) and (intval($this->get['id']) > 1)){

$NewUser = $this->getUser("user_id = ".intval($this->get['id'])."");

if ($NewUser){

$verification_code = $NewUser->verification_code;

if ($NewUser->row['user_amsgroup'] != 1){ //allready verified
$this->verification_result = 2;
}
else{
if ((isset($this->get['verify'])) and ($verification_code == $this->get['verify'])){
$q = $this->db->query("UPDATE {$this->pre}users SET user_amsgroup = '".intval($this->default_group_id)."' WHERE user_id = '".intval($this->get['id'])."' LIMIT 1");
$this->verification_result = 1;
}
else{
$this->verification_result = 0;
}
}
}
else{
$this->verification_result = 0;
}
}
else{
$this->verification_result = 0;
}
$this->doTemplates('login','verification');
}

function executeEmailUnsubscribe(){

$this->unsubscribe_result = 0;
if ( (isset($this->get['id'])) and (intval($this->get['id']) > 1)){

$NewUser = $this->getUser("user_id = ".intval($this->get['id'])."");

if ($NewUser){

$verification_code = $NewUser->verification_code;

if ((isset($this->get['pw'])) and ($verification_code == $this->get['pw'])){

if (isset($this->get['type'])){

$this->unsubscribe_result = $this->get['type'];

switch ($this->get['type']){
case 'news': $NewUser->settings['email_subscribe_newsletter'] = 0; break;
case 'approve': $NewUser->settings['email_subscribe_approve'] = 0; break;
case 'decline': $NewUser->settings['email_subscribe_reject'] = 0; break;
case 'contact': $NewUser->settings['email_allow_contact'] = 0; break;
case 'moderate': $NewUser->settings['email_subscribe_moderate'] = 0; break;
case 'comments': $NewUser->settings['email_subscribe_comments'] = 0; break;
default: $this->unsubscribe_result = 0;
}

if ($this->unsubscribe_result){
$this->db->query("UPDATE {$this->pre}users SET
user_settings = '".real_addslashes(serialize($NewUser->settings))."'
WHERE user_id = {$NewUser->id} LIMIT 1");
}
}
}
else{
$this->unsubscribe_result = 0;
}
}
else{
$this->unsubscribe_result = 0;
}
}
else{
$this->unsubscribe_result = 0;
}

$this->doTemplates('preferences','unsubscribe');

}

function executeUserPreferences(){

global $Profile;
global $Plugins;

if ($this->perms->auth('is_guest')){
return $this->permission_denied();
}

if ( (!isset($this->get['penname'])) or (intval($this->get['penname']) == $this->User->id)){

$Profile->User = $this->getUser('user_id = '.$this->User->id);
}
else{
$Profile->User = $this->getUser('user_id = '.intval($this->get['penname']));
if ($Profile->User->parent_id != $this->User->id){ //this penname does not belong to current user
if (!$this->perms->auth('is_admin')){ //only admin can edit other users
return $this->permission_denied();
}
}
}

$this->updateok = 0;
$this->updateresult = '';
$this->error_messages = array();

if (isset($this->post['submit'])){

//only valid for main user
$Profile->User->settings['email_subscribe_newsletter'] = ( (isset($this->post['email_subscribe_newsletter'])) and ($this->post['email_subscribe_newsletter']))? 1:0;

$Profile->User->collaboration_model = $this->settings['collaboration_model'];
switch ($this->post['collaboration_model']){
case 'closed': $Profile->User->collaboration_model = 'closed'; break;
case 'moderated': $Profile->User->collaboration_model = 'moderated'; break;
case 'open': $Profile->User->collaboration_model = 'open'; break;
}

//valid for all pennames
$Profile->User->preferences['email_subscribe_approve'] = ( (isset($this->post['email_subscribe_approve'])) and ($this->post['email_subscribe_approve']))? 1:0;
$Profile->User->preferences['email_subscribe_reject'] = ( (isset($this->post['email_subscribe_reject'])) and ($this->post['email_subscribe_reject']))? 1:0;
$Profile->User->preferences['email_subscribe_comments'] = ( (isset($this->post['email_subscribe_comments'])) and ($this->post['email_subscribe_comments']))? 1:0;
$Profile->User->preferences['email_subscribe_moderate'] = ( (isset($this->post['email_subscribe_moderate'])) and ($this->post['email_subscribe_moderate']))? 1:0;

$Profile->User->preferences['collaboration_model'] = $Profile->User->collaboration_model;
$Profile->User->settings['email_allow_contact'] = ( (isset($this->post['email_allow_contact'])) and ($this->post['email_allow_contact']))? 1:0;

$prefs = unserialize($Profile->User->row['user_preferences']);
if (!is_array($prefs)){
$prefs = array();
}
$prefs[$this->section_id] = $Profile->User->preferences;

if (!$this->error_messages){
$this->db->query("UPDATE {$this->pre}users SET
user_settings = '".real_addslashes(serialize($Profile->User->settings))."',
user_preferences = '".real_addslashes(serialize($prefs))."'
WHERE (user_id = {$Profile->User->main_account_id} OR user_parent_id = {$Profile->User->main_account_id})");

$this->_getUser($this->db->fetch("SELECT * FROM {$this->pre}users WHERE user_id = {$Profile->User->id}"), $Profile->User);

$this->updateok = 1;
$this->updateresult = 'Settings Updated';
}
else{
$Profile->User->email_subscribe_reject = $Profile->User->preferences['email_subscribe_reject'];
$Profile->User->email_subscribe_approve = $Profile->User->preferences['email_subscribe_approve'];
$Profile->User->email_subscribe_comments = $Profile->User->preferences['email_subscribe_comments'];
$Profile->User->email_subscribe_moderate = $Profile->User->preferences['email_subscribe_moderate'];
$Profile->User->email_allow_contact = $Profile->User->settings['email_allow_contact'];
$Profile->User->email_subscribe_newsletter = $Profile->User->settings['email_subscribe_newsletter'];
}
}

$this->doTemplates('preferences','userpreferences');
}

function executeUserCP(){

global $Profile;
global $Plugins;

if ($this->perms->auth('is_guest')){
return $this->permission_denied();
}

if ( (!isset($this->get['penname'])) or (intval($this->get['penname']) == $this->User->id)){

$Profile->User = $this->getUser('user_id = '.$this->User->id);
}
else{
$Profile->User = $this->getUser('user_id = '.intval($this->get['penname']));
if ($Profile->User->parent_id != $this->User->id){ //this penname does not belong to current user
if (!$this->perms->auth('is_admin')){ //only admin can edit other users
return $this->permission_denied();
}
}
}

$this->updateok = 0;
$this->updateresult = '';
$this->error_messages = array();

//---Pennames------------------------------
$this->updateok_penname = 0;
$this->error_messages_penname = array();
if (isset($this->post['submit_penname'])){
$username = htmlentities(trim($this->post['penname']), ENT_COMPAT, 'UTF-8');

if (strlen($username)< $this->skin_settings['registration_minimum_username_length']) {
$this->error_messages_penname[] = array($this->skin_settings['registration_minimum_username_length_m'], 'penname');
}

$exists = $this->db->fetch("SELECT user_id FROM {$this->pre}users WHERE REPLACE(LOWER(user_name), ' ', '')='" . str_replace(' ', '', strtolower($username)) . "'");
if ($exists) {
$this->error_messages_penname[] = array($this->skin_settings['registration_duplicate_name_m'], 'penname');
}

if (!$this->error_messages_penname){
if (!$this->db->query("INSERT INTO {$this->pre}users set
user_name = '$username',
user_parent_id = {$Profile->User->main_account_id},
user_ip = INET_ATON('".$this->getIp()."'),
user_registered = NOW(),
user_password = '',
user_amsgroup = {$Profile->User->group_id},
user_referral = 0,
user_email = '{$Profile->User->email}'")){

echo mysql_error();
}
$this->updateok_penname = 1;
}
}
if (isset($this->post['delete_penname'])){

}
//---/Pennames-----------------------------

if (isset($this->post['submit'])){

//user cannot change his email if email verification is required.
if ($this->settings['email_verification']){
$email = $Profile->User->email;
}
else{
if (isset($this->post['user_email'])){
$email = $this->post['user_email'];

if (!$this->validate_email($email)){
$this->add_error_message($this->skin_settings['usercp_invalid_email_m'], 'user_email');
}
}
else{
$email = $Profile->User->email;
}
}
$about = (isset($this->post['user_about'])? $this->post['user_about']: $Profile->User->about);


$homepage = (isset($this->post['user_homepage'])? $this->post['user_homepage']: $Profile->User->homepage);

$result = 1;

if ( (isset($this->post['user_birthday_year'])) and (isset($this->post['user_birthday_month'])) and (isset($this->post['user_birthday_day']))){
$user_birthday = $this->post['user_birthday_year'] . '-' . $this->post['user_birthday_month'] . '-' . $this->post['user_birthday_day'];
}
else{
$user_birthday = '0000-00-00';
}

if ( ($user_birthday != '0000-00-00') and !checkdate($this->post['user_birthday_month'], $this->post['user_birthday_day'], $this->post['user_birthday_year'])) {
$this->add_error_message($this->skin_settings['usercp_invalid_birthday_m'], 'user_birthday_year');
$this->updateok = 0;
}

//get all custom fields
$this->get_custom_fields($this->skin_settings['usercp_custom_fields'], $Profile->User, 1);

if (isset($this->post['user_bio'])){


if ($this->skin_settings['usercp_bio_tags'] != 'ALL'){
$user_bio = strip_tags($this->safehtml->parse(stripslashes($this->post['user_bio'])), $this->skin_settings['usercp_bio_tags']);
}
else{
if ($this->skin_settings['usercp_bio_filter_unsafe']){
$user_bio = stripslashes($this->post['user_bio']);
}
else{
$user_bio = $this->safehtml->parse(stripslashes($this->post['user_bio']));
}
}

$user_bio = $this->nl2br($user_bio);

if (($this->skin_settings['usercp_bio_length_max'] > 0) and (strlen($user_bio) > $this->skin_settings['usercp_bio_length_max'])){
$this->add_error_message($this->skin_settings['usercp_bio_message'], 'user_bio');
}
elseif (($this->skin_settings['usercp_bio_length_min'] > 0) and (strlen($user_bio) < $this->skin_settings['usercp_bio_length_max'])){
$this->add_error_message($this->skin_settings['usercp_bio_message'], 'user_bio');
}
}

//check custom submission settings
$this->errors_template = array();
$this->errors_template['name'] = 'USERCP SETTINGS';
$this->errors_template['skin'] = '';
$this->errors_template['parentset'] = 'ADMIN';
$this->errors_template['type'] = 'php';
eval($this->skin_settings['usercp_custom_settings']);
$this->errors_template['type'] = '';

if (!$this->error_messages){
$this->db->query("UPDATE {$this->pre}users SET
user_email = '$email',
user_custom_fields = '".real_addslashes(serialize($Profile->User->custom_fields))."',
user_bio = '".real_addslashes($user_bio)."',
user_birthday = '".$user_birthday."',
user_settings = '".real_addslashes(serialize($Profile->User->settings))."',
user_homepage = '$homepage' WHERE user_id = {$Profile->User->id} LIMIT 1");


$this->_getUser($this->db->fetch("SELECT * FROM {$this->pre}users WHERE user_id = {$Profile->User->id}"), $Profile->User);

$this->updateok = 1;
$this->updateresult = 'Settings Updated';
}

Обсуждение

Неизвестный
19.05.2010, 08:28
общий
ошибка на строке:
eval ($_blockrow['block_php']);
?

похоже, $_blockrow['block_php'] у Вас начинается с <?рнр

можно так:
eval ('?>' . $_blockrow['block_php']);
Неизвестный
19.05.2010, 16:41
общий
Салун Александр Александрович:
Как известно, ф-я eval вычисляет строку как PHP код. Соответственно, причина обоих сообщений — в коде, передаваемом для выполнения в функцию eval. Этот код читается из базы данных.
Попробуйте способ, предложенный экспертом HookEst. Если первое сообщение исчезло — причина угадана верно.
Второе сообщение — код, выполняемый в eval($_blockrow['block_php']) производит какой-то вывод, помимо заголовков. Все заголовки должны передаваться клиенту до каких-либо данных. Опять же, проверьте, какой код читается в $_blockrow['block_php'] из базы данных.
Неизвестный
19.05.2010, 18:33
общий
Цитата: 119055
Строку заменил. Первое сообщение исчезло. Вместе с этим все пункты меню стали отображаться некорректно (на странице отображается код вместо шаблона).

Это означает, что причина не была угадана верно (это ведь было всего лишь предположение, поскольку полных данных для анализа у нас нет). Добавление '?>' в начале строки привело к выходу из режима PHP-интерпретатора (PHP выполняет только код между <?php и ?>, все остальное передается клиенту "как есть"), поэтому и стал "отображаться код вместо шаблона". Нужно смотреть, что именно передается в eval, а не гадать.

Цитата: 119055
И как проверить, какой код читается в $_blockrow['block_php'] из базы данных?

1. воспользоваться PHPMyAdmin и посмотреть содержимое базы. Можно также скопировать запрос из скрипта, выполнить в PHPMyAdmin и посмотреть результат.
2. добавить в скрипт отладочный вывод - ну и пусть, что содержимое страницы временно будет испорчено - зато Вы увидите значения переменных. Это не самый удобный способ, зато не требуется дополнительных программных средств.
3. выполнить скрипт в отладчике (установить точку прерывания, протрассировать, посмотреть значения переменных).
Форма ответа