Exemplo n.º 1
0
 /**
  * Main installation entry point. This function create db tables, set default settings, check for changes.
  */
 function install_plugin()
 {
     global $wp_version;
     $this->wp_version = substr(str_replace('.', '', $wp_version), 0, 2);
     $this->o = get_option('gd-press-tools');
     $this->r = get_option('gd-press-tools-robots');
     $this->g = get_option('gd-press-tools-avatars');
     $this->s = get_option('gd-press-tools-status');
     $this->a = get_site_option('gd-press-tools-global');
     if (!is_array($this->a)) {
         update_site_option('gd-press-tools-global', $this->default_global);
         $this->a = get_site_option('gd-press-tools-global');
     }
     if (!is_array($this->s)) {
         update_option('gd-press-tools-status', array());
         $this->s = get_option('gd-press-tools-status');
     }
     if (!is_array($this->r)) {
         update_option('gd-press-tools-robots', $this->default_robots);
         $this->r = get_option('gd-press-tools-robots');
     }
     if (!is_array($this->g)) {
         update_option('gd-press-tools-avatars', array());
         $this->g = get_option('gd-press-tools-avatars');
     }
     $installed = false;
     if (!is_array($this->o)) {
         $this->default_options["memory_limit"] = ini_get('memory_limit');
         update_option('gd-press-tools', $this->default_options);
         $this->o = get_option('gd-press-tools');
         $installed = true;
     }
     if ($this->o["build"] != $this->default_options["build"] || $this->o["edition"] != $this->default_options["edition"] || $installed) {
         $this->o = gdFunctionsGDPT::upgrade_settings($this->o, $this->default_options);
         $this->a = gdFunctionsGDPT::upgrade_settings($this->a, $this->default_global);
         gdDBInstallGDPT::delete_tables(PRESSTOOLS_PATH);
         gdDBInstallGDPT::create_tables(PRESSTOOLS_PATH);
         gdDBInstallGDPT::upgrade_tables(PRESSTOOLS_PATH);
         gdDBInstallGDPT::alter_tables(PRESSTOOLS_PATH);
         $this->o["database_upgrade"] = date("r");
         $this->o["version"] = $this->default_options["version"];
         $this->o["date"] = $this->default_options["date"];
         $this->o["status"] = $this->default_options["status"];
         $this->o["build"] = $this->default_options["build"];
         $this->o["revision"] = $this->default_options["revision"];
         $this->o["edition"] = $this->default_options["edition"];
         update_option('gd-press-tools', $this->o);
         update_site_option('gd-press-tools-global', $this->a);
         $this->fix_folders();
         $this->backup_folder();
         update_option('gd-press-tools-avatars', $this->gravatar_folder($this->g));
         $this->g = get_option('gd-press-tools-avatars');
         gd_create_protection_file(WP_CONTENT_DIR . "/avatars/");
         gd_create_protection_file(WP_CONTENT_DIR . "/gdbackup/");
     }
     $this->script = $_SERVER["PHP_SELF"];
     $this->script = end(explode("/", $this->script));
 }
Exemplo n.º 2
0
 /**
  * Imports data from file into table
  *
  * @global object $wpdb Wordpress DB class
  * @global string $table_prefix Wordpress table prefix
  * @param string $path base path to folder where the install folder is located with trailing slash
  */
 function import_data($path)
 {
     global $wpdb, $table_prefix;
     $path .= "install/data";
     $files = gdDBInstallGDPT::scan_folder($path);
     $wpdb->show_errors = true;
     foreach ($files as $file) {
         if (substr($file, 0, 1) != '.') {
             $file_path = $path . "/" . $file;
             $handle = @fopen($file_path, "r");
             if ($handle) {
                 while (!feof($handle)) {
                     $line = fgets($handle);
                     $sql = sprintf($line, $table_prefix);
                     $wpdb->query($sql);
                 }
                 fclose($handle);
             }
         }
     }
 }