$importuser = getBestVersion($versions); # print $importuser["personal"]." <".$importuser["email"]."><br/>"; printf('<input type="hidden" name="importemail[%s] value="%s">', $importuser["email"], $importuser["personal"]); # split personal in first and last name list($importuser["firstname"], $importuser["lastname"]) = explode(" ", $importuser["personal"], 2); $x++; if ($x % 25 == 0) { print $x . "/{$num} " . $GLOBALS['I18N']->get('done') . "<br/>"; flush(); } # check for full email if ($_POST["onlyfull"] != "yes" || $_POST["onlyfull"] == "yes" && strpos($importuser["personal"], "@") === false && strlen($importuser["email"]) > 4) { $new = 0; $result = Sql_query(sprintf('SELECT id,uniqid FROM %s WHERE email = "%s"', $tables["user"], $importuser["email"])); if (Sql_affected_rows()) { // Email exist, remember some values to add them to the lists $count_exist++; $user = Sql_fetch_array($result); $userid = $user["id"]; $uniqid = $user["uniqid"]; Sql_Query(sprintf('update %s set htmlemail = %d where id = %d', $tables["user"], $_POST["markhtml"] ? "1" : "0", $userid)); } else { // Email does not exist $new = 1; // Create unique number mt_srand((double) microtime() * 1000000); $randval = mt_rand(); $uniqid = getUniqid(); $query = sprintf('INSERT INTO %s (email,entered,confirmed,uniqid,htmlemail) values("%s",current_timestamp,%d,"%s",%d)', $tables["user"], $importuser["email"], $_POST["notify"] != "yes", $uniqid, $_POST["markhtml"] ? "1" : "0");
echo formStart(); print $GLOBALS['I18N']->get('Load data from') . ' ' . PageLinkButton('defaults', $GLOBALS['I18N']->get('predefined defaults')) . '<br />'; $res = Sql_Query("select * from {$tables['attribute']} order by listorder"); if (Sql_Affected_Rows()) { print '<p class="information">' . $GLOBALS['I18N']->get('Existing attributes') . ':</p>'; } else { print '<p class="information">' . $GLOBALS['I18N']->get('No Attributes have been defined yet') . '</p>'; } $c = 0; print '<div class="accordion">'; while ($row = Sql_Fetch_array($res)) { ++$c; print '<h3><a name="' . $row['id'] . '">' . $GLOBALS['I18N']->get('Attribute') . ': ' . $row['id'] . ' ' . htmlspecialchars(stripslashes(strip_tags($row['name']))); if ($formtable_exists) { sql_query('select * from formfield where attribute = ' . $row['id']); print ' (' . $GLOBALS['I18N']->get('used in') . ' ' . Sql_affected_rows() . ' ' . $GLOBALS['I18N']->get('forms') . ')'; } print '</a></h3><div><label>' . $GLOBALS['I18N']->get('Tag') . ' <input type="checkbox" name="tag[' . $c . ']" value="' . $row['id'] . '" /></label>'; print '<label>' . s('Name') . ':</label> <input type="text" name="name[' . $row['id'] . ']" value="' . htmlspecialchars(stripslashes(strip_tags($row['name']))) . '" size="40" />'; print '<label>' . s('Type') . ': </label> <!--<input type="hidden" name="type[' . $row['id'] . ']" value="' . $row['type'] . '">' . $row['type'] . '-->'; print '<select name="type[' . $row['id'] . ']" onchange="warn();">'; foreach ($types as $key => $val) { printf('<option value="%s" %s>%s</option>', $val, $val == $row['type'] ? 'selected="selected"' : '', $GLOBALS['I18N']->get($val)); } print ' </select>'; if (defined('IN_WEBBLER') && IN_WEBBLER || defined('WEBBLER') && WEBBLER) { if ($row['type'] == 'select' || $row['type'] == 'radio' || $row['type'] == 'checkboxgroup') {
on (usermessage.messageid = %d and usermessage.userid = listuser.userid) where listmessage.messageid = %d and listmessage.listid = listuser.listid and user.id = listuser.userid and usermessage.userid IS NULL %s %s %s', $tables['listuser'], $tables['user'], $tables['listmessage'], $tables['usermessage'], $messageid, $messageid, $userconfirmed, $exclusion, $user_attribute_query); if (VERBOSE) { output($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_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 {
return; } } $script_stage = 3; # we know the users by attribute $query = "select distinct {$tables['listuser']}.userid from {$tables['listuser']},{$tables['listmessage']} "; $query .= "where {$tables['listmessage']}.messageid = $messageid and {$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);