- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
<?php
require_once('global.php');
$id = $_GET['id'];
if( !$lore_system->db->id_exists( $id, 'lore_articles') )
{
$lore_system->te->assign('error_message', 'invalid_article');
$lore_system->te->display('error_message.tpl');
exit;
}
if( !$lore_db_interface->article_is_published( $id ) )
{
$lore_system->te->assign('error_message', 'article_not_published');
$lore_system->te->display('error_message.tpl');
exit;
}
$action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : 'article';
switch( $action )
{
case 'print':
$article = $lore_db_interface->get_article_info( $id );
$article['comments'] = $lore_db_interface->get_article_comments( $id );
$lore_system->te->assign('category_path', $lore_db_interface->get_category_path( $article['category_id'] ));
$lore_system->te->assign('article', $article);
$lore_system->te->display('article_print.tpl');
break;
case 'article':
if( !@in_array( $id, $lore_user_session->session_vars['viewed_articles'] ) )
{
$lore_db_interface->increment_article_views( $id );
$lore_user_session->session_vars['viewed_articles'][] = $id;
}
$article = $lore_db_interface->get_article_info( $id );
$article['comments'] = $lore_db_interface->get_article_comments( $id );
$article['num_comments'] = count($article['comments']);
$article['attachments'] = $lore_db_interface->get_article_attachments( $id );
$article['allow_comments'] = $lore_db_interface->can_comment_on_article( $id );
$article['related_articles'] = $lore_db_interface->get_related_articles( $id );
if( $lore_user_session->has_article_write_permission( $id ) )
{
$article['display_edit_link'] = true;
}
if( $lore_system->settings['enable_glossary_popups'] )
{
$glossary_terms = $lore_db_interface->get_glossary_terms();
if( count($glossary_terms) )
{
$term_html = array();
$html_tags = array();
$term_c = 0;
// strip out HTML tags first
@preg_match_all("/<[^>]+>/", $article['content'], $matches);
for( $i = 1; $i < count($matches[0]); $i++ )
{
// save html tag for later
$html_tags[$i] = $matches[0][$i];
// parse in placeholder
$article['content'] = str_replace( $matches[0][$i], "{{h$i}}", $article['content']);
}
foreach( $glossary_terms AS $term )
{
// Add "i" (NOT case sensitive) modifier to regular expression if necessary
$case = ( $term['case_sensitive'] ) ? '' : 'i';
$term['definition'] = ereg_replace("[\n\r]", '', $term['definition']);
$lore_system->te->assign('term', htmlspecialchars(str_replace("'", "\\'", $term['term'])) );
guest 05.03.2009 18:25 # 0
ЗЫ. а пхп массивы от единицы нумеруюцо?