KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/astrosfm/pmwiki/cookbook/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/astrosfm/pmwiki/cookbook/storedauthname.php
<?php if (!defined('PmWiki')) exit();
/*
        * Copyright *
        Copyright 2006, by Antony Templier ([email protected])
        Also, a lot of lines of code come from Patrick R. Michaud (authuser.php).

        Version 0.3 (development version - works with pmwiki-2.1.beta20)

        * License *
        Same as PmWiki (GNU GPL)

        * Description *
        For sites with authenticated users (with AuthUser), this script
        allow you to use author name ($Author) stored in the $SiteGroup.AuthUser
        page and to automatically set the author name in the author field
        in case it's blank.

        * Installation Instructions *
        1- Install authuser.php before
           See -  http://www.pmwiki.org/wiki/Cookbook/AuthUser
        2- Put this script (storedauthname.php) in your cookbook directory
        3- Add the line below in your local/config.php :

            include_once('cookbook/storedauthname.php');

        * Usage *
        To set an author name:
        Edit your $SiteGroup.AuthUser page (usually Site.AuthUser) and
        add lines like this one:

            userid::authorname

        Where userid is $AuthId and authorname is $Author separated
        by two colons.
        The script set automatically the author name during edition.
        If no author name is found, the author name is set to the user id.
        To enforce author tracking for authenticated users, you can set the
        variable $ForceAuthorTracking in your local/config.php just before
        the include_once function, like this :

            $ForceAuthorTracking=1; # 1 to enable, 0 (default) to disable
            include_once('cookbook/storedauthname.php');
                
*/
SDV($ForceAuthorTracking,0);

$page = RetrieveAuthPage($pagename, 'read', false, READPAGE_CURRENT);

if ($action == 'edit' &&
   $page['=auth']['edit'] &&
   ($ForceAuthorTracking || !@$_COOKIE['author']) ){
    SetAuthorName($pagename);
}

function SetAuthorName($pagename) {

    global $Author, $AuthUserPageFmt, $AuthId;

    @session_start();
    if (@$_SESSION['authid']){

        SDV($AuthUserPageFmt, '$SiteGroup.AuthUser');
        $pn = FmtPageName($AuthUserPageFmt, $pagename);
        $apage = ReadPage($pn, READPAGE_CURRENT);

        if ($apage && preg_match_all("/\n\\s*([@\\w][^\\s:]*):{2,2}(.*)/",
                                $apage['text'], $matches, PREG_SET_ORDER)) {
             foreach($matches as $m){              
                #if ($m[1] == @$_SESSION['authid']){
                if ($m[1] == $AuthId) {
                    $Author = $m[2];
                }
            }
        }

        if (!$Author){
            #$Author = @$_SESSION['authid'];
            $Author = $AuthId;
        }

        setcookie('author',$Author,0,'/');
    }
}
?>

Anon7 - 2021