Exemple #1
0
function &get_export_plugin($pluginName)
{
    if (is_export_plugin($pluginName)) {
        include_once "./lib/export/" . $pluginName . ".class.php";
        $exportPlugin = new $pluginName();
        return $exportPlugin;
    } else {
        return NULL;
    }
}
Exemple #2
0
function validate_s_config_group_item($group_id, $id, $keyid, $value)
{
    if (strlen($group_id) > 0 && strlen($id) > 0 && strlen($keyid) > 0) {
        $query = "SELECT type, subtype FROM s_config_group_item WHERE group_id = '{$group_id}' AND id = '{$id}' ";
        if (is_numeric($keyid)) {
            $query .= " AND (type = 'array' OR keyid = '{$keyid}') ";
        } else {
            $query .= " AND keyid = '{$keyid}' ";
        }
        $query .= "LIMIT 0,1";
        $result = db_query($query);
        if ($result && db_num_rows($result) > 0) {
            $found = db_fetch_assoc($result);
            $value = trim($value);
            // will not directly validate an array, but instead the subtype of the array.
            if ($found['type'] == 'array') {
                // by default its text
                if (strlen($found['subtype']) == 0) {
                    $found['subtype'] = 'text';
                }
                if ($found['subtype'] == 'usertype') {
                    $found['type'] = 'usertype';
                } else {
                    if ($found['subtype'] == 'number') {
                        $found['type'] = 'number';
                    } else {
                        $found['type'] = 'text';
                    }
                }
            }
            switch ($found['type']) {
                case 'boolean':
                    $value = strtoupper($value);
                    if ($value == 'TRUE' || $value == 'FALSE') {
                        return $value;
                    } else {
                        return 'FALSE';
                    }
                case 'email':
                    if (is_valid_email_addr($value)) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                case 'number':
                    // filter out any non-numeric characters, but pass the rest in.
                    $value = remove_illegal_chars($value, expand_chars_exp('0-9'));
                    if (strlen($value) > 0) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                case 'datemask':
                    // TODO: Provide a date-mask filter
                    return $value;
                case 'language':
                    if (is_exists_language($value)) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                case 'theme':
                    if (is_exists_theme($value)) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                case 'export':
                    if (strlen($value) == 0 || is_export_plugin($value)) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                case 'value_select':
                    if (strlen($found['subtype']) > 0) {
                        $options_r = explode(',', $found['subtype']);
                    }
                    if (!is_array($options_r) || in_array($value, $options_r) !== FALSE) {
                        return $value;
                    } else {
                        return FALSE;
                    }
                    //case 'readonly':
                    //    return $value;
                    //case 'text':
                    //case 'password':
                    //case 'textarea':
                    //    return addslashes(replace_newlines(trim($value)));
                //case 'readonly':
                //    return $value;
                //case 'text':
                //case 'password':
                //case 'textarea':
                //    return addslashes(replace_newlines(trim($value)));
                default:
                    return addslashes(replace_newlines(trim($value)));
            }
            //switch
            db_free_result($result);
        } else {
            return FALSE;
        }
    }
    //else
    return FALSE;
}
Exemple #3
0
             echo format_footer_links($instance_info_links_r);
             echo "</div>";
             if (get_opendb_config_var('item_review', 'enable') !== FALSE) {
                 echo "<div class=\"{$otherTabsClass}\" id=\"reviews\">";
                 echo get_item_review_block($item_r);
                 echo "</div>";
             }
             echo "</div>";
             // end of tab content
             echo "</div>";
             // end of tabContainer
         } else {
             echo _theme_header(get_opendb_lang_var('item_not_found'));
             echo "<p class=\"error\">" . get_opendb_lang_var('item_not_found') . "</p>";
         }
         if (is_export_plugin(get_opendb_config_var('item_display', 'export_link')) && is_user_granted_permission(PERM_USER_EXPORT)) {
             $footer_links_r[] = array(url => "export.php?op=export&plugin=" . get_opendb_config_var('item_display', 'export_link') . "&item_id=" . $item_r['item_id'] . "&instance_no=" . $item_r['instance_no'], text => get_opendb_lang_var('export_item_record'));
         }
         // Include a Back to Listing link.
         if (is_opendb_session_var('listing_url_vars')) {
             $footer_links_r[] = array(url => "listings.php?" . get_url_string(get_opendb_session_var('listing_url_vars')), text => get_opendb_lang_var('back_to_listing'));
         }
         echo format_footer_links($footer_links_r);
         echo _theme_footer();
     } else {
         opendb_not_authorised_page(PERM_VIEW_ITEM_DISPLAY, $HTTP_VARS);
     }
 } else {
     // invalid login, so login instead.
     redirect_login($PHP_SELF, $HTTP_VARS);
 }