Пример #1
0
 $s->SetMainTable("User", "u");
 $s->AddFieldNameValue("FirstName", "Administrative");
 $s->AddFieldNameValue("LastName", "User");
 $s->AddFieldNameValue("Email", FormatStringForDatabaseInput($SupportEmail));
 $s->AddFieldNameValue("Name", $Username);
 $s->AddFieldNameValue("Password", $Password, 1, "md5");
 $s->AddFieldNameValue("DateFirstVisit", MysqlDateTime());
 $s->AddFieldNameValue("DateLastActive", MysqlDateTime());
 $s->AddFieldNameValue("CountVisit", 0);
 $s->AddFieldNameValue("CountDiscussions", 0);
 $s->AddFieldNameValue("CountComments", 0);
 $s->AddFieldNameValue("RoleID", 6);
 $s->AddFieldNameValue("StyleID", 1);
 $s->AddFieldNameValue("UtilizeEmail", 0);
 $s->AddFieldNameValue("RemoteIP", GetRemoteIp(1));
 if (!@mysql_query($s->GetInsert(), $Connection)) {
     $WarningCollector->Add("Something bad happened when we were trying to create your administrative user account. Mysql said: " . mysql_error($Connection));
 } else {
     // Now insert the role history assignment
     $NewUserID = mysql_insert_id($Connection);
     $s->Clear();
     $s->SetMainTable("UserRoleHistory", "h");
     $s->AddFieldNameValue("UserID", $NewUserID);
     $s->AddFieldNameValue("RoleID", 6);
     $s->AddFieldNameValue("Date", MysqlDateTime());
     $s->AddFieldNameValue("AdminUserID", $NewUserID);
     $s->AddFieldNameValue("Notes", "Initial administrative account created");
     $s->AddFieldNameValue("RemoteIp", GetRemoteIp(1));
     // Fail silently on this one
     @mysql_query($s->GetInsert(), $Connection);
 }