Topic on Project:Support desk

[RESOLVED]cookies error message during connection to wiki

4
78.206.72.23 (talkcontribs)

Hi,

to prevent acces to my mediawiki server, I create a form requiring the login to server and I check the answer according to values saved into a DB table created with phymyadmin Now, before to run the mediawiki object the form is displayed

to perform this , I modified the index.php as following

 <?php
 session_start();
 header('Content-Type: text/html; charset=UTF-8');
 if ( !function_exists( 'version_compare' ) || version_compare( phpversion(), '5.3.2' ) < 0 ) {
	// We need to use dirname( __FILE__ ) here cause __DIR__ is PHP5.3+
	require dirname( __FILE__ ) . '/includes/PHPVersionError.php';
	wfPHPVersionError( 'index.php' );
 }
 if (isset($_SESSION['Acces']) && ($_SESSION['Acces']==false)){
      echo "<center><h2><font color='red'>Incorrect Login</font></h2><center>"; }
      
  if (isset($_SESSION['Acces']) && ($_SESSION['Acces'])){

     require __DIR__ . '/includes/WebStart.php'; 
     $mediaWiki = new MediaWiki();
     $mediaWiki->run();
     }
  else { 
   ?>
     <center>
       <form action ="checkForm.php" method="post">
       <b>identifiant : </b><input type="text" name="inputlogin" size="30"> <br />
       <b>password : </b><input type="password" name="inputpwd" size="30"> <br />
           <div class="action">
           <input type="submit" class="btn primary" value="Valider">
           </div>
       </form>     
    </center>
  <?php
  }

and I create a checkForm.php as following

<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE);

 $_SESSION['mytwikiLog'] = $_POST['inputlogin'];
 $_SESSION['mywikiPwd'] = sha1($_POST['inputpwd']);

 $connect = mysqli_connect("localhost","root","rootpass","myDB") or die('error BD connect');
 $query = 'SELECT * FROM myTable' ;
 $result = mysqli_query($connect,$query) or die('Table error') ;
 
  while($row = mysqli_fetch_row($result)){
    if ( ($_SESSION['mywikiLog']==$row[1]) && ($_SESSION['mywikiPwd']==$row[2]) ){
        $_SESSION['Acces']=true;
        break;}
    else {
        $_SESSION['Acces']=false;}
  }
  mysqli_free_result($result);
  mysqli_close($connect);
  
  require("./index.php");
  exit();
 ?>

But Now when I want to enter my connect login to the mediawiki The login is performed but I always have the two messages (brown and pink)

  • 'userlogin-loggedin' : you are already logged in as .... use the form below to ogin an another user
  • 'nocookieslogin' : SITENAME uses cookies to login users. You have cookies disabled. Please enabe them and try again

but I am corectly connect to the wiki and my cookies are activated

WHY HAVE I THIS TWO MESSAGES ?

Please coud you help me great thanks

Florianschmidtwelzow (talkcontribs)

Ehhh, please Do not hack MediaWiki core :) It's really not the best solution, what you are doing. MediaWiki itself should handle session initialization and all other stuff, so i think, that your problem is somewhere in your implementation.

For what i understand, what you want to reach its much better to use the MediaWiki-built in functions. So why not require login for users in order to read/access the content in your wiki?

If you really want to have a pre-login login, then maybe it's better to use .htaccess login, instead of the above code.

Last, but not least, if you really want to have a pre-login form with your own stuff, you should read, how to implement Extensions in MediaWiki. I think it would be much better to use one (or more) of MediaWikis hooks to break in to MediaWiki's page creation process.

78.206.72.23 (talkcontribs)

Before I protected all the serveur access with a .htaccess .htpassword but the form which was displayed are different according to the navigators and the access text was limited (no possibiity to add one image in background !)

So, it was requested to me to make a pre-login login form

because it is a private wiki we want "accueil page" should be accessible only when this pre-login is validated

Is existing an extension to perform that : I don't find it

After entering into the wiki: Ok the user right are correctly configurated with the localsetting (the anonymous can read but not write..., the extension confirmAccount is installed to accept only any users ....)

manage one hook is not clear for me : where can I find an exemple of pre-login form which run the mediawiki ony if the prelogin is correct ?

Thanks for your help

Jackmcbarn (talkcontribs)

Delete checkForm.php and put index.php back to normal. Add $wgGroupPermissions['*']['read'] = false; to your LocalSettings.php. Everything will work right with just the regular login then.

Reply to "[RESOLVED]cookies error message during connection to wiki"