Pith - miter
miter/front/quote.php [3.3 kb]
Modified: 17:48:02 114 026 (11 Jul 026)
14 Days Ago
<?php
echo "<div class=\"quote_container\">\n";

$safe_m_link = $m_link ?? '';

$quote_link  = str_replace('index.php?m=', 'miters/', $safe_m_link);
$quote_link  = $quote_link . '.txt';

if (file_exists($quote_link)) {
	$quote_arc 	 = file($quote_link, FILE_IGNORE_NEW_LINES);
	$quote_data  = $quote_arc[0] ?? '';
	$quote_link  = $quote_arc[1] ?? '';
	$quote_img   = $quote_arc[2] ?? '';
	$quote_keys  = $quote_arc[3] ?? '';
	$quote_odate = $quote_arc[4] ?? '';
	$quote_gdate = $quote_arc[5] ?? '';
	$quote_udate = $quote_arc[6] ?? '';
	
	$quote = htmlspecialchars($quote_data, ENT_QUOTES, 'UTF-8');
	$quote = str_replace('&#039;', '\'', $quote); // dumb solution
	$quote = str_replace(['&lt;br&gt;', '&lt;br /&gt;'], '<br>', $quote);
	$quote = preg_replace('/(?<!\w)#([0-9a-zA-Z]+)/m', '<a href="index.php?q=$1">#$1</a>', $quote);
	$quote = preg_replace('#\[b\](.*?)\[/b\]#', '<b>$1</b>', $quote);
	$quote = preg_replace('#\[i\](.*?)\[/i\]#', '<i>$1</i>', $quote);
	$quote = preg_replace('#\[u\](.*?)\[/u\]#', '<u>$1</u>', $quote);
	$quote = preg_replace('#\[s\](.*?)\[/s\]#', '<s>$1</s>', $quote);
	$quote = preg_replace('#\[img\](.*?)\[/img\]#', '<a href="$1" target="_blank"><img src="$1"></a>', $quote);
	$quote = preg_replace('#\[url\](.*?)\[/url\]#', '<a href="$1" target="_blank">$1</a>', $quote);
	$quote = str_replace('[hr]', '<hr />', $quote);
	
	if (substr($quote, 0, 4) === '&gt;') {
		$quote = preg_replace('/&gt;([^<]*)/m', '<span class="green_text">&gt;$1</span>', $quote, 1);
	}
	$quote = preg_replace('/<br \/>&gt;([^<]*)/m', '<br><span class="green_text">&gt;$1</span>', $quote);
	
	$quote_url_scheme = parse_url($safe_m_link, PHP_URL_SCHEME);
	$quote_url_host = parse_url($safe_m_link, PHP_URL_HOST);
	$quote_user_file = $quote_url_scheme . '://' . $quote_url_host . '/user/user.xml';
	
	$quote_user_username = '';
	if (file_exists($quote_user_file)) { 
		$quote_user_get = simplexml_load_file($quote_user_file);

		if ($quote_user_get !== false) {
			$quote_user_array = $quote_user_get->xpath("/miter/user[@id='probe']");
			if (!empty($quote_user_array)) {
				$quote_user_username = (string)$quote_user_array[0]->name;
			}
		}
	}
	
	$safe_username = htmlspecialchars($quote_user_username, ENT_QUOTES, 'UTF-8');
	echo "<span class=\"name\">{$safe_username} ";
	
	$q_start = new DateTime('now');
	$q_end  = new DateTime($quote_gdate);
	$q_dif = $q_start->diff($q_end);
	

	if ($q_dif->days < 1) {
		$q_since = ($q_dif->h < 1) ? $q_dif->i . "m" : $q_dif->h . "h";
	} else {
		if ($q_dif->days > 365) {
			$q_y = floor($q_dif->days / 365);
			$q_y_d = $q_dif->days % 365;
			$q_since = $q_y . 'y ' . $q_y_d . 'd';
		} else {
			$q_since = $q_dif->days . 'd';
		}
	}
	
	echo "&middot; {$q_since}</span><br>\n";
	echo "<div class=\"space_name\"></div>\n";
	echo "<span class=\"miter_text\">{$quote}</span><br>\n";
	
	echo "<div class=\"date_table-div\">\n";
	
	$safe_link = htmlspecialchars($safe_m_link, ENT_QUOTES, 'UTF-8');
	$safe_odate = htmlspecialchars($quote_odate, ENT_QUOTES, 'UTF-8');
	echo "<a href=\"{$safe_link}\" target=\"_blank\" class=\"permalink\">{$safe_odate}";
	
	if ($quote_udate > $quote_gdate) {
		echo " &#177;";
	}
	echo "</a>\n";
	echo "</div>\n";
	
} else {
	echo "<span class=\"grey\">miter no longer exists</span>\n";
}

echo "</div>\n";
?>
Updates
Wedge - Android 126.026
Wedge - Linux 124.026
Shim - Android 117.026
Miter - 114.026
Kerf - Android 112.026
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Peen (Messaging)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)