Example #1
0
 public function __construct()
 {
     parent::__construct();
     $this->load->helper('file');
     $cf = get_config_file('creeper');
     $this->path = $cf['html_path'];
     $this->load->library('multicurlclass');
 }
print "function helpPopup03(which) {";
print "location.href = 'editlang_edit_settings.php?' + which + '&new_shortcut=' + document.new_lang_form.new_shortcut.value;";
print "return false;";
print "}";
print PGV_JS_END;
// Create array with configured languages in gedcoms and users
$configuredlanguages = array();
// Read gedcom configuration and collect language data
foreach (get_all_gedcoms() as $ged_id => $ged_name) {
    require get_config_file($ged_id);
    if (!isset($configuredlanguages["gedcom"][$LANGUAGE][$ged_name])) {
        $configuredlanguages["gedcom"][$LANGUAGE][$ged_name] = true;
    }
}
// Restore the current settings
require get_config_file(PGV_GED_ID);
// Read user configuration and collect language data
foreach (get_all_users() as $user_id => $user_name) {
    if (!isset($configuredlanguages["users"][get_user_setting($user_id, 'language')][$user_id])) {
        $configuredlanguages["users"][get_user_setting($user_id, 'language')][$user_id] = true;
    }
}
// Sort the Language table into localized language name order
foreach ($pgv_language as $key => $value) {
    $d_LangName = "lang_name_" . $key;
    // If we've added a new language, but haven't defined its name in the current language,
    // then display something to indicate what is required, rather than an error.
    if (!array_key_exists($d_LangName, $pgv_lang)) {
        $pgv_lang[$d_LangName] = "\$pgv_lang['{$d_LangName}']";
    }
    $Sorted_Langs[$key] = $pgv_lang[$d_LangName];
            $ctparts = count($parts) - 1;
            if (count($parts) == 1) {
                $path = $INDEX_DIRECTORY;
            } else {
                foreach ($parts as $key => $pathpart) {
                    if ($key < $ctparts) {
                        $path .= $pathpart . "/";
                    }
                }
            }
        }
        $GEDFILENAME = $ged;
        if (!isset($gedcom_title)) {
            $gedcom_title = get_gedcom_setting($ged_id, 'title');
        }
        $gedcom_config = get_config_file($ged_id);
        $gedcom_privacy = get_privacy_file($ged_id);
        $FILE = $ged;
        $oldged = $ged;
    } else {
        if (empty($_POST["GEDCOMPATH"])) {
            $GEDCOMPATH = "";
            $gedcom_title = "";
        }
        $gedcom_config = "config_gedcom.php";
        $gedcom_privacy = "privacy.php";
    }
} else {
    $GEDCOMPATH = "";
    $gedcom_title = "";
    $gedcom_config = "config_gedcom.php";
/**
 * Load config file
 *
 * @param   string   $path                         the configuration file path
 * @param   boolean  $load_user_configuration_dir  do we have to parse all user configuration files ? No for upgrade for example...
 *
 * @return  array    [ badges , files ]
 */
function config_load($load_user_configuration_dir = true)
{
    $badges = false;
    $files = false;
    // Read config file
    $config = get_config_file();
    if (is_null($config)) {
        return array($badges, $files);
    }
    // Get badges
    $badges = $config['badges'];
    // Set user constant
    foreach ($config['globals'] as $cst => $val) {
        if ($cst == strtoupper($cst)) {
            @define($cst, $val);
        }
    }
    // Set unset constants
    load_default_constants();
    // Set time limit
    @set_time_limit(MAX_SEARCH_LOG_TIME + 2);
    // Append files from the USER_CONFIGURATION_DIR
    if ($load_user_configuration_dir === true) {
        if (is_dir(PML_CONFIG_BASE . DIRECTORY_SEPARATOR . USER_CONFIGURATION_DIR)) {
            $dir = PML_CONFIG_BASE . DIRECTORY_SEPARATOR . USER_CONFIGURATION_DIR;
            $userfiles = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD), '/^.+\\.(json|php)$/i', RecursiveRegexIterator::GET_MATCH);
            foreach ($userfiles as $userfile) {
                $filepath = realpath($userfile[0]);
                $c = get_config_file($filepath);
                if (!is_null($c)) {
                    foreach ($c as $k => $v) {
                        $fileid = get_slug(str_replace(PML_CONFIG_BASE, '', $filepath) . '/' . $k);
                        $config['files'][$fileid] = $v;
                        $config['files'][$fileid]['included_from'] = $filepath;
                    }
                }
            }
        }
    }
    // Oups, there is no file... abort
    if (!isset($config['files'])) {
        return array($badges, $files);
    }
    // Try to generate the files tree if there are globs...
    $files_tmp = $config['files'];
    $files = array();
    foreach ($files_tmp as $fileid => $file) {
        $path = $file['path'];
        $count = max(1, @(int) $file['count']);
        $gpaths = glob($path, GLOB_MARK | GLOB_NOCHECK);
        if (count($gpaths) == 0) {
        } else {
            if (count($gpaths) == 1) {
                $files[$fileid] = $file;
                $files[$fileid]['path'] = $gpaths[0];
            } else {
                $new_paths = array();
                $i = 1;
                foreach ($gpaths as $path) {
                    $new_paths[$path] = filemtime($path);
                }
                // The most recent file will be the first
                arsort($new_paths, SORT_NUMERIC);
                // The first file id is the ID of the configuration file then others files are suffixed with _2, _3, etc...
                foreach ($new_paths as $path => $lastmodified) {
                    $ext = $i > 1 ? '_' . $i : '';
                    $files[$fileid . $ext] = $file;
                    $files[$fileid . $ext]['oid'] = $fileid;
                    $files[$fileid . $ext]['odisplay'] = $files[$fileid . $ext]['display'];
                    $files[$fileid . $ext]['path'] = $path;
                    $files[$fileid . $ext]['display'] .= ' > ' . basename($path);
                    if ($i >= $count) {
                        break;
                    }
                    $i++;
                }
            }
        }
    }
    // Remove forbidden files
    if (Sentinel::isAuthSet()) {
        // authentication is enabled on this instance
        $username = Sentinel::getCurrentUsername();
        $final = array();
        // Anonymous access only
        if (is_null($username)) {
            foreach ($files as $fileid => $file) {
                $a = $fileid;
                // glob file
                if (isset($files[$fileid]['oid'])) {
                    $a = $files[$fileid]['oid'];
                }
                if (Sentinel::isLogAnonymous($a)) {
                    $final[$fileid] = $file;
                }
            }
        } else {
            foreach ($files as $fileid => $file) {
                $a = $fileid;
                // glob file
                if (isset($files[$fileid]['oid'])) {
                    $a = $files[$fileid]['oid'];
                }
                if (Sentinel::userCanOnLogs($a, 'r', true, $username) || Sentinel::isLogAnonymous($a)) {
                    $final[$fileid] = $file;
                }
            }
        }
        $files = $final;
    }
    // Fix missing values with defaults
    foreach ($files as $fileid => $file) {
        foreach (array('max' => LOGS_MAX, 'refresh' => LOGS_REFRESH, 'notify' => NOTIFICATION) as $fix => $value) {
            if (!isset($file[$fix])) {
                $files[$fileid][$fix] = $value;
            }
        }
    }
    // Finally sort files
    if (!function_exists('display_asc')) {
        function display_asc($a, $b)
        {
            return strcmp($a["display"], $b["display"]);
        }
    }
    if (!function_exists('display_desc')) {
        function display_desc($a, $b)
        {
            return strcmp($b["display"], $a["display"]);
        }
    }
    if (!function_exists('display_insensitive_asc')) {
        function display_insensitive_asc($a, $b)
        {
            return strcmp($a["display"], $b["display"]);
        }
    }
    if (!function_exists('display_insensitive_desc')) {
        function display_insensitive_desc($a, $b)
        {
            return strcmp($b["display"], $a["display"]);
        }
    }
    switch (trim(str_replace(array('-', '_', ' ', 'nsensitive'), '', SORT_LOG_FILES))) {
        case 'display':
        case 'displayasc':
            usort($files, 'display_asc');
            break;
        case 'displayi':
        case 'displayiasc':
            usort($files, 'display_insensitive_asc');
            break;
        case 'displaydesc':
            usort($files, 'display_desc');
            break;
        case 'displayidesc':
            usort($files, 'display_insensitive_desc');
            break;
        default:
            # do not sort
            break;
    }
    return array($badges, $files);
}
}
if ($action == "cancel") {
    header("Location: changelanguage.php");
    exit;
}
//-- make sure that they have admin status before they can use this page
//-- otherwise have them login again
if (!PGV_USER_IS_ADMIN) {
    echo "Please close this window and do a Login in the former window first...";
    exit;
}
// Create array with configured languages in gedcoms and users
$configuredlanguages = array();
// Read gedcoms configuration and collect language data
foreach (get_all_gedcoms() as $ged_id => $gedcom) {
    require get_config_file($ged_id);
    $configuredlanguages["gedcom"][$LANGUAGE][$gedcom] = true;
}
// Read user configuration and collect language data
foreach (get_all_users() as $user_id => $user_name) {
    $configuredlanguages["users"][get_user_setting($user_id, 'language')][$user_id] = true;
}
// Determine whether this language's Active status should be protected
$protectActive = false;
if (array_key_exists($ln, $configuredlanguages["gedcom"]) or array_key_exists($ln, $configuredlanguages["users"])) {
    $protectActive = true;
}
$d_LangName = "lang_name_" . $ln;
$sentHeader = false;
// Indicates whether HTML headers have been sent
if ($action != "save" and $action != "toggleActive") {
Example #6
0
function AddToChangeLog($LogString, $ged = "")
{
    global $INDEX_DIRECTORY, $CHANGELOG_CREATE, $GEDCOM, $username, $SEARCHLOG_CREATE;
    //-- do not allow code to be written to the log file
    $LogString = preg_replace("/<\\?.*\\?>/", "*** CODE DETECTED ***", $LogString);
    if (empty($ged)) {
        $ged = $GEDCOM;
    }
    $oldged = $GEDCOM;
    $GEDCOM = $ged;
    if ($ged != $oldged) {
        include get_config_file();
    }
    if ($CHANGELOG_CREATE != "none") {
        $REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
        if (empty($CHANGELOG_CREATE)) {
            $CHANGELOG_CREATE = "daily";
        }
        if ($CHANGELOG_CREATE == "daily") {
            $logfile = $INDEX_DIRECTORY . "/ged-" . $GEDCOM . date("Ymd") . ".log";
        }
        if ($CHANGELOG_CREATE == "weekly") {
            $logfile = $INDEX_DIRECTORY . "/ged-" . $GEDCOM . date("Ym") . "-week" . date("W") . ".log";
        }
        if ($CHANGELOG_CREATE == "monthly") {
            $logfile = $INDEX_DIRECTORY . "/ged-" . $GEDCOM . date("Ym") . ".log";
        }
        if ($CHANGELOG_CREATE == "yearly") {
            $logfile = $INDEX_DIRECTORY . "/ged-" . $GEDCOM . date("Y") . ".log";
        }
        if (is_writable($INDEX_DIRECTORY)) {
            $logline = date("d.m.Y H:i:s") . " - " . $REMOTE_ADDR . " - " . $LogString . "\r\n";
            $fp = fopen($logfile, "a");
            flock($fp, 2);
            fputs($fp, $logline);
            flock($fp, 3);
            fclose($fp);
        }
    }
    $GEDCOM = $oldged;
    if ($ged != $oldged) {
        include get_config_file();
    }
}
Example #7
0
//-->
</script>
<form name="delete_form" method="post" action="">
<table>
	<tr>
		<td>
		<ul id="reorder_list">
		<?php 
$locked_with_warning = array("lang_settings.php", "pgv_changes.php");
//-- lock the GEDCOM and settings files
foreach (get_all_gedcoms() as $ged_id => $ged_name) {
    $file = get_privacy_file($ged_id);
    if ($file != 'privacy.php') {
        $locked_by_context[] = str_replace($INDEX_DIRECTORY, "", $file);
    }
    $file = get_config_file($ged_id);
    if ($file != 'config_gedcom.php') {
        $locked_by_context[] = str_replace($INDEX_DIRECTORY, "", $file);
    }
}
$dir = dir($INDEX_DIRECTORY);
$path = $INDEX_DIRECTORY;
// snag our path
$entryList = array();
while (false !== ($entry = $dir->read())) {
    $entryList[] = $entry;
}
sort($entryList);
foreach ($entryList as $entry) {
    //echo $entry, "\n";
    if ($entry[0] != '.') {
Example #8
0
// Do not run until user clicks "show", as default page may take a while to load.
// Instead, show some useful help info.
if (!isset($_POST['action'])) {
    echo '<p>', $pgv_lang['gedcheck_text'], '</p><hr />';
    print_footer();
    exit;
}
// If we're checking a gedcom that is imported into the database, check that the file is synchronised
if (in_array($ged, get_all_gedcoms())) {
    require get_config_file($ged);
    if (!$SYNC_GEDCOM_FILE && ($ged = $GEDCOM)) {
        $ged_link = 'href="javascript:" onclick="window.open(\'' . encode_url("export_gedcom.php?export={$ged}") . '\', \'_blank\',\'left=50,top=50,width=500,height=500,resizable=1,scrollbars=1\');"';
        echo '<div class="error">', print_text('gedcheck_sync', 0, 1);
        echo '</div><hr/>';
    }
    require get_config_file(PGV_GEDCOM);
}
// Special cases.  Other facts link to themselves; SUBN, SUBN, OBJE, NOTE, REPO, SOUR
$XREF_LINK = array('FAMC' => 'FAM', 'FAMS' => 'FAM', 'HUSB' => 'INDI', 'WIFE' => 'INDI', 'CHIL' => 'INDI', 'ASSO' => 'INDI', 'ALIA' => 'INDI', 'ANCI' => 'SUBM', 'DESI' => 'SUBM', '_PGV_OBJS' => 'OBJE', 'AUTH' => 'INDI');
// Use the global settings for these (if they exist)
if (isset($FAM_FACTS_UNIQUE)) {
    $fam_facts_unique = preg_split('/[, ;:]+/', $FAM_FACTS_UNIQUE, -1, PREG_SPLIT_NO_EMPTY);
} else {
    $fam_facts_unique = array();
}
if (isset($INDI_FACTS_UNIQUE)) {
    $indi_facts_unique = preg_split('/[, ;:]+/', $INDI_FACTS_UNIQUE, -1, PREG_SPLIT_NO_EMPTY);
} else {
    $indi_facts_unique = array();
}
// Match end of line in DOS/UNIX/MAC format
 /**
  * generate the backup zip file
  *
  */
 function backup()
 {
     global $INDEX_DIRECTORY, $GEDCOMS, $GEDCOM;
     global $MEDIA_DIRECTORY, $USE_MEDIA_FIREWALL, $MEDIA_FIREWALL_ROOTDIR;
     $this->flist = array();
     // Backup user information
     if (isset($_POST["um_usinfo"])) {
         // If in pure DB mode, we must first create new .dat files and authenticate.php
         // First delete the old files
         if (file_exists($INDEX_DIRECTORY . "authenticate.php")) {
             unlink($INDEX_DIRECTORY . "authenticate.php");
         }
         if (file_exists($INDEX_DIRECTORY . "news.dat")) {
             unlink($INDEX_DIRECTORY . "news.dat");
         }
         if (file_exists($INDEX_DIRECTORY . "messages.dat")) {
             unlink($INDEX_DIRECTORY . "messages.dat");
         }
         if (file_exists($INDEX_DIRECTORY . "blocks.dat")) {
             unlink($INDEX_DIRECTORY . "blocks.dat");
         }
         if (file_exists($INDEX_DIRECTORY . "favorites.dat")) {
             unlink($INDEX_DIRECTORY . "favorites.dat");
         }
         // Then make the new ones
         um_export($this->proceed);
         // Make filelist for files to ZIP
         if (file_exists($INDEX_DIRECTORY . "authenticate.php")) {
             $this->flist[] = $INDEX_DIRECTORY . "authenticate.php";
         }
         if (file_exists($INDEX_DIRECTORY . "news.dat")) {
             $this->flist[] = $INDEX_DIRECTORY . "news.dat";
         }
         if (file_exists($INDEX_DIRECTORY . "messages.dat")) {
             $this->flist[] = $INDEX_DIRECTORY . "messages.dat";
         }
         if (file_exists($INDEX_DIRECTORY . "blocks.dat")) {
             $this->flist[] = $INDEX_DIRECTORY . "blocks.dat";
         }
         if (file_exists($INDEX_DIRECTORY . "favorites.dat")) {
             $this->flist[] = $INDEX_DIRECTORY . "favorites.dat";
         }
     }
     // Backup config.php
     if (isset($_POST["um_config"])) {
         $this->flist[] = "config.php";
     }
     // Backup gedcoms and media
     if (isset($_POST["um_gedcoms"]) || isset($_POST["um_media"])) {
         $exportOptions = array();
         $exportOptions['privatize'] = 'none';
         $exportOptions['toANSI'] = 'no';
         $exportOptions['noCustomTags'] = 'no';
         $exportOptions['slashes'] = 'forward';
         foreach ($GEDCOMS as $key => $gedcom) {
             //-- load the gedcom configuration settings
             require get_config_file($key);
             if (isset($_POST["um_gedcoms"])) {
                 //-- backup the original gedcom file
                 if (file_exists($gedcom["path"])) {
                     $this->flist[] = $gedcom["path"];
                 }
                 //-- recreate the GEDCOM file from the DB
                 //-- backup the DB in case of GEDCOM corruption
                 $gedname = $INDEX_DIRECTORY . $key . ".bak";
                 $gedout = fopen(filename_decode($gedname), "wb");
                 $exportOptions['path'] = $MEDIA_DIRECTORY;
                 export_gedcom($key, $gedout, $exportOptions);
                 fclose($gedout);
                 $this->flist[] = $gedname;
             }
             if (isset($_POST["um_media"])) {
                 // backup media files
                 $dir = dir($MEDIA_DIRECTORY);
                 while (false !== ($entry = $dir->read())) {
                     if ($entry[0] != ".") {
                         if ($entry != "thumbs") {
                             $this->flist[] = $MEDIA_DIRECTORY . $entry;
                         }
                     }
                 }
                 if ($USE_MEDIA_FIREWALL) {
                     $dir = dir($MEDIA_FIREWALL_ROOTDIR . $MEDIA_DIRECTORY);
                     while (false !== ($entry = $dir->read())) {
                         if ($entry[0] != ".") {
                             if ($entry != "thumbs" && $entry != "watermark") {
                                 $this->flist[] = $MEDIA_FIREWALL_ROOTDIR . $MEDIA_DIRECTORY . $entry;
                             }
                         }
                     }
                 }
             }
         }
         //-- restore the old configuration file
         require get_config_file($GEDCOM);
         $this->flist[] = $INDEX_DIRECTORY . "pgv_changes.php";
     }
     // Backup gedcom settings
     if (isset($_POST["um_gedsets"])) {
         // Gedcoms file
         if (file_exists($INDEX_DIRECTORY . "gedcoms.php")) {
             $this->flist[] = $INDEX_DIRECTORY . "gedcoms.php";
         }
         foreach ($GEDCOMS as $key => $gedcom) {
             // Config files
             if (file_exists($INDEX_DIRECTORY . $gedcom["gedcom"] . "_conf.php")) {
                 $this->flist[] = $INDEX_DIRECTORY . $gedcom["gedcom"] . "_conf.php";
             }
             // Privacy files
             if (file_exists($INDEX_DIRECTORY . $gedcom["gedcom"] . "_priv.php")) {
                 $this->flist[] = $INDEX_DIRECTORY . $gedcom["gedcom"] . "_priv.php";
             }
         }
     }
     // Backup logfiles and counters
     if (isset($_POST["um_logs"])) {
         foreach ($GEDCOMS as $key => $gedcom) {
             // Gedcom counters
             if (file_exists($INDEX_DIRECTORY . $gedcom["gedcom"] . "pgv_counters.php")) {
                 $this->flist[] = $INDEX_DIRECTORY . $gedcom["gedcom"] . "pgv_counters.php";
             }
             // Gedcom searchlogs and changelogs
             $dir_var = opendir($INDEX_DIRECTORY);
             while ($file = readdir($dir_var)) {
                 if (strpos($file, ".log") > 0 && (strstr($file, "srch-" . $gedcom["gedcom"]) !== false || strstr($file, "ged-" . $gedcom["gedcom"]) !== false)) {
                     $this->flist[] = $INDEX_DIRECTORY . $file;
                 }
             }
             closedir($dir_var);
         }
         // PhpGedView logfiles
         $dir_var = opendir($INDEX_DIRECTORY);
         while ($file = readdir($dir_var)) {
             if (strpos($file, ".log") > 0 && strstr($file, "pgv-") !== false) {
                 $this->flist[] = $INDEX_DIRECTORY . $file;
             }
         }
         closedir($dir_var);
     }
     // Make the zip
     if (count($this->flist) > 0) {
         require_once "includes/pclzip.lib.php";
         $this->buname = date("YmdHis") . ".zip";
         $this->fname = $INDEX_DIRECTORY . $this->buname;
         $comment = "Created by " . PGV_PHPGEDVIEW . " " . PGV_VERSION_TEXT . " on " . date("r") . ".";
         $archive = new PclZip($this->fname);
         //-- remove ../ from file paths when creating zip
         $ct = preg_match("~((\\.\\./)+)~", $INDEX_DIRECTORY, $match);
         $rmpath = "";
         if ($ct > 0) {
             $rmpath = $match[1];
         }
         $this->v_list = $archive->create($this->flist, PCLZIP_OPT_COMMENT, $comment, PCLZIP_OPT_REMOVE_PATH, $rmpath);
         if ($this->v_list == 0) {
             $this->errorMsg = "Error : " . $archive->errorInfo(true);
         }
         if (isset($_POST["um_usinfo"])) {
             // Remove temporary files again
             if (file_exists($INDEX_DIRECTORY . "authenticate.php")) {
                 unlink($INDEX_DIRECTORY . "authenticate.php");
             }
             if (file_exists($INDEX_DIRECTORY . "news.dat")) {
                 unlink($INDEX_DIRECTORY . "news.dat");
             }
             if (file_exists($INDEX_DIRECTORY . "messages.dat")) {
                 unlink($INDEX_DIRECTORY . "messages.dat");
             }
             if (file_exists($INDEX_DIRECTORY . "blocks.dat")) {
                 unlink($INDEX_DIRECTORY . "blocks.dat");
             }
             if (file_exists($INDEX_DIRECTORY . "favorites.dat")) {
                 unlink($INDEX_DIRECTORY . "favorites.dat");
             }
         }
     }
 }