ProcessError(Sql_Error($database_connection)); } # now we have all our users to send the message to $num_users = Sql_affected_rows(); if ($skipped >= 10000) { $num_users -= $skipped; } output($GLOBALS['I18N']->get('Found them') . ': ' . $num_users . ' ' . $GLOBALS['I18N']->get('to process')); setMessageData($messageid, 'to process', $num_users); if ($num_per_batch) { # send in batches of $num_per_batch users $batch_total = $num_users; if ($num_per_batch > 0) { #$query .= sprintf(' limit 0,%d',$num_per_batch); $userids = Sql_query("{$query}"); if (Sql_Has_Error($database_connection)) { ProcessError(Sql_Error($database_connection)); } } else { output($GLOBALS['I18N']->get('No users to process for this batch')); $userids = Sql_Query(sprintf('select * from %s where id = 0', $tables["user"])); } } $affrows = Sql_Affected_Rows(); while ($userdata = Sql_fetch_row($userids)) { if ($num_per_batch && $sent >= $num_per_batch) { output($GLOBALS['I18N']->get('batch limit reached') . ": {$sent} ({$num_per_batch})"); $GLOBALS["wait"] = $batch_period; return; } $userid = $userdata[0];
} else { $query .= "{$column} " . $struct[0] . ","; } } # get rid of the last , $query = substr($query, 0, -1); $query .= "\n)"; # submit it to the database echo $GLOBALS['I18N']->get("Initialising table") . " <b>{$table}</b>"; if ($force && Sql_Table_Exists($tables[$table])) { Error($GLOBALS['I18N']->get("Table already exists") . '<br />'); echo "... " . $GLOBALS['I18N']->get("failed") . "<br />\n"; $success = 0; } else { $res = Sql_Query($query, 0); $error = Sql_Has_Error($database_connection); $success = $force || $success && !$error; if (!$error || $force) { if ($table == "admin") { # create a default admin Sql_Query(sprintf('insert into %s values(0,"%s","%s","%s",now(),now(),"%s","%s",now(),%d,0)', $tables["admin"], "admin", "admin", "", $adminname, "phplist", 1)); } elseif ($table == "task") { while (list($type, $pages) = each($system_pages)) { foreach ($pages as $page => $access_level) { Sql_Query(sprintf('replace into %s (page,type) values("%s","%s")', $tables["task"], $page, $type)); } } } echo "... " . $GLOBALS['I18N']->get("ok") . "<br />\n"; } else { echo "... " . $GLOBALS['I18N']->get("failed") . "<br />\n";
{$tables['listmessage']}.listid = {$tables['listuser']}.listid"; $query .= " $user_attribute_query"; $userids = Sql_query("$query"); if (Sql_Has_Error($database_connection)) { ProcessError(Sql_Error($database_connection)); } # now we have all our users to send the message to $num = Sql_affected_rows(); output( "Found them: $num to process"); if ($safemode) { # send in batches of $num_per_batch users $safemode_total = $num; $query .= sprintf(' limit %d,%d',$reload * $num_per_batch,$num_per_batch); $userids = Sql_query("$query"); if (Sql_Has_Error($database_connection)) { ProcessError(Sql_Error($database_connection)); } } while ($userdata = Sql_fetch_row($userids)) { $some = 1; #set_time_limit(60); # check if we have been "killed" $alive = checkLock($send_process_id); if ($alive) keepLock($send_process_id); else ProcessError("Process Killed by other process"); # check if the message we are working on is still there $res = Sql_query("select id from {$tables['message']} where id = $messageid"); if (!Sql_Affected_Rows()) ProcessError("Message I was working on has disappeared");