本文整理汇总了PHP中is_not_empty_array函数的典型用法代码示例。如果您正苦于以下问题:PHP is_not_empty_array函数的具体用法?PHP is_not_empty_array怎么用?PHP is_not_empty_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_not_empty_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_export_item_rs
function fetch_export_item_rs($s_item_type, $owner_id, $restrict_status_type_r = NULL)
{
$query = "SELECT DISTINCT i.id as item_id, i.title, i.s_item_type " . "FROM user u, item i, item_instance ii, s_status_type sst " . "WHERE u.user_id = ii.owner_id AND i.id = ii.item_id AND sst.s_status_type = ii.s_status_type ";
if (strlen($owner_id) > 0) {
$query .= "AND ii.owner_id = '{$owner_id}' ";
}
// can only export items for active users.
$query .= "AND u.active_ind = 'Y' ";
if (strlen($s_item_type) > 0) {
$query .= "AND i.s_item_type = '{$s_item_type}'";
}
if (is_not_empty_array($restrict_status_type_r)) {
$query .= 'AND sst.s_status_type IN(' . format_sql_in_clause($restrict_status_type_r) . ')';
}
// Not the status_type restriction could override this, but thats fine leave it as is.
if (!is_user_granted_permission(PERM_ITEM_ADMIN)) {
$query .= " AND ( sst.hidden_ind = 'N' OR ii.owner_id = '" . get_opendb_session_var('user_id') . "') ";
}
$result = db_query($query);
if ($result && db_num_rows($result) > 0) {
return $result;
} else {
return FALSE;
}
}
示例2: display_s_item_type_group_row
function display_s_item_type_group_row($item_type_group_r, $row)
{
global $PHP_SELF;
global $ADMIN_TYPE;
echo "\n<tr>";
if (is_not_empty_array($item_type_group_r)) {
echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">";
echo "<td class=\"data\">";
echo get_input_field("s_item_type_group[{$row}]", NULL, "Item Type Group", "readonly", "Y", $item_type_group_r['s_item_type_group'], FALSE);
if (fetch_item_type_item_type_group_cnt($item_type_group_r['s_item_type_group']) === 0) {
echo "*";
}
echo "</td>";
} else {
echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">";
echo "\n<td class=\"data\">" . get_input_field("s_item_type_group[{$row}]", NULL, "Item Type Group", "text(10,10)", "Y", NULL, FALSE) . "</td>";
}
echo "<td class=\"data\">" . get_input_field("description[{$row}]", NULL, "Description", "text(30,255)", 'Y', $item_type_group_r['description'], FALSE) . "</td>";
echo "\n<td class=\"data\">";
if (is_not_empty_array($item_type_group_r)) {
echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=edit_item_type_group_rltshps&s_item_type_group=" . $item_type_group_r['s_item_type_group'] . "\">Edit</a>" . " / <a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete_item_type_group&s_item_type_group=" . $item_type_group_r['s_item_type_group'] . "\">Delete</a>";
}
echo "\n</td>";
echo "</tr>";
}
示例3: check_item_type_structure
function check_item_type_structure($s_item_type, &$error)
{
if (is_exists_item_type($s_item_type)) {
$missing_s_field_types = NULL;
if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'TITLE')) {
$missing_s_field_types[] = 'TITLE';
}
if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSTYPE')) {
$missing_s_field_types[] = 'STATUSTYPE';
}
if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'STATUSCMNT')) {
$missing_s_field_types[] = 'STATUSCMNT';
}
if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'CATEGORY')) {
$missing_s_field_types[] = 'CATEGORY';
}
if (get_opendb_config_var('borrow', 'enable') !== FALSE && get_opendb_config_var('borrow', 'duration_support') !== FALSE) {
if (!fetch_sfieldtype_item_attribute_type($s_item_type, 'DURATION')) {
$missing_s_field_types[] = 'DURATION';
}
}
if (is_not_empty_array($missing_s_field_types)) {
$error = array('error' => 'The following Field Type attribute relationships are missing.', 'detail' => $missing_s_field_types);
return FALSE;
} else {
// No errors so no problem.
return TRUE;
}
} else {
// no message if s_item_type does not even exist.
return FALSE;
}
}
示例4: generate_language_sql
function generate_language_sql($language, $options = NULL)
{
$CRLF = get_user_browser_crlf();
$sqlscript = '';
//language, description, default_ind
$language_r = fetch_language_r($language);
if (is_not_empty_array($language_r)) {
$sqlscript = '#########################################################' . $CRLF . '# OpenDb ' . get_opendb_version() . ' \'' . $language . '\' Language Pack' . $CRLF . '#########################################################' . $CRLF . $CRLF;
$sqlscript .= "INSERT INTO s_language (language, description, default_ind) " . "VALUES ('" . $language_r['language'] . "', '" . addslashes($language_r['description']) . "', '" . $language_r['default_ind'] . "'); " . $CRLF;
$results = fetch_language_langvar_rs($language, $options);
if ($results) {
$sqlscript .= $CRLF . '#' . $CRLF . '# System Language Variables' . $CRLF . '#' . $CRLF;
while ($lang_var_r = db_fetch_assoc($results)) {
if ($language_r['default_ind'] != 'Y') {
$value = ifempty($lang_var_r['value'], $lang_var_r['default_value']);
} else {
$value = $lang_var_r['value'];
}
$sqlscript .= "INSERT INTO s_language_var (language, varname, value) " . "VALUES ('" . $language_r['language'] . "', '" . $lang_var_r['varname'] . "', '" . addslashes($value) . "'); " . $CRLF;
}
db_free_result($results);
}
if ($language_r['default_ind'] != 'Y') {
$table_r = get_system_table_r();
if (is_array($table_r)) {
$sqlscript .= $CRLF . '#' . $CRLF . '# System Table Language Variables' . $CRLF . '#' . $CRLF;
reset($table_r);
while (list(, $table) = each($table_r)) {
$tableconf_r = get_system_table_config($table);
// key, column
if (is_array($tableconf_r) && is_array($tableconf_r['columns'])) {
reset($tableconf_r['columns']);
while (list(, $column) = each($tableconf_r['columns'])) {
$results = fetch_system_table_column_langvar_rs($language, $table, $column, $options);
if ($results) {
while ($lang_var_r = db_fetch_assoc($results)) {
if ($language_r['default_ind'] != 'Y') {
$value = ifempty($lang_var_r['value'], $lang_var_r[$column]);
} else {
$value = $lang_var_r['value'];
}
if (strlen($value)) {
$sqlscript .= "INSERT INTO s_table_language_var (language, tablename, columnname, key1, key2, key3, value) " . "VALUES ('" . $language_r['language'] . "', '" . $table . "', '" . $column . "', '" . $lang_var_r['key1'] . "', " . (strlen($lang_var_r['key2']) > 0 ? "'" . $lang_var_r['key2'] . "'" : "''") . ", " . (strlen($lang_var_r['key3']) > 0 ? "'" . $lang_var_r['key3'] . "'" : "''") . ", '" . addslashes($value) . "'); " . $CRLF;
}
}
db_free_result($results);
}
}
}
}
}
}
}
return $sqlscript;
}
示例5: display_s_file_type_row
function display_s_file_type_row($file_type_r, $row)
{
global $PHP_SELF;
global $ADMIN_TYPE;
echo "\n<tr>";
if (is_not_empty_array($file_type_r)) {
echo "\n<td class=\"data\">" . get_input_field("content_type[{$row}]", NULL, NULL, "readonly", "N", $file_type_r['content_type'], FALSE) . "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">" . "</td>";
} else {
echo "\n<td class=\"data\">" . get_input_field("content_type[{$row}]", NULL, NULL, "text(20,100)", "Y", $file_type_r['content_type'], FALSE) . "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">" . "</td>";
}
$groups = array();
$results = fetch_s_file_type_content_group_rs();
if ($results) {
while ($content_group_r = db_fetch_assoc($results)) {
$groups[] = $content_group_r['content_group'];
}
}
echo "<td class=\"data\">" . custom_select("content_group[{$row}]", $groups, "%value%", 1, $file_type_r['content_group'], "value") . "</td>";
//description
echo "\n<td class=\"data\">" . get_input_field("description[{$row}]", NULL, NULL, "text(20,255)", "N", $file_type_r['description'], FALSE) . "</td>";
echo "\n<td class=\"data\">" . get_input_field("extension[{$row}]", NULL, "Extension", "text(10,10)", "Y", $file_type_r['extension'], FALSE) . "</td>";
$alt_extensions = '';
if (is_not_empty_array($file_type_r)) {
$alt_extensions_r = fetch_s_file_type_alt_extension_r($file_type_r['content_type']);
if (is_array($alt_extensions_r)) {
$alt_extensions = implode(', ', $alt_extensions_r);
}
}
// convert array of extensiosn to a string
echo "\n<td class=\"data\">" . get_input_field("alt_extensions[{$row}]", NULL, "Alternate Extensions", "text(20,255)", "N", $alt_extensions, FALSE) . "</td>";
echo "<td class=\"data\">";
// Get the theme specific source of the image.
if (strlen($file_type_r['image']) > 0) {
$src = theme_image_src($file_type_r['image']);
}
if ($src !== FALSE && strlen($src) > 0) {
echo "<img src=\"{$src}\">";
} else {
echo " ";
}
echo "</td>";
echo "\n<td class=\"data\">" . get_input_field("image[{$row}]", NULL, NULL, "url(15,*,\"gif,jpg,png\",N)", "N", $file_type_r['image'], FALSE) . "</td>";
echo "\n<td class=\"data\">" . get_input_field("thumbnail_support_ind[{$row}]", NULL, NULL, "simple_checkbox(" . (strtoupper($file_type_r['thumbnail_support_ind']) == "Y" ? "CHECKED" : "") . ")", "N", "Y", FALSE) . "</td>";
echo "\n<td class=\"data\">";
if (is_not_empty_array($file_type_r)) {
echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete&content_type=" . $file_type_r['content_type'] . "\">Delete</a>";
} else {
echo " ";
}
echo "\n</td>";
echo "</tr>";
}
示例6: show_login_form
function show_login_form($HTTP_VARS, $errors = NULL)
{
global $PHP_SELF;
echo _theme_header(get_opendb_lang_var('login'), is_show_login_menu_enabled());
echo "<h2>" . get_opendb_lang_var('login') . "</h2>";
if (is_not_empty_array($errors)) {
echo format_error_block($errors);
}
echo "<div id=\"loginFormDiv\">";
if ($HTTP_VARS['rememberMeLogin'] == 'true') {
echo "<p class=\"rememberMeLoginMessage\">" . get_opendb_lang_var('not_authorized_to_page_login') . "</p>";
}
if (strlen($HTTP_VARS['redirect']) > 0) {
echo "<p class=\"redirectMessage\">" . get_opendb_lang_var('login_redirect_message', array('pageid' => get_page_id($HTTP_VARS['redirect']))) . "</p>";
}
echo "<form id=\"loginForm\" action=\"{$PHP_SELF}\" method=\"POST\" name=\"login\">";
// The user tried to go straight to a menu item with an invalid session.
// Set a "redirect" variable here so that after we give them a full session
// we can redirect them back to the page they really wanted.
if (strlen($HTTP_VARS['redirect']) > 0) {
echo "<input type=\"hidden\" name=\"redirect\" value=\"" . $HTTP_VARS['redirect'] . "\">";
}
echo "<input type=\"hidden\" name=\"op\" value=\"login\">";
echo "\n<ul>" . "\n<li><label class=\"label\" for=\"uid\">" . get_opendb_lang_var('userid') . "</label>" . "<input type=\"text\" class=\"text\" id=\"uid\" name=\"uid\" value=\"" . $HTTP_VARS['uid'] . "\"></li>" . "\n<li><label class=\"label\" for=\"password\">" . get_opendb_lang_var('password') . "</label>" . "<input type=\"password\" class=\"password\" id=\"passwd\" name=\"passwd\"></li>";
echo "\n<li><label class=\"label\" for=\"remember\">" . get_opendb_lang_var('remember_me') . "</label>" . "<input type=\"checkbox\" class=\"remember\" id=\"remember\" name=\"remember\" value=\"true\"></li>";
echo "</ul>" . "\n<input type=\"submit\" class=\"submit\" value=\"" . get_opendb_lang_var('login') . "\">";
echo "</form>";
// force uid field focus for login
echo "\n<script type=\"text/javascript\">\n\t\tdocument.forms['login']['uid'].focus();\n\t</script>";
if (is_site_enabled() && is_valid_opendb_mailer()) {
if (strlen($HTTP_VARS['uid']) > 0 && get_opendb_config_var('login', 'enable_new_pwd_gen') !== FALSE && is_user_granted_permission(PERM_CHANGE_PASSWORD, $HTTP_VARS['uid'])) {
$footer_links_r[] = array(url => $PHP_SELF . "?op=newpassword&uid=" . urlencode($HTTP_VARS['uid']), text => get_opendb_lang_var('forgot_your_pwd'));
}
// no point if site disabled, email is not available
if (get_opendb_config_var('email', 'send_to_site_admin') !== FALSE) {
$footer_links_r[] = array(text => get_opendb_lang_var('email_administrator'), target => "popup(640,480)", url => "email.php?op=send_to_site_admin&inc_menu=N");
}
}
// Indicate we should show the signup link.
if (get_opendb_config_var('login.signup', 'enable') !== FALSE) {
$footer_links_r[] = array(url => "user_admin.php?op=signup", text => get_opendb_lang_var('sign_me_up'));
}
echo format_footer_links($footer_links_r);
echo "</div>";
echo _theme_footer();
}
示例7: display_patch_list
function display_patch_list($title, $patchdir)
{
global $ADMIN_TYPE;
echo "<h3>" . $title . "</h3>";
$filelist = get_file_list('./admin/patch_facility/sql/' . $patchdir, 'sql');
$sqllist = NULL;
if (is_not_empty_array($filelist)) {
for ($i = 0; $i < count($filelist); $i++) {
$parsedfile_r = parse_file($filelist[$i]);
$sqllist[] = array('sqlfile' => $filelist[$i], 'name' => initcap(str_replace('_', ' ', $parsedfile_r['name'])));
}
if (is_not_empty_array($sqllist)) {
echo "<table>";
echo "<tr class=\"navbar\">" . "<th>Patch</th>" . "<th>SQL File</th>" . "<th></th>" . "<th></th>" . "</tr>";
for ($i = 0; $i < count($sqllist); $i++) {
echo "<tr class=\"oddRow\">" . "<td>" . $sqllist[$i]['name'] . "</td>" . "<td>" . $sqllist[$i]['sqlfile'] . "</td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=previewsql&mode=job&title=" . urlencode($sqllist[$i]['sqlfile']) . "&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "&preview=true\" target=\"_new\">Preview</a></td>" . "<td><a href=\"admin.php?type={$ADMIN_TYPE}&op=installsql&patchdir={$patchdir}&sqlfile=" . $sqllist[$i]['sqlfile'] . "\">Install</a></td>" . "</tr>";
}
echo "</table>";
}
}
}
示例8: build_new_items_feed
function build_new_items_feed($URL, $datemask)
{
$rssout = '';
$last_items_list_conf_r = get_opendb_config_var('feeds.new_items');
$list_item_rs = get_last_num_items_rs($last_items_list_conf_r['total_num_items'], NULL, NULL, NULL, NULL, NULL, 'feeds');
if (is_not_empty_array($list_item_rs)) {
reset($list_item_rs);
while (list(, $list_item_r) = @each($list_item_rs)) {
$rssout .= "\n\t<item>" . "\n\t\t<title>" . rss_encoded($list_item_r['title']) . "</title>" . "\n\t\t<link>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</link>" . "\n\t\t<pubDate>" . $list_item_r['update_on'] . " " . date('T') . "</pubDate>" . "\n\t\t<guid>" . rss_encoded($URL . $list_item_r['item_display_url']) . "</guid>" . "\n\t\t<description>";
$results = fetch_item_attribute_type_rs($list_item_r['s_item_type'], 'rss_ind');
if ($results) {
$attribute_block = '';
while ($item_attribute_type_r = db_fetch_assoc($results)) {
if (has_role_permission($item_attribute_type_r['view_perm'])) {
if (strlen($attribute_block) > 0) {
$attribute_block .= "\n";
}
$attributes_r = fetch_attribute_val_r($list_item_r['item_id'], $list_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
if (is_array($attributes_r)) {
$attribute = "";
while (list(, $value) = each($attributes_r)) {
if (strlen($attribute) > 0) {
$attribute .= ", ";
}
$attribute .= rss_encoded($value);
}
$attribute_block .= $attribute;
}
}
}
//while
db_free_result($results);
$rssout .= $attribute_block;
}
$rssout .= "\n\t\t</description>" . "\n\t</item>";
}
}
return $rssout;
}
示例9: OpenDbMailer
function OpenDbMailer($mailer)
{
$this->PluginDir = './lib/phpmailer/';
if (get_opendb_config_var('email', 'windows_smtp_server') === TRUE) {
$this->LE = "\r\n";
} else {
$this->LE = "\n";
}
$this->Mailer = $mailer;
$this->Priority = "3";
// in case we want to change it
$this->Sender = get_opendb_config_var('email', 'noreply_address');
if ($this->Mailer == 'smtp') {
$email_smtp_r = get_opendb_config_var('email.smtp');
// at least host should be defined.
if (is_not_empty_array($email_smtp_r) && strlen($email_smtp_r['host']) > 0) {
$this->Host = $email_smtp_r['host'];
if (strlen($email_smtp_r['port']) > 0) {
$this->Port = $email_smtp_r['port'];
}
if ($email_smtp_r['secure'] != 'none') {
$this->SMTPSecure = $email_smtp_r['secure'];
// sets the prefix to the server
}
if (strlen($email_smtp_r['username']) > 0 && strlen($email_smtp_r['password']) > 0) {
$this->Username = $email_smtp_r['username'];
$this->Password = $email_smtp_r['password'];
$this->SMTPAuth = TRUE;
}
} else {
// set to 'mail' mailer as default, and log configuration error.
opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Email SMTP Configuration missing', array($mailer));
// override, because mailer smtp is misconfigured.
$this->Mailer = 'mail';
}
}
}
示例10: doAlbumSearch
function doAlbumSearch($search_vars_r)
{
$entries = NULL;
$pageBuffer = $this->fetchURI("http://freedb2.org/~cddb/cddb.cgi?cmd=cddb+album+" . urlencode($search_vars_r['title']) . "&hello=" . get_hello_param() . "&proto=5");
if (strlen($pageBuffer) > 0) {
$lines = preg_split("/[\r\n]/m", trim($pageBuffer), NULL, PREG_SPLIT_NO_EMPTY);
if (is_not_empty_array($lines)) {
$code = NULL;
if (preg_match("/([0-9]+) ([^\$]+)/", $lines[0], $matches)) {
$code = $matches[1];
}
if ($code == '211' || $code == '210') {
array_shift($lines);
array_pop($lines);
} else {
return TRUE;
}
//blues 590ff119 Various Artists / Cool, Cool Blues, The Classic Sides (1951-54) - Disc B (Jackson, MS)
reset($lines);
while (list(, $line) = each($lines)) {
$entry = NULL;
if (preg_match("/([^\\ ]+) ([^\\ ]+) ([^\$]+)/", $line, $matches)) {
$entry['cddbgenre'] = $matches[1];
$entry['freedb_id'] = $matches[2];
$entry['title'] = $matches[3];
$idx = strrpos($entry['title'], "/");
if ($idx !== FALSE) {
$entry['artist'] = trim(substr($entry['title'], 0, $idx));
$entry['title'] = initcap(substr($entry['title'], $idx + 1));
}
$entries[] = $entry;
}
}
}
}
return $entries;
}
示例11: get_s_attribute_type_lookup_row
function get_s_attribute_type_lookup_row($lookup_r, $row)
{
$block = "<tr>";
$block .= "<td class=\"data\">";
if (is_not_empty_array($lookup_r)) {
$block .= get_input_field("delete_ind[{$row}]", NULL, NULL, "simple_checkbox()", "N", "Y", FALSE);
} else {
$block .= " ";
}
$block .= "</td>";
$block .= "<td class=\"data\">" . get_input_field("order_no[{$row}]", NULL, NULL, "number(3)", "N", $lookup_r['order_no'], FALSE) . "</td>";
if (is_not_empty_array($lookup_r)) {
$block .= "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Value", "readonly", "Y", $lookup_r['value'], FALSE) . "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">" . "</td>";
} else {
$block .= "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Value", "text(10,50)", "Y", NULL, FALSE) . "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">" . "</td>";
}
$block .= "<td class=\"data\">" . get_input_field("display[{$row}]", NULL, NULL, "text(20,255)", "N", $lookup_r['display'], FALSE) . "</td>";
if ($lookup_r['img'] != 'none') {
$src = theme_image_src($lookup_r['img']);
}
$block .= "<td class=\"data\">";
if ($src !== FALSE && strlen($src) > 0) {
$block .= "<img src=\"{$src}\">";
} else {
$block .= " ";
}
$block .= "</td>";
$block .= "<td class=\"data\">" . get_input_field("img[{$row}]", NULL, "Image", "url(15,*,\"gif,jpg,png\",N)", "N", $lookup_r['img'] != "none" ? $lookup_r['img'] : NULL, FALSE, NULL, "if(this.value.length>0){this.form['none_img[{$row}]'].checked=false;}") . "</td>";
$block .= "<td class=\"data\">" . get_input_field("none_img[{$row}]", NULL, NULL, "simple_checkbox(" . ($lookup_r['img'] == "none" ? "CHECKED" : "") . ")", "N", "Y", FALSE, NULL, "if(this.checked){this.form['img[{$row}]'].value='';}") . "</td>";
$block .= "<td class=\"data\"><input type=\"checkbox\" class=\"checkbox\" name=\"checked_ind[{$row}]\" value=\"Y\" onclick=\"toggleChecked(this, 'checked_ind')\" " . (strtoupper($lookup_r['checked_ind']) == 'Y' ? 'CHECKED' : '') . ">";
$block .= "</tr>";
return $block;
}
示例12: queryItem
function queryItem($search_attributes_r, $s_item_type)
{
// assumes we have an exact match here
$pageBuffer = $this->fetchURI("http://" . $this->url . "/gp/product/" . $search_attributes_r[$this->asinId]);
// no sense going any further here.
if (strlen($pageBuffer) == 0) {
return FALSE;
}
$pageBuffer = preg_replace('/[\\r\\n]+/', ' ', $pageBuffer);
$pageBuffer = preg_replace('/>[\\s]*</', '><', $pageBuffer);
//<span id="btAsinTitle">Prometheus (Blu-ray/ DVD + Digital Copy) (2012)</span>
//<span id="btAsinTitle" style="">Homeland: The Dark Elf Trilogy, Part 1 (Forgotten Realms: The Legend of Drizzt, Book I) (Bk. 1) <span style="text-transform:capitalize; font-size: 16px;">[Mass Market Paperback]</...
//<h1 class="a-size-large a-spacing-none" id="title"> Illustration School: Let's Draw Happy People <span class="a-size-medium a-color-secondary a-text-normal">Hardcover</span></h1>
//<span id="productTitle" class="a-size-large">Men in Black 3 [Blu-ray]</span>
if (preg_match("/<span id=\"btAsinTitle\"[^>]*>([^<]+)<\\/?span/s", $pageBuffer, $regs) || preg_match("/<span id=\"productTitle\"[^>]*?>([^<]+)<\\/span/s", $pageBuffer, $regs) || preg_match("/<h[^>]*?id=\"title\"[^>]*>([^<]+)</", $pageBuffer, $regs) || preg_match("/<b class=\"sans\">([^<]+)<\\/b>/s", $pageBuffer, $regs) || preg_match("/<b class=\"sans\">([^<]+)<!--/s", $pageBuffer, $regs)) {
$title = trim($regs[1]);
// If extra year appended, remove it and just get the title.
if (preg_match("/(.*)\\([0-9]+\\)\$/", $title, $regs2)) {
$title = $regs2[1];
}
$title = trim(str_replace("\"", "", $title));
if (($idx = strpos($title, '(Blu-ray')) !== FALSE) {
$title = substr($title, 0, $idx);
} else {
if (($idx = strpos($title, '[Blu-ray')) !== FALSE) {
$title = substr($title, 0, $idx);
}
}
$this->addItemAttribute('title', $title);
//Amazon.com: DVD: First Blood (Special Edition) (1982)
// Need to escape any (, ), [, ], :, .,
if (preg_match("/" . preg_quote($this->getItemAttribute('title'), "/") . " \\(([0-9]*)\\)/s", $pageBuffer, $regs)) {
$this->addItemAttribute('year', $regs[1]);
}
}
// a hack!
$upcId = get_upc_code($search_attributes_r['search.title']);
if ($upcId && $upcId != $this->getItemAttribute('title')) {
$this->addItemAttribute('upc_id', $upcId);
}
// ** Front Cover Image **
if (preg_match("!<img id=\"main-image\" src=\"([^\"]+)\"!s", $pageBuffer, $regs)) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $regs[1]);
$this->addItemAttribute('imageurl', $image);
} else {
if (preg_match("!registerImage\\(\"original_image[^\"]*\", \"([^\"]+)\"!", $pageBuffer, $regs)) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $regs[1]);
$this->addItemAttribute('imageurl', $image);
} else {
if (preg_match("!<img id=\"landingImage\".*?src=\"([^\"]+)\"!s", $pageBuffer, $regs)) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $regs[1]);
$this->addItemAttribute('imageurl', $image);
} else {
if (preg_match("!<img [^>]*?id=\"imgBlkFront\" [^>]*?src=\"([^\"]+)\"!s", $pageBuffer, $regs) || preg_match("!<img [^>]*?src=\"([^\"]+)\" [^>]*?id=\"imgBlkFront\"!s", $pageBuffer, $regs)) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $regs[1]);
$this->addItemAttribute('imageurl', $image);
}
}
}
}
// ** Back Cover Image **
if (preg_match("!<img [^>]*?id=\"imgBlkBack\" [^>]*?src=\"([^\"]+)\"!", $pageBuffer, $regs) || preg_match("!<img [^>]*?src=\"([^\"]+)\" [^>]*?id=\"imgBlkBack\"!", $pageBuffer, $regs)) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $regs[1]);
$this->addItemAttribute('imageurlb', $image);
}
if (preg_match_all("!registerImage\\(\"cust_image[^\"]*\", \"([^\"]+)\"!", $pageBuffer, $regs)) {
while (list(, $image) = each($regs[1])) {
// remove image extras _xxx_.
$image = preg_replace('!(\\/[^.]+\\.)_[^.]+_\\.!', "\$1", $image);
$this->addItemAttribute('cust_imageurl', $image);
}
}
//http://www.amazon.com/gp/product/product-description/0007136587/ref=dp_proddesc_0/002-1041562-0884857?ie=UTF8&n=283155&s=books
if (preg_match("!<a href=\"http://" . $this->url . "/gp/product/product-description/" . $search_attributes_r[$this->asinId] . "/[^>]*>See all Editorial Reviews</a>!", $pageBuffer, $regs) || preg_match("!<a href=\"http://" . $this->url . "/gp/product/product-description/" . $search_attributes_r[$this->asinId] . "/[^>]*>See all Reviews</a>!", $pageBuffer, $regs)) {
$reviewPage = $this->fetchURI("http://" . $this->url . "/gp/product/product-description/" . $search_attributes_r[$this->asinId] . "/reviews/");
if (strlen($reviewPage) > 0) {
$reviews = parse_amazon_reviews($reviewPage);
if (is_not_empty_array($reviews)) {
$this->addItemAttribute('blurb', $reviews);
}
}
} else {
$reviews = parse_amazon_reviews($pageBuffer);
if (is_not_empty_array($reviews)) {
$this->addItemAttribute('blurb', $reviews);
}
}
if (preg_match("/<span class=listprice>\\\$([^<]*)<\\/span>/i", $pageBuffer, $regs)) {
$this->addItemAttribute('listprice', $regs[1]);
} else {
if (preg_match("/<td class=\"listprice\">\\\$([^<]*)<\\/td>/i", $pageBuffer, $regs)) {
$this->addItemAttribute('listprice', $regs[1]);
} else {
if (preg_match("!>List Price:</[^\\\$]+\\\$([0-9\\.]+)!m", $pageBuffer, $regs)) {
$this->addItemAttribute('listprice', $regs[1]);
//.........这里部分代码省略.........
示例13: get_decoded_item_instance_rs
function get_decoded_item_instance_rs($op, $item_instance_list_r)
{
$item_instance_rs = array();
if (is_array($item_instance_list_r)) {
reset($item_instance_list_r);
while (list(, $item_id_and_instance_no) = each($item_instance_list_r)) {
if (strlen($item_id_and_instance_no) > 0) {
$item_instance_r = get_item_id_and_instance_no($item_id_and_instance_no);
if (is_not_empty_array($item_instance_r)) {
$item_instance_r = fetch_item_instance_r($item_instance_r['item_id'], $item_instance_r['instance_no']);
if (is_array($item_instance_r)) {
if ($op == 'checkin') {
$sequence_number = fetch_borrowed_item_seq_no($item_instance_r['item_id'], $item_instance_r['instance_no'], 'B');
if ($sequence_number != FALSE) {
$item_instance_r['sequence_number'] = $sequence_number;
$item_instance_rs[] = $item_instance_r;
}
} else {
$item_instance_rs[] = $item_instance_r;
}
}
}
}
}
}
return $item_instance_rs;
}
示例14: _expand_field_mask
/**
* A simple field mask parser, which only supports 'if' and 'switch' and config_var_key(...)
* config_var_value(...)
*/
function _expand_field_mask(&$values_rs, $mask, &$mask_element_rs, $config_var_rs = NULL)
{
// If no parsed mask elements, then return $mask.
if (is_empty_array($mask_element_rs)) {
// Only return mask if there is something to return.
if (strlen($mask) > 0) {
return $mask;
} else {
return NULL;
}
}
for ($i = 0; $i < count($mask_element_rs); $i++) {
// no array set, or simple attribute variable 's_attribute_type.option' not set.
if (is_not_empty_array($mask_element_rs[$i]) && !isset($mask_element_rs[$i]['s_attribute_type']) && !isset($mask_element_rs[$i]['option'])) {
// Replace the array index.
switch ($mask_element_rs[$i]['type']) {
case 'ifdef':
// ifdef(s_attribute_type, "if_mask"[, "else_mask"])
if (isset($values_rs[$mask_element_rs[$i]['varname']])) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['if_mask'], $mask_element_rs[$i]['if_mask_elements'], $config_var_rs);
} else {
if (strlen($mask_element_rs[$i]['else_mask']) > 0) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['else_mask'], $mask_element_rs[$i]['else_mask_elements'], $config_var_rs);
} else {
$value = NULL;
}
}
break;
case 'if':
// if(varname[<|<=|>=|>|==|!=]value, "if_mask"[, "else_mask"])
$value = $values_rs[$mask_element_rs[$i]['varname']];
// The attribute is defined, so now lets do the comparison.
if (!empty($value)) {
if ($this->_test_if_condition($value, $mask_element_rs[$i]['op'], $mask_element_rs[$i]['value'])) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['if_mask'], $mask_element_rs[$i]['if_mask_elements'], $config_var_rs);
} else {
if (strlen($mask_element_rs[$i]['else_mask']) > 0) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['else_mask'], $mask_element_rs[$i]['else_mask_elements'], $config_var_rs);
} else {
$value = NULL;
}
}
} else {
$value = NULL;
}
break;
case 'switch':
$value = $values_rs[$mask_element_rs[$i]['varname']];
// The attribute is defined, so now lets do the comparison.
if (!empty($value)) {
if (is_not_empty_array($mask_element_rs[$i]['cases'])) {
for ($j = 0; $j < count($mask_element_rs[$i]['cases']); $j++) {
// if a match.
if (strcmp($value, $mask_element_rs[$i]['cases'][$j]['case']) === 0) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['cases'][$j]['result']['mask'], $mask_element_rs[$i]['cases'][$j]['result']['mask_elements'], $config_var_rs);
break 2;
// break out of switch
}
}
}
if (is_not_empty_array($mask_element_rs[$i]['default_case'])) {
$value = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['default_case']['mask'], $mask_element_rs[$i]['cases']['default_case']['mask_elements'], $config_var_rs);
}
} else {
$value = NULL;
}
break;
case 'config_var_key':
// config_var_key(name, value)
if (is_not_empty_array($config_var_rs) && is_array($config_var_rs[$mask_element_rs[$i]['name']])) {
if (is_array($mask_element_rs[$i]['value'])) {
$srchValue = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['value']['mask'], $mask_element_rs[$i]['value']['elements'], $config_var_rs);
} else {
$srchValue = $mask_element_rs[$i]['value'];
}
$tmpValue = array_search2($srchValue, $config_var_rs[$mask_element_rs[$i]['name']]);
if ($tmpValue !== FALSE) {
$value = $tmpValue;
} else {
$value = '';
}
} else {
$value = '';
}
break;
case 'config_var_value':
// config_var_value(name, keyid)
if (is_not_empty_array($config_var_rs) && is_array($config_var_rs[$mask_element_rs[$i]['name']])) {
if (is_array($mask_element_rs[$i]['key'])) {
$srchKey = $this->_expand_field_mask($values_rs, $mask_element_rs[$i]['key']['mask'], $mask_element_rs[$i]['key']['elements'], $config_var_rs);
} else {
$srchKey = $mask_element_rs[$i]['key'];
}
if (isset($config_var_rs[$mask_element_rs[$i]['name']][$srchKey])) {
$value = $config_var_rs[$mask_element_rs[$i]['name']][$srchKey];
} else {
//.........这里部分代码省略.........
示例15: is_uri_domain_in_list
/**
* Will parse string
*/
function is_uri_domain_in_list($url, $domain_list_r)
{
if (strlen($url) && is_not_empty_array($domain_list_r)) {
$url_parts_r = parse_url($url);
$domain = $url_parts_r['host'];
while (($index = strpos($domain, '.')) !== FALSE) {
if (in_array($domain, $domain_list_r)) {
return TRUE;
} else {
$domain = substr($domain, $index + 1);
}
}
}
////else
return FALSE;
}