omo conectar una base de datos de una WEB (SMF Forum) a AutoIndex PHP Script

Started by ^SoporteGSM^, September 20, 2018, 06:09:12 PM

Previous topic - Next topic

^SoporteGSM^

Hola a todos....

Tengo una duda... soy administrador de un foro echo con SMF
Y acabo de añadir una extensión /ftp.index.php con este Script (http://autoindex.sourceforge.net/)

La intencion es crear un directorio de archivos via FTP y que lo usuarios que deen descargar lo hagan con el usuario que ya tienen en el foro.

Mi pregunta es como conecto mi Script con la base de datos de los usuarios de mi foro???

MorderBR

no sé si entendí mal pero podrías usar SSI

require("/tu/directorio/SSI.php");

y la descarga la condicionas con algo como

if($user_info['is_guest']){//...tu descarga}

después de haber globalizado la variable $user_info

-Rock Lee-

¿Lo queres conectar a la base de datos para que precisamente? ¿es para administrar que usuarios tienen acceso? Si es de esa manera como dice @MorderBR seria la forma mas sencilla y rapida.


Saludos!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

vicram10

la condicional deberia ser si el usuario "NO" es visitante que pueda descargar.

if(!$user_info['is_guest']){//...tu descarga}

si es que entendi bien.





* vicram10 dice: agregue un ! en la condicional

^SoporteGSM^

Ok solo los Usuarios con membresia deben acceder a las descargas (es decir podran descargar) pero obviamente el script debe terner un login o acceso de usuarios y contraseñas de esos usuarios VIP.

MorderBR

Intenta esto:
Crea el grupo de membresía
Una vez creado, busca la id del grupo, ya sea en la base de datos o en el mismo foro
Modifica el array $user_info en el archivo Load.php
por ejemplo, yo modifiqué el array para ciertos grupos y ciertos permisos
'is_vip' => in_array(4, $user_info['groups']),
donde el 4 es el id del grupo creado para la membresía
Después usas la condición
if($user_info['is_vip']){//código de las descargas}

^SoporteGSM^

Hola ya hice el proceso basico y no aparece el login en la web de descargas...:

Aqui parte del archivo modificado.-

<?php

/**
 * Handles all requests by the browser. This is the only file that can be
 * accessed directly.
 *
 * @package AutoIndex
 * @author Justin Hagstrom <[email protected]>
 * @version 1.2.1 (January 06, 2007)
 *
 * @copyright Copyright (C) 2002-2007 Justin Hagstrom
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
 *
 * @link http://autoindex.sourceforge.net
 */

/*
   AutoIndex PHP Script is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   AutoIndex PHP Script is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/**
 * OPTIONAL SETTINGS:
 */

//filenames and paths for configuration related files
define('CONFIG_STORED''AutoIndex.conf.php');
define('CONFIG_GENERATOR''config.php');

//paths for files that will be included
define('PATH_TO_CLASSES''./classes/');
define('PATH_TO_LANGUAGES''./languages/');
define('LANGUAGE_FILE_EXT''.txt');

//filenames of template files
define('GLOBAL_HEADER''global_header.tpl');
define('GLOBAL_FOOTER''global_footer.tpl');
define('TABLE_HEADER''table_header.tpl');
define('TABLE_FOOTER''table_footer.tpl');
define('EACH_FILE''each_file.tpl');

/**
 * When ENABLE_CACHE is true, the indexes of directories will be stored in
 * files in the folder CACHE_STORAGE_DIR. You will notice a speed improvement
 * when viewing folders that contain a few thousand files. However, the contents
 * of the indexed folders will not be updated until you delete the cache file.
 */
define('ENABLE_CACHE'false);

/**
 * This is the folder cache data will be stored in. PHP needs write permission
 * in this directory. You can use an absolute path or a relative path, just
 * make sure there is a slash at the end.
 */
define('CACHE_STORAGE_DIR''./cache/');

/**
 * Format to display dates in.
 * @see date()
 */
define('DATE_FORMAT''Y-M-d');

/**
 * Sets debug mode. Off (false) by default.
 */
define('DEBUG'false);

/* END OPTIONAL SETTINGS */


/** The time this script began to execute. */
define('START_TIME'microtime(true));

/** Level for disabled/banned accounts. */
define('BANNED', -1);

/** Level for Guest users (users who are not logged in). */
define('GUEST'0);

/** Level for regular user accounts. */
define('USER'1);

/** Level for moderator ("super user") accounts. */
define('MODERATOR'2);

/** Level for Admin users. */
define('ADMIN'3);

/**
 * Minimum user level allowed to upload files.
 * Use the ADMIN, MODERATOR, USER, GUEST constants.
 * GUEST will allow non-logged-in users to upload.
 */
define('LEVEL_TO_UPLOAD'USER);

/** The version of AutoIndex PHP Script (the whole release, not based on individual files). */
define('VERSION''2.2.4');

/**
 * This must be set to true for other included files to run. Setting it to
 * false could be used to temporarily disable the script.
 */
define('IN_AUTOINDEX'true);

if (@
get_magic_quotes_gpc())
//remove any slashes added by the "magic quotes" setting
{
$_GET array_map('stripslashes'$_GET);
$_POST array_map('stripslashes'$_POST);
}
@
set_magic_quotes_runtime(0);

$_GET array_change_key_case($_GETCASE_LOWER);
$_POST array_change_key_case($_POSTCASE_LOWER);

if (@
ini_get('zlib.output_compression') == '1')
//compensate for compressed output set in php.ini
{
header('Content-Encoding: gzip');
}

/*
 * Uncomment the following code to turn on strict XHTML 1.1 compliance in
 * users' browsers. If you do this, make sure any changes you make to the
 * template do not break XHTML 1.1 compliance.
 */
/*if (isset($_SERVER['HTTP_ACCEPT']) && preg_match('#application/(xhtml\+xml|\*)#i', $_SERVER['HTTP_ACCEPT']))
{
header('Content-Type: application/xhtml+xml');
}*/

session_name('AutoIndex2');
session_start();

/**
 * Formats $text within valid XHTML 1.1 tags and doctype.
 *
 * @param string $text
 * @param string $title
 * @return string
 */
function simple_display($text$title 'Error on Page')
{
return '<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<?php require("/home/bibitlub/public_html/SSI.php"); ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<?php ssi_login(); ?>
<?php ssi_logout(); ?>
<?php ssi_welcome(); ?>
<?php ssi_recentTopics(); ?>
<title>' . $title . '</title>
<style type="text/css" title="AutoIndex Default">
html, body
{
font-family: verdana, lucidia, sans-serif;
font-size: 13px;
background-color: #F0F0F0;
color: #000000;
}
</style>
</head>


Aqui esta mi WEB con descargas: http://www.gsmarena.com.mx/ftp/

Se que el codigo funciona por esta prueba: http://www.gsmarena.com.mx/login.php

pd. el script por default trae un sistema de login, pero deseo usar el SSI de SMF

MorderBR

<?php

/**
 * Handles all requests by the browser. This is the only file that can be
 * accessed directly.
 *
 * @package AutoIndex
 * @author Justin Hagstrom <[email protected]>
 * @version 1.2.1 (January 06, 2007)
 *
 * @copyright Copyright (C) 2002-2007 Justin Hagstrom
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL)
 *
 * @link http://autoindex.sourceforge.net
 */

/*
   AutoIndex PHP Script is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   AutoIndex PHP Script is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/**
 * OPTIONAL SETTINGS:
 */

//filenames and paths for configuration related files
define('CONFIG_STORED''AutoIndex.conf.php');
define('CONFIG_GENERATOR''config.php');

//paths for files that will be included
require("/home/bibitlub/public_html/SSI.php");
define('PATH_TO_CLASSES''./classes/');
define('PATH_TO_LANGUAGES''./languages/');
define('LANGUAGE_FILE_EXT''.txt');


//filenames of template files
define('GLOBAL_HEADER''global_header.tpl');
define('GLOBAL_FOOTER''global_footer.tpl');
define('TABLE_HEADER''table_header.tpl');
define('TABLE_FOOTER''table_footer.tpl');
define('EACH_FILE''each_file.tpl');

/**
 * When ENABLE_CACHE is true, the indexes of directories will be stored in
 * files in the folder CACHE_STORAGE_DIR. You will notice a speed improvement
 * when viewing folders that contain a few thousand files. However, the contents
 * of the indexed folders will not be updated until you delete the cache file.
 */
define('ENABLE_CACHE'false);

/**
 * This is the folder cache data will be stored in. PHP needs write permission
 * in this directory. You can use an absolute path or a relative path, just
 * make sure there is a slash at the end.
 */
define('CACHE_STORAGE_DIR''./cache/');

/**
 * Format to display dates in.
 * @see date()
 */
define('DATE_FORMAT''Y-M-d');

/**
 * Sets debug mode. Off (false) by default.
 */
define('DEBUG'false);

/* END OPTIONAL SETTINGS */


/** The time this script began to execute. */
define('START_TIME'microtime(true));

/** Level for disabled/banned accounts. */
define('BANNED', -1);

/** Level for Guest users (users who are not logged in). */
define('GUEST'0);

/** Level for regular user accounts. */
define('USER'1);

/** Level for moderator ("super user") accounts. */
define('MODERATOR'2);

/** Level for Admin users. */
define('ADMIN'3);

/**
 * Minimum user level allowed to upload files.
 * Use the ADMIN, MODERATOR, USER, GUEST constants.
 * GUEST will allow non-logged-in users to upload.
 */
define('LEVEL_TO_UPLOAD'USER);

/** The version of AutoIndex PHP Script (the whole release, not based on individual files). */
define('VERSION''2.2.4');

/**
 * This must be set to true for other included files to run. Setting it to
 * false could be used to temporarily disable the script.
 */
define('IN_AUTOINDEX'true);

if (@
get_magic_quotes_gpc())
//remove any slashes added by the "magic quotes" setting
{
$_GET array_map('stripslashes'$_GET);
$_POST array_map('stripslashes'$_POST);
}
@
set_magic_quotes_runtime(0);

$_GET array_change_key_case($_GETCASE_LOWER);
$_POST array_change_key_case($_POSTCASE_LOWER);

if (@
ini_get('zlib.output_compression') == '1')
//compensate for compressed output set in php.ini
{
header('Content-Encoding: gzip');
}

/*
 * Uncomment the following code to turn on strict XHTML 1.1 compliance in
 * users' browsers. If you do this, make sure any changes you make to the
 * template do not break XHTML 1.1 compliance.
 */
/*if (isset($_SERVER['HTTP_ACCEPT']) && preg_match('#application/(xhtml\+xml|\*)#i', $_SERVER['HTTP_ACCEPT']))
{
header('Content-Type: application/xhtml+xml');
}*/

session_name('AutoIndex2');
session_start();

/**
 * Formats $text within valid XHTML 1.1 tags and doctype.
 *
 * @param string $text
 * @param string $title
 * @return string
 */
function simple_display($text$title 'Error on Page')
{
return '<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<?php ssi_login(); ?>
<?php ssi_logout(); ?>
<?php ssi_welcome(); ?>
<?php ssi_recentTopics(); ?>
<title>' . $title . '</title>
<style type="text/css" title="AutoIndex Default">
html, body
{
font-family: verdana, lucidia, sans-serif;
font-size: 13px;
background-color: #F0F0F0;
color: #000000;
}
</style>
</head>

Pues para empezar, si ocuparás el SSI en toda esta sección, creo sería más conveniente si lo llamas al principio
Cómo llamas a la función simple_display(... ?? y deberías buscar la forma de desactivar la sesión de ese script

-Rock Lee-

No he tenido tiempo de mirarlo del todo pero el problema plantea @MorderBR ya que por lo que vi el script usa la sesiones, lo ideal seria sacar todo rastro dejando unicamente la de SMF aunque no se hasta que punto te dara problemas llegando a ser mas rapido crearlo de 0 capas (por las llamadas a variables que me generan dudas en varias cosas sumado por la version del php). Al usar el SSI, no estoy seguro, tenes que declararlo en la primera linea de php ya sea lo usaras en alguna carpeta como en el mismo directorio raiz.


Saludos!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

Advertisement: