uri = $_GET['uri'];
}
# standard canonical
$this->canonical = WEBSITE_CANONICAL . '/' . $this->uri;
$this->route = $route;
# create a view pointer (should be passed along with construction)
$this->view = new $view_name($this);
$this->directory = "mvc/" . $this->route['controller'] . "/";
# template used
$this->template = (!empty($this->route['passed_params']['template'])) ? $this->route['passed_params']['template'] : "index.html";
# this is used for login
require_once $_SERVER["DOCUMENT_ROOT"] . '/amf/library/Am/Lite.php';
# merge the params
$this->appendParams($route['passed_params']);
# if you are logged in, we can adjust the navigation
if (Am_Lite::getInstance()->isLoggedIn()) {
$user = Am_Lite::getInstance()->getUser();
$this->login = $user['login'];
$name_f = $user['name_f'];
$name_l = $user['name_l'];
$added = $user['added'];
$last_login = $user['last_login'];
$last_ip = $user['last_ip'];
$is_locked = $user['is_locked'];
$is_approved = $user['is_approved'];
$this->email = $user['email'];
$this->user = $user;
$this->getUserPlan($this->login);
} else {
$this->user = "";
$this->product_string = "none";
}
$checked = " ";
# check if not a coins page
if ($this->route['controller'] != 'coin') {
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$url = "https://";
else
$url = "http://";
$url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
# $url = $_SERVER['HTTP_REFERER'];
setcookie('back', $url, time() + 3600000, "/");
# if we have a where clause, we need to add the coin data
# check what columns we are seeing
if (!isset($_COOKIE["cpt_page"])) {
setcookie('cpt_page', 1, time() + 3600000, "/");
# this is a hack to fix it for this page iteration, so we can use the data
$_COOKIE['cpt_page'] = 1;
}
$page = $_COOKIE['cpt_page'];
if ($this->route['pattern'] == 'price' || $this->route['pattern'] == 'prices') {
$select_options = $gCrypto->doGetOptions($page);
$this->switch_page_string = "
";
}
} # main pages
else {
# if we have a where clause, we need to add the coin data
# check what columns we are seeing
if (!isset($_COOKIE["cpt_page"])) {
setcookie('cpt_page', 1, time() + 3600000, "/");
# this is a hack to fix it for this page iteration, so we can use the data
$_COOKIE['cpt_page'] = 1;
}
$page = $_COOKIE['cpt_page'];
# do not sow these options on regular pages
# $select_options = $gCrypto->doGetOptions($page);
$this->switch_page_string = "";
}
foreach ($this->params as $key => $value) {
$this->appendTags(array("{{" . $key . "}}" => $value));
}
}
public function isLoggedIn()
{
if (empty($this->user)) {
return false;
}
return true;
}
public function appendParams($params)
{
$this->params = array_merge($this->params, $params);
}
public function prependTags($tags)
{
$this->tags = $tags + $this->tags;
}
public function appendTags($tags)
{
$this->tags = array_merge($this->tags, $tags);
}
# check for popup and append the old way - this
public function checkAppendPopup()
{
global $gMysql;
global $gPopupLookUp;
global $version;
if (isset($this->route['passed_params']['pUpdate'])) {
# go through all popup connotations
if (array_key_exists($this->route['passed_params']['pUpdate'], $gPopupLookUp) == true) {
# appends a popup
$this->appendTags(array("{{announcement_string}}" => ""));
$this->appendTags(array("" => $gPopupLookUp[$this->route['passed_params']['pUpdate']]['html']));
return;
}
}
$this->appendTags(array("" => ""));
$this->appendTags(array("0" => $version));
}
# gets the template
public function getTemplate()
{
$fn = DOCUMENT_ROOT . $this->directory . $this->template;
if (!file_exists($fn)) {
$fn = DOCUMENT_ROOT . $this->template;
if (!file_exists($fn)) {
echo "getTemplate Error: File not found: $fn";
exit;
}
}
return $fn;
}
# gets the header
public function getHeader()
{
return "templates/" . $this->params['header'];
}
# gets the footer
public function getFooter()
{
return "templates/" . $this->params['footer'];
}
# renders all the crypto for a page (order by etc) - in fact, this can send all the data and only update the id's prices and position 1d's every 15min
# so you dont even need to rebuild the table - do it all in JS
# we could build smaller width tables based on preferences, or leave some data out when the page is drawn
# we could start with a default settings for viewed tables
public function render_crypto()
{
global $gMysql;
global $gCrypto;
global $gCache;
AddCommentOnly("");
AddCommentOnly("");
AddCommentOnly("");
AddComment("render_crypto() ");
# if we have a where clause, we need to add the coin data
# check what columns we are seeing
if (!isset($_COOKIE["cpt_page"])) {
setcookie('cpt_page', 1, time() + 3600000, "/");
# this is a hack to fix it for this page iteration, so we can use the data
$_COOKIE['cpt_page'] = 1;
}
$page = $_COOKIE['cpt_page'];
$select_options = $gCrypto->doGetOptions($page);
# get the sql statement
# $strSQL = $gCrypto->getRenderSQL($page, false);
# $tags = $gCrypto->doRenderCrypto($strSQL, true);
# $strSQL = Chart_Class::getCoinsSQL("","","",100);
# $strSQL = $gCrypto->getRenderSQL(1);
$query = strtoupper(GetVariableString('query', $_POST, 0));
$orderby = GetVariableString('id', $_POST, 0);
$dir = GetVariableString('dir', $_POST, 0);
$category = GetVariableString('category', $_POST, 0);
$category = $gCrypto->getSetCookie("category", "category");
$orderby = $gCrypto->getSetCookie("orderby", "orderby");
$dir = $gCrypto->getSetCookie("dir", "dir");
$query = $gCrypto->getSetCookie("query", "query");
$gCrypto->setCookie("category", "");
$strSQL = Chart_Class::getCoinsSQL($query, "", $dir, 100, "", "", "");
$tags = Chart_Class::doRenderCrypto($strSQL, true);
$categories = [
['slug' => 'all', 'label' => 'All'],
['slug' => 'artificial-intelligence', 'label' => 'AI'],
['slug' => 'real-world-assets-rwa', 'label' => 'RWA'],
['slug' => 'depin', 'label' => 'DePin'],
['slug' => 'meme', 'label' => 'Meme'],
['slug' => 'the-boy-s-club', 'label' => 'BoysClub'],
['slug' => 'cat-themed-coins', 'label' => 'Cats'],
['slug' => 'pump-fun', 'label' => 'PumpFun'],
['slug' => 'politifi', 'label' => 'Political'],
['slug' => 'solana-ecosystem', 'label' => 'Sol'],
['slug' => 'sui-ecosystem', 'label' => 'Sui'],
['slug' => 'dexscreener', 'label' => 'Dexscreener Coins'],
];
$htmlOutput = "
\n";
$htmlOutput .= "
\n";
foreach ($categories as $cat) {
$slug = htmlspecialchars($cat['slug'], ENT_QUOTES, 'UTF-8');
$label = htmlspecialchars($cat['label'], ENT_QUOTES, 'UTF-8');
$activeClass = ($slug === $category) ? ' active' : ''; // Add active class if the category matches
$htmlOutput .= " \n";
}
$htmlOutput .= "
';
return $menu_string;
}
# used on many pages
public function getSidePanel()
{
global $gCache;
$sidepanel_string = $gCache->cache_or_get(CACHE_CACHE_TIME_TINY, "template", "sidepanel", "load_template_file", "mvc/base/sidepanel.html", true);
return $sidepanel_string;
}
# ok, so renders the top 20 coins by volume vs market volume
public function renderNews()
{
global $gMysql;
global $gCrypto;
global $gCache;
AddCommentOnly("");
AddCommentOnly("");
AddCommentOnly("");
AddComment("renderNews() ");
# rss news feed
$news_feed = $gCache->cache_or_get(CACHE_CACHE_TIME_TINY, "", "The News", "get_main_news", "");
# twitter news feed
$twitter_feed = $gCache->cache_or_get(CACHE_CACHE_TIME_TINY, "", "Twitter", "get_twitter_news", "");
/*
# run this once every so often
$market_array = $gMysql->selectToArray("select * from crypto_market_cap order by market_cap_rank > 0 and c_name ", __FILE__, __LINE__);
foreach ($market_array as $market_data)
{
$c_id = $market_data['c_id'];
$gMysql->update("UPDATE crypto_market_cap SET mention_count_1d =0,positive_count_1d=0,negative_count_1d=0 WHERE c_id = '$c_id';", __FILE__, __LINE__);
# no short names
if (strlen($market_data['c_name']) > 2)
{
$c_name = mysqli_real_escape_string($gMysql->mysqli,$market_data['c_name']);
$mention_count_1d = $gMysql->queryItem("SELECT COUNT(*) FROM rss_feed WHERE title like BINARY '%$c_name%' AND szDateTime >= DATE_SUB(NOW(), INTERVAL 1 DAY);", __FILE__, __LINE__);
if ($mention_count_1d > 5)
{
$gMysql->update("UPDATE crypto_market_cap SET mention_count_1d ='$mention_count_1d' WHERE c_id = '$c_id';", __FILE__, __LINE__);
$gMysql->update("UPDATE crypto_market_cap SET positive_count_1d = ( SELECT COUNT(*) FROM rss_feed WHERE title like BINARY '%$c_name%' AND sentiment_twinword='positive' and szDateTime >= DATE_SUB(NOW(), INTERVAL 1 DAY) ) WHERE c_id = '$c_id';", __FILE__, __LINE__);
$gMysql->update("UPDATE crypto_market_cap SET negative_count_1d = ( SELECT COUNT(*) FROM rss_feed WHERE title like BINARY '%$c_name%' AND sentiment_twinword='negative' and szDateTime >= DATE_SUB(NOW(), INTERVAL 1 DAY) ) WHERE c_id = '$c_id';", __FILE__, __LINE__);
}
}
}
*/
/*
# build the charts out of the top 20 things
# run this once every so often
$market_array = $gMysql->selectToArray("select * from crypto_market_cap where c_name not in ('SEC','FOMC','NFT','42','INU') and mention_count_1d > 2 order by mention_count_1d desc limit 10 ", __FILE__, __LINE__);
foreach ($market_array as $market_data)
{
$c_id = $market_data['c_id'];
$mentions = $market_data['mention_count_1d'];
$positive = $market_data['positive_count_1d'];
$negative = $market_data['negative_count_1d'];
$neutral = $mentions - $positive - $negative;
$c_name = mysqli_real_escape_string($gMysql->mysqli,$market_data['c_name']);
# now get the number of positive and negative
$labels .= "'$c_name', ";
$chart_data .= "$mentions, ";
$chart_data_p .= "$positive, ";
$chart_data_n .= "$negative, ";
$chart_data_b .= "$neutral, ";
$red = rand(0, 255);
$green = rand(0, 255);
$blue = rand(0, 255);
$rgbaColor = "'rgba($red, $green, $blue, 0.9)'";
$rgbaColor2 = "'#FAC030'";
$rgbaColor = "'#3273E9'";
$rgbaColor3 = "'#C0C0C0'";
$backgroundColor .= "$rgbaColor, ";
$backgroundColor2 .= "$rgbaColor2, ";
$backgroundColor3 .= "$rgbaColor3, ";
}
$labels = rtrim($labels,',');
$chart_data = rtrim($chart_data,',');
$chart_data_p = rtrim($chart_data_p,',');
$chart_data_n = rtrim($chart_data_n,',');
$chart_data_b = rtrim($chart_data_b,',');
$backgroundColor = rtrim($backgroundColor,',');
$backgroundColor2 = rtrim($backgroundColor2,',');
$backgroundColor3 = rtrim($backgroundColor3,',');
# run once a day
#$this-> rank_by_volume();
$volume_table = get_volume_ranking_table();
# side panel
# $side_panel = $this->getSidePanel();
# adds additional tags
$more_tags = array(
"{{news_feed}}" => $news_feed,
"{{twitter_feed}}" => $twitter_feed,
"{{volume_table}}" => $volume_table,
"{{chart_labels}}" => $labels,
"{{chart_data}}" => $chart_data,
"{{chart_data_p}}" => $chart_data_p,
"{{chart_data_n}}" => $chart_data_n,
"{{chart_data_b}}" => $chart_data_b,
"{{chart_backgroundColor}}" => $backgroundColor,
"{{chart_backgroundColor2}}" => $backgroundColor2,
"{{chart_backgroundColor3}}" => $backgroundColor3,
);
$this->appendTags($more_tags);
*/
$this->render();
}
}
# the rankign
function get_volume_ranking_table()
{
global $gMysql;
global $gCrypto;
$strSQL = "SELECT * FROM crypto_market_cap where 1d_pc > 0 and volume24_delta > 0 and c_symbol not like '%USD%' and c_symbol not in (" . CRYPTO_EXCLUDED_SYMBOLS_STRING . ") ORDER BY 24hour_volume DESC ,volume24_rank ASC LIMIT 50";
$coin_array = $gMysql->selectToArray($strSQL, __FILE__, __LINE__);
$coin_list = "