News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Paste-1209096942:v:use_geshi-1:v:type-php

Started by SleePy, Apr 25, 2008, 04:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SleePy

<?php
$block_size = 200;

require_once(dirname(__FILE__) . '/SSI.php');
error_reporting(E_ALL);
@mysql_select_db($db_name, $db_connection);

$request = db_query("
   SELECT MAX(ID_MSG)
   FROM {$db_prefix}messages
   WHERE 1
   LIMIT 1", __FILE__, __LINE__);
list($total_messages) = mysql_fetch_row($request);
mysql_free_result($request);

while ($total_messages > $block_size)
{
   $request = db_query("
      SELECT t.ID_TOPIC, m.subject
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)
      WHERE m.ID_MSG = t.ID_FIRST_MSG
         AND lss.ID_TOPIC IS NULL", __FILE__, __LINE__);
      
   $insertRows = array();
   while ($row = mysql_fetch_assoc($request))
   {
      foreach (text2words($row['subject']) as $word)
         $insertRows[] = "'$word', $row[ID_TOPIC]";
      if (count($insertRows) > 500)
      {
         db_query("
            INSERT IGNORE INTO {$db_prefix}log_search_subjects
               (word, ID_TOPIC)
            VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
            $insertRows = array();
      }
   }
   mysql_free_result($request);

   if (!empty($insertRows))
      db_query("
         INSERT IGNORE INTO {$db_prefix}log_search_subjects
            (word, ID_TOPIC)
         VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
}

echo "\n Completed!\n\n";
?>
No siggy! :D

SleePy

<?php
$block_size = 200;
$completed = 0;

require_once(dirname(__FILE__) . '/SSI.php');
error_reporting(E_ALL);
@mysql_select_db($db_name, $db_connection);

$request = db_query("
   SELECT MAX(ID_MSG)
   FROM {$db_prefix}messages
   WHERE 1
   LIMIT 1", __FILE__, __LINE__);
list($total_messages) = mysql_fetch_row($request);
mysql_free_result($request);

while ($completed < $total_messages)
{
   $request = db_query("
      SELECT t.ID_TOPIC, m.subject
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)
      WHERE m.ID_MSG = t.ID_FIRST_MSG
         AND lss.ID_TOPIC IS NULL
      LIMIT {$completed}, {$block_size}", __FILE__, __LINE__);
      
   $insertRows = array();
   while ($row = mysql_fetch_assoc($request))
   {
      foreach (text2words($row['subject']) as $word)
         $insertRows[] = "'$word', $row[ID_TOPIC]";
      if (count($insertRows) > 500)
      {
         db_query("
            INSERT IGNORE INTO {$db_prefix}log_search_subjects
               (word, ID_TOPIC)
            VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
            $insertRows = array();
      }
   }
   mysql_free_result($request);

   // Update it.
   $completed += $block_size;

   // Sleep for a bit if we can divide by 30k evenly.
   if ($completed % 30000 == 1)
      sleep(4);
}


   if (!empty($insertRows))
      db_query("
         INSERT IGNORE INTO {$db_prefix}log_search_subjects
            (word, ID_TOPIC)
         VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);

echo "\n Completed!\n\n";
?>
No siggy! :D

Guest

<?php
$block_size = 200;
$completed = 0;

require_once(dirname(__FILE__) . '/SSI.php');
error_reporting(E_ALL);
@mysql_select_db($db_name, $db_connection);

$request = db_query("
   SELECT MAX(ID_MSG)
   FROM {$db_prefix}messages
   WHERE 1
   LIMIT 1", __FILE__, __LINE__);
list($total_messages) = mysql_fetch_row($request);
mysql_free_result($request);

while ($completed < $total_messages)
{
   $request = db_query("
      SELECT t.ID_TOPIC, m.subject
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)
      WHERE m.ID_MSG = t.ID_FIRST_MSG
         AND lss.ID_TOPIC IS NULL
      LIMIT {$completed}, {$block_size}", __FILE__, __LINE__);
      
   $insertRows = array();
   while ($row = mysql_fetch_assoc($request))
   {
      foreach (text2words($row['subject']) as $word)
         $insertRows[] = "'$word', $row[ID_TOPIC]";
      if (count($insertRows) > 500)
      {
         db_query("
            INSERT IGNORE INTO {$db_prefix}log_search_subjects
               (word, ID_TOPIC)
            VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
            $insertRows = array();
      }
   }
   mysql_free_result($request);

   if (!empty($insertRows))
      db_query("
         INSERT IGNORE INTO {$db_prefix}log_search_subjects
            (word, ID_TOPIC)
         VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);

   // Update it.
   $completed += $block_size;

   // Sleep for a bit if we can divide by 30k evenly.
   if ($completed % 30000 == 1)
      sleep(4);
}

echo "n Completed!nn";
?>

SleePy

<?php
// Change this to handle more messages at once.
$block_size = 200;
$completed = 0;

// Sleep count should be a a number that the $block_size will hit a couple times to allow the server to take a break
$sleep_count = 30000;

require_once(dirname(__FILE__) . '/SSI.php');
error_reporting(E_ALL);
@mysql_select_db($db_name, $db_connection);

$request = db_query("
   SELECT MAX(ID_MSG)
   FROM {$db_prefix}messages
   WHERE 1
   LIMIT 1", __FILE__, __LINE__);
list($total_messages) = mysql_fetch_row($request);
mysql_free_result($request);

while ($completed < $total_messages)
{
   $request = db_query("
      SELECT t.ID_TOPIC, m.subject
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)
      WHERE m.ID_MSG = t.ID_FIRST_MSG
         AND lss.ID_TOPIC IS NULL
      LIMIT {$completed}, {$block_size}", __FILE__, __LINE__);
      
   $insertRows = array();
   while ($row = mysql_fetch_assoc($request))
   {
      foreach (text2words($row['subject']) as $word)
         $insertRows[] = "'$word', $row[ID_TOPIC]";
      if (count($insertRows) > 500)
      {
         db_query("
            INSERT IGNORE INTO {$db_prefix}log_search_subjects
               (word, ID_TOPIC)
            VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
            $insertRows = array();
      }
   }
   mysql_free_result($request);

   if (!empty($insertRows))
      db_query("
         INSERT IGNORE INTO {$db_prefix}log_search_subjects
            (word, ID_TOPIC)
         VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);

   // Update it.
   $completed += $block_size;

   // Sleep for a bit if we can divide by 30k evenly.
   if ($completed % $sleep_count == 0)
      sleep(4);
}

echo "\n Completed!\n\n";
?>
No siggy! :D

SleePy

<?php
// Change this to handle more messages at once.
$block_size = 200;

// Sleep count should be a a number that the $block_size will hit a couple times to allow the server to take a break
// It isn't required to edit this. Just may be needed if you are using a weird block size
$sleep_count = 30000;

// Do not change these
$completed = 0;
require_once(dirname(__FILE__) . '/SSI.php');
error_reporting(E_ALL);
@mysql_select_db($db_name, $db_connection);

$request = db_query("
   SELECT MAX(ID_MSG)
   FROM {$db_prefix}messages
   WHERE 1
   LIMIT 1", __FILE__, __LINE__);
list($total_messages) = mysql_fetch_row($request);
mysql_free_result($request);

while ($completed < $total_messages)
{
   $request = db_query("
      SELECT t.ID_TOPIC, m.subject
      FROM ({$db_prefix}topics AS t, {$db_prefix}messages AS m)
         LEFT JOIN {$db_prefix}log_search_subjects AS lss ON (lss.ID_TOPIC = t.ID_TOPIC)
      WHERE m.ID_MSG = t.ID_FIRST_MSG
         AND lss.ID_TOPIC IS NULL
      LIMIT {$completed}, {$block_size}", __FILE__, __LINE__);
      
   $insertRows = array();
   while ($row = mysql_fetch_assoc($request))
   {
      foreach (text2words($row['subject']) as $word)
         $insertRows[] = "'$word', $row[ID_TOPIC]";
      if (count($insertRows) > 500)
      {
         db_query("
            INSERT IGNORE INTO {$db_prefix}log_search_subjects
               (word, ID_TOPIC)
            VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);
            $insertRows = array();
      }
   }
   mysql_free_result($request);

   if (!empty($insertRows))
      db_query("
         INSERT IGNORE INTO {$db_prefix}log_search_subjects
            (word, ID_TOPIC)
         VALUES (" . implode('),
            (', $insertRows) . ")", __FILE__, __LINE__);

   // Update it.
   $completed += $block_size;

   // Sleep for a bit if we can divide by 30k evenly.
   if ($completed % $sleep_count == 0)
      sleep(4);
}

echo "\n Completed!\n\n";
?>
No siggy! :D