本文整理汇总了PHP中FormatStringForDatabaseInput函数的典型用法代码示例。如果您正苦于以下问题:PHP FormatStringForDatabaseInput函数的具体用法?PHP FormatStringForDatabaseInput怎么用?PHP FormatStringForDatabaseInput使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FormatStringForDatabaseInput函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->Label = FormatStringForDatabaseInput($this->Label);
$this->Contents = FormatStringForDatabaseInput($this->Contents);
$this->Contents = eregi_replace("<textarea>", "<textarea>", $this->Contents);
$this->Contents = eregi_replace("<//textarea>", "</textarea>", $this->Contents);
}
示例2: GetIdentity
function GetIdentity()
{
if (!session_id()) {
session_start();
}
$UserID = ForceInt(@$_SESSION[$this->Context->Configuration['SESSION_USER_IDENTIFIER']], 0);
if ($UserID == 0) {
// UserID wasn't found in the session, so attempt to retrieve it from the cookies
// Retrieve cookie values
$EncryptedUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], '');
$VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], '');
if ($EncryptedUserID != '' && $VerificationKey != '') {
// Compare against db values
// Sadly, because this class is meant to be an interface for distributed objects, I can't use any of the error checking in the Lussumo Framework
$Query = "select UserID\n from LUM_User\n where VerificationKey = '" . FormatStringForDatabaseInput($VerificationKey) . "'";
$Result = $this->Context->Database->Execute($Query, 'Authenticator', 'GetIdentity', 'An error occurred while attempting to validate your remember me credentials');
if ($Result) {
$UserID = 0;
while ($rows = $this->Context->Database->GetRow($Result)) {
if ($EncryptedUserID == md5($rows['UserID'])) {
$UserID = ForceInt($rows['UserID'], 0);
$EncryptedUserID = $rows['EncryptedUserID'];
break;
}
}
if ($UserID > 0) {
// 1. Set a new verification key
$VerificationKey = DefineVerificationKey();
// 2. Update the user's information
$this->UpdateLastVisit($UserID, $VerificationKey);
// 3. Set the 'remember me' cookies
$this->SetCookieCredentials($EncryptedUserID, $VerificationKey);
// 4. Log the user's IP address
$this->LogIp($UserID);
}
}
}
}
// If it has now been found, set up the session.
$this->AssignSessionUserID($UserID);
return $UserID;
}
示例3: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->RoleName = FormatStringForDatabaseInput($this->RoleName, 1);
$this->Icon = FormatStringForDatabaseInput($this->Icon, 1);
$this->Description = FormatStringForDatabaseInput($this->Description, 1);
if (is_array($this->Permissions)) {
// Make sure to remove the hard-coded permissions from the array before saving
if (array_key_exists('PERMISSION_SIGN_IN', $this->Permissions)) {
unset($this->Permissions['PERMISSION_SIGN_IN']);
}
if (array_key_exists('PERMISSION_HTML_ALLOWED', $this->Permissions)) {
unset($this->Permissions['PERMISSION_HTML_ALLOWED']);
}
if (array_key_exists('PERMISSION_RECEIVE_APPLICATION_NOTIFICATION', $this->Permissions)) {
unset($this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION']);
}
// Now serialize the array
$this->Permissions = SerializeArray($this->Permissions);
}
}
示例4: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->Name = FormatStringForDatabaseInput($this->Name, 1);
$this->Url = FormatStringForDatabaseInput($this->Url, 1);
$this->PreviewImage = FormatStringForDatabaseInput($this->PreviewImage, 1);
}
示例5: VerifyPasswordResetRequest
function VerifyPasswordResetRequest($VerificationUserID, $EmailVerificationKey)
{
$VerificationUserID = ForceInt($VerificationUserID, 0);
$EmailVerificationKey = ForceString($EmailVerificationKey, '');
$EmailVerificationKey = FormatStringForDatabaseInput($EmailVerificationKey);
// Attempt to retrieve email address
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('User', 'u');
$s->AddSelect('UserID', 'u');
$s->AddWhere('u', 'UserID', '', $VerificationUserID, '=');
$s->AddWhere('u', 'EmailVerificationKey', '', $EmailVerificationKey, '=');
$UserResult = $this->Context->Database->Select($s, $this->Name, 'VerifyPasswordResetRequest', 'An error occurred while retrieving account information.');
if ($this->Context->Database->RowCount($UserResult) == 0) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrPasswordResetRequest'));
}
return $this->Context->WarningCollector->Iif();
}
示例6: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->Label = FormatStringForDatabaseInput($this->Label);
$this->Keywords = FormatStringForDatabaseInput($this->Keywords);
$this->Query = FormatStringForDatabaseInput($this->Query);
$this->AuthUsername = FormatStringForDatabaseInput($this->AuthUsername);
$this->Categories = FormatStringForDatabaseInput($this->Categories);
$this->Roles = FormatStringForDatabaseInput($this->Roles);
}
示例7: ForceString
}
}
if ($Type != "") {
// Perform some http authentication if public browsing is not enabled.
if (!agPUBLIC_BROWSING && $Context->Session->UserID == 0) {
$UserIsAuthenticated = 0;
// Assume user is not authenticated
$PHP_AUTH_USER = ForceString(@$_SERVER["PHP_AUTH_USER"], "");
$PHP_AUTH_PW = ForceString(@$_SERVER["PHP_AUTH_PW"], "");
if ($PHP_AUTH_USER != "" && $PHP_AUTH_PW != "") {
// Validate the inputs
$s = $Context->ObjectFactory->NewContextObject($Context, "SqlBuilder");
$s->SetMainTable("User", "u");
$s->AddSelect("UserID", "u");
$s->AddWhere("Name", FormatStringForDatabaseInput($PHP_AUTH_USER), "=");
$s->AddWhere("Password", FormatStringForDatabaseInput($PHP_AUTH_PW), "=", "and", "md5");
$ValidationData = $Context->Database->Select($Context, $s, "Feed", "ValidateCredentials", "An error occurred while validating user credentials.");
if ($Context->Database->RowCount($ValidationData) > 0) {
$UserIsAuthenticated = true;
}
}
if (!$UserIsAuthenticated) {
header('WWW-Authenticate: Basic realm="Private"');
header('HTTP/1.0 401 Unauthorized');
}
}
if ($UserIsAuthenticated) {
// Create a new sqlbuilder to retrieve feed data
$s = $Context->ObjectFactory->NewContextObject($Context, "SqlBuilder");
$s->SetMainTable("Discussion", "d");
$s->AddSelect(array("DiscussionID", "CategoryID", "AuthUserID", "Name", "DateCreated", "DateLastActive", "CountComments"), "d");
示例8: ValidateWhisperUsername
function ValidateWhisperUsername(&$Comment)
{
if ($Comment->WhisperUsername != '') {
$Name = FormatStringForDatabaseInput($Comment->WhisperUsername);
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('User', 'u');
$s->AddSelect('UserID', 'u');
$s->AddWhere('u', 'Name', '', $Name, '=');
$Result = $this->Context->Database->Select($s, $this->Name, 'ValidateWhisperUsername', 'An error occurred while attempting to validate the username entered as the whisper recipient.');
while ($Row = $this->Context->Database->GetRow($Result)) {
$Comment->WhisperUserID = ForceInt($Row['UserID'], 0);
}
if ($Comment->WhisperUserID == 0) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrWhisperInvalid'));
}
}
return $this->Context->WarningCollector->Iif();
}
示例9: ValidateWhisperUsername
function ValidateWhisperUsername(&$Comment)
{
if ($Comment->WhisperUsername != "") {
$Name = FormatStringForDatabaseInput($Comment->WhisperUsername);
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("User", "u");
$s->AddSelect("UserID", "u");
$s->AddWhere("Name", $Name, "=");
$Result = $this->Context->Database->Select($this->Context, $s, $this->Name, "ValidateWhisperUsername", "An error occurred while attempting to validate the username entered as the whisper recipient.");
while ($Row = $this->Context->Database->GetRow($Result)) {
$Comment->WhisperUserID = ForceInt($Row["UserID"], 0);
}
if ($Comment->WhisperUserID == 0) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrWhisperInvalid"));
}
}
return $this->Context->WarningCollector->Iif();
}
示例10: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->Name = FormatStringForDatabaseInput($this->Name, 1);
$this->Description = FormatStringForDatabaseInput($this->Description, 1);
}
示例11: SaveDiscussion
function SaveDiscussion($Discussion)
{
if (!$this->Context->Session->User->Permission('PERMISSION_START_DISCUSSION')) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrPermissionStartDiscussions'));
} else {
// If not editing, and the posted discussion count is less than the
// user's current discussion count, silently skip the posting and
// redirect as if everything is normal.
if ($Discussion->DiscussionID == 0 && $Discussion->UserDiscussionCount < $this->Context->Session->User->CountDiscussions) {
// Silently fail to post the data
// Need to get the user's last posted discussionID and direct them to it
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('Discussion', 'd');
$s->AddSelect('DiscussionID', 'd');
$s->AddWhere('c', 'AuthUserID', '', $this->Context->Session->UserID, '=');
$s->AddOrderBy('DateCreated', 'd', 'desc');
$s->AddLimit(0, 1);
$LastDiscussionData = $this->Context->Database->Select($s, $this->Name, 'SaveDiscussion', 'An error occurred while retrieving your last discussion.');
while ($Row = $this->Context->Database->GetRow($LastDiscussionData)) {
$Discussion->DiscussionID = ForceInt($Row['DiscussionID'], 0);
}
// Make sure we got it
if ($Discussion->DiscussionID == 0) {
$this->Context->ErrorManager->AddError($this->Context, $this->Name, 'SaveDiscussion', 'Your last discussion could not be found.');
}
} else {
$NewDiscussion = 0;
$OldDiscussion = false;
if ($Discussion->DiscussionID == 0) {
$NewDiscussion = 1;
} else {
$OldDiscussion = $this->GetDiscussionById($Discussion->DiscussionID);
}
// Validate the Discussion topic
$Name = FormatStringForDatabaseInput($Discussion->Name);
Validate($this->Context->GetDefinition('DiscussionTopicLower'), 1, $Name, 100, '', $this->Context);
//Validate the category ID and role
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('Category', 'c');
$s->AddSelect('CategoryID', 'c');
$s->AddJoin('CategoryRoleBlock', 'crb', 'CategoryID', 'c', 'CategoryID', 'left join', ' and crb.' . $this->Context->DatabaseColumns['CategoryRoleBlock']['RoleID'] . ' = ' . $this->Context->Session->User->RoleID);
$s->AddWhere('crb', 'Blocked', '', '0', '=', 'and', '', 1, 1);
$s->AddWhere('crb', 'Blocked', '', '0', '=', 'or', '', 0, 0);
$s->AddWhere('crb', 'Blocked', '', 'null', 'is', 'or', '', 0, 0);
$s->AddWhere('c', 'CategoryID', '', $Discussion->CategoryID, '=', 'and');
$s->EndWhereGroup();
$CategoryAllowed = $this->Context->Database->Select($s, $this->Name, 'SaveDiscussion', 'An error occurred while validating category permissions.');
if ($this->Context->Database->RowCount($CategoryAllowed) < 1) {
$Discussion->CategoryID = 0;
}
if ($Discussion->CategoryID <= 0) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrSelectCategory'));
}
// Validate first comment
$Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
if ($OldDiscussion) {
$Discussion->Comment->CommentID = $OldDiscussion->FirstCommentID;
} else {
$Discussion->Comment->CommentID = 0;
}
$CommentManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'CommentManager');
$CommentManager->ValidateComment($Discussion->Comment, 0);
// Validate the whisperusername
$CommentManager->ValidateWhisperUsername($Discussion);
// If updating, validate that this is admin or the author
if (!$NewDiscussion) {
if ($OldDiscussion->AuthUserID != $this->Context->Session->UserID && !$this->Context->Session->User->Permission('PERMISSION_EDIT_DISCUSSIONS')) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition('ErrPermissionEditComments'));
}
}
// If validation was successful, then reset the properties to db safe values for saving
if ($this->Context->WarningCollector->Count() == 0) {
$Discussion->Name = $Name;
}
if ($this->Context->WarningCollector->Iif()) {
$s->Clear();
// Update the user info & check for spam
if ($NewDiscussion) {
$UserManager = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager');
$UserManager->UpdateUserDiscussionCount($this->Context->Session->UserID);
}
// Proceed with the save if there are no warnings
if ($this->Context->WarningCollector->Count() == 0) {
$this->DelegateParameters['SqlBuilder'] =& $s;
$this->CallDelegate('PreSaveDiscussion');
$s->SetMainTable('Discussion', 'd');
$s->AddFieldNameValue('Name', $Discussion->Name);
$s->AddFieldNameValue('CategoryID', $Discussion->CategoryID);
if ($NewDiscussion) {
$s->AddFieldNameValue('AuthUserID', $this->Context->Session->UserID);
$s->AddFieldNameValue('DateCreated', MysqlDateTime());
$s->AddFieldNameValue('DateLastActive', MysqlDateTime());
$s->AddFieldNameValue('CountComments', 0);
$s->AddFieldNameValue('WhisperUserID', $Discussion->WhisperUserID);
if ($Discussion->WhisperUserID != '0') {
$s->AddFieldNameValue('DateLastWhisper', MysqlDateTime());
}
$Discussion->DiscussionID = $this->Context->Database->Insert($s, $this->Name, 'NewDiscussion', 'An error occurred while creating a new discussion.');
$Discussion->Comment->DiscussionID = $Discussion->DiscussionID;
} else {
//.........这里部分代码省略.........
示例12: provided
$Connection = @mysql_connect($DBHost, $DBUser, $DBPass);
if (!$Connection) {
$WarningCollector->Add("We couldn't connect to the server you provided (" . $DBHost . "). Are you sure you entered the right server, username and password?");
} elseif (!mysql_select_db($DBName, $Connection)) {
$WarningCollector->Add("We connected to the server, but we couldn't access the \"" . $DBName . "\" database. Are you sure it exists and that the specified user has access to it?");
}
}
// Create the administrative user
if ($WarningCollector->Count() == 0 && $Connection) {
$Username = FormatStringForDatabaseInput($Username);
$Password = FormatStringForDatabaseInput($Password);
$s = new SqlBuilder($Context);
$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
示例13: VerifyPasswordResetRequest
function VerifyPasswordResetRequest($VerificationUserID, $EmailVerificationKey)
{
$VerificationUserID = ForceInt($VerificationUserID, 0);
$EmailVerificationKey = ForceString($EmailVerificationKey, "");
$EmailVerificationKey = FormatStringForDatabaseInput($EmailVerificationKey);
// Attempt to retrieve email address
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("User");
$s->AddSelect("UserID");
$s->AddWhere("UserID", $VerificationUserID, "=");
$s->AddWhere("EmailVerificationKey", $EmailVerificationKey, "=");
$UserResult = $this->Context->Database->Select($this->Context, $s, $this->Name, "VerifyPasswordResetRequest", "An error occurred while retrieving account information.");
if ($this->Context->Database->RowCount($UserResult) == 0) {
$this->Context->WarningCollector->Add($this->Context->GetDefinition("ErrPasswordResetRequest"));
}
return $this->Context->WarningCollector->Iif();
}
示例14: FormatPropertiesForDatabaseInput
function FormatPropertiesForDatabaseInput()
{
$this->CustomStyle = FormatStringForDatabaseInput($this->CustomStyle, 1);
$this->Name = FormatStringForDatabaseInput($this->Name, 1);
$this->FirstName = FormatStringForDatabaseInput($this->FirstName, 1);
$this->LastName = FormatStringForDatabaseInput($this->LastName, 1);
$this->Email = FormatStringForDatabaseInput($this->Email, 1);
$this->Icon = FormatStringForDatabaseInput($this->Icon, 1);
$this->Picture = FormatStringForDatabaseInput($this->Picture, 1);
$this->Password = FormatStringForDatabaseInput($this->Password, 1);
$this->OldPassword = FormatStringForDatabaseInput($this->OldPassword, 1);
$this->NewPassword = FormatStringForDatabaseInput($this->NewPassword, 1);
$this->ConfirmPassword = FormatStringForDatabaseInput($this->ConfirmPassword, 1);
$this->VerificationKey = FormatStringForDatabaseInput($this->VerificationKey);
$this->Attributes = SerializeArray($this->Attributes);
$this->Discovery = FormatStringForDatabaseInput($this->Discovery, 1);
}
示例15: GetIdentity
function GetIdentity()
{
if (!session_id()) {
session_set_cookie_params(0, $this->Context->Configuration['COOKIE_PATH'], $this->Context->Configuration['COOKIE_DOMAIN']);
session_start();
}
$UserID = ForceInt(@$_SESSION[$this->Context->Configuration['SESSION_USER_IDENTIFIER']], 0);
if ($UserID == 0) {
// UserID wasn't found in the session, so attempt to retrieve it from the cookies
// Retrieve cookie values
$CookieUserID = ForceIncomingCookieString($this->Context->Configuration['COOKIE_USER_KEY'], '');
$VerificationKey = ForceIncomingCookieString($this->Context->Configuration['COOKIE_VERIFICATION_KEY'], '');
if ($CookieUserID != '' && $VerificationKey != '') {
// Compare against db values
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('User', 'u');
$s->AddJoin('Role', 'r', 'RoleID', 'u', 'RoleID', 'inner join');
$s->AddSelect('UserID', 'u');
$s->AddWhere('u', 'UserID', '', FormatStringForDatabaseInput($CookieUserID), '=');
$s->AddWhere('u', 'VerificationKey', '', FormatStringForDatabaseInput($VerificationKey), '=');
$Result = $this->Context->Database->Select($s, 'Authenticator', 'GetIdentity', 'An error occurred while attempting to validate your remember me credentials');
if ($Result) {
while ($rows = $this->Context->Database->GetRow($Result)) {
$UserID = ForceInt($rows['UserID'], 0);
}
if ($UserID > 0) {
// 1. Update the user's information
$this->UpdateLastVisit($UserID);
// 2. Log the user's IP address
$this->LogIp($UserID);
}
}
}
}
// If it has now been found, set up the session.
$this->AssignSessionUserID($UserID);
return $UserID;
}