break; case 'dist-poller': if ($config['distributed_poller'] !== true) { print_fail('You have not enabled distributed_poller'); } else { if (empty($config['distributed_poller_memcached_host'])) { print_fail('You have not configured $config[\'distributed_poller_memcached_host\']'); } elseif (empty($config['distributed_poller_memcached_port'])) { print_fail('You have not configured $config[\'distributed_poller_memcached_port\']'); } else { $connection = @fsockopen($config['distributed_poller_memcached_host'], $config['distributed_poller_memcached_port']); if (!is_resource($connection)) { print_fail('We could not get memcached stats, it is possible that we cannot connect to your memcached server, please check'); } else { fclose($connection); print_ok('Connection to memcached is ok'); } } if (empty($config['rrdcached'])) { print_fail('You have not configured $config[\'rrdcached\']'); } elseif (empty($config['rrd_dir'])) { print_fail('You have not configured $config[\'rrd_dir\']'); } else { check_rrdcached(); } } break; case 'rrdcheck': // Loop through the rrd_dir $rrd_directory = new RecursiveDirectoryIterator($config['rrd_dir']); // Filter out any non rrd files
print_fail('We could not get memcached stats, it is possible that we cannot connect to your memcached server, please check'); } else { fclose($connection); print_ok('Connection to memcached is ok'); } } if (empty($config['rrdcached'])) { print_fail('You have not configured $config[\'rrdcached\']'); } elseif (empty($config['rrd_dir'])) { print_fail('You have not configured $config[\'rrd_dir\']'); } else { list($host, $port) = explode(':', $config['rrdcached']); $connection = @fsockopen($host, $port); if (is_resource($connection)) { fclose($connection); print_ok('Connection to rrdcached is ok'); } else { print_fail('Cannot connect to rrdcached instance'); } } } break; } //end switch } //end foreach // End function print_ok($msg) { echo "[OK] {$msg}\n"; }
} if (empty($config['email_smtp_port'])) { print_fail('You have selected smtp but not configured an smtp port'); $run_test = 0; } if ($config['email_smtp_auth'] === true && (empty($config['email_smtp_username']) || empty($config['email_smtp_password']))) { print_fail('You have selected smtp but not configured a username or password'); $run_test = 0; } } } } //end if if ($run_test == 1) { if ($err = send_mail($config['alert']['default_mail'], 'Test email', 'Testing email from NMS')) { print_ok('Email has been sent'); } else { print_fail('Issue sending email to ' . $config['alert']['default_mail'] . ' with error ' . $err); } } } //end if break; } //end switch } //end foreach // End function print_ok($msg) { global $console_color;
if (empty($config['email_smtp_host'])) { print_fail("You have selected smtp but not configured an smtp host"); $run_test = 0; } if (empty($config['email_smtp_port'])) { print_fail("You have selected smtp but not configured an smtp port"); $run_test = 0; } if ($config['email_smtp_auth'] === TRUE && (empty($config['email_smtp_username']) || empty($config['email_smtp_password']))) { print_fail("You have selected smtp but not configured a username or password"); $run_test = 0; } } if ($run_test == 1) { if ($err = send_mail($config['alert']['default_mail'], 'Test email', 'Testing email from NMS')) { print_ok("Email has been sent"); } else { print_fail("Issue sending email to " . $config['alert']['default_mail'] . " with error " . $err); } } } break; } } // End function print_ok($msg) { global $console_color; print $console_color->convert("%g[OK]%n %W{$msg}\n"); } function print_fail($msg)
if (CONVERT_COMMENTS) { $max_post_id = (int) get_max_val(BB_POSTS, 'post_id'); $max_topic_id = (int) get_max_val(BB_TOPICS, 'topic_id'); $max_attach_id = (int) get_max_val(BB_ATTACHMENTS, 'attach_id'); $comments_count = (int) get_count(TB_COMMENTS_TABLE, 'id'); $loops = (int) ceil($comments_count / C_COMMENTS_PER_ONCE); for ($i = 0; $i < $loops; $i++) { $start = $i * C_COMMENTS_PER_ONCE; $offset = C_COMMENTS_PER_ONCE; $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\tc.id, c.user, c.torrent, c.text, tor.category,\n\t\t\t\t\tUNIX_TIMESTAMP(c.added) AS added, UNIX_TIMESTAMP(c.editedat) AS editedat, c.ip\n\t\t\t\tFROM " . TB_COMMENTS_TABLE . " c\n\t\t\t\tLEFT JOIN " . TB_TORRENTS_TABLE . " tor ON(tor.id = c.torrent)\n\t\t\t\tWHERE c.torrent <> 0\n\t\t\t\tORDER BY c.id\n\t\t\t\tLIMIT {$start}, {$offset}"; $comments = DB()->fetch_rowset($sql); DB()->sql_freeresult(); foreach ($comments as $comment) { $comment['user'] += $max_uid; $comment['id'] += $max_post_id; convert_comment($comment); } } unset($comments); set_auto_increment(BB_POSTS, 'post_id'); print_ok("Total {$comments_count} comments from TBDev converted"); } } ?> </div> <br /> Converting completed. </body> </html> <?php }
} else { @ini_set('memory_limit', '512M'); @ini_set('max_execution_time', @ini_get('max_execution_time') + 1200); $torrents_count = (int) get_count(BB_BT_TORRENTS, 'attach_id'); $loops = (int) ceil($torrents_count / C_TORRENTS_PER_ONCE); $not_exist = array(); $attach_dir = get_attachments_dir() . '/'; for ($i = 0; $i < $loops; $i++) { $start = $i * C_TORRENTS_PER_ONCE; $offset = C_TORRENTS_PER_ONCE; $sql = "SELECT\n\t\t\t\ttor.attach_id, tor.topic_id, ad.physical_filename\n\t\t\tFROM " . BB_BT_TORRENTS . " tor\n\t\t\tLEFT JOIN " . BB_ATTACHMENTS_DESC . " ad ON(ad.attach_id = tor.attach_id)\n\t\t\tORDER BY tor.attach_id\n\t\t\tLIMIT {$start}, {$offset}"; $torrents = DB()->fetch_rowset($sql); DB()->sql_freeresult(); foreach ($torrents as $torrent) { $filename = $attach_dir . $torrent['physical_filename']; if (!file_exists($filename)) { $not_exist[] = '<a href="viewtopic.php?t=' . $torrent['topic_id'] . '">' . $filename . '</a>'; } else { $tor = bdecode_file($filename); $info = !empty($tor['info']) ? $tor['info'] : array(); $info_hash = pack('H*', sha1(bencode($info))); $info_hash_sql = rtrim(DB()->escape($info_hash), ' '); DB()->query("UPDATE " . BB_BT_TORRENTS . "\n\t\t\t\t\t\tSET info_hash = '{$info_hash_sql}'\n\t\t\t\t\t\tWHERE attach_id = {$torrent['attach_id']}"); } } } print_ok("Completed"); if (!empty($not_exist)) { print_ok("These torrents doesn't exist in filesystem: " . implode(', ', array_unique($not_exist))); } }