Exemplo n.º 1
0
 /**
  * Checks if a URL exists (if it is correct or not)
  *
  * @param string url to check
  * @return boolean true if the url is correct, false otherwise
  */
 function url_exists($url)
 {
     $file = merge_fetch_remote_file($url);
     if (!$file) {
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 function after_insert($data, $insert_data, $aid)
 {
     global $import_session, $mybb, $db;
     // Transfer attachment thumbnail
     $thumb_not_exists = "";
     if ($data['id_thumb'] != 0) {
         // Transfer attachment thumbnail
         $query = $this->old_db->simple_select("attachments", "*", "id_attach = '{$data['id_thumb']}'");
         $data['thumb_file_name'] = $data['id_thumb'] . "_" . $this->old_db->fetch_field($query, "file_hash");
         $this->old_db->free_result($query);
         $attachment_thumbnail_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['thumb_file_name']);
         if (!empty($attachment_thumbnail_file)) {
             $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], 'w');
             if ($attachrs) {
                 @fwrite($attachrs, $attachment_thumbnail_file);
             } else {
                 $this->board->set_error_notice_in_progress("Error transfering the attachment thumbnail (ID: {$aid})");
             }
             @fclose($attachrs);
             @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], '0777');
         } else {
             $this->board->set_error_notice_in_progress("Error could not find the attachment thumbnail (ID: {$aid})");
         }
     }
     // Transfer attachment
     $attachment_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['id_attach'] . "_" . $data['file_hash']);
     if (!empty($attachment_file)) {
         $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], 'w');
         if ($attachrs) {
             @fwrite($attachrs, $attachment_file);
         } else {
             $this->board->set_error_notice_in_progress("Error transfering the attachment (ID: {$aid})");
         }
         @fclose($attachrs);
         @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], '0777');
     } else {
         $this->board->set_error_notice_in_progress("Error could not find the attachment (ID: {$aid})");
     }
     if (!$posthash) {
         // Restore connection
         $db->update_query("posts", array('posthash' => $insert_data['posthash']), "pid = '{$insert_data['pid']}'");
     }
     $posthash = $this->get_import->post_attachment_details($data['id_msg']);
     $db->write_query("UPDATE " . TABLE_PREFIX . "threads SET attachmentcount = attachmentcount + 1 WHERE tid = '" . $posthash['tid'] . "'");
 }
Exemplo n.º 3
0
 function after_insert($data, $insert_data, $aid)
 {
     global $mybb, $import_session;
     $thumb_not_exists = "";
     if ($data['attach_thumb_location']) {
         // Transfer attachment thumbnail
         $data_thumbnail_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['attach_thumb_location']);
         if (!empty($data_thumbnail_file)) {
             $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], 'w');
             if ($attachrs) {
                 @fwrite($attachrs, $data_thumbnail_file);
             } else {
                 $this->board->set_error_notice_in_progress("Error transfering the attachment thumbnail (ID: {$aid})");
             }
             @fclose($attachrs);
             @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], '0777');
         } else {
             $this->board->set_error_notice_in_progress("Error could not find the attachment thumbnail (ID: {$aid})");
         }
     }
     // Transfer attachment
     $data_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['attach_location']);
     if (!empty($data_file)) {
         $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], 'w');
         if ($attachrs) {
             @fwrite($attachrs, $data_file);
         } else {
             $this->board->set_error_notice_in_progress("Error transfering the attachment (ID: {$aid})");
         }
         @fclose($attachrs);
         @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], '0777');
         $attach_not_exists = "";
     } else {
         $this->board->set_error_notice_in_progress("Error could not find the attachment (ID: {$aid})");
     }
 }
Exemplo n.º 4
0
        // Generate the list of stats we have (Amount of threads imported, amount of posts imported, etc)
        foreach ($import_stats as $key => $title) {
            if (array_key_exists($key, $import_session)) {
                $post_data[$key] = $import_session[$key];
            }
        }
        $post_data['newdb_query_count'] = intval($import_session['newdb_query_count']);
        $post_data['olddb_query_count'] = intval($import_session['olddb_query_count']);
        $post_data['start_date'] = $import_session['start_date'];
        $post_data['end_date'] = $import_session['end_date'];
        $post_data['board'] = $import_session['board'];
        $post_data['return'] = "1";
        $post_data['rev'] = $revision;
    }
    // Try and send statistics
    merge_fetch_remote_file("http://www.mybb.com/stats/mergesystem.php", $post_data);
    $import_session['allow_anonymous_info'] = 0;
    update_import_session();
    $output->update_progress_bar(200);
    echo "done.<br />\n";
    flush();
    // We cannot do a header() redirect here because on some servers with gzip or zlib auto compressing content, it creates an  Internal Server Error.
    // Who knows why. Maybe it wants to send the content to the browser after it trys and redirects?
    echo "<br /><br />\nPlease wait...<meta http-equiv=\"refresh\" content=\"2; url=index.php?action=completed\">";
    exit;
} elseif ($import_session['counters_cleanup']) {
    $debug->log->event("Show the counters cleanup page");
    define("BACK_BUTTON", false);
    // Get the converter up.
    require_once MERGE_ROOT . "boards/" . $import_session['board'] . ".php";
    $class_name = strtoupper($import_session['board']) . "_Converter";
Exemplo n.º 5
0
 function after_insert($data, $insert_data, $aid)
 {
     global $mybb, $db, $import_session;
     $thumb_not_exists = $error_notice = "";
     if ($data['thumbnail']) {
         // Transfer attachment thumbnail
         $attachment_thumbnail_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $insert_data['thumbnail']);
         if (!empty($attachment_thumbnail_file)) {
             $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], 'w');
             if ($attachrs) {
                 @fwrite($attachrs, $attachment_thumbnail_file);
             } else {
                 $this->board->set_error_notice_in_progress("Error transfering the attachment thumbnail (ID: {$aid})");
             }
             @fclose($attachrs);
             @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['thumbnail'], '0777');
         } else {
             $this->board->set_error_notice_in_progress("Error could not find the attachment thumbnail (ID: {$aid})");
         }
     }
     // Transfer attachment
     $attachment_file = merge_fetch_remote_file($import_session['uploadspath'] . '/' . $data['attachname']);
     if (!empty($attachment_file)) {
         $attachrs = @fopen($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], 'w');
         if ($attachrs) {
             @fwrite($attachrs, $attachment_file);
             @fclose($attachrs);
         } else {
             $this->board->set_error_notice_in_progress("Error transfering the attachment (ID: {$aid}), Uploads folder is not writable.");
         }
         @my_chmod($mybb->settings['uploadspath'] . '/' . $insert_data['attachname'], '0777');
     } else {
         $this->board->set_error_notice_in_progress("Error could not find the attachment (ID: {$aid})");
     }
     // Restore connection
     $query = $db->simple_select("posts", "message", "pid = '{$insert_data['pid']}'");
     $message = $db->fetch_field($query, 'message');
     $db->free_result($query);
     $message = str_replace('[attachment=' . $data['aid'] . ']', '[attachment=' . $aid . ']', $message);
     $db->update_query("posts", array('posthash' => $insert_data['posthash'], 'message' => $db->escape_string($message)), "pid = '{$insert_data['pid']}'");
 }