Jump to content

How Do I Get $Salt When It's In The Config.php File?


ChayaCooper

Recommended Posts

I know this is a really basic question, but I'm still a real php noob. I want to move $salt to the config.php file, but I'm not sure how to call the variable correctly so the page can use it.

 

I tried this:

require_once('config.php);    
$salt = loadSaltFromConfig();

 

I'm assuming that I need to declare loadSaltFromConfig somewhere, but I'm not quite sure what that would need to be.

I'll try that again :-) I thought that should be the case, but when it didn't work I figured I must be doing something wrong ;-)

 

Just to make sure that I'm not missing something

 

I'm declaring in config.php $salt = "XYZ"; // 10 digit string.

 

Then if I've created a connection to config.php in the other file I can just use it like this:

'".sha1($salt + $_POST['password'])."'

You can also use:

$dir_name = dirname(__FILE__):

 

Once you have the string directory, you can then search the directory for example:

$files = scandir($dir_name);

echo "<pre>";
print_r($files);
echo "</pre>";

 

Hope it helps.

 

Regards,

 

AoTB.

@jazzman1:

 

Here are the results from the 3 folders:

 

Parent Directory

/home4/clickfi4/public_html

 

'demo' folder

/home4/clickfi4/public_html/demo

 

'secure_folder' subfolder

/home4/clickfi4/public_html/demo/secure_folder

I think your directories looks good.

Make a simple test for me>

Create a new file in directory- "/home4/clickfi4/public_html/demo" and named it - debug.php.

On the top of your config.php file put it - echo 'test'.

A config.php must locate in "/home4/clickfi4/public_html/demo/secure_folder"

In a debug.php file copy/paste next code:

<?php
error_reporting(E_ALL);
require_once 'secure_folder/config.php';

Did that :-)

 

I added to the config.php

echo ("test");

 

In 'demo folder' - debug.php

<?php 
   session_start(); 
error_reporting(E_ALL);
require_once 'secure_folder/config.php';  
?>

 

And when I go to http://www.click2fit.com/demo/debug.php it echos 'test' :-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.