home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / upgrade / upd-2.0.16-to-2.0.17 / index.php
Encoding:
PHP Script  |  2007-09-09  |  1.5 KB  |  66 lines

  1. <?php
  2.  
  3. class upgrade_2017 {
  4.     
  5.     var $usedFiles = array( );
  6.     
  7.     function isApplied() {
  8.         return ( /*$this->check_file_patch() &&*/ $this->check_auth_db() );
  9.     }
  10.  
  11.     function apply() {    
  12.         return $this->apply_auth_db();
  13.     }
  14.  
  15.     function check_file_patch() {
  16.         /* $path = XOOPS_ROOT_PATH . '/class/auth';
  17.         $lines = file( "$path/auth_provisionning.php");
  18.         foreach ( $lines as $line ) {
  19.             if ( strpos( $line, "ldap_provisionning_upd" ) !== false ) {
  20.                 // Patch found: do not apply again
  21.                 return true;
  22.             }
  23.         } */
  24.         return true;
  25.     }
  26.  
  27.  
  28.     function check_auth_db() {
  29.         $db = $GLOBALS['xoopsDB'];
  30.         $value = getDbValue( $db, 'config', 'conf_id',
  31.             "`conf_name` = 'ldap_use_TLS' AND `conf_catid` = " . XOOPS_CONF_AUTH
  32.         );
  33.         return (bool)($value);
  34.     }
  35.     
  36.     function query( $sql ) {
  37.         $db = $GLOBALS['xoopsDB'];
  38.         if ( ! ( $ret = $db->queryF( $sql ) ) ) {
  39.             echo $db->error();
  40.         }
  41.     }
  42.  
  43.     function apply_auth_db() {
  44.         $db = $GLOBALS['xoopsDB'];
  45.         
  46.         // Insert config values
  47.         $table = $db->prefix( 'config' );
  48.         $data = array(
  49.                'ldap_use_TLS'    => "'_MD_AM_LDAP_USETLS', '0', '_MD_AM_LDAP_USETLS_DESC', 'yesno', 'int', 21",
  50.         );
  51.         foreach ( $data as $name => $values ) {
  52.             if ( !getDbValue( $db, 'config', 'conf_id', "`conf_modid`=0 AND `conf_catid`=7 AND `conf_name`='$name'" ) ) {
  53.                 $this->query(
  54.                     "INSERT INTO `$table` (conf_modid,conf_catid,conf_name,conf_title,conf_value,conf_desc,conf_formtype,conf_valuetype,conf_order) " .
  55.                     "VALUES ( 0,7,'$name',$values)"
  56.                 );
  57.             }
  58.         }
  59.         return true;
  60.     }
  61. }
  62.  
  63. $upg = new upgrade_2017();
  64. return $upg;
  65.  
  66. ?>