当前位置: 首页>>代码示例>>C#>>正文


C# Connector.Query_Read方法代码示例

本文整理汇总了C#中Connector.Query_Read方法的典型用法代码示例。如果您正苦于以下问题:C# Connector.Query_Read方法的具体用法?C# Connector.Query_Read怎么用?C# Connector.Query_Read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connector的用法示例。


在下文中一共展示了Connector.Query_Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: reload

 /// <summary>
 /// Reloads the settings from the database.
 /// </summary>
 /// <param name="conn"></param>
 public void reload(Connector conn)
 {
     lock (categories)
     {
         categories.Clear();
         foreach (ResultRow setting in conn.Query_Read("SELECT category, keyname, value FROM settings ORDER BY category ASC, keyname ASC"))
         {
             // Check the category exists
             if (!categories.ContainsKey(setting["category"]))
                 categories.Add(setting["category"], new SettingsCategory());
             // Set the value
             categories[setting["category"]].settings.Add(setting["keyname"], setting["value"]);
         }
     }
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:19,代码来源:Settings.cs

示例2: cmsStart

 public static string cmsStart(string pluginid, Connector conn)
 {
     // The directory where all of our files will be stored
     downloadsPath = Core.basePath + "/_downloads";
     // Check the local directory exists for downloads
     if (!Directory.Exists(downloadsPath))
         Directory.CreateDirectory(downloadsPath);
     else
         // Begin indexing pre-existing files for changes
         indexMainFolder();
     // Initialize file-watcher
     watcherEnable();
     // Check all the icons in the cache exist physically - else delete the db version
     List<string> iconsFound = new List<string>();
     StringBuilder deleteBuffer = new StringBuilder("DELETE FROM downloads_ext_icons WHERE ");
     int dbLength = deleteBuffer.Length;
     foreach (ResultRow icon in conn.Query_Read("SELECT extension FROM downloads_ext_icons"))
     {
         if (!File.Exists(Core.basePath + "\\Content\\Images\\downloads\\icons"))
             deleteBuffer.Append("extension='" + Utils.Escape(icon["extension"]) + "' OR ");
         else
             iconsFound.Add(icon["extension"]);
     }
     if (deleteBuffer.Length != dbLength)
         conn.Query_Execute(deleteBuffer.Remove(deleteBuffer.Length - 4, 4).Append(";").ToString());
     // Add any new physical icons to the database
     string ext;
     Dictionary<string, object> attribs;
     foreach (string file in Directory.GetFiles(Core.basePath + "\\Content\\Images\\downloads\\icons", "*.png", SearchOption.AllDirectories))
         try
         {
             if (!iconsFound.Contains((ext = Path.GetFileNameWithoutExtension(file))))
             {
                 attribs = new Dictionary<string, object>();
                 attribs.Add("extension", ext);
                 attribs.Add("icon", File.ReadAllBytes(file));
                 conn.Query_Execute_Parameters("INSERT INTO downloads_ext_icons (extension, icon) VALUES(@extension, @icon)", attribs);
             }
         }
         catch { }
     return null;
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:42,代码来源:Downloads.cs

示例3: pageUsers

 public static void pageUsers(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     if (request.QueryString["2"] != null)
     {
         // Editing a user
         string error = null;
         bool updatedAccount = false;
         // Set SQL injection protection flag (to disable flag)
         pageElements.setFlag(Plugins.BasicSiteAuth.FLAG_PASSWORD_ACCESSED);
         // Grab the user's info, bans and available user groups
         Result user = conn.Query_Read("SELECT * FROM bsa_users WHERE userid='" + Utils.Escape(request.QueryString["2"]) + "'");
         if (user.Rows.Count != 1) return;
         Result bans = conn.Query_Read("SELECT b.*, u.username FROM bsa_user_bans AS b LEFT OUTER JOIN bsa_users AS u ON u.userid=b.banner_userid ORDER BY datetime DESC");
         Result userGroups = conn.Query_Read("SELECT groupid, title FROM bsa_user_groups ORDER BY access_login ASC, access_changeaccount ASC, access_media_create ASC, access_media_edit ASC, access_media_delete ASC, access_media_publish ASC, access_admin ASC, title ASC");
         string dban = request.QueryString["dban"];
         // Check for deleting a ban
         if (dban != null)
         {
             conn.Query_Execute("DELETE FROM bsa_user_bans WHERE banid='" + Utils.Escape(dban) + "'");
             conn.Disconnect();
             response.Redirect(pageElements["ADMIN_URL"] + "/" + user[0]["userid"], true);
         }
         // Check for postback of banning the user
         string ban = request.QueryString["ban"];
         string banCustom = request.QueryString["ban_custom"];
         string banReason = request.QueryString["ban_reason"];
         if (ban != null || banCustom != null)
         {
             int banAmount = 0;
             if (ban != null)
             {
                 if (ban.Equals("Permanent"))
                     banAmount = 0;
                 else if (ban.Equals("1 Month"))
                     banAmount = 2628000;
                 else if (ban.Equals("1 Week"))
                     banAmount = 604800;
                 else if (ban.Equals("3 Days"))
                     banAmount = 259200;
                 else if (ban.Equals("1 Day"))
                     banAmount = 86400;
                 else
                     error = "Invalid ban period!";
             }
             else
             {
                 if (banCustom != null && !int.TryParse(banCustom, out banAmount))
                     error = "Invalid ban period, not numeric!";
                 else if (banAmount < 0)
                     error = "Ban period cannot be less than zero!";
             }
             if(error == null)
             {
                 // Get the time at which the user will be unbanned
                 DateTime dt = DateTime.Now.AddSeconds(-banAmount);
                 // Insert the record
                 conn.Query_Execute("INSERT INTO bsa_user_bans (userid, reason, unban_date, datetime, banner_userid) VALUES('" + Utils.Escape(user[0]["userid"]) + "', '" + Utils.Escape(banReason) + "', " + (banAmount == 0 ? "NULL" : "'" + Utils.Escape(dt.ToString("yyyy-MM-dd HH:mm:ss")) + "'") + ", NOW(), '" + Utils.Escape(HttpContext.Current.User.Identity.Name) + "')");
                 // Refresh the page
                 conn.Disconnect();
                 response.Redirect(pageElements["ADMIN_URL"] + "/" + user[0]["userid"], true);
             }
         }
         // Check for postback of editing the user
         string username = request.Form["username"];
         string password = request.Form["password"];
         string email = request.Form["email"];
         string secretQuestion = request.Form["secret_question"];
         string secretAnswer = request.Form["secret_answer"];
         string groupid = request.Form["groupid"];
         if (username != null && password != null && email != null && secretQuestion != null && secretAnswer != null && groupid != null)
         {
             if (username.Length < Plugins.BasicSiteAuth.USERNAME_MIN || username.Length > Plugins.BasicSiteAuth.USERNAME_MAX)
                 error = "Username must be " + Plugins.BasicSiteAuth.USERNAME_MIN + " to " + Plugins.BasicSiteAuth.USERNAME_MAX + " characters in length!";
             else if ((error = Plugins.BasicSiteAuth.validUsernameChars(username)) != null)
                 ;
             else if (!Plugins.BasicSiteAuth.validEmail(email))
                 error = "Invalid e-mail!";
             else if (password.Length != 0 && (password.Length < Plugins.BasicSiteAuth.PASSWORD_MIN || password.Length > Plugins.BasicSiteAuth.PASSWORD_MAX))
                 error = "Password must be " + Plugins.BasicSiteAuth.PASSWORD_MIN + " to " + Plugins.BasicSiteAuth.PASSWORD_MAX + " characters in length!";
             else if (secretQuestion.Length < Plugins.BasicSiteAuth.SECRET_QUESTION_MIN || secretQuestion.Length > Plugins.BasicSiteAuth.SECRET_QUESTION_MAX)
                 error = "Secret question must be " + Plugins.BasicSiteAuth.SECRET_QUESTION_MIN + " to " + Plugins.BasicSiteAuth.SECRET_QUESTION_MAX + " characters in length!";
             else if (secretAnswer.Length < Plugins.BasicSiteAuth.SECRET_ANSWER_MIN || secretAnswer.Length > Plugins.BasicSiteAuth.SECRET_ANSWER_MAX)
                 error = "Secret answer must be " + Plugins.BasicSiteAuth.SECRET_ANSWER_MIN + " to " + Plugins.BasicSiteAuth.SECRET_ANSWER_MAX + " characters in length!";
             else
             {
                 // Ensure the groupid is valid
                 bool groupFound = false;
                 foreach (ResultRow group in userGroups) if (group["groupid"] == groupid) groupFound = true;
                 if (!groupFound)
                     error = "Invalid group!";
                 else
                 {
                     // Attempt to update the user's details
                     try
                     {
                         conn.Query_Execute("UPDATE bsa_users SET username='" + Utils.Escape(username) + "', email='" + Utils.Escape(email) + "', " + (password.Length > 0 ? "password='" + Utils.Escape(Plugins.BasicSiteAuth.generateHash(password, Plugins.BasicSiteAuth.salt1, Plugins.BasicSiteAuth.salt2)) + "', " : string.Empty) + "secret_question='" + Utils.Escape(secretQuestion) + "', secret_answer='" + Utils.Escape(secretAnswer) + "', groupid='" + Utils.Escape(groupid) + "' WHERE userid='" + Utils.Escape(user[0]["userid"]) + "'");
                         updatedAccount = true;
                     }
                     catch (DuplicateEntryException ex)
                     {
//.........这里部分代码省略.........
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:101,代码来源:BasicSiteAuth.cs

示例4: pageDownload_Thumb

        public static void pageDownload_Thumb(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response, bool admin, ResultRow file)
        {
            // Check the background has been loaded/cached
            if (pageDownload_Thumb_bbcode == null)
                pageDownload_Thumb_bbcode = (Bitmap)Image.FromFile(Core.basePath + "\\Content\\Images\\downloads\\bbcode.png");
            // Construct the image
            Bitmap output = (Bitmap)pageDownload_Thumb_bbcode.Clone();
            Graphics g = Graphics.FromImage(output);
            // Grab the associated icon
            byte[] rawIcon = null;
            if (file["iconid"].Length > 0 && file["iconid"] != "0")
            {
                // Grab the icon generated of the file
                Result data = conn.Query_Read("SELECT data FROM downloads_files_icons WHERE iconid='" + Utils.Escape(file["iconid"]) + "'");
                if (data.Rows.Count == 1)
                    rawIcon = data[0].GetByteArray("data");
            }
            if (rawIcon == null && file["extension"].Length > 0)
            {
                // Grab the icon associated with the extension
                Result data = conn.Query_Read("SELECT icon FROM downloads_ext_icons WHERE extension='" + Utils.Escape(file["extension"]) + "'");
                if (data.Rows.Count == 1)
                    rawIcon = data[0].GetByteArray("icon");
            }
            if (rawIcon == null)
            {
                // Associate unknown extension with this file
                if (pageDownloads_Icon_Unknown == null)
                    loadUknownIcon();
                rawIcon = pageDownloads_Icon_Unknown;
            }
            // Draw icon
            MemoryStream ms = new MemoryStream(rawIcon);
            Bitmap icon = (Bitmap)Image.FromStream(ms);
            // Apply fake rounded edges
            icon.SetPixel(0, 0, Color.Transparent); // Top-left
            icon.SetPixel(1, 0, Color.Transparent);
            icon.SetPixel(0, 1, Color.Transparent);

            icon.SetPixel(31, 0, Color.Transparent); // Top-right
            icon.SetPixel(30, 0, Color.Transparent);
            icon.SetPixel(31, 1, Color.Transparent);

            icon.SetPixel(0, 31, Color.Transparent); // Bottom-left
            icon.SetPixel(0, 30, Color.Transparent);
            icon.SetPixel(1, 31, Color.Transparent);

            icon.SetPixel(31, 31, Color.Transparent); // Bottom-right
            icon.SetPixel(31, 30, Color.Transparent);
            icon.SetPixel(30, 31, Color.Transparent);
            g.DrawImage(icon, 5, 8, 32, 32);
            icon.Dispose();
            ms.Dispose();
            // Draw title
            g.DrawString(file["title"], new Font("Arial", 12.0f, FontStyle.Regular, GraphicsUnit.Pixel), new SolidBrush(Color.White), 40, 8);
            // Draw downloads
            g.DrawString(conn.Query_Scalar("SELECT COUNT('') FROM (SELECT ip_addr FROM downloads WHERE downloadid='" + Utils.Escape(file["downloadid"]) + "' GROUP BY ip_addr) AS a").ToString() + " downloads", new Font("Arial", 12.0f, FontStyle.Regular, GraphicsUnit.Pixel), new SolidBrush(Color.LightGray), 40, 24);
            // Output it to the user
            ms = new MemoryStream();
            output.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            output.Dispose();
            response.ContentType = "image/png";
            response.BinaryWrite(ms.ToArray());
            ms.Dispose();
            conn.Disconnect();
            response.End();
        }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:67,代码来源:Downloads.cs

示例5: pageRegister

 /// <summary>
 /// Used to register new accounts; this supports activation as well.
 /// </summary>
 /// <param name="pluginid"></param>
 /// <param name="conn"></param>
 /// <param name="pageElements"></param>
 /// <param name="request"></param>
 /// <param name="response"></param>
 private static void pageRegister(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     switch (request.QueryString["1"])
     {
         case "success":
             // Check which template to display - welcome or activation-required
             bool activationNeeded = conn.Query_Scalar("SELECT access_login FROM bsa_user_groups WHERE groupid='" + Utils.Escape(Core.settings[SETTINGS_CATEGORY][SETTINGS_USER_GROUP_DEFAULT]) + "'").ToString().Equals("0");
             if (activationNeeded)
             {
                 pageElements["TITLE"] = "Register - Success - Verification Required";
                 pageElements["CONTENT"] = Core.templates["basic_site_auth"]["register_success_activate"];
                 // Add CSS file
                 Misc.Plugins.addHeaderCSS("/Content/CSS/BasicSiteAuth.css", ref pageElements);
             }
             else
             {
                 pageElements["TITLE"] = "Register - Success";
                 pageElements["CONTENT"] = Core.templates["basic_site_auth"]["register_success"];
                 // Add CSS file
                 Misc.Plugins.addHeaderCSS("/Content/CSS/BasicSiteAuth.css", ref pageElements);
             }
             break;
         case "activate":
         case "deactivate":
             bool activate = request.QueryString["1"].Equals("activate");
             string dkey = request.QueryString["key"];
             if (dkey != null)
             {
                 // Locate the user-group associated with the key
                 Result res = conn.Query_Read("SELECT a.keyid, a.userid, u.groupid, u.username FROM bsa_activations AS a LEFT OUTER JOIN bsa_users AS u ON u.userid=a.userid");
                 // Ensure the condition is valid
                 if (res.Rows.Count == 1 && res[0]["groupid"] == Core.settings[SETTINGS_CATEGORY][SETTINGS_USER_GROUP_DEFAULT])
                 {
                     // Ensure the user wants to activate/deactivate their account
                     if (request.Form["confirm"] == null)
                     {
                         if (activate)
                         {
                             pageElements["TITLE"] = "Register - Activate Account";
                             pageElements["CONTENT"] = Core.templates["basic_site_auth"]["activate"]
                                 .Replace("%KEY%", request.QueryString["key"])
                                 .Replace("%USERNAME%", HttpUtility.HtmlEncode(res[0]["username"]));
                         }
                         else
                         {
                             pageElements["TITLE"] = "Register - Deactivate Account";
                             pageElements["CONTENT"] = Core.templates["basic_site_auth"]["deactivate"]
                                 .Replace("%KEY%", request.QueryString["key"])
                                 .Replace("%USERNAME%", HttpUtility.HtmlEncode(res[0]["username"]));
                         }
                         // Add CSS file
                         Misc.Plugins.addHeaderCSS("/Content/CSS/BasicSiteAuth.css", ref pageElements);
                     }
                     else
                     {
                         if (activate)
                         {
                             // Remove the activation key and change the groupid
                             conn.Query_Execute("DELETE FROM bsa_activations WHERE keyid='" + Utils.Escape(res[0]["keyid"]) + "'; UPDATE bsa_users SET groupid='" + Utils.Escape(Core.settings[SETTINGS_CATEGORY][SETTINGS_USER_GROUP_USER]) + "' WHERE userid='" + Utils.Escape(res[0]["userid"]) + "';");
                             // Log the event
                             logEvent(res[0]["userid"], LogEvents.Registration_Activated, request.UserHostAddress, conn);
                             // Display confirmation
                             pageElements["TITLE"] = "Account Activated";
                             pageElements["CONTENT"] = Core.templates["basic_site_auth"]["activate_success"];
                         }
                         else
                         {
                             // Delete the account
                             conn.Query_Execute("DELETE FROM bsa_users WHERE userid='" + Utils.Escape(res[0]["userid"]) + "';");
                             // Display confirmation
                             pageElements["TITLE"] = "Account Deactivated";
                             pageElements["CONTENT"] = Core.templates["basic_site_auth"]["deactivate_success"];
                         }
                         // Add CSS file
                         Misc.Plugins.addHeaderCSS("/Content/CSS/BasicSiteAuth.css", ref pageElements);
                     }
                 }
             }
             break;
         case null:
             string error = null;
             string username = request.Form["username"];
             string password = request.Form["password"];
             string confirmPassword = request.Form["confirm_password"];
             string email = request.Form["email"];
             string secretQuestion = request.Form["secret_question"];
             string secretAnswer = request.Form["secret_answer"];
             string captcha = request.Form["captcha"];
             if (username != null && password != null && confirmPassword != null && email != null && secretQuestion != null && secretAnswer != null)
             {
                 // Validate
                 if (!Common.Validation.validCaptcha(captcha))
//.........这里部分代码省略.........
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:101,代码来源:BasicSiteAuth.cs

示例6: pageProfile_Settings


//.........这里部分代码省略.........
                    error = "Contact Flickr cannot exceed " + maxContactItem + " characters!";
                else if (contactTwitter.Length > maxContactItem)
                    error = "Contact Twitter cannot exceed " + maxContactItem + " characters!";
                else if (contactXfire.Length > maxContactItem)
                    error = "Contact Xfire cannot exceed " + maxContactItem + " characters!";
                else if (contactDeviantArt.Length > maxContactItem)
                    error = "Contact DeviantArt cannot exceed " + maxContactItem + " characters!";
                else
                {
                    // Posted data is valid - update the database
                    try
                    {
                        StringBuilder query = new StringBuilder("UPDATE bsa_profiles SET ")
                        .Append("disabled='").Append(Utils.Escape(profileEnabled)).Append("',")
                        .Append("background_url='").Append(Utils.Escape(frameBgURL)).Append("',")
                        .Append("background_colour='").Append(Utils.Escape(frameBgColour)).Append("',")
                        .Append("colour_background='").Append(Utils.Escape(paneBgColour)).Append("',")
                        .Append("colour_text='").Append(Utils.Escape(paneTextColour)).Append("',")
                        .Append("nutshell='").Append(Utils.Escape(nutshell)).Append("',")
                        .Append("gender='").Append(Utils.Escape(gender)).Append("',")
                        .Append("country_code=").Append(country.Length == 0 ? "NULL" : "'" + Utils.Escape(country) + "'").Append(",")
                        .Append("occupation='").Append(Utils.Escape(occupation)).Append("',")
                        .Append("contact_github='").Append(Utils.Escape(contactGithub)).Append("',")
                        .Append("contact_website='").Append(Utils.Escape(contactWebsite)).Append("',")
                        .Append("contact_email='").Append(Utils.Escape(contactEmail)).Append("',")
                        .Append("contact_facebook='").Append(Utils.Escape(contactFacebook)).Append("',")
                        .Append("contact_reddit='").Append(Utils.Escape(contactReddit)).Append("',")
                        .Append("contact_googleplus='").Append(Utils.Escape(contactGooglePlus)).Append("',")
                        .Append("contact_steam='").Append(Utils.Escape(contactSteam)).Append("',")
                        .Append("contact_wlm='").Append(Utils.Escape(contactWlm)).Append("',")
                        .Append("contact_skype='").Append(Utils.Escape(contactSkype)).Append("',")
                        .Append("contact_youtube='").Append(Utils.Escape(contactYouTube)).Append("',")
                        .Append("contact_soundcloud='").Append(Utils.Escape(contactSoundcloud)).Append("',")
                        .Append("contact_xbox='").Append(Utils.Escape(contactXbox)).Append("',")
                        .Append("contact_psn='").Append(Utils.Escape(contactPsn)).Append("',")
                        .Append("contact_flickr='").Append(Utils.Escape(contactFlickr)).Append("',")
                        .Append("contact_twitter='").Append(Utils.Escape(contactTwitter)).Append("',")
                        .Append("contact_xfire='").Append(Utils.Escape(contactXfire)).Append("',")
                        .Append("contact_deviantart='").Append(Utils.Escape(contactDeviantArt)).Append("'")
                        .Append(" WHERE profileid='").Append(Utils.Escape(profileData["profileid"])).Append("'")
                        ;
                        conn.Query_Execute(query.ToString());
                        updatedProfile = true;
                        // Reload the profile settings
                        profileData = conn.Query_Read(profileQuery)[0];
                    }
                    catch
                    {
                        error = "Failed to update profile settings, try again!";
                    }
                }
            }
            // Build options
            StringBuilder profileEnabledItems = new StringBuilder();
            profileEnabledItems.Append("<option value=\"0\"").Append("0" == (profileEnabled ?? profileData["disabled"]) ? " selected=\"selected\"" : string.Empty).Append(">Enabled</option>");
            profileEnabledItems.Append("<option value=\"1\"").Append("1" == (profileEnabled ?? profileData["disabled"]) ? " selected=\"selected\"" : string.Empty).Append(">Disabled</option>");

            StringBuilder countryItems = new StringBuilder();
            countryItems.Append("<option value=\"\">Unknown</option>");
            foreach (Common.Country c in Common.Country.getCountries(conn))
                countryItems.Append("<option value=\"").Append(c.countryCode).Append("\"").Append(c.countryCode == (country ?? profileData["country_code"]) ? " selected=\"selected\"" : string.Empty).Append(">").Append(HttpUtility.HtmlEncode(c.countryTitle)).Append("</option>");

            StringBuilder genderItems = new StringBuilder();
            genderItems.Append("<option value=\"0\"").Append("0" == (gender ?? profileData["gender"]) ? " selected=\"selected\"" : string.Empty).Append(">Not Specified</option>");
            genderItems.Append("<option value=\"1\"").Append("1" == (gender ?? profileData["gender"]) ? " selected=\"selected\"" : string.Empty).Append(">Male</option>");
            genderItems.Append("<option value=\"2\"").Append("2" == (gender ?? profileData["gender"]) ? " selected=\"selected\"" : string.Empty).Append(">Female</option>");

            // Set the content
            pageElements["PROFILE_CONTENT"] = Core.templates["bsa_profiles"]["profile_settings"]
                .Replace("<USERID>", HttpUtility.HtmlEncode(profileData["userid"]))
                .Replace("<ERROR>", error != null ? Core.templates[pageElements["TEMPLATE"]]["error"].Replace("<ERROR>", HttpUtility.HtmlEncode(error)) : updatedProfile ? Core.templates[pageElements["TEMPLATE"]]["success"].Replace("<SUCCESS>", "Successfully updated profile settings!") : string.Empty)
                .Replace("<ENABLED>", profileEnabledItems.ToString())
                .Replace("<FRAME_BG_URL>", HttpUtility.HtmlEncode(profileData["background_url"]))
                .Replace("<FRAME_BG_COLOUR>", HttpUtility.HtmlEncode(profileData["background_colour"]))
                .Replace("<PANE_BG_COLOUR>", HttpUtility.HtmlEncode(profileData["colour_background"]))
                .Replace("<PANE_TEXT_COLOUR>", HttpUtility.HtmlEncode(profileData["colour_text"]))
                .Replace("<NUTSHELL>", HttpUtility.HtmlEncode(profileData["nutshell"]))
                .Replace("<COUNTRY>", countryItems.ToString())
                .Replace("<GENDER>", genderItems.ToString())
                .Replace("<OCCUPATION>", HttpUtility.HtmlEncode(profileData["occupation"]))
                .Replace("<CONTACT_GITHUB>", HttpUtility.HtmlEncode(profileData["contact_github"]))
                .Replace("<CONTACT_WEBSITE>", HttpUtility.HtmlEncode(profileData["contact_website"]))
                .Replace("<CONTACT_EMAIL>", HttpUtility.HtmlEncode(profileData["contact_email"]))
                .Replace("<CONTACT_FACEBOOK>", HttpUtility.HtmlEncode(profileData["contact_facebook"]))
                .Replace("<CONTACT_GOOGLEPLUS>", HttpUtility.HtmlEncode(profileData["contact_googleplus"]))
                .Replace("<CONTACT_REDDIT>", HttpUtility.HtmlEncode(profileData["contact_reddit"]))
                .Replace("<CONTACT_STEAM>", HttpUtility.HtmlEncode(profileData["contact_steam"]))
                .Replace("<CONTACT_WLM>", HttpUtility.HtmlEncode(profileData["contact_wlm"]))
                .Replace("<CONTACT_SKYPE>", HttpUtility.HtmlEncode(profileData["contact_skype"]))
                .Replace("<CONTACT_YOUTUBE>", HttpUtility.HtmlEncode(profileData["contact_youtube"]))
                .Replace("<CONTACT_SOUNDCLOUD>", HttpUtility.HtmlEncode(profileData["contact_soundcloud"]))
                .Replace("<CONTACT_XBOX>", HttpUtility.HtmlEncode(profileData["contact_xbox"]))
                .Replace("<CONTACT_PSN>", HttpUtility.HtmlEncode(profileData["contact_psn"]))
                .Replace("<CONTACT_FLICKR>", HttpUtility.HtmlEncode(profileData["contact_flickr"]))
                .Replace("<CONTACT_TWITTER>", HttpUtility.HtmlEncode(profileData["contact_twitter"]))
                .Replace("<CONTACT_XFIRE>", HttpUtility.HtmlEncode(profileData["contact_xfire"]))
                .Replace("<CONTACT_DEVIANTART>", HttpUtility.HtmlEncode(profileData["contact_deviantart"]))
                ;
            pageElements.setFlag("PROFILE_SETTINGS");
        }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:101,代码来源:Base.cs

示例7: handleRequest

 public static void handleRequest(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     // Add headers - CSS and JS
     if (pageElements["HEADER"] == null) pageElements["HEADER"] = string.Empty;
     pageElements["HEADER"] += "<link href=\"" + pageElements["URL"] + "/Content/CSS/CC128.css\" type=\"text/css\" rel=\"Stylesheet\" />";
     pageElements["HEADER"] += "<script src=\"" + pageElements["URL"] + "/Content/JS/CC128.js\"></script>";
     // Determine which page the user wants
     string subPage = request.QueryString["1"];
     if (subPage != null && subPage == "history")
         pageHistory(pluginid, conn, ref pageElements, request, response);
     else if (subPage == "ajax")
     {
         // Write the last watt reading
         ResultRow lastReading = conn.Query_Read("SELECT (SELECT watts FROM cc128_readings WHERE datetime >= DATE_SUB(NOW(), INTERVAL 24 HOUR) ORDER BY datetime DESC LIMIT 1) AS last_reading, (SELECT MAX(watts) FROM cc128_readings WHERE datetime >= DATE_SUB(NOW(), INTERVAL 24 HOUR)) AS max_watts")[0];
         response.ContentType = "text/xml";
         response.Write("<d><w>" + lastReading["last_reading"] + "</w><m>" + lastReading["max_watts"] + "</m></d>");
         conn.Disconnect();
         response.End();
     }
     else
         pagePower(pluginid, conn, ref pageElements, request, response);
     // Set the base content
     pageElements["TITLE"] = "CC128 Energy Monitor - <!--CC128_TITLE-->";
     pageElements["CONTENT"] = Core.templates["cc128"]["base"];
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:25,代码来源:Base.cs

示例8: pageHome

 public static void pageHome(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     pageElements["TITLE"] = "Developers - Package Automator";
     StringBuilder plugins = new StringBuilder();
     foreach (ResultRow plugin in conn.Query_Read("SELECT title, pluginid FROM plugins ORDER BY title ASC"))
     {
         plugins.Append(
             Core.templates["devpackage"]["home_plugin"]
             .Replace("%PLUGINID%", HttpUtility.HtmlEncode(plugin["pluginid"]))
             .Replace("%TITLE%", HttpUtility.HtmlEncode(plugin["title"]))
             );
     }
     pageElements["CONTENT"] = Core.templates["devpackage"]["home"].Replace("%PLUGINS%", plugins.ToString());
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:14,代码来源:DevPackage.cs

示例9: pageProfileImage

 public static void pageProfileImage(string pluginid, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     response.ContentType = "image/jpeg";
     // Cache the unknown image - spam/bot or failed responses will be a lot easier on the web server in terms of I/O
     if (pageProfileImage_CachedUnknown == null)
     {
         Image unknownImage = Image.FromFile(Core.basePath + "\\Content\\Images\\bsa_profiles\\unknown.jpg");
         MemoryStream ms = new MemoryStream();
         unknownImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
         pageProfileImage_CachedUnknown = ms.ToArray();
         ms.Dispose();
         ms = null;
         unknownImage.Dispose();
         unknownImage = null;
     }
     // Check if a userid was specified, if so we'll try to get the actual image and output it
     string userid = request.QueryString["1"];
     if (userid != null && userid.Length > 0)
     {
         Result filename = conn.Query_Read("SELECT profile_picture FROM bsa_profiles WHERE userid='" + Utils.Escape(userid) + "'");
         if (filename.Rows.Count == 1 && filename[0].ColumnsByteArray != null)
         {
             try
             {
                 response.BinaryWrite(filename[0].GetByteArray("profile_picture"));
                 conn.Disconnect();
                 response.End();
                 return;
             }
             catch
             {
             }
         }
     }
     // The response has not ended, write the unknown image
     response.BinaryWrite(pageProfileImage_CachedUnknown);
     conn.Disconnect();
     response.End();
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:39,代码来源:Base.cs

示例10: pageEmailQueue

 public static void pageEmailQueue(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     // Check for e-mail deletion
     string deleteEmailID = request.QueryString["delete"];
     if (deleteEmailID != null)
     {
         conn.Query_Execute("DELETE FROM email_queue WHERE emailid='" + Utils.Escape(deleteEmailID) + "'");
         conn.Disconnect();
         response.Redirect(pageElements["ADMIN_URL"], true);
     }
     // Grab statistics about the number of e-mails pending
     ResultRow queueStats = conn.Query_Read("SELECT (SELECT COUNT('') FROM email_queue) AS count, (SELECT COUNT(DISTINCT email) FROM email_queue) AS unique_count")[0];
     // Generate a list of pending e-mails at the top of the queue
     StringBuilder pending = new StringBuilder();
     foreach (ResultRow email in conn.Query_Read("SELECT * FROM email_queue ORDER BY emailid ASC LIMIT 10"))
         pending.Append(
             Core.templates["admin_panel"]["emailqueue_item"]
             .Replace("%EMAILID%", HttpUtility.HtmlEncode(email["emailid"]))
             .Replace("%EMAIL%", HttpUtility.HtmlEncode(email["email"]))
             .Replace("%SUBJECT%", HttpUtility.HtmlEncode(email["subject"]))
             );
     if (pending.Length == 0) pending.Append("No e-mails in the queue!");
     // Display page
     pageElements["ADMIN_CONTENT"] =
         Core.templates["admin_panel"]["emailqueue"]
         .Replace("%COUNT%", HttpUtility.HtmlEncode(queueStats["count"]))
         .Replace("%UNIQUE_COUNT%", HttpUtility.HtmlEncode(queueStats["unique_count"]))
         .Replace("%ERRORS%", HttpUtility.HtmlEncode(Core.emailQueue.mailErrors.ToString()))
         .Replace("%THREAD_STATUS%", HttpUtility.HtmlEncode(Core.emailQueue.cyclerThread != null ? Core.emailQueue.cyclerThread.ThreadState.ToString() : "Not operational - critical failure or undefined mail settings."))
         .Replace("%EMAILS%", pending.ToString())
         ;
     pageElements["ADMIN_TITLE"] = "Core - E-mail Queue";
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:33,代码来源:Base.cs

示例11: pageSettings

 public static void pageSettings(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     string error = null;
     bool successfullyUpdated = false;
     // Check if the user has requested to delete a setting
     string deleteCategory = request.QueryString["delete_category"];
     string deleteKey = request.QueryString["delete_key"];
     if (deleteCategory != null && deleteKey != null)
     {
         conn.Query_Execute("DELETE FROM settings WHERE category='" + Utils.Escape(deleteCategory) + "' AND keyname='" + Utils.Escape(deleteKey) + "'");
         response.Redirect(pageElements["ADMIN_URL"]);
     }
     // Check if the user has posted updated settings
     Dictionary<string[], string> updatedSettings = new Dictionary<string[], string>();
     string category, key, value;
     string[] rawKey;
     for (int i = 0; i < request.Form.Count; i++)
     {
         rawKey = request.Form.Keys[i].Split('$');
         value = request.Form[i];
         if (rawKey.Length == 2 && rawKey[0].StartsWith("setting_") && rawKey[0].Length > 10 && validateAlphaNumericUnderscroll(key = rawKey[0].Substring(8)))
             updatedSettings.Add(new string[] { key, rawKey[1] }, value);
     }
     if (updatedSettings.Count > 0)
     {
         StringBuilder updateQuery = new StringBuilder();
         foreach (KeyValuePair<string[], string> setting in updatedSettings)
             updateQuery.Append("UPDATE settings SET value='" + Utils.Escape(setting.Value) + "' WHERE category='" + Utils.Escape(setting.Key[0]) + "' AND keyname='" + Utils.Escape(setting.Key[1]) + "';");
         try
         {
             conn.Query_Execute(updateQuery.ToString());
             successfullyUpdated = true;
             // Reload settings
             Core.settings.reload(conn);
         }
         catch (Exception ex)
         {
             error = "Failed to update settings - " + ex.Message + "!";
         }
     }
     // Display the settings
     StringBuilder settingItems = new StringBuilder();
     category = null;
     foreach (ResultRow setting in conn.Query_Read("SELECT category, keyname, value, description FROM settings ORDER BY category ASC, keyname ASC"))
     {
         if (setting["category"] != category)
         {
             category = setting["category"];
             settingItems.Append(
                 Core.templates["admin_panel"]["settings_category"]
                 .Replace("%CATEGORY%", HttpUtility.HtmlEncode(category))
                 );
         }
         settingItems.Append(
             Core.templates["admin_panel"]["settings_item"]
             .Replace("%KEYNAME%", HttpUtility.HtmlEncode(setting["keyname"]))
             .Replace("%KEYNAME_URL%", HttpUtility.UrlEncode(setting["keyname"]))
             .Replace("%CATEGORY%", HttpUtility.HtmlEncode(setting["category"]))
             .Replace("%CATEGORY_URL%", HttpUtility.UrlEncode(setting["category"]))
             .Replace("%VALUE%", HttpUtility.HtmlEncode(request.Form["setting_" + setting["keyname"]] ?? setting["value"]))
             .Replace("%DESCRIPTION%", HttpUtility.HtmlEncode(setting["description"]))
             );
     }
     pageElements["ADMIN_CONTENT"] =
         Core.templates["admin_panel"]["settings"]
         .Replace("%ITEMS%", settingItems.ToString())
         .Replace("%SUCCESS%", successfullyUpdated ? Core.templates[pageElements["TEMPLATE"]]["success"].Replace("<SUCCESS>", "Successfully saved settings!") : string.Empty)
         .Replace("%ERROR%", error != null ? Core.templates[pageElements["TEMPLATE"]]["error"].Replace("<ERROR>", HttpUtility.HtmlEncode(error)) : string.Empty);
     pageElements["ADMIN_TITLE"] = "Core - Settings";
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:70,代码来源:Base.cs

示例12: pageUserGroups

 public static void pageUserGroups(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     string error = null;
     bool updatedSettings = false;
     // Check for transfer of users
     string transferGroupID = request.QueryString["transfer"];
     if (transferGroupID != null)
     {
         // -- Transfer users to another group
         // Grab the title of the origin group - this will also help to validate it exists too, else we'll 404
         Result groupOrigin = conn.Query_Read("SELECT title FROM bsa_user_groups WHERE groupid='" + Utils.Escape(transferGroupID) + "'");
         if (groupOrigin.Rows.Count != 1) return; // 404 - the group does not exist
         string newTransferGroupID = request.QueryString["transfer_b"]; // The destination group ID
         if (newTransferGroupID != null)
         {
             // Validate the group exists
             if (conn.Query_Count("SELECT COUNT('') FROM bsa_user_groups WHERE groupid='" + Utils.Escape(newTransferGroupID) + "'") != 1)
                 error = "Destination group does not exist!";
             else
             {
                 // Transfer all the users http://memegenerator.net/instance/23587059
                 conn.Query_Execute("UPDATE bsa_users SET groupid='" + Utils.Escape(newTransferGroupID) + "' WHERE groupid='" + Utils.Escape(transferGroupID) + "'");
                 conn.Disconnect();
                 response.Redirect(pageElements["ADMIN_URL"]);
             }
         }
         // Build a list of the current groups
         StringBuilder currentGroups = new StringBuilder();
         foreach (ResultRow group in conn.Query_Read("SELECT groupid, title FROM bsa_user_groups WHERE groupid != '" + Utils.Escape(transferGroupID) + "' ORDER BY title ASC"))
             currentGroups.Append("<option value=\"").Append(group["groupid"]).Append("\">").Append(group["title"]).Append("</option>");
         // Display form
         pageElements["ADMIN_CONTENT"] =
             Core.templates["basic_site_auth"]["admin_user_groupstransfer"]
             .Replace("%GROUPID%", HttpUtility.HtmlEncode(transferGroupID))
             .Replace("%TITLE%", HttpUtility.HtmlEncode(groupOrigin[0]["title"]))
             .Replace("%GROUPS%", currentGroups.ToString())
             .Replace("%ERROR%", error != null ? Core.templates[pageElements["TEMPLATE"]]["error"].Replace("<ERROR>", HttpUtility.HtmlEncode(error)) : string.Empty)
             ;
     }
     else
     {
         // -- List all user groups
         // Check for postback - delete a group
         string delete = request.QueryString["delete"];
         if (delete != null)
         {
             if (conn.Query_Count("SELECT COUNT('') FROM bsa_users WHERE groupid='" + Utils.Escape(delete) + "'") > 0)
                 error = "Cannot delete group - the group contains users, transfer them to another group first!";
             else
             {
                 conn.Query_Execute("DELETE FROM bsa_user_groups WHERE groupid='" + Utils.Escape(delete) + "'");
                 conn.Disconnect();
                 response.Redirect(pageElements["ADMIN_URL"], true);
             }
         }
         // Check for postback - added group
         string groupAddTitle = request.Form["group_add_title"];
         if (groupAddTitle != null)
         {
             if (groupAddTitle.Length < Plugins.BasicSiteAuth.USER_GROUP_TITLE_MIN || groupAddTitle.Length > Plugins.BasicSiteAuth.USER_GROUP_TITLE_MAX)
                 error = "Group title must be between " + Plugins.BasicSiteAuth.USER_GROUP_TITLE_MIN + " to " + Plugins.BasicSiteAuth.USER_GROUP_TITLE_MAX + " characters in length!";
             else
                 conn.Query_Execute("INSERT INTO bsa_user_groups (title) VALUES('" + Utils.Escape(groupAddTitle) + "')");
         }
         // Grab the current permissions
         const string dbPermissionsQuery = "SELECT * FROM bsa_user_groups ORDER BY title ASC";
         Result dbPermissions = conn.Query_Read(dbPermissionsQuery);
         // Check for postback - permissions
         string groupid, column, value;
         string[] parts;
         Dictionary<string, Dictionary<string, string>> groupRowsUpdate = new Dictionary<string, Dictionary<string, string>>();
         for (int i = 0; i < request.Form.Count; i++)
         {
             parts = request.Form.Keys[i].Split('$');
             if (parts.Length == 2 && parts[0].StartsWith("group_"))
             {
                 groupid = parts[0].Substring(6);
                 column = parts[1];
                 value = request.Form[i];
                 if (!groupRowsUpdate.ContainsKey(groupid))
                     groupRowsUpdate.Add(groupid, new Dictionary<string, string>());
                 groupRowsUpdate[groupid].Add(column, value);
             }
         }
         if (groupRowsUpdate.Count > 0)
         {
             // Postback made - generate query by going through each permissions row and checking for a state (or lack of state) change
             StringBuilder queries = new StringBuilder();
             StringBuilder query;
             const string queryStart = "UPDATE bsa_user_groups SET ";
             string currGroupId;
             foreach (ResultRow dbPermissionsRow in dbPermissions)
             {
                 currGroupId = dbPermissionsRow["groupid"];
                 // Check if this group has been updated at all
                 if (groupRowsUpdate.ContainsKey(currGroupId))
                 {
                     query = new StringBuilder(queryStart);
                     foreach (KeyValuePair<string, object> groupColumn in dbPermissionsRow.Columns)
                     {
//.........这里部分代码省略.........
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:101,代码来源:BasicSiteAuth.cs

示例13: pageUserLogs

 public static void pageUserLogs(Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     string error = null;
     // Check if a username has been posted
     string username = request.Form["log_username"];
     if (username != null)
     {
         if (username.Length < Plugins.BasicSiteAuth.USERNAME_MIN || username.Length > Plugins.BasicSiteAuth.USERNAME_MAX || Plugins.BasicSiteAuth.validUsernameChars(username) != null)
             error = "Invalid username!";
         else
         {
             // Fetch the userid
             Result userid = conn.Query_Read("SELECT userid FROM bsa_users WHERE username LIKE '" + Utils.Escape(username.Replace("%", "")) + "'");
             if (userid.Rows.Count != 1) error = "User not found!";
             else
             {
                 conn.Disconnect();
                 response.Redirect(pageElements["URL"] + "/log/" + userid[0]["userid"], true);
             }
         }
     }
     // Display form
     pageElements["ADMIN_TITLE"] = "Authentication - User Logs";
     pageElements["ADMIN_CONTENT"] = Core.templates["basic_site_auth"]["admin_user_logs"]
         .Replace("%ERROR%", error != null ? Core.templates[pageElements["TEMPLATE"]]["error"].Replace("<ERROR>", HttpUtility.HtmlEncode(error)) : string.Empty)
         .Replace("%USERNAME%", username ?? string.Empty);
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:27,代码来源:BasicSiteAuth.cs

示例14: getRequestPlugin

 /// <summary>
 /// Returns the classpath of the plugin responsible for the passed request.
 /// 
 /// If a 404 occurs, this method will return a method able to handle the error;
 /// if no plugin is able to handle a 404, the returned collection will be empty.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public static RequestHandlers getRequestPlugin(Connector conn, HttpRequest request)
 {
     // If no page is provided, we'll check for a default page in the setting, else we'll just use home
     string page = request.QueryString["page"] ?? (Core.settings.contains("core", "default_page") ? Core.settings["core"]["default_page"] : "home");
     RequestHandlers handlers = new RequestHandlers();
     foreach (ResultRow handler in conn.Query_Read("SELECT p.pluginid, p.classpath FROM urlrewriting AS u LEFT OUTER JOIN plugins AS p ON p.pluginid=u.pluginid WHERE u.parent IS NULL AND u.title LIKE '" + Utils.Escape(page.Replace("%", "")) + "' AND p.state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' ORDER BY p.invoke_order ASC LIMIT 1"))
         handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
     return handlers;
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:17,代码来源:Plugins.cs

示例15: getRequest404s

 /// <summary>
 /// Returns the class-path for the 404 pages in their invoke order ascending.
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 public static RequestHandlers getRequest404s(Connector conn)
 {
     RequestHandlers handlers = new RequestHandlers();
     foreach (ResultRow handler in conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_404='1' ORDER BY invoke_order ASC"))
         handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
     return handlers;
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:12,代码来源:Plugins.cs


注:本文中的Connector.Query_Read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。