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; } }
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>"; }
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; } }
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; }
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>"; }
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(); }
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>"; } } }
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; }
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'; } } }
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; }
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; }
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]); } } } // amazon price value: <b class="priceLarge">$7.99</b> if (preg_match("!<b class=\"(priceLarge|price)\">\\\$([^<]*)</b>!i", $pageBuffer, $regs)) { $this->addItemAttribute('listprice', $regs[2]); $this->addItemAttribute('price', $regs[2]); } //http://g-ec2.images-amazon.com/images/G/01/x-locale/common/customer-reviews/stars-4-0._V47081936_.gif if (preg_match("!<li><b>Average Customer Review:</b>[\\s]*<img src=\".*?/stars-([^\\.]+).!i", $pageBuffer, $regs)) { $amazonreview = str_replace('-', '.', $regs[1]); $this->addItemAttribute('amznrating', $amazonreview); $this->addItemAttribute('amazon_review', $amazonreview); } if (($startIndex = strpos($pageBuffer, "<h2>Look for Similar Items by Subject</h2>")) !== FALSE && ($endIndex = strpos($pageBuffer, "matching ALL checked", $startIndex)) !== FALSE) { $subjectform = substr($pageBuffer, $startIndex, $endIndex - $startIndex); if (preg_match_all("!<input type=\"checkbox\" name=\"field\\+keywords\" value=\"([^\"]+)\"!", $subjectform, $matches)) { $this->addItemAttribute('genre', $matches[1]); } } // Get the mapped AMAZON index type $index_type = ifempty($this->getConfigValue('item_type_to_index_map', $s_item_type), strtolower($s_item_type)); switch ($index_type) { case 'dvd': case 'vhs': $this->parse_amazon_video_data($search_attributes_r, $s_item_type, $pageBuffer); break; case 'videogames': $this->parse_amazon_game_data($search_attributes_r, $pageBuffer); break; case 'books': $this->parse_amazon_books_data($search_attributes_r, $pageBuffer); break; case 'music': $this->parse_amazon_music_data($search_attributes_r, $pageBuffer); break; default: //Not much here, but what else can we do? break; } return TRUE; }
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; }
/** * 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 { $value = ''; } } else { $value = ''; } break; default: // No valid function specified, so set to empty. $value = ''; } } else { // in the case of this function, all {variables} are not actually s_attribute_type references, but // references to key's in the $values_rs array, thus we ignore the 'option' and assume 'value' in // every case. if (is_array($mask_element_rs[$i]) && isset($mask_element_rs[$i]['s_attribute_type']) && isset($mask_element_rs[$i]['option'])) { $value = ifempty($values_rs[$mask_element_rs[$i]['s_attribute_type']], $values_rs[strtolower($mask_element_rs[$i]['s_attribute_type'])]); } else { $value = $values_rs[$mask_element_rs[$i]]; } } // Replace the array index. $mask = str_replace('{' . $i . '}', $value, $mask); } // Now return expanded subject. return $mask; }
/** * 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; }
function get_column_details($record_r, $row) { if (is_not_empty_array($record_r)) { $new_record = FALSE; } else { $new_record = TRUE; } $columns_r = NULL; $columns_r[] = array('column' => 'button', 'field' => '<a style="{cursor: pointer;}" onClick="moveRowUp(document.forms[\'s_item_listing_conf\'], document.forms[\'s_item_listing_conf\'][\'column_no[' . $row . ']\']); return false;"><img src="./images/admin/up.gif" border=0></a><br />' . '<a style="{cursor: pointer;}" onClick="moveRowDown(document.forms[\'s_item_listing_conf\'], document.forms[\'s_item_listing_conf\'][\'column_no[' . $row . ']\']); return false;"><img src="./images/admin/down.gif" border=0></a>'); $column_types_r = array(array('value' => '', 'display' => ''), array('value' => 's_field_type', 'display' => 'Field Type'), array('value' => 's_attribute_type', 'display' => 'Attribute Type'), array('value' => 'action_links', 'display' => 'Action Links'), array('value' => 'borrow_status', 'display' => 'Borrow Status')); $columns_r[] = array('column' => 'column_type', 'field' => custom_select("column_type[{$row}]", $column_types_r, '%display%', 1, $record_r['column_type'], 'value', NULL, '', 'doOnChange(this.form, this)', FALSE)); // disabled $field_type_r = array(); if ($new_record || $record_r['column_type'] != 's_field_type') { $field_type_r = array(array('value' => '', 'display' => '')); } //ITEM_ID, TITLE, STATUSTYPE, STATUSCMNT, CATEGORY, RATING, ITEMTYPE, OWNER, INTEREST $field_type_r = array_merge($field_type_r, array(array('value' => 'ITEM_ID', 'display' => 'Item ID'), array('value' => 'ITEMTYPE', 'display' => 'Item Type'), array('value' => 'TITLE', 'display' => 'Title'), array('value' => 'CATEGORY', 'display' => 'Category'), array('value' => 'STATUSTYPE', 'display' => 'Status Type'), array('value' => 'STATUSCMNT', 'display' => 'Status Comment'), array('value' => 'OWNER', 'display' => 'Owner'), array('value' => 'INTEREST', 'display' => 'Interest'), array('value' => 'RATING', 'display' => 'Rating'))); $columns_r[] = array('column' => 's_field_type', 'field' => custom_select("s_field_type[{$row}]", $field_type_r, '%display%', 1, $record_r['s_field_type'], 'value', NULL, '', 'doOnChange(this.form, this)', $new_record || is_field_disabled('s_field_type', $record_r))); $attribute_type_rs = array(); if ($new_record || $record_r['column_type'] != 's_attribute_type') { $attribute_type_rs = array(array('value' => '', 'display' => '')); } $attribute_type_rs = get_attribute_type_rs($attribute_type_rs); // this is to avoid confusion if system data is defined for non-existent s_attribute_types if (!$new_record && !in_array($record_r['s_attribute_type'], $attribute_type_rs)) { $attribute_type_rs[] = array('value' => $record_r['s_attribute_type'], 'display' => $record_r['s_attribute_type']); } $columns_r[] = array('column' => 's_attribute_type', 'field' => custom_select("s_attribute_type[{$row}]", $attribute_type_rs, '%value%', 1, $record_r['s_attribute_type'], 'value', NULL, '', 'doOnChange(this.form, this)', $new_record || is_field_disabled('s_attribute_type', $record_r))); $columns_r[] = array('column' => 'override_prompt', 'field' => get_input_field("override_prompt[{$row}]", NULL, 'Override Prompt', 'text(20,30)', 'N', $record_r['override_prompt'], FALSE, '', '', $new_record || is_field_disabled('override_prompt', $record_r))); $disabled = $new_record || is_field_disabled('printable_support_ind', $record_r); if ($disabled) { $record_r['printable_support_ind'] = 'N'; } $columns_r[] = array('column' => 'printable_support_ind', 'field' => get_input_field("printable_support_ind[{$row}]", NULL, 'Printable Support', "simple_checkbox(" . ($record_r['printable_support_ind'] == 'Y' ? 'CHECKED' : '') . ")", 'N', 'Y', FALSE, '', '', $disabled)); $disabled = $new_record || is_field_disabled('orderby_support_ind', $record_r); if ($disabled) { $record_r['orderby_support_ind'] = 'N'; } $columns_r[] = array('column' => 'orderby_support_ind', 'field' => get_input_field('orderby_support_ind[' . $row . ']', NULL, 'Order By Support', "simple_checkbox(" . ($record_r['orderby_support_ind'] == 'Y' ? 'CHECKED' : '') . ")", 'N', 'Y', FALSE, NULL, 'doOnChange(this.form, this);', $new_record || is_field_disabled('orderby_support_ind', $record_r))); $orderby_datatypes_r = array(); if (is_field_disabled('orderby_datatype', $record_r)) { $orderby_datatypes_r = array(array('value' => '', 'display' => '')); } $orderby_datatypes_r = array_merge($orderby_datatypes_r, array(array('value' => 'alpha'), array('value' => 'numeric'))); $columns_r[] = array('column' => 'orderby_datatype', 'field' => custom_select("orderby_datatype[{$row}]", $orderby_datatypes_r, '%value%', 1, $record_r['orderby_datatype'], 'value', NULL, '', '', $new_record || is_field_disabled('orderby_datatype', $record_r))); $disabled = $new_record || is_field_disabled('orderby_default_ind', $record_r); if ($disabled) { $record_r['orderby_default_ind'] = 'N'; } $columns_r[] = array('column' => 'orderby_default_ind', 'field' => get_input_field("orderby_default_ind[{$row}]", NULL, 'Default Orderby', "simple_checkbox(" . ($record_r['orderby_default_ind'] == 'Y' ? 'CHECKED' : '') . ")", 'N', 'Y', FALSE, '', 'doOnChange(this.form, this);', $disabled)); $sortorder_r = array(); if (is_field_disabled('orderby_sort_order', $record_r)) { $sortorder_r = array(array('value' => '', 'display' => '')); } $sortorder_r = array_merge($sortorder_r, array(array('value' => 'asc'), array('value' => 'desc'))); $columns_r[] = array('column' => 'orderby_sort_order', 'field' => custom_select("orderby_sort_order[{$row}]", $sortorder_r, '%value%', 1, $record_r['orderby_sort_order'], 'value', NULL, '', '', $new_record || is_field_disabled('orderby_sort_order', $record_r))); $buffer = "<tr>"; $buffer .= '<input type="hidden" name="is_new_row[' . $row . ']" value="' . ($new_record ? 'true' : 'false') . '">'; $class = 'data'; if (strlen($columns_r['error']) > 0) { $class = 'error'; } // column_no hidden must be null for us to determine if a row has been populated $buffer .= get_input_field("column_no[{$row}]", NULL, 'Column No', 'hidden', 'N', $record_r['column_no'], FALSE); while (list(, $column_r) = each($columns_r)) { $buffer .= '<td class="' . $class . '" id="' . $column_r['column'] . '[' . $row . ']" nowrap>' . $column_r['field'] . '</td>'; } $buffer .= '</tr>'; return $buffer; }
function display_site_plugin_s_attribute_type_lookup_map_row($record_r, $row) { global $PHP_SELF; global $ADMIN_TYPE; if (is_not_empty_array($record_r)) { echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"Y\">"; echo "<input type=\"hidden\" name=\"sequence_number[{$row}]\" value=\"" . $record_r['sequence_number'] . "\">"; echo "<td class=\"data\">" . get_input_field("s_attribute_type[{$row}]", NULL, "Attribute Type", "readonly", "Y", $record_r['s_attribute_type'], FALSE) . "</td>"; echo "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Site Value", "readonly", "Y", $record_r['value'], FALSE) . "</td>"; $results = fetch_attribute_type_lookup_rs($record_r['s_attribute_type'], 'order_no, value ASC'); echo "\n<td class=\"data\">" . custom_select("lookup_attribute_val[{$row}]", $results, "%value% - %display%", 1, $record_r['lookup_attribute_val']) . "</td>"; } else { echo "<input type=\"hidden\" name=\"exists_ind[{$row}]\" value=\"N\">"; $attribute_types[] = ''; $results = fetch_lookup_s_attribute_type_rs(); if ($results) { while ($attribute_type_r = db_fetch_assoc($results)) { $attribute_types[] = $attribute_type_r['s_attribute_type']; } db_free_result($results); } echo "\n<td class=\"data\">" . custom_select("s_attribute_type[{$row}]", $attribute_types, "%value%", 1, NULL, 'value', NULL, NULL, "populateList(this.options[this.options.selectedIndex].value, this.form['lookup_attribute_val[{$row}]'], arrayOfLookupValues, false, null, false);") . "</td>"; echo "<td class=\"data\">" . get_input_field("value[{$row}]", NULL, "Site Value", "text(20,100)", "Y", NULL, FALSE) . "</td>"; echo "\n<td class=\"data\">" . custom_select("lookup_attribute_val[{$row}]", array(array('value' => '', 'display' => '')), "%value% - %display%", 1, NULL) . "</td>"; } echo "\n<td class=\"data\">"; if (is_not_empty_array($record_r)) { echo "<a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=delete_site_plugin_s_attribute_type_lookup_map&site_type=" . $record_r['site_type'] . "&sequence_number=" . $record_r['sequence_number'] . "\">Delete</a>"; } else { echo " "; } echo "\n</td>"; }
function get_search_query_matrix($HTTP_VARS) { function get_match_type($match) { if ($match == 'word') { return get_opendb_lang_var('word_match'); } else { if ($match == 'partial') { return get_opendb_lang_var('partial_match'); } else { if ($match == 'exact') { return get_opendb_lang_var('exact_match'); } else { return NULL; } } } } $searches = array(); if (strlen($HTTP_VARS['title']) > 0) { // Default title match is exact match. $HTTP_VARS['title_match'] = ifempty($HTTP_VARS['title_match'], 'exact'); if ($HTTP_VARS['title_match'] == 'word' || $HTTP_VARS['title_match'] == 'partial') { if (is_null($HTTP_VARS['title_case'])) { $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . '</em>)', field => $HTTP_VARS['title']); } else { $searches[] = array(prompt => get_opendb_lang_var('title') . ' (<em>' . get_match_type($HTTP_VARS['title_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['title']); } } else { $searches[] = array(prompt => get_opendb_lang_var('title'), field => $HTTP_VARS['title']); } } if (strlen($HTTP_VARS['category']) > 0) { // If s_item_type defined, we can get at the s_attribute_type of the category value. if (strlen($HTTP_VARS['s_item_type']) > 0) { $attribute_type_r = fetch_sfieldtype_item_attribute_type_r($HTTP_VARS['s_item_type'], 'CATEGORY'); $searches[] = array(prompt => get_opendb_lang_var('category'), field => get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['category'], FALSE)); } else { $searches[] = array(prompt => get_opendb_lang_var('category'), field => $HTTP_VARS['category']); } } if (strlen($HTTP_VARS['owner_id']) > 0) { $username = fetch_user_name($HTTP_VARS['owner_id']); if (strlen($username) > 0) { $searches[] = array(prompt => get_opendb_lang_var('owner'), field => $username . ' (' . $HTTP_VARS['owner_id'] . ')'); } } if (strlen($HTTP_VARS['s_item_type_group']) > 0) { $searches[] = array(prompt => get_opendb_lang_var('s_item_type_group'), field => $HTTP_VARS['s_item_type_group']); } if (is_array($HTTP_VARS['s_item_type'])) { $field = ''; for ($i = 0; $i < count($HTTP_VARS['s_item_type']); $i++) { $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type'][$i]); $field .= theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type'); } $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => $field); } else { if (strlen($HTTP_VARS['s_item_type']) > 0) { $item_type_r = fetch_item_type_r($HTTP_VARS['s_item_type']); $searches[] = array(prompt => get_opendb_lang_var('s_item_type'), field => theme_image($item_type_r['image'], $item_type_r['description'], 's_item_type')); } } if (is_numeric($HTTP_VARS['rating'])) { $attribute_type_r = fetch_cached_attribute_type_r('S_RATING'); $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_display_field($attribute_type_r['s_attribute_type'], NULL, 'review()', $HTTP_VARS['rating'], FALSE)); } $attribute_type_r = NULL; if (strlen($HTTP_VARS['attribute_type']) > 0) { $attribute_type_r = fetch_cached_attribute_type_r($HTTP_VARS['attribute_type']); if (is_not_empty_array($attribute_type_r)) { $attribute_type_r['listing_link_ind'] = 'N'; // Default title match is exact match. $HTTP_VARS['attr_match'] = ifempty($HTTP_VARS['attr_match'], 'exact'); // Special category search, but ignore if category variable actually specified. if (strlen($HTTP_VARS['category']) == 0 && strlen($HTTP_VARS['attribute_val']) > 0 && $HTTP_VARS['attr_match'] == 'category') { // We do not want the Listing Link to be added to this display field $searches[] = array(prompt => $attribute_type_r['prompt'], field => get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['attribute_val']), FALSE)); } else { if (strlen($HTTP_VARS['attribute_val']) > 0) { $HTTP_VARS['attribute_val'] = stripslashes($HTTP_VARS['attribute_val']); if (starts_with($HTTP_VARS['attribute_val'], '"') && ends_with($HTTP_VARS['attribute_val'], '"')) { $HTTP_VARS['attribute_val'] = substr($HTTP_VARS['attribute_val'], 1, -1); } $search = ifempty(get_item_display_field(NULL, $attribute_type_r, $HTTP_VARS['attribute_val'], FALSE), $HTTP_VARS['attribute_val']); } else { if (strlen($HTTP_VARS['lookup_attribute_val']) > 0) { $search = get_item_display_field(NULL, $attribute_type_r, stripslashes($HTTP_VARS['lookup_attribute_val']), FALSE); } } if (!is_lookup_attribute_type($HTTP_VARS['attribute_type']) && $HTTP_VARS['attr_match'] != 'exact') { $searches[] = array(prompt => $attribute_type_r['prompt'] . ' (<em>' . get_match_type($HTTP_VARS['attr_match']) . '</em>)', field => $search); } else { $searches[] = array(prompt => $attribute_type_r['prompt'], field => $search); } } } //if(is_not_empty_array($attribute_type_r)) } else { if (strlen($HTTP_VARS['attribute_val']) > 0) { // specified a search term without attribute type, this is a global search. if (is_null($HTTP_VARS['attr_case'])) { $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . '</em>)', field => stripslashes($HTTP_VARS['attribute_val'])); } else { $searches[] = array(prompt => get_opendb_lang_var('attribute_val') . ' (<em>' . get_match_type(ifempty($HTTP_VARS['attr_match'], 'exact')) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => stripslashes($HTTP_VARS['attribute_val'])); } } } // add another search field if update_on value also specified. if (strlen($HTTP_VARS['attr_update_on']) > 0) { if (is_not_empty_array($attribute_type_r)) { $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt'])); } else { $prompt = get_opendb_lang_var('attributes_updated'); } if (strlen($HTTP_VARS['datetimemask']) > 0) { $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')'); } else { $searches[] = array(prompt => $prompt, field => $HTTP_VARS['attr_update_on']); } } else { if (is_numeric($HTTP_VARS['attr_update_on_days'])) { if (is_not_empty_array($attribute_type_r)) { $prompt = get_opendb_lang_var('attribute_prompt_updated', array('s_attribute_type' => $attribute_type_r['s_attribute_type'], 'prompt' => $attribute_type_r['prompt'])); } else { $prompt = get_opendb_lang_var('attributes_updated'); } if ($HTTP_VARS['attr_update_on_days'] == '1') { $field = get_opendb_lang_var('one_day_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '7') { $field = get_opendb_lang_var('one_week_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '28') { $field = get_opendb_lang_var('one_month_ago'); } else { if ($HTTP_VARS['attr_update_on_days'] == '365') { $field = get_opendb_lang_var('one_year_ago'); } } } } $searches[] = array(prompt => $prompt, field => $field); } } if (strlen($HTTP_VARS['update_on']) > 0) { if (strlen($HTTP_VARS['datetimemask']) > 0) { $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on'] . ' (' . $HTTP_VARS['datetimemask'] . ')'); } else { $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $HTTP_VARS['update_on']); } } else { if (is_numeric($HTTP_VARS['update_on_days'])) { if ($HTTP_VARS['update_on_days'] == '1') { $field = get_opendb_lang_var('one_day_ago'); } else { if ($HTTP_VARS['update_on_days'] == '7') { $field = get_opendb_lang_var('one_week_ago'); } else { if ($HTTP_VARS['update_on_days'] == '28') { $field = get_opendb_lang_var('one_month_ago'); } else { if ($HTTP_VARS['update_on_days'] == '365') { $field = get_opendb_lang_var('one_year_ago'); } } } } $searches[] = array(prompt => get_opendb_lang_var('updated'), field => $field); } } if (is_not_empty_array($HTTP_VARS['s_status_type']) > 0) { $search = ''; for ($i = 0; $i < count($HTTP_VARS['s_status_type']); $i++) { if (strlen($search) > 0) { $search .= ' '; } $status_type_r = fetch_status_type_r($HTTP_VARS['s_status_type'][$i]); if (is_not_empty_array($status_type_r)) { $search .= format_display_value('%img%', $status_type_r['img'], 'Y', $status_type_r['description'], 's_status_type'); } } if (strlen($search) > 0) { $searches[] = array(prompt => get_opendb_lang_var('s_status_type'), field => $search); } } if (strlen($HTTP_VARS['status_comment']) > 0) { // Default status_comment match is exact match. $HTTP_VARS['status_comment_match'] = ifempty($HTTP_VARS['status_comment_match'], 'exact'); if ($HTTP_VARS['status_comment_match'] == 'word' || $HTTP_VARS['status_comment_match'] == 'partial' || $HTTP_VARS['status_comment_match'] == 'exact') { if (is_null($HTTP_VARS['status_comment_case'])) { $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . '</em>)', field => $HTTP_VARS['status_comment']); } else { $searches[] = array(prompt => get_opendb_lang_var('status_comment') . ' (<em>' . get_match_type($HTTP_VARS['status_comment_match']) . ', ' . get_opendb_lang_var('case_sensitive') . '</em>)', field => $HTTP_VARS['status_comment']); } } else { $searches[] = array(prompt => get_opendb_lang_var('status_comment'), field => $HTTP_VARS['status_comment']); } } if (is_numeric($HTTP_VARS['interest_level']) && $HTTP_VARS['interest_level'] > 0) { $searches[] = array(prompt => get_opendb_lang_var('interest'), field => theme_image("interest_1.gif", get_opendb_lang_var('interest'), 's_item_type')); } return $searches; }
/** * */ function copy_item_to_http_vars($old_item_r, $new_item_type) { $HTTP_VARS = array(); $results = fetch_item_attribute_type_rs($old_item_r['s_item_type'], 'not_instance_field_types'); if ($results) { $attr_order_no_r = array(); while ($item_attribute_type_r = db_fetch_assoc($results)) { if ($item_attribute_type_r['s_field_type'] == 'TITLE') { $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type']); $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); $HTTP_VARS[$fieldname] = $old_item_r['title']; } else { $last_order_no = NULL; if (is_numeric($attr_order_no_r[$item_attribute_type_r['s_attribute_type']])) { $last_order_no = $attr_order_no_r[$item_attribute_type_r['s_attribute_type']]; } $order_no = fetch_s_item_attribute_type_next_order_no($new_item_type, $item_attribute_type_r['s_attribute_type'], $last_order_no); if ($order_no !== FALSE) { $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $order_no); // update with latest order no $attr_order_no_r[$item_attribute_type_r['s_attribute_type']] = $order_no; if ($item_attribute_type_r['lookup_attribute_ind'] == 'Y' || $item_attribute_type_r['multi_attribute_ind'] == 'Y') { $attribute_val_r = fetch_attribute_val_r($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (is_not_empty_array($attribute_val_r)) { $HTTP_VARS[$fieldname] = $attribute_val_r; } } else { $attribute_val = fetch_attribute_val($old_item_r['item_id'], $old_item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']); if (strlen($attribute_val) > 0) { $HTTP_VARS[$fieldname] = $attribute_val; } } } } } db_free_result($results); } return $HTTP_VARS; }
function getContentType() { if (is_not_empty_array($this->_file_cache_r)) { return $this->_file_cache_r['content_type']; } else { return FALSE; } }
/** * Returns a HTML div block with all the data elements currently set in this * class. * * @param unknown_type $itemData * @param unknown_type $buffer * @return unknown */ function getDebugItemDataAsHtml($s_item_type = NULL) { $buffer = '<div class="sitePluginDebug">'; $buffer .= '<h2>Debug HTTP Requests</h2>'; $buffer .= $this->_httpClient->getDebugMessagesAsHtml(); $itemData = $this->getItemData($s_item_type); if (is_not_empty_array($itemData)) { $buffer .= '<h2>Debug ' . $this->getTitle() . ' Site Data</h2>'; $buffer .= $this->__getDebugItemData($itemData); } $buffer .= "</div>"; return $buffer; }
// else add item to session array. insert_cart_item($HTTP_VARS['item_id'], $HTTP_VARS['instance_no'], get_opendb_session_var('user_id')); } } } else { if ($HTTP_VARS['op'] == 'update_my_reserve_basket' && is_not_empty_array($HTTP_VARS['item_id_instance_no'])) { // initiated from listings.php page! while (list(, $item_id_instance_no) = each($HTTP_VARS['item_id_instance_no'])) { $item_r = get_item_id_and_instance_no($item_id_instance_no); if (!is_item_in_reserve_basket($item_r['item_id'], $item_r['instance_no'], get_opendb_session_var('user_id'))) { // else add item to session array. insert_cart_item($item_r['item_id'], $item_r['instance_no'], get_opendb_session_var('user_id')); } } } else { if ($HTTP_VARS['op'] == 'delete_from_my_reserve_basket' && is_not_empty_array($HTTP_VARS['sequence_number'])) { while (list(, $sequence_number) = each($HTTP_VARS['sequence_number'])) { delete_cart_item($sequence_number); } } } } } $page_title = get_opendb_lang_var('item_reserve_list'); if (is_numeric($listingObject->getItemsPerPage())) { $listingObject->setTotalItems(fetch_my_basket_item_cnt(get_opendb_session_var('user_id'))); if ($listingObject->getTotalItemCount() > 0) { $checkbox_column = TRUE; $result = fetch_my_basket_item_rs(get_opendb_session_var('user_id'), $listingObject->getCurrentOrderBy(), $listingObject->getCurrentSortOrder(), $listingObject->getStartIndex(), $listingObject->getItemsPerPage()); } } else {
/** */ function get_user_ids_tovalue($user_id_rs) { $to = ""; if (is_not_empty_array($user_id_rs)) { reset($user_id_rs); while (list(, $user_id) = each($user_id_rs)) { if (strlen($to) == 0) { $to = $user_id; } else { $to .= ", " . $user_id; } } } return $to; }
/** @param $item_r where provided will give the item_id / instance_no, where not provided is safe to assume that this is a new item insert field and this information is not relevant. */ function url($name, $item_r, $item_attribute_type_r, $prompt, $length, $maxlength, $content_groups, $value, $onchange_event, $disabled = FALSE, $multi_value = FALSE) { // Default size. $size = $length; if (!is_numeric($size) || $size <= 0) { $size = 50; } if (get_opendb_config_var('widgets', 'enable_javascript_validation') !== FALSE) { if (strlen(trim($content_groups)) > 0) { // might be an array of content groups $content_group_r = prc_args($content_groups); $extensions_r = fetch_file_type_extensions_r($content_group_r); if (is_not_empty_array($extensions_r)) { $extensions = implode(', ', $extensions_r); } else { // else just list of extensions otherwise $extensions = $content_groups; $extensions_r = $content_group_r; } $url_is_not_valid_message = addslashes(get_opendb_lang_var('url_is_not_valid', array('prompt' => $prompt, 'extensions' => $extensions))); $onchange = "onchange=\"if(!isValidExtension(this.value, " . encode_javascript_array($extensions_r) . ")){alert('" . $url_is_not_valid_message . "'); this.focus(); return false;} {$onchange_event} return true;\""; } } else { $onchange = "onchange=\"{$onchange_event}\""; } if ($item_attribute_type_r['file_attribute_ind'] == 'Y') { $field .= "\n<ul class=\"urlOptionsMenu\" id=\"{$name}-tab-menu\" class=\"file-upload-menu\">"; $field .= "<li id=\"menu-{$name}_saveurl\" class=\"activeTab\" onclick=\"return activateTab('{$name}_saveurl', '{$name}-tab-menu', '{$name}-tab-content', 'activeTab', 'fieldContent');\">URL</li>"; if (is_file_upload_enabled()) { $field .= "<li id=\"menu-{$name}_upload\" onclick=\"return activateTab('{$name}_upload', '{$name}-tab-menu', '{$name}-tab-content', 'activeTab', 'fieldContent');\">Upload File</li>"; } $field .= "</ul>"; $field .= "<div class=\"urlOptionsContainer\" id=\"{$name}-tab-content\">"; $field .= "\n<div class=\"fieldContent\" id=\"{$name}_saveurl\">"; $field .= "<input type=\"text\" class=\"text\" name=\"{$name}\" value=\"{$value}\" {$onchange} size=\"" . $length . "\" " . (is_numeric($maxlength) ? "maxlength=\"" . $maxlength . "\"" : "") . ">"; $field .= "<input type=\"button\" class=\"button\" onclick=\"if(this.form['{$name}'].value.length>0){popup(this.form['{$name}'].value,'400','300');}else{alert('" . get_opendb_lang_var('prompt_must_be_specified', 'prompt', $prompt) . "');}\" value=\"" . get_opendb_lang_var('view') . "\"" . ($disabled ? ' DISABLED' : '') . ">"; $field .= "</div>"; if (is_file_upload_enabled()) { $field .= "<div class=\"fieldContentHidden\" id=\"{$name}_upload\">"; $field .= "<input type=\"file\" class=\"file\" name=\"{$name}_upload\" {$onchange} size=\"" . $size . "\"" . ($disabled ? ' DISABLED' : '') . ">"; $field .= "</div>"; } $field .= '</div>'; } else { if ($multi_value) { return multivalue_text_field('text', $name, $size, $maxlength, $onchange, $value); } else { return singlevalue_text_field('text', $name, $size, $maxlength, $onchange, $value, $disabled); } } return $field; }
/** */ function __getItemHTTPVars(&$itemObj) { $attribute_type_rs = $this->__getItemTypeAttribs($itemObj->getItemType()); if (is_array($attribute_type_rs)) { // this will be set if array encountered, but not lookup value. $processing_s_attribute_type = FALSE; $new_attributes_rs = $itemObj->getAttributes(); reset($attribute_type_rs); while (list(, $attribute_type_r) = each($attribute_type_rs)) { if ($attribute_type_r['s_field_type'] != 'DURATION' && $attribute_type_r['s_field_type'] != 'TITLE' && $attribute_type_r['s_field_type'] != 'STATUSTYPE' && $attribute_type_r['s_field_type'] != 'STATUSCMNT' && $attribute_type_r['s_field_type'] != 'ITEM_ID') { $fieldname = get_field_name($attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']); if (isset($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { // TODO: Consider adding values not found in the lookup table to the s_attribute_type_lookup. if ($attribute_type_r['lookup_attribute_ind'] == 'Y') { // reset $value_r = NULL; // here is where we want some sanity checking of the options if (is_not_empty_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { $value_r = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } else { $value_r[] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } $lookup_value_r = array(); for ($i = 0; $i < count($value_r); $i++) { $raw_value = trim($value_r[$i]); if (strlen($raw_value) > 0) { $value = fetch_attribute_type_lookup_value($attribute_type_r['s_attribute_type'], $raw_value); if ($value !== FALSE) { $lookup_value_r[] = $value; } else { $lookup_value_r[] = $raw_value; } } } $item_attributes_rs[$fieldname] = $lookup_value_r; } else { if (is_not_empty_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { // This indicates we have a repeated s_attribute_type, and so should act appropriately. if ($processing_s_attribute_type != NULL && $attribute_type_r['s_attribute_type'] == $processing_s_attribute_type) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; array_splice($new_attributes_rs[$attribute_type_r['s_attribute_type']], 0, 1); } else { if (count($new_attributes_rs[$attribute_type_r['s_attribute_type']]) > 1) { // this is the first occurence of the s_attribute_type, so lets see if its repeated at least once. if (is_numeric(fetch_s_item_attribute_type_next_order_no($itemObj->getItemType(), $attribute_type_r['s_attribute_type'], $attribute_type_r['order_no']))) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; array_splice($new_attributes_rs[$attribute_type_r['s_attribute_type']], 0, 1); $processing_s_attribute_type = $attribute_type_r['s_attribute_type']; } else { // otherwise just copy the whole thing. $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } } else { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']][0]; } } } else { if (!is_array($new_attributes_rs[$attribute_type_r['s_attribute_type']])) { $item_attributes_rs[$fieldname] = $new_attributes_rs[$attribute_type_r['s_attribute_type']]; } } } } } else { // instance class if (strcasecmp(get_class($itemObj), 'ItemInstance') === 0) { if ($attribute_type_r['s_field_type'] == 'DURATION' && is_numeric($itemObj->getBorrowDuration())) { $item_attributes_rs['borrow_duration'] = $itemObj->getBorrowDuration(); } else { if ($attribute_type_r['s_field_type'] == 'STATUSTYPE') { $item_attributes_rs['s_status_type'] = $itemObj->getStatusType(); } else { if ($attribute_type_r['s_field_type'] == 'STATUSCMNT' && strlen($itemObj->getStatusComment()) > 0) { $item_attributes_rs['status_comment'] = $itemObj->getStatusComment(); } } } } else { if ($attribute_type_r['s_field_type'] == 'TITLE') { $item_attributes_rs['title'] = $itemObj->getTitle(); } } } } //while return $item_attributes_rs; } else { return FALSE; } }
echo get_op_confirm_form($PHP_SELF, "Are you sure you want to delete all cache files?", array('type' => $ADMIN_TYPE, 'op' => 'flush')); } else { $HTTP_VARS['op'] = ''; } } } else { if ($HTTP_VARS['op'] == 'flushexpired') { $files_deleted = file_cache_delete_files($HTTP_VARS['cache_type'], EXPIRED_ONLY); if ($files_deleted > 0) { $success[] = 'Deleted ' . $files_deleted . ' cache files'; } $HTTP_VARS['op'] = ''; } } if (strlen($HTTP_VARS['op']) == 0) { if (is_not_empty_array($success)) { echo format_error_block($success, 'information'); } echo "<p>[<a href=\"admin.php?type={$ADMIN_TYPE}&op=flushexpired\">Delete expired cache entries</a>] " . "[<a href=\"admin.php?type={$ADMIN_TYPE}&op=flush\">Delete all cache entries</a>]</p>"; if (strlen($HTTP_VARS['order_by']) == 0) { $HTTP_VARS['order_by'] = 'cache_date'; } $listingObject = new HTML_Listing($PHP_SELF, $HTTP_VARS); $listingObject->setNoRowsMessage(get_opendb_lang_var('no_items_found')); $listingObject->startListing(); $listingObject->addHeaderColumn('URL', 'url'); $listingObject->addHeaderColumn('Cached', 'cache_date'); $listingObject->addHeaderColumn('Expires', 'expire_date'); if (is_numeric($listingObject->getItemsPerPage())) { $listingObject->setTotalItems(fetch_file_cache_cnt($HTTP_VARS['cache_type'])); }
function format_error_block($errors, $err_type = 'error') { switch ($err_type) { case 'error': $class = 'error'; $smclass = 'smerror'; break; case 'smerror': $class = 'smerror'; $smclass = 'smerror'; break; case 'warning': // If it becomes necessary, new CSS style classes will be introduced. // If it becomes necessary, new CSS style classes will be introduced. case 'information': default: $class = 'smsuccess'; $smclass = 'footer'; } if (!is_array($errors)) { if (strlen(trim($errors)) == 0) { return NULL; } else { $error_rs[] = array('error' => $errors, 'detail' => ''); } } else { if (isset($errors['error'])) { $error_rs[] = $errors; } else { $error_rs = $errors; } } $error_entries = NULL; while (list(, $error) = each($error_rs)) { if (is_not_empty_array($error)) { $error_entry = $error['error']; if (!is_array($error['detail']) && strlen($error['detail']) > 0) { $detail_rs[] = $error['detail']; } else { if (is_array($error['detail'])) { $detail_rs = $error['detail']; } } if (is_not_empty_array($detail_rs)) { $details = ""; while (list(, $detail) = each($detail_rs)) { $details .= "\n<li class=\"{$smclass}\">" . $detail . "</li>"; } if (strlen($details) > 0) { $error_entry .= "\n<ul>" . $details . "</ul>"; } } } else { $error_entry = $error; } $error_entries[] = $error_entry; } if (count($error_entries) > 1) { $error_block = "\n<ul>"; while (list(, $error_entry) = each($error_entries)) { $error_block .= "\n<li class=\"{$class}\">{$error_entry}</li>"; } $error_block .= "</ul>"; return $error_block; } else { if (count($error_entries) == 1) { return "\n<p class=\"{$class}\">" . $error_entries[0] . "</p>"; } else { return NULL; } } }
echo "<tr><td class=\"data\">" . $title_mask_r['description'] . "</td>"; $title_mask_items_r = fetch_title_mask_items_r($title_mask_r['id'], $HTTP_VARS['s_item_type_group'], $HTTP_VARS['s_item_type']); echo "<td class=\"data\"><textarea wrap=\"off\" cols=\"125\" rows=\"3\" name=\"display_mask[" . $title_mask_r['id'] . "]\">" . htmlspecialchars($title_mask_items_r['display_mask']) . "</textarea></td>"; echo "</tr>"; } db_free_result($results); } echo "</table>"; echo "\n<input type=\"button\" class=\"button\" onclick=\"this.form.op.value='update'; this.form.submit();\" value=\"Update\">"; echo "</form>"; } else { // error } } if ($HTTP_VARS['op'] == '') { if (is_not_empty_array($errors)) { echo format_error_block($errors); } echo "\n<form name=\"s_title_display_mask\" action=\"{$PHP_SELF}\" method=\"POST\">"; echo "\n<input type=\"hidden\" name=\"type\" value=\"" . $ADMIN_TYPE . "\">"; $results = fetch_item_type_group_rs(); if ($results) { echo "<h3>Item Type Groups</h3>"; echo "<ul class=\"itemTypeGroupList\">"; while ($item_type_group_r = db_fetch_assoc($results)) { $classattr = NULL; if (is_exists_s_title_display_mask_group($item_type_group_r['s_item_type_group'], NULL)) { $classattr = 'class="active"'; } echo "\n<li {$classattr}><a href=\"{$PHP_SELF}?type={$ADMIN_TYPE}&op=edit&s_item_type_group=" . $item_type_group_r['s_item_type_group'] . "&s_item_type=*\">Edit " . $item_type_group_r['s_item_type_group'] . "</a></li>"; }
function send_signup_info_to_admin($HTTP_VARS, &$errors) { global $PHP_SELF; $role_r = fetch_role_r($HTTP_VARS['user_role']); $user_info_lines = get_opendb_lang_var('userid') . ": " . $HTTP_VARS['user_id'] . "\n" . get_opendb_lang_var('fullname') . ": " . $HTTP_VARS['fullname'] . "\n" . get_opendb_lang_var('user_role') . ": " . $role_r['description'] . "\n" . get_opendb_lang_var('user_theme') . ": " . $HTTP_VARS['uid_theme'] . "\n" . get_opendb_lang_var('email') . ": " . $HTTP_VARS['email_addr']; $addr_results = fetch_address_type_rs(TRUE); if ($addr_results) { while ($address_type_r = db_fetch_assoc($addr_results)) { $address_type = strtolower($address_type_r['s_address_type']); $attr_results = fetch_address_type_attribute_type_rs($address_type_r['s_address_type'], 'update', TRUE); if ($attr_results) { while ($addr_attribute_type_r = db_fetch_assoc($attr_results)) { $fieldname = get_field_name($addr_attribute_type_r['s_attribute_type'], $addr_attribute_type_r['order_no']); // may have to change this if statement, if fieldname will contain array, instead of scalar value if (is_not_empty_array($HTTP_VARS[$address_type][$fieldname]) || !is_array($HTTP_VARS[$address_type][$fieldname]) && strlen($HTTP_VARS[$address_type][$fieldname]) > 0) { if (is_not_empty_array($HTTP_VARS[$address_type][$fieldname])) { $value = ''; for ($i = 0; $i < count($HTTP_VARS[$address_type][$fieldname]); $i++) { if (strlen($value) > 0) { $value .= ','; } $value .= $HTTP_VARS[$address_type][$fieldname][$i]; } } else { $value = $HTTP_VARS[$address_type][$fieldname]; } $user_info_lines .= "\n" . $addr_attribute_type_r['prompt'] . ": " . $value; } } db_free_result($attr_results); } //if($attr_results) } db_free_result($addr_results); } //if($addr_results) $activate_url = get_site_url() . 'user_admin.php?op=activate&user_id=' . $HTTP_VARS['user_id']; $delete_url = get_site_url() . 'user_admin.php?op=delete&user_id=' . $HTTP_VARS['user_id']; $message = get_opendb_lang_var('new_account_email', array('admin_name' => get_opendb_lang_var('site_administrator', 'site', get_opendb_config_var('site', 'title')), 'user_info' => $user_info_lines, 'site' => get_opendb_config_var('site', 'title'), 'activate_url' => $activate_url, 'delete_url' => $delete_url)); return send_email_to_site_admins(PERM_ADMIN_CREATE_USER, $HTTP_VARS['email_addr'], get_opendb_lang_var('new_account'), $message, $errors); }
/** * Used by all insert/update item_instance functions to make sure the data is valid. Will * also update $status_comment / $borrow_duration and set them to a legal value for the * specified $s_status_type */ function validate_item_instance_fields($s_status_type, &$status_comment, &$borrow_duration) { // At this point, a specific $s_status_type MUST be supplied. if (strlen($s_status_type) > 0) { $status_type_r = fetch_status_type_r($s_status_type); } if (is_not_empty_array($status_type_r)) { // A $borrow_duration explicitly set to FALSE, is // an indication that nothing should be done with it. if ($borrow_duration !== FALSE && $borrow_duration !== NULL) { //if already null, no need to check again. // Ensure we have a valid $borrow_duration if (is_numeric($borrow_duration)) { //column cannot handle more than 999 if ($borrow_duration > 999) { $borrow_duration = '999'; } } else { $borrow_duration = NULL; } } $status_comment = addslashes(substr(replace_newlines(trim(strip_tags($status_comment))), 0, 255)); return TRUE; } else { opendb_logger(OPENDB_LOG_ERROR, __FILE__, __FUNCTION__, 'Invalid Status Type', array($s_status_type)); return FALSE; } }