Ejemplo n.º 1
0
 /**
  * load site Info
  * 
  * @return array site info (name of logo.suffix, params_include_only, params_exclude)
  */
 function loadInfo()
 {
     if (!Request::isPhpmvLogModule()) {
         $db =& Db::getInstance();
         if (!$db->isReady() || !$db->areAllTablesInstalled() || Request::isCurrentModuleAnInstallModule()) {
             return array();
         }
     }
     $siteInfo = array();
     $fileAdress = INCLUDE_PATH . "/config/site_info.php";
     // file exists and is correct
     if (is_file($fileAdress)) {
         require $fileAdress;
         if (sizeof($siteInfo) != 0) {
             return $siteInfo;
         }
     }
     $r = query("SELECT idsite, name, logo, params_choice, params_names, idpdf, path_theme" . " FROM " . T_SITE);
     if (mysql_num_rows($r) == 0) {
         $GLOBALS['content_message_tpl'] = $GLOBALS['lang']['generique_aucune_site_bdd'];
         return;
     } else {
         while ($l = mysql_fetch_assoc($r)) {
             $siteInfo[$l['idsite']] = $l;
         }
         // ip to exclude
         // select excluded Ip2long
         $r2 = query("SELECT ip_min, ip_max, idsite " . " FROM " . T_IP_IGNORE);
         if (mysql_num_rows($r2) > 0) {
             $i = 0;
             while ($l2 = mysql_fetch_assoc($r2)) {
                 $siteInfo[$l2['idsite']]['ips'][] = array($l2['ip_min'], $l2['ip_max']);
             }
         }
         saveConfigFile($fileAdress, $siteInfo, 'siteInfo');
         return $siteInfo;
     }
 }
 function write()
 {
     saveConfigFile($this->url, $this->content, $this->varname);
 }
Ejemplo n.º 3
0
function saveCountInFile($fileName)
{
    $count = 0;
    $fileName = './count/' . $fileName;
    if (is_file($fileName)) {
        include $fileName;
        if (isset($count) && is_integer($count) && $count != 0) {
            saveConfigFile($fileName, $count + 1, "count");
        }
    }
}
Ejemplo n.º 4
0
     break;
 case 'saveGlobalconfig':
     $smtp_host = isset($_POST['smtp_host']) ? $_POST['smtp_host'] : '';
     $smtp_auth = isset($_POST['smtp_auth']) ? $_POST['smtp_auth'] : 0;
     $smtp_login = isset($_POST['smtp_login']) ? $_POST['smtp_login'] : '';
     $smtp_pass = isset($_POST['smtp_pass']) ? $_POST['smtp_pass'] : '';
     $mod_sub = isset($_POST['mod_sub']) ? $_POST['mod_sub'] : 0;
     $timezone = isset($_POST['timezone']) ? $_POST['timezone'] : '';
     if (saveConfig($cnx, $_POST['table_config'], $_POST['admin_pass'], 50, $_POST['base_url'], $_POST['path'], $_POST['language'], $_POST['table_email'], $_POST['table_temp'], $_POST['table_listsconfig'], $_POST['table_archives'], $_POST['sending_method'], $smtp_host, $smtp_auth, $smtp_login, $smtp_pass, $_POST['sending_limit'], $_POST['validation_period'], $_POST['sub_validation'], $_POST['unsub_validation'], $_POST['admin_email'], $_POST['admin_name'], $_POST['mod_sub'], $_POST['table_sub'], $_POST['charset'], $_POST['table_track'], $_POST['table_send'], $_POST['table_sauvegarde'], $_POST['table_upload'])) {
         $configSaved = true;
         $row_config_globale = $cnx->SqlRow("SELECT * FROM {$table_global_config}");
     } else {
         $configSaved = false;
     }
     if ($_POST['file'] == 1) {
         $configFile = saveConfigFile($PMNL_VERSION, $_POST['db_host'], $_POST['db_login'], $_POST['db_pass'], $_POST['db_name'], $_POST['table_config'], $_POST['db_type'], $_POST['type_serveur'], $_POST['type_env'], $timezone);
         $forceUpdate = 1;
         include "include/config.php";
         unset($forceUpdate);
     }
     saveBounceFile($_POST['bounce_host'], $_POST['bounce_user'], $_POST['bounce_pass'], $_POST['bounce_port'], $_POST['bounce_service'], $_POST['bounce_option']);
     break;
 case 'subscriber_add':
     $add_addr = empty($_POST['add_addr']) ? "" : $_POST['add_addr'];
     if (!empty($add_addr)) {
         $add_r = add_subscriber($cnx, $row_config_globale['table_email'], $list_id, $add_addr);
         if ($add_r == 0) {
             $subscriber_op_msg = "<h4 class='alert_error'>" . translate("ERROR_ADDING_SUBSCRIBER", " <b>{$add_addr}</b>") . ".</h4>";
         } else {
             if ($add_r == -1) {
                 $subscriber_op_msg = "<h4 class='alert_error'>" . translate("ERROR_ALREADY_SUBSCRIBER", "<b>{$add_addr}</b>") . ".</h4>";
 function getPagesDetailsZoom($categoryAsked = '')
 {
     $this->objects['category'] = new ArchiveTable('category');
     $this->objects['page'] = new ArchiveTable('page');
     $this->objects['file'] = new ArchiveTable('file');
     $this->objects['vars_name'] = new ArchiveTable('vars_name');
     $this->objects['vars_value'] = new ArchiveTable('vars_value');
     $nbVis = $this->getContent('nb_vis');
     //		printDebug($all); exit;
     if ($this->archive->periodType === DB_ARCHIVES_PERIOD_DAY) {
         $nbLast = 15;
     } else {
         $nbLast = 3;
     }
     $archives = $this->getLastArchives($nbLast, 1, DATE_NORMAL);
     printTime('beg 1 of pages details');
     $i = 0;
     // load "pure" pages array
     foreach ($archives as $dateToDisplay => $archive) {
         printTime('foreach' . ++$i . ' of pages details');
         $o_data = new DataModel($archive, $this->request);
         $displayInfo[] = $dateToDisplay;
         printTime('before uz' . $i . ' of pages details');
         if (STORE_PAG_ARRAY_IN_FILE) {
             $file = INCLUDE_PATH . "/datas/archives/" . $o_data->infoSerialized['idarchives'] . ".dat";
             if (!is_readable($file)) {
                 saveConfigFile($file, unserialize($o_data->infoSerialized['vis_pag_grp']), 'visPagGrp');
             }
             if (is_readable($file)) {
                 $visPagGrp = array();
                 require_once $file;
                 $array = $visPagGrp;
             }
         } else {
             $visPagGrp = array();
             if (!is_null($o_data->infoSerialized['vis_pag_grp'])) {
                 $visPagGrp = $o_data->getContent('vis_pag_grp');
             }
         }
         //var_dump($visPagGrp);exit;
         $a_all[] = $visPagGrp;
         printTime('after uz' . $i . ' of pages details');
         $headerInfo[] = array('nb_pag' => $o_data->getContent('nb_pag'), 'nb_uniq_pag' => $o_data->getContent('nb_uniq_pag'), 'nb_max_pag' => $o_data->getContent('nb_max_pag'));
         //printDebug($headerInfo);
     }
     printTime('beg 2 of pages details');
     foreach ($a_all as $j => $all) {
         if (empty($categoryAsked)) {
             $a_infosDay[$j] = $all;
             $level = 0;
         } else {
             $categoryAsked = (string) $categoryAsked;
             //print("Zoom cate '$categoryAsked' <br>");
             //print($categoryAsked[2]);
             $detailsCategory = explode(">", $categoryAsked);
             //printDebug($detailsCategory);
             $level = sizeof($detailsCategory);
             //print("level : $level <br>");
             $array = $this->getPagesDetailsZoomArrayLevel($all, $level, $detailsCategory);
             $a_infosDay[$j] = $array;
         }
     }
     printTime('mid of pages details');
     // list asked category
     if ($level != 0) {
         $categoryAsked .= '>';
     }
     //		var_dump($categoryAsked);
     //		var_dump($a_infosDay[0]);
     $return = array();
     if (is_array($a_infosDay[0])) {
         //var_dump($a_infosDay[0]);
         foreach ($a_infosDay[0] as $currentId => $info) {
             // page or file or category, but not total
             if ($currentId != 'p_pmv_sum' && $currentId != 'f_pmv_sum') {
                 $id = '';
                 $parentId = '';
                 $data = '';
                 $sum = 0;
                 $sumN1 = 0;
                 $sumN2 = 0;
                 $percentN1 = 0;
                 $percentN2 = 0;
                 $type = '';
                 $entry = 0;
                 $sumtime = 0;
                 $exit = 0;
                 $singlepage = 0;
                 $a_vars = array();
                 // category
                 if (substr($currentId, 0, 1) === 'c') {
                     $type = 'category';
                     $entry = @$info['p_pmv_sum'][ARRAY_INDEX_ENTRYPAGE];
                     $exit = @$info['p_pmv_sum'][ARRAY_INDEX_EXITPAGE];
                     $sum = @$info['p_pmv_sum'][ARRAY_INDEX_COUNT] + @$info['f_pmv_sum'][ARRAY_INDEX_COUNT];
                     $sumtime = @$info['p_pmv_sum'][ARRAY_INDEX_TIME_TOTAL];
                     $singlepage = @$info['p_pmv_sum'][ARRAY_INDEX_PAGES_VISIT_ONEPAGE];
                     $allInfoInGroup = $this->getPagesDetailsZoomArrayLevel($a_infosDay[0], 1, array($currentId));
                     //var_dump($allInfoInGroup);exit;
                     //$a_vars = $this->getVarIdToName($a_infosDay[0]['p_pmv_sum'][ARRAY_INDEX_VARS]);
                     $a_vars = $this->getVarIdToName(@$allInfoInGroup['p_pmv_sum'][ARRAY_INDEX_VARS]);
                     //var_dump($a_vars);
                     if (isset($a_infosDay[1][$currentId]['p_pmv_sum'][ARRAY_INDEX_COUNT])) {
                         $sumN1 = $a_infosDay[1][$currentId]['p_pmv_sum'][ARRAY_INDEX_COUNT] + @$a_infosDay[1][$currentId]['f_pmv_sum'][ARRAY_INDEX_COUNT];
                     }
                     $percentN1 = $this->getDiffPercent($sum, $sumN1);
                     if (isset($a_infosDay[2][$currentId]['p_pmv_sum'][ARRAY_INDEX_COUNT])) {
                         $sumN2 = $a_infosDay[2][$currentId]['p_pmv_sum'][ARRAY_INDEX_COUNT] + @$a_infosDay[2][$currentId]['f_pmv_sum'][ARRAY_INDEX_COUNT];
                     }
                     $percentN2 = $this->getDiffPercent($sum, $sumN2);
                     $id = $categoryAsked . $currentId;
                     if ($level != 0) {
                         $parentId = substr($categoryAsked, 0, strlen($categoryAsked) - 1);
                     } else {
                         $parentId = "root";
                     }
                     $data = @$info[ARRAY_INDEX_IDCATEGORY];
                     //if($data != -1)
                     //	$toLoad['category'][] = $data;
                 } else {
                     if (substr($currentId, 0, 1) === 'p') {
                         //print("pages = ".$currentId);
                         $type = 'page';
                         $id = $currentId;
                         //printDebug($info);
                         if (!isset($info[ARRAY_INDEX_COUNT])) {
                             $info[ARRAY_INDEX_COUNT] = 0;
                         }
                         $sum = @$info[ARRAY_INDEX_COUNT];
                         $entry = @$info[ARRAY_INDEX_ENTRYPAGE];
                         $exit = @$info[ARRAY_INDEX_EXITPAGE];
                         $sumtime = @$info[ARRAY_INDEX_TIME_TOTAL];
                         $singlepage = @$info[ARRAY_INDEX_PAGES_VISIT_ONEPAGE];
                         if (isset($info[ARRAY_INDEX_VARS])) {
                             $a_vars = $this->getVarIdToName($info[ARRAY_INDEX_VARS]);
                         }
                         // Period-1
                         if (isset($a_infosDay[1][$currentId][ARRAY_INDEX_COUNT])) {
                             $sumN1 = $a_infosDay[1][$currentId][ARRAY_INDEX_COUNT];
                         }
                         $percentN1 = $this->getDiffPercent($sum, $sumN1);
                         // Period -2
                         if (isset($a_infosDay[2][$currentId][ARRAY_INDEX_COUNT])) {
                             $sumN2 = $a_infosDay[2][$currentId][ARRAY_INDEX_COUNT];
                         }
                         $percentN2 = $this->getDiffPercent($sum, $sumN2);
                         // Name
                         if (!isset($info[ARRAY_INDEX_IDPAGE])) {
                             //print("Problem, please report this error message :");
                             //var_dump($info);
                             $data = -1;
                         } else {
                             $data = $info[ARRAY_INDEX_IDPAGE];
                         }
                         //print("$data : ".$sumtime . "<br>");
                     } else {
                         if (substr($currentId, 0, 1) === 'f') {
                             $type = 'file';
                             $id = $currentId;
                             $sum = $info[ARRAY_INDEX_COUNT];
                             // Period-1
                             //print("idfile=$currentId<br>");
                             if (isset($a_infosDay[1][$currentId][ARRAY_INDEX_COUNT])) {
                                 $sumN1 = $a_infosDay[1][$currentId][ARRAY_INDEX_COUNT];
                             }
                             $percentN1 = $this->getDiffPercent($sum, $sumN1);
                             // Period -2
                             if (isset($a_infosDay[2][$currentId][ARRAY_INDEX_COUNT])) {
                                 $sumN2 = $a_infosDay[2][$currentId][ARRAY_INDEX_COUNT];
                             }
                             $percentN2 = $this->getDiffPercent($sum, $sumN2);
                             // Name
                             $data = $info[ARRAY_INDEX_IDPAGE];
                         } else {
                             // this is related to the ARRAY_INDEX_IDCATEGORY
                             //print("Whats that? Report it to phpmyvisites forums: ");
                             //print($currentId);
                         }
                     }
                 }
                 if (!empty($data) && !empty($type) && $sum > 0) {
                     $return[] = array('type' => $type, 'sum' => $sum, 'sumn1' => $sumN1, 'sumn2' => $sumN2, 'percentn1' => $percentN1, 'percentn2' => $percentN2, 'data' => $data, 'id' => $id, 'parentid' => $parentId, 'entry' => $entry, 'exit' => $exit, 'sumtime' => $sumtime, 'avgtime' => round($sumtime / $sum), 'exitrate' => 100 * $exit / $sum, 'singlepage' => $singlepage, 'vars' => $a_vars);
                 }
             }
         }
         printTime('end of pages details');
         $GLOBALS['sorting_index'] = 'sum';
         uasort($return, "sortingDataInfo");
         return array($displayInfo, $return, $headerInfo);
     }
     return false;
 }
Ejemplo n.º 6
0
if (isset($_REQUEST["submitting"])) {
    $saveArray = array();
    $saveArray["blogname"] = addslashes($_REQUEST["blogname"]);
    $saveArray["username"] = $_CONFIG["username"];
    if ($_REQUEST["password"] != "") {
        $saveArray["password"] = $_REQUEST["password"];
    }
    $saveArray["baseDomain"] = $_REQUEST["baseDomain"];
    $saveArray["fullOrPart"] = $_REQUEST["fullOrPart"];
    $saveArray["itemsPerPage"] = $_REQUEST["itemsPerPage"];
    $saveArray["menu"] = addslashes($_REQUEST["menu"]);
    $saveArray["logoURL"] = $_REQUEST["logoURL"];
    $saveArray["copyright"] = addslashes($_REQUEST["copyright"]);
    $saveArray["googleAnalytics"] = $_REQUEST["googleAnalytics"];
    $saveArray["social"] = "&" . $_REQUEST["hackernews"] . "&" . $_REQUEST["reddit"] . "&" . $_REQUEST["facebook"] . "&" . $_REQUEST["twitter"];
    saveConfigFile($saveArray);
    @file_put_contents("data/amends.dat", 0, FILE_APPEND | LOCK_EX);
    $_SESSION["successmessage"] = "Settings saved";
    header("Location: /admin");
    exit(0);
} else {
    $blogname = htmlentities($_CONFIG["blogname"]);
    $username = $_CONFIG["username"];
    $password = $_CONFIG["password"];
    $baseDomain = $_CONFIG["baseDomain"];
    $fullOrPart = $_CONFIG["fullOrPart"];
    $itemsPerPage = $_CONFIG["itemsPerPage"];
    $menu = htmlentities($_CONFIG["menu"]);
    $logoURL = $_CONFIG["logoURL"];
    $copyright = htmlentities($_CONFIG["copyright"]);
    $googleAnalytics = $_CONFIG["googleAnalytics"];
Ejemplo n.º 7
0
 function reloadLangFile()
 {
     $handle = opendir(LANGS_PATH);
     while ($file = readdir($handle)) {
         if (strpos($file, '-utf-8.php')) {
             $lang = array();
             require LANGS_PATH . "/" . $file;
             if (count($lang) === 0) {
                 trigger_error("Problems while loading Lang file. Try to upload the /langs/ directory", E_USER_ERROR);
             }
             $langAvailable[$file] = array($lang['lang_libelle_fr'], $lang['lang_libelle_en'], $lang['charset'], $lang['lang_iso'], $lang['auteur_nom'], $lang['auteur_email']);
         }
     }
     closedir($handle);
     // sort by english language name
     function sortLangArray($a, $b)
     {
         return $a[1] < $b[1] ? -1 : 1;
     }
     uasort($langAvailable, "sortLangArray");
     // used in getNearestLang but it seems useless since the introduction of
     // interface_default_lang
     // in 2.2RC1
     $langAvailable['default_lang'] = defined('INTERFACE_DEFAULT_LANG') ? INTERFACE_DEFAULT_LANG : 'en-utf-8.php';
     saveConfigFile($this->fileAdress, $langAvailable, 'langAvailable');
     $this->langAvailable = $langAvailable;
 }
Ejemplo n.º 8
0
function savePreferencesDialog()
{
    global $dialogPreferences, $glade, $config, $radioGroup, $i18n, $gui;
    // Display preview
    $config['displayPreview'] = $dialogPreferences->get_widget('_prefDisplayPreview')->get_active();
    gtShow($glade->get_widget('_previewArea'), $config['displayPreview']);
    // Check if temporary directory is accessible
    $config['tempDirectory'] = $dialogPreferences->get_widget('_prefTempPath')->get_filenames()[0];
    if (!is_dir($config['tempDirectory'])) {
        setPreferencesNoticeBox($i18n->_('prefErrTempDir404'), $gui['CNoticeBarErrBG']);
        return false;
    }
    $accessTest = $config['tempDirectory'] . DIRECTORY_SEPARATOR . 'tmpTest';
    if (!touch($accessTest)) {
        setPreferencesNoticeBox($i18n->_('prefErrTempDirAccess', $config['tempDirectory']), $gui['CNoticeBarErrBG']);
        return false;
    }
    unlink($accessTest);
    unset($accessTest);
    $inkPath = $dialogPreferences->get_widget('_prefInkscapePath')->get_filenames();
    $config['inkscapePath'] = isset($inkPath[0]) ? $inkPath[0] : '';
    unset($inkPath);
    if (!file_exists($config['inkscapePath']) && $config['displayPreview']) {
        setPreferencesNoticeBox($i18n->_('prefErrInkscapeAccess'), $gui['CNoticeBarErrBG']);
        return false;
    }
    // Display info bar
    $config['displayInfobar'] = $dialogPreferences->get_widget('_prefDisplayInfobar')->get_active();
    gtShow($glade->get_widget('_infoBar'), $config['displayInfobar']);
    // Display navigation bar
    $config['displayNavbar'] = $dialogPreferences->get_widget('_prefDisplayNavbar')->get_active();
    gtShow($glade->get_widget('_navBar'), $config['displayNavbar']);
    // Hide upload button if upload is disabled
    $config['enableUpload'] = $dialogPreferences->get_widget('_prefUploadEnable')->get_active();
    gtShow($glade->get_widget('_btnUpload'), $config['enableUpload']);
    $i = 0;
    foreach ($radioGroup['toolbarStyle'] as $radio) {
        if ($dialogPreferences->get_widget($radio)->get_active()) {
            $config['toolbarStyle'] = $i;
            break;
        }
        $i++;
    }
    $glade->get_widget('_toolbar')->set_toolbar_style($config['toolbarStyle']);
    $i = 0;
    foreach ($radioGroup['previewArea'] as $radio) {
        if ($dialogPreferences->get_widget($radio)->get_active()) {
            $config['previewArea'] = $i;
            break;
        }
        $i++;
    }
    // Active language
    preg_match('/\\(([a-zA-Z_]*)\\)/', $dialogPreferences->get_widget('_prefLanguageSelect')->get_active_text(), $matches);
    $config['language'] = $matches[1];
    unset($matches);
    $config['uploadUsername'] = trim(gtGetText($dialogPreferences->get_widget('_prefUploadUsername')));
    $config['uploadAPIKey'] = trim(gtGetText($dialogPreferences->get_widget('_prefUploadAPIKey')));
    if ($config['enableUpload']) {
        $uploadCredWarn = '';
        if (!$config['uploadUsername']) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrNoUsername') . "\n";
        }
        if (!$config['uploadAPIKey']) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrNoAPIKey');
        } elseif (!ctype_xdigit($config['uploadAPIKey']) || strlen($config['uploadAPIKey']) !== 32) {
            $uploadCredWarn .= '• ' . $i18n->_('prefErrWrongAPIKey');
        }
        if ($uploadCredWarn) {
            $uploadCredWarn = trim($uploadCredWarn) . "\n" . $i18n->_('prefErrUploadCredentials');
            setPreferencesNoticeBox($uploadCredWarn, $gui['CNoticeBarErrBG']);
            return false;
        }
    }
    $config['NSFWTagToFlag'] = $dialogPreferences->get_widget('_prefUploadNSFW')->get_active();
    saveConfigFile();
    // @functions.php
    $dialogPreferences->get_widget('_dialogPreferences')->destroy();
}
Ejemplo n.º 9
0
// If config exists then we have already installed
if (file_exists("config.php")) {
    header("Location: /admin");
    exit(0);
}
include_once "page_functions.php";
// we are trying to install
if (isset($_REQUEST["install"])) {
    @mkdir("../uploads");
    @mkdir("../uploads/thumbs");
    @mkdir("../blog");
    @mkdir("data");
    @file_put_contents("data/amends.dat", 0);
    @file_put_contents("data/.htaccess", "Deny from all");
    saveConfigFile(array("blogname" => addslashes($_REQUEST["blogname"]), "username" => $_REQUEST["adminname"], "password" => $_REQUEST["adminpassword"]));
    @unlink("install.php");
    @file_put_contents("install.php", "Install file has been removed for security.");
    header("Location: /admin");
    exit(0);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Install</title>
<link rel="stylesheet" type="text/css" href="admin.css" />
</head>