function FormPluginConfig(&$template) { parent::Form($template); // Get installed plugins $this->configPluginFile =& PmvConfig::getInstance("plugin.php", false); // Get list available plugins $dir = PLUGINS_PATH; $d = dir($dir); $arDir = array(); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..' && is_dir($dir . $entry) && is_file($dir . $entry . "/config.xml")) { $serializer_options = array('addDecl' => TRUE, 'encoding' => 'UTF-8', 'indent' => ' ', 'rootName' => 'plugin', 'defaultTagName' => 'item', 'rootAttributes' => array('version' => '1.0')); $unserializer =& new XML_Unserializer($serializer_options); if (($res = $unserializer->unserialize($dir . $entry . "/config.xml", true)) === true) { $conf = $unserializer->getUnserializedData(); if (isset($this->configPluginFile->content[$entry])) { $conf['pmv_install'] = true; $conf['pmv_type'] = $this->configPluginFile->content[$entry]['type']; $conf['pmv_menuModName'] = $this->configPluginFile->content[$entry]['menuModName']; } else { $conf['pmv_install'] = false; $conf['pmv_type'] = $conf['type']; $conf['pmv_menuModName'] = $conf['menuModName']; } if (isset($conf['langPath']) && !empty($conf['langPath'])) { Lang::addPluginLangFile($entry . "/" . $conf['langPath'], $conf['defaultLang']); } $arDir[$entry] = $conf; } } } $d->close(); $this->listAvailablePlugin = $arDir; }
function isCorrect($login, $password) { $db =& Db::getInstance(); $toReturn = false; $conf =& PmvConfig::getInstance(); $suLogin = $conf->content['su_login']; $suPassword = $conf->content['su_password']; //print($login . " and $password"); if ($login === $suLogin && $password === $suPassword) { $this->suPermission = true; $toReturn = true; } elseif ($login === PMV_ANONYMOUS_LOGIN) { $toReturn = true; } elseif (!empty($login) && !empty($password)) { if ($db->isReady()) { // select password for the login $r = query("SELECT password\n\t\t\t\t\t\t\tFROM " . T_USERS . "\n\t\t\t\t\t\t\tWHERE login = '******'"); if (mysql_num_rows($r) > 0) { while ($rr = mysql_fetch_array($r)) { if ($rr['password'] === $password) { $toReturn = true; break; } } } } } if ($toReturn) { $this->setLoginAndPassword($login, $password); } return $toReturn; }
function process() { $installedPlugin =& PmvConfig::getInstance("plugin.php", false); foreach ($installedPlugin->content as $key => $value) { if ($value['type'] == "admin" || $value['type'] == "all") { if (isset($value['langPath']) && $value['langPath'] != "") { Lang::addPluginLangFile($key . "/" . $value['langPath'], $value['defaultLang']); } } } $this->tpl->assign("installedPlugin", $installedPlugin->content); }
function postProcess() { $configPhpFileContent = array('su_login' => $this->getElementValue('form_login'), 'su_email' => $this->getElementValue('form_email'), 'send_mail' => $this->getSubmitValue('form_send_mail'), 'phpmv_url' => $this->getElementValue('form_phpmvurl'), 'monday_first' => $this->getSubmitValue('form_monday_first'), 'interface_default_lang' => $this->getSubmitValue('form_interface_default_lang')); $c =& PmvConfig::getInstance(); $c->update($configPhpFileContent); $passwordPost = $this->getElementValue('form_password'); // Verify if there is change on password if (defined('SU_PASSWORD') && $passwordPost == md5(SU_PASSWORD)) { $passwordPost = SU_PASSWORD; } if (!defined('SU_PASSWORD') || $passwordPost != SU_PASSWORD) { $c->update(array('su_password' => md5($passwordPost))); } $c->write(); }
/** * Point d'entr�e de l'application * */ function init() { $c =& PmvConfig::getInstance(); $Lang =& Lang::getInstance(); // id used for caching define('SMARTY_CACHE_ID', md5(@$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'] . serialize($_GET) . serialize($_POST) . (isset($_COOKIE[COOKIE_NAME_SESSION]) ? serialize($_COOKIE[COOKIE_NAME_SESSION]) : '') . $Lang->getFileName() . date("Y-m-d") . TIME_BEFORE_NEW_DAY_ARCHIVE . PHPMV_VERSION . INTERNAL_STATS)); setIncludePath(); $db =& Db::getInstance(); if (defined('DB_HOST')) { $db->connect(); } // try to set memory limit to MEMORY_LIMIT setMemoryLimit(); $controller =& ApplicationController::getInstance(); $controller->loadLang(); $controller->parseRequest(); $controller->loadModule(); $controller->executeAction(); }
function postProcess() { $configPhpFileContent = array('db_login' => $this->getElementValue('form_dblogin'), 'db_password' => $this->getElementValue('form_dbpassword'), 'db_host' => $this->getElementValue('form_dbhost'), 'db_name' => $this->getElementValue('form_dbname'), 'db_tables_prefix' => $this->getElementValue('form_dbprefix')); $db =& Db::getInstance(); // Verify if there is change on password if (defined('DB_PASSWORD') && $configPhpFileContent['db_password'] == md5(DB_PASSWORD)) { $configPhpFileContent['db_password'] = DB_PASSWORD; } // try to connect with new values $db->host = $configPhpFileContent['db_host']; $db->login = $configPhpFileContent['db_login']; $db->password = $configPhpFileContent['db_password']; $db->name = $configPhpFileContent['db_name']; $db->init(); if ($db->isReady()) { $c =& PmvConfig::getInstance(); $c->update($configPhpFileContent); $c->write(); $GLOBALS['header_error_message_tpl'] = ''; $this->tpl->assign('db_connect_ok', true); } else { $this->display(); } }
function showAll() { $idSite = getRequestVar('site', -1, 'int'); if ($idSite == -1) { $allSiteArchive = DataModel::getSites(); } else { $allSiteArchive[] = new Site($idSite); } $uniqCacheId = DataModel::getSitesSignature() . date("Y-m-d") . serialize($_GET) . '.rss'; // Set a few options $options = array('cacheDir' => DIR_CACHE_RSS, 'lifeTime' => CACHE_RSS_LIFETIME); // Create a Cache_Lite object $Cache_Lite = new Cache_Lite($options); if (time() % 500 === 0) { $Cache_Lite->clean(); } // Test if thereis a valide cache for this id if (SMARTY_DEBUG || !($allData = $Cache_Lite->get($uniqCacheId))) { $dataTmp = $this->data; $o_config =& PmvConfig::getInstance(); $allItems = array(); foreach ($allSiteArchive as $id => $infoSite) { $allArchives = $dataTmp->getLastArchives(NB_DAYS_FOR_RSS_ITEMS, 0, DATE_NORMAL, $infoSite); $i = 0; foreach ($allArchives as $date => $o_archive) { //var_dump($date); $this->request->setDate($o_archive->date->get()); $this->request->setModuleName('view_visits_rss'); $o_mod = new ViewVisitsRss($infoSite); $o_mod->init($this->request, $this->tpl, $o_archive); //var_dump($o_mod->data->archive->date->get()); $rssContent = $o_mod->showAll(true); $dateRss = date("r", time() - 100 * $i++ - 10 * $id); $item['pubDate'] = $dateRss; $url = PHPMV_URL . "/?site=" . $infoSite->getId() . "&mod=view_visits&date=" . $o_archive->date->get(); $item['guid'] = $url; //"http://www.phpmyvisites.us/".md5($dateRss); $item['link'] = $url; $item['title'] = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $date)); $rssContent = $item['title'] . $rssContent; $item['author'] = "phpmyvisites@gmail.com (phpMyVisites)"; $item['date_ts'] = time() - 10 * $id; $item['description'] = $rssContent; $item['date_ts'] = $o_archive->date->getTimestamp(); $allItems[] = $item; $urls[] = $url; } } $GLOBALS['sorting_index'] = 'date_ts'; uasort($allItems, "sortingDataInfo"); $channel['title'] = "phpMyVisites stats by RSS"; $channel['link'] = "http://www.phpmyvisites.us"; $channel['description'] = "Enjoy phpmyvisites power ! :)"; $channel['pubDate'] = date("r"); $channel['generator'] = "phpMyVisites"; $channel['language'] = $GLOBALS['lang']['lang_iso']; $channel['lastBuildDate'] = date("r"); foreach ($allItems as $chan) { unset($chan['date_ts']); $channel[] = $chan; } $rss = array('channel' => $channel); // An array of serializer options $serializer_options = array('addDecl' => TRUE, 'encoding' => 'UTF-8', 'indent' => ' ', 'rootName' => 'rss', 'defaultTagName' => 'item', 'rootAttributes' => array('version' => '2.0')); $Serializer =& new XML_Serializer($serializer_options); // Serialize the data structure $Serializer->setOption("keyAttribute", "rdf:about"); $status = $Serializer->serialize($rss); $allData = $Serializer->getSerializedData(); $Cache_Lite->save($allData); } $this->displayRss($allData); }
require_once INCLUDE_PATH . "/core/include/common.functions.php"; require_once INCLUDE_PATH . "/core/include/Cookie.class.php"; require_once INCLUDE_PATH . "/core/include/Site.class.php"; require_once INCLUDE_PATH . "/core/include/PmvConfig.class.php"; if (!SAVE_STAT) { redirectToUrlIfNecessary(); // else, display pixel $img = INCLUDE_PATH . "/images/logos/pixel.gif"; header("Content-type: image/gif"); readfile($img); exit; } // hack for not to show tables (because getCurrentCompleteUrl bugs // with url containing another url in one parameter) $GLOBALS['currentModuleIsLogModule'] = true; $c =& PmvConfig::getInstance(); $db =& Db::getInstance(); $db->connect(); // when no get specified, display a marketing page :) if (sizeof($_GET) === 0) { require_once INCLUDE_PATH . "/core/include/Lang.class.php"; $l =& Lang::getInstance(); displayPageWhenEmptyGet(); exit; } if (DEBUG) { require_once INCLUDE_PATH . "/core/include/functions.php"; } if (DEBUG) { ob_start(); }
function showAll() { $this->tpl->setMainTemplate("structure_mail.tpl"); $this->request->setModuleName('view_visits_rss'); $allSiteArchive = DataModel::getSites(); /** * Cache Lite */ $options = array('cacheDir' => DIR_CACHE_MAIL, 'lifeTime' => CACHE_MAIL_LIFETIME); $Cache_Lite = new Cache_Lite($options); $lang =& Lang::getInstance(); // case update to 2.2RC1 without executing global info if (!defined('INTERFACE_DEFAULT_LANG')) { define('INTERFACE_DEFAULT_LANG', 'en-utf-8.php'); } $lang->setNewLang(INTERFACE_DEFAULT_LANG); /** * Compute mails */ $o_config =& PmvConfig::getInstance(); foreach ($allSiteArchive as $infoSite) { /** * php Mailer */ $mail = new MyMailer(); $mail->IsHTML(true); $imgUrl = INCLUDE_PATH . "/themes/default/images/phpmv.png"; $mail->AddEmbeddedImage($imgUrl, "my-attach", $GLOBALS['lang']['logo_description'], "base64", "image/png"); $uniqCacheId = md5(serialize($infoSite) . date("Y-m-d")) . '.mail'; // Test if thereis a valide cache for this id if (true) { $o_mod = new ViewVisitsRss($infoSite); $this->request->date = getDateFromTimestamp(time() - 86400); $o_mod->init($this->request); $dateLiteral = $o_mod->data->archive->getLiteralDate(); $body = '<html xml:lang="fr" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body> '; $body .= $o_mod->showAll(true, true); $body .= '</body></html>'; $textBody = strip_tags($body); $subject = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $dateLiteral)); print "<br>Subject : {$subject}<hr>"; print "<br>Content : {$body}<hr>"; //$Cache_Lite->save($body); } $mail->Subject = $subject; $mail->Body = $body; $mail->AltBody = $textBody; $mail->CharSet = $GLOBALS['lang']['charset']; $user = new UserConfigDb(); $groups = $user->getGroups(); $users = array_merge(array(0 => array('email' => SU_EMAIL, 'alias' => 'phpMyVisites Administrator', 'send_mail' => SEND_MAIL == "yes" ? 1 : 0)), $user->getUserByGroup(1, $infoSite->getId()), $user->getUserByGroup(2, $infoSite->getId())); // we send all emails once $emailsToSend_infos = array('object' => $mail, 'to' => array()); // add recipients for the mail foreach ($users as $userInfo) { //print_r($userInfo); if (!empty($userInfo['email']) && $userInfo['send_mail'] == 1) { $emailsToSend_infos['to'][] = array($userInfo['email'], $userInfo['alias']); } } $emailsToSend[] = $emailsToSend_infos; } // send all emails foreach ($emailsToSend as $currMail) { $mail =& $currMail['object']; foreach ($currMail['to'] as $recipient) { $mail->AddAddress($recipient[0], $recipient[1]); if (!@$mail->Send()) { echo "<u><b>There was an error sending the message to " . $userInfo['email'] . "</u></b><br>"; } else { echo "<u><b>Message was sent successfully to " . $userInfo['email'] . "</u></b><br>"; } $mail->ClearAddresses(); } } }
function process() { $conf =& PmvConfig::getInstance(); $conf->update(array('install_ok' => true)); $conf->write(); }