本文整理汇总了PHP中misc::parseDate方法的典型用法代码示例。如果您正苦于以下问题:PHP misc::parseDate方法的具体用法?PHP misc::parseDate怎么用?PHP misc::parseDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类misc
的用法示例。
在下文中一共展示了misc::parseDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateListingsData
function updateListingsData($listing_id, $or_owner)
{
// UPDATES THE LISTINGS INFORMATION
global $conn, $lang, $config;
require_once $config['basepath'] . '/include/misc.inc.php';
$misc = new misc();
$sql_listing_id = $misc->make_db_safe($listing_id);
$sql = "DELETE FROM " . $config['table_prefix'] . "listingsdbelements WHERE listingsdb_id = {$sql_listing_id}";
$recordSet = $conn->Execute($sql);
if ($recordSet === false) {
$misc->log_error($sql);
}
foreach ($_POST as $ElementIndexValue => $ElementContents) {
// first, ignore all the stuff that's been taken care of above
$sql2 = "SELECT listingsformelements_field_type FROM " . $config['table_prefix'] . "listingsformelements WHERE listingsformelements_field_name='" . $ElementIndexValue . "'";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false) {
$misc->log_error($sql2);
}
$field_type = $recordSet2->fields['listingsformelements_field_type'];
if ($ElementIndexValue == "title" || $ElementIndexValue == "notes" || $ElementIndexValue == "action" || $ElementIndexValue == "PHPSESSID" || $ElementIndexValue == "edit" || $ElementIndexValue == "edit_active" || $ElementIndexValue == "edit_expiration" || $ElementIndexValue == "featured" || $ElementIndexValue == "pclass" || $ElementIndexValue == "send_notices") {
// do nothing
} elseif (is_array($ElementContents)) {
// deal with checkboxes & multiple selects elements
$feature_insert = "";
foreach ($ElementContents as $feature_item) {
$feature_insert = "{$feature_insert}||{$feature_item}";
}
// end while
// now remove the first two characters
$feature_insert_length = strlen($feature_insert);
$feature_insert_length = $feature_insert_length - 2;
$feature_insert = substr($feature_insert, 2, $feature_insert_length);
$sql_ElementIndexValue = $misc->make_db_safe($ElementIndexValue);
$sql_feature_insert = $misc->make_db_safe(html_entity_decode($feature_insert, ENT_COMPAT, $config['charset']));
$sql_or_owner = $misc->make_db_safe($or_owner);
$sql = "INSERT INTO " . $config['table_prefix'] . "listingsdbelements (listingsdbelements_field_name, listingsdbelements_field_value, listingsdb_id, userdb_id) VALUES ({$sql_ElementIndexValue}, {$sql_feature_insert}, {$sql_listing_id}, {$sql_or_owner})";
$recordSet = $conn->Execute($sql);
if ($recordSet == false) {
$misc->log_error($sql);
}
} else {
// process the form
$returnValue = '';
if ($field_type == 'price' && $ElementContents != '') {
for ($i = 0; $i < strlen($ElementContents); $i++) {
if (ereg('[0-9]', substr($ElementContents, $i, 1))) {
$returnValue .= substr($ElementContents, $i, 1);
}
if (ereg('[.]', substr($ElementContents, $i, 1))) {
$i = strlen($ElementContents) + 1;
}
}
}
if ($field_type == 'date' && $ElementContents != '') {
if ($config['date_format'] == 1) {
$format = "%m/%d/%Y";
} elseif ($config['date_format'] == 2) {
$format = "%Y/%d/%m";
} elseif ($config['date_format'] == 3) {
$format = "%d/%m/%Y";
}
$returnValue = $misc->parseDate($ElementContents, $format);
} else {
$returnValue = $ElementContents;
}
$sql_ElementIndexValue = $misc->make_db_safe($ElementIndexValue);
if ($returnValue == '') {
$sql_ElementContents = $misc->make_db_safe($ElementContents);
} else {
$sql_ElementContents = $misc->make_db_safe($returnValue);
}
$sql_listing_id = $misc->make_db_safe($listing_id);
$sql_or_owner = $misc->make_db_safe($or_owner);
$sql = "INSERT INTO " . $config['table_prefix'] . "listingsdbelements (listingsdbelements_field_name, listingsdbelements_field_value, listingsdb_id, userdb_id) VALUES ({$sql_ElementIndexValue}, {$sql_ElementContents}, {$sql_listing_id}, {$sql_or_owner})";
$recordSet = $conn->Execute($sql);
if ($recordSet == false) {
$misc->log_error($sql);
}
}
// end else
}
// end while
return "success";
}
示例2: updateUserData
function updateUserData($user_id)
{
// UPDATES THE USER INFORMATION
global $conn, $lang, $config;
require_once $config['basepath'] . '/include/misc.inc.php';
$misc = new misc();
$sql_user_id = $misc->make_db_extra_safe($user_id);
$sql = 'DELETE FROM ' . $config['table_prefix'] . 'userdbelements WHERE userdb_id = ' . $sql_user_id;
$recordSet = $conn->Execute($sql);
if ($recordSet === false) {
$misc->log_error($sql);
}
$sql3 = 'SELECT userdb_is_agent FROM ' . $config['table_prefix'] . 'userdb WHERE userdb_id = ' . $sql_user_id;
$recordSet3 = $conn->Execute($sql3);
if ($recordSet3 === false) {
$misc->log_error($sql3);
}
if ($recordSet3->fields['userdb_is_agent'] == 'yes') {
$db_to_use = 'agent';
} else {
$db_to_use = 'member';
}
foreach ($_POST as $ElementIndexValue => $ElementContents) {
$sql2 = "SELECT " . $db_to_use . "formelements_field_type FROM " . $config['table_prefix'] . $db_to_use . "formelements WHERE " . $db_to_use . "formelements_field_name='" . $ElementIndexValue . "'";
$recordSet2 = $conn->Execute($sql2);
if ($recordSet2 === false) {
$misc->log_error($sql2);
}
$field_type = $recordSet2->fields[$db_to_use . 'formelements_field_type'];
// first, ignore all the stuff that's been taken care of above
if ($ElementIndexValue == 'user_user_name' || $ElementIndexValue == 'edit_user_pass' || $ElementIndexValue == 'edit_user_pass2' || $ElementIndexValue == 'user_email' || $ElementIndexValue == 'PHPSESSID' || $ElementIndexValue == 'edit' || $ElementIndexValue == 'edit_isAdmin' || $ElementIndexValue == 'edit_active' || $ElementIndexValue == 'edit_isAgent' || $ElementIndexValue == 'edit_limitListings' || $ElementIndexValue == 'edit_canEditSiteConfig' || $ElementIndexValue == 'edit_canMemberTemplate' || $ElementIndexValue == 'edit_canAgentTemplate' || $ElementIndexValue == 'edit_canListingTemplate' || $ElementIndexValue == 'edit_canViewLogs' || $ElementIndexValue == 'edit_canModerate' || $ElementIndexValue == 'edit_canFeatureListings' || $ElementIndexValue == 'edit_canPages' || $ElementIndexValue == 'edit_canVtour' || $ElementIndexValue == 'edit_canFiles' || $ElementIndexValue == 'edit_canUserFiles') {
// do nothing
} elseif (is_array($ElementContents)) {
// deal with checkboxes & multiple selects elements
$feature_insert = '';
foreach ($ElementContents as $feature_item) {
$feature_insert = $feature_insert . '||' . $feature_item;
}
// end foreach
// now remove the first two characters
$feature_insert_length = strlen($feature_insert);
$feature_insert_length = $feature_insert_length - 2;
$feature_insert = substr($feature_insert, 2, $feature_insert_length);
$sql_ElementIndexValue = $misc->make_db_safe($ElementIndexValue);
$sql_feature_insert = $misc->make_db_safe($feature_insert);
$sql = 'INSERT INTO ' . $config['table_prefix'] . 'userdbelements (userdbelements_field_name, userdbelements_field_value, userdb_id) VALUES (' . $sql_ElementIndexValue . ', ' . $sql_feature_insert . ', ' . $sql_user_id . ')';
// }
$recordSet = $conn->Execute($sql);
if ($recordSet === false) {
$misc->log_error($sql);
}
} else {
// it's time to actually insert the form data into the db
$sql_ElementIndexValue = $misc->make_db_safe($ElementIndexValue);
$sql_ElementContents = $misc->make_db_safe($ElementContents);
// if ($_SESSION['admin_privs'] == 'yes' && $_GET['edit'] != "")
// {
// $sql_edit = $misc->make_db_safe($_GET['edit']);
// $sql = 'INSERT INTO ' . $config['table_prefix'] . 'userdbelements (userdbelements_field_name, userdbelements_field_value, userdb_id) VALUES ('.$sql_ElementIndexValue.', '.$sql_ElementContents.', '.$sql_edit.')';
// }
// else
// {
// $sql_user_id = $misc->make_db_safe($_SESSION['userID']);
if ($field_type == 'date' && $ElementContents != '') {
if ($config['date_format'] == 1) {
$format = "%m/%d/%Y";
} elseif ($config['date_format'] == 2) {
$format = "%Y/%d/%m";
} elseif ($config['date_format'] == 3) {
$format = "%d/%m/%Y";
}
$returnValue = $misc->parseDate($ElementContents, $format);
$sql_ElementContents = $misc->make_db_safe($returnValue);
}
$sql = 'INSERT INTO ' . $config['table_prefix'] . 'userdbelements (userdbelements_field_name, userdbelements_field_value, userdb_id) VALUES (' . $sql_ElementIndexValue . ', ' . $sql_ElementContents . ', ' . $sql_user_id . ')';
// }
$recordSet = $conn->Execute($sql);
}
// end else
}
// end while
return 'success';
}
示例3: misc
//.........这里部分代码省略.........
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND (`{$subk}`.listingsdbelements_field_value IS NOT NULL AND `{$subk}`.listingsdbelements_field_value <> ''))";
if (!in_array($subk, $tablelist)) {
$tablelist[] = $subk;
}
} elseif (substr($k, -4) == '-max') {
$subk = substr($k, 0, -4);
if ($db_type == 'mysql') {
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as signed) <= '{$v}')";
} else {
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as int4) <= '{$v}')";
}
if (!in_array($subk, $tablelist)) {
$tablelist[] = $subk;
}
} else {
if (substr($k, -4) == '-min') {
$subk = substr($k, 0, -4);
if ($db_type == 'mysql') {
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as signed) >= '{$v}')";
} else {
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND CAST(`{$subk}`.listingsdbelements_field_value as int4) >= '{$v}')";
}
if (!in_array($subk, $tablelist)) {
$tablelist[] = $subk;
}
} elseif (substr($k, -8) == '-maxdate') {
if ($config['date_format'] == 1) {
$format = "%m/%d/%Y";
} elseif ($config['date_format'] == 2) {
$format = "%Y/%d/%m";
} elseif ($config['date_format'] == 3) {
$format = "%d/%m/%Y";
}
$v = $misc->parseDate($v, $format);
$subk = urldecode(substr($k, 0, -8));
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value <= '{$v}')";
if (!in_array($subk, $tablelist)) {
$tablelist[] = $subk;
}
} else {
if (substr($k, -8) == '-mindate') {
if ($config['date_format'] == 1) {
$format = "%m/%d/%Y";
} elseif ($config['date_format'] == 2) {
$format = "%Y/%d/%m";
} elseif ($config['date_format'] == 3) {
$format = "%d/%m/%Y";
}
$v = $misc->parseDate($v, $format);
$subk = urldecode(substr($k, 0, -8));
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value >= '{$v}')";
if (!in_array($subk, $tablelist)) {
$tablelist[] = $subk;
}
} else {
if (substr($k, -5) == '-date') {
if ($config['date_format'] == 1) {
$format = "%m/%d/%Y";
} elseif ($config['date_format'] == 2) {
$format = "%Y/%d/%m";
} elseif ($config['date_format'] == 3) {
$format = "%d/%m/%Y";
}
$v = $misc->parseDate($v, $format);
$subk = urldecode(substr($k, 0, -5));
$searchresultSQL .= "(`{$subk}`.listingsdbelements_field_name = '{$subk}' AND `{$subk}`.listingsdbelements_field_value = '{$v}')";