deeemm-cms /includes/build_list_content.php

Language PHP Lines 86
MD5 Hash 72cb39cf4e5a25075ec9c270263d77c9 Estimated Cost $1,114 (why?)
Repository https://bitbucket.org/mpercy/deeemm-cms View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
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
77
78
79
80
81
82
83
84
85
86
<?php

defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );



/*===========================================================================
Get title
===========================================================================*/
$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `table` = '$page'");
while ($sql_result = mysql_fetch_array($sql_query)){
	$list_page_title = $sql_result[category_lan_ . $language];
}

if (htmlspecialchars($_GET["id"], ENT_QUOTES) <> '' && $action !== 'edit' && $action !=='show_index'){

	//read template data
	$main = read_file($default_url . $templates_dir  . "list_article.tpl");

	//get article info from database
	$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$page` WHERE `id` = '$id'");
	while($sql_result = mysql_fetch_array($sql_query)){
		$main = str_replace('[var]article_image[/var]', $article_image, $main);
		$main = str_replace('[var]article_date[/var]', strftime("%a %d %b %y", strtotime($sql_result[1])), $main);
		$main = str_replace('[var]article_image[/var]', $article_image, $main);
		$main = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $main);
		$main = str_replace('[var]article_text[/var]', $sql_result[description_lan_ . $language], $main);
	}

} else {
	$main .= read_file($default_url . $templates_dir . "list_index.tpl");

	$first_article = true;
	$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . $page . "` ORDER BY `date` DESC");
	while($sql_result = @mysql_fetch_array($sql_query)){

  //get latest article (first article)
  if ($first_article) {
  	$list_content_main_article .= read_file($default_url . $templates_dir . "list_index_item.tpl");
  	$tool_tip = $sql_result[tool_tip_lan_ . $language];
  	$article_text = $sql_result[description_lan_ . $language];
  	
  	//replace template markers with data from database
  	$list_content_main_article = str_replace('[var]article_href[/var]', $list_item_href, $list_content_main_article);
  	$list_content_main_article = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $list_content_main_article);
  	
  	//show first item in entirety
  	$list_content_main_article = str_replace('[var]article_text[/var]', $article_text, $list_content_main_article);
  	$list_content_main_article = str_replace('[var]article_date[/var]', strftime("%A %d %B %Y", strtotime($sql_result[1])), $list_content_main_article);
  }

/*===========================================================================
Get previous articles
===========================================================================*/
  if (!$first_article) {
  	$list_index_previous_articles .= read_file($content);
  	$tool_tip = $sql_result[tool_tip_lan_ . $language];
  	$list_item_href = '<A class="list_index_item" title="' . $tool_tip . '" href="' .$default_url .'index.php?page=' . $page . '&amp;id=' . $sql_result[id] . '">';
  	$article_text = $sql_result[description_lan_ . $language];
  	//$article_text = preg_replace('/\n|\r|\n\r/','<BR>',$article_text); //convert crlf to <BR>
  
  	//replace template markers with data from database
  	$list_index_previous_articles = str_replace('[var]article_href[/var]', $list_item_href, $list_index_previous_articles);
  	$list_index_previous_articles = str_replace('[var]article_title[/var]', $sql_result[title_lan_ . $language], $list_index_previous_articles);
  	//this line for titles only
  	$list_index_previous_articles = str_replace('[var]article_text[/var]', '', $list_index_previous_articles);
  
  	//this line for truncated article text as well
  	//$list_index_previous_articles = str_replace('[var]article_text[/var]', balanceTags(truncate($article_text, 260)), $list_index_previous_articles);
  	$list_index_previous_articles = str_replace('[var]article_date[/var]', strftime("%A %d %B %Y", strtotime($sql_result[1])), $list_index_previous_articles);
  	if (!$article_text) {
  		$previous_articles = '';
  	} else {
  		$previous_articles = $lan[previous_articles];
  	}
  }

  $first_article = false;

	}// end while

	if($err=mysql_errno())return $err;

}

?>
Back to Top