Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Jan. 2009
In Community Server, dynamic user fields are saved in extended properties. In order to retrieve them in Sql add the following function:
/*------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
------------------------------------------------------------------------------*/
CREATE function [dbo].[FetchExtendendAttributeValue] (
@Key nvarchar(4000),
@Keys nvarchar(4000),
@Values nvarchar(4000)
)
/*
CS uses ExtendedAttributes to allow metadata about a post, user, or section to be stored
in a special ':' delimited format. This enables storing metadata without adding new columns
to any tables, changing sprocs, etc.
However, any data stored in this format is not easily queryable (so use it wisely :)
Occassionaly, you may want to query against this data. This function should make that task simple!
Keys are stored in this format: string:S:Int:Int = Key + :S : Starting Location : Length :
An example: 'Theme:S:0:7:dummyTotalPosts:S:7:1:BannedUntil:S:8:21:UserBanReason:S:29:5:'
Values are stored in a single string with no spaces between them.
An example: 'default04/20/2005 12:16:41 AMOther'
Theme starts a 0 and continues for 7 characters (default)
dummyTotalPosts starts at 7 and coninutes for 1 character (0)
BannedUntil starts at 8 and continues for 21 characters (4/20/2005 12:16:41 AM)
*/
RETURNS nvarchar(4000)
AS
BEGIN
DECLARE @Value nvarchar(4000)
Declare @CharIndex int
Declare @StartIndex int
Declare @Len int
--Find the index of the key
Set @CharIndex = CHARINDEX(@Key + ':s',@Keys)
--If the key does not exist, return NULL
if(@CharIndex = 0)
RETURN NULL
--If the key is not the first, remove any leading keys
if(@CharIndex > 1)
Begin
Set @Keys = Stuff(@Keys,1,@CharIndex-1,'')
End
--Remove the Key from the keys list. This will
Set @Keys = Stuff(@Keys,1,Len(@Key+':S:'),'')
--Find the location of the : after the starting location
Set @CharIndex = CHARINDEX(':',@Keys)
--Grab the starting location
Set @StartIndex = SUBSTRING(@Keys,1,@CharIndex-1)
--Remove the starting location from the Keys
Set @Keys = Stuff(@Keys,1,@CharIndex,'')
--Find the lenght value's index
Set @CharIndex = CHARINDEX(':',@Keys)
--Find the lenghth value
Set @Len = SUBSTRING(@Keys,1,@CharIndex-1)
--Get the value from the values string
Set @Value = SUBSTRING(@Values,@StartIndex+1,@Len)
RETURN @Value
END
Source: http://code.communityserver.org...
Posted by Anders Vindberg
in Lunarmedia Blog
on the 16 Jan. 2009
Today I was reminded of a wonderful CSControl that will allow a textbox to initiate a submit button (when pressing enter). Using the:
<CSControl:DefaultButtonTextBox ID="..." ButtonId="SubscriptionEmailButton" runat="server" />
you define the buttonId of the submit button.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 12 Nov. 2008
Removing all SVN files from a specific folder can easily be done from within Explore. Simply run this registry file: Remove All SVN Files. It will enable a new option "Delete SVN Folders" when you right-click on a folder in Explorer.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 04 Oct. 2008
Here are some valuable information about integrating with Paypal found in the support forum (thanks to PayPal_HarryX):
There are several ways PayPal returns payment data to you after
the payment is completed. You get to choose how you get the data back.
But you have to use the correct technology for your choice. I see some
confusion about the ways you receive and process data from PayPal.
Often times the technology is mismatched with the settings you made and
you get unexpected results. I hope this article will help clear things
up.
Option 1: POST to Return Page
How does it work?
- After finishing the payment on PayPal, the customer clicks on a button.
- PayPal posts payment data to your URL in a HTML form.
- You post a form (format is described in the IPN section below) to
PayPal. PayPal responds with a single word VERIFIED or INVALID.
- If you receive VERIFIED, you can be confident that the form you
received came from PayPal and wasn't tampered with. Do whatever you
need to do with the form data.
Settings:
- specify a return url in the return variable in your html form. The return url must be an absolute url.Code:
<input type="hidden" name="return" value="your_url_here">
- set the rm variable to 2. Code:
<input type="hidden" name="rm" value="2">
- Auto Return = Disabled in account profile (if Auto Return = Enabled, you won't get any data)
- PDT = Disabled in account profile
- IPN = Disabled in account profile
I don't recommend this as a
stand-alone solution because you can't guarantee that the customer will
click on that button. Many customers simply close their browser or
navigate away because they are done with their payment.
Option 2: Payment Data Transfer (PDT)
How does it work?
- After finishing the payment on PayPal, the customer is automatically redirected to your page.
- PayPal sends a GET request to your page. If your URL contains a query string, PayPal will append parameters to the URL. For example: Code:
http://yoursite/yourpage?yourparam=yourvalue&tx=3KK900354R868601V&......
- You post a form to PayPal with cmd=_notify-synch, the tx token you received in the query string and the identity token in your account profile when you turned on PDT.Code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="POST">
<input type="hidden" name="cmd" value="_notify-synch">
<input type="hidden" name="tx" value="3KK900354R868601V">
<input type="hidden" name="at" value="lpeb7DhJWXz5BU43tiarWlo42x5g-Nvv0oJCORuEVsmY9JiRuVUDW2jAHUI">
</form>
- PayPal responds with a block of text with SUCCESS or FAIL on the top. If it's SUCCESS, name value pairs on separate lines follow the SUCCESS line.
- If the response has SUCCESS on the top, you read the rest of the lines from the response.
Settings:
- specify an url for PDT in your account profile or in the return variable in your html form. The url must be an absolute url.Code:
<input type="hidden" name="return" value="your_pdt_url_here">
- Auto Return = Enabled in account profile
- PDT = Enabled in account profile
- IPN = Disabled in account profile
Sample script: http://paypaltech.com/PDTGen/
More info: https://www.paypal.com/IntegrationCenter/ic_pdt.html
This approach is better than Option 1 but there still may be breakage
from the auto redirect after the payment is done. For example the
customer could close the browser or navigate away before redirect is
completed. If the redirect breaks, you won't know about the payment. It
is possible for the customer to refresh the page. So if you are
inserting records to a database, you must check for duplicates. Don't
count on the PDT url being called only once. Use PDT if you must know immediately
whether the payment went through, while the customer is still on your
site, for example for providing immediate access to digital downloads.
If you are shipping physical goods, you can wait for the IPN (see
Option 3 below). Because PDT is a front end technology, you will only
get data for the initial payment. You won't get data on eCheck
clearance and other events. If you want to get notified
programmatically about those events, you will still have to do IPN.
Option 3: Instant Payment Notification (IPN)
How does it work?
- After finishing the payment on PayPal, the customer is auto-redirected to your page ("return" variable)
- Customer returns to your page. PayPal does NOT send any payment data there.
- Separately in the background, you receive a form POST from PayPal at a different URL (notify_url variable).
- You post back a form with cmd=_notify-validate and all fields you received from PayPal. PayPal responds with a single word VERIFIED or INVALID
- If you receive VERIFIED, you can be confident that the form you
received came from PayPal and wasn't tampered with. Do whatever you
need to do with the form fields.
Settings:
- Specify an auto return url in your profile or in the return
variable in your html form. The url must be an absolute url. This is
just a generic page with no PayPal processing logic. Display something
like "Thank you and your order will be processed shortly." Code:
<input type="hidden" name="return" value="your_return_url_here">
- Specify an IPN url in your profile or in the notify_url
variable in your html form. This is where you process payment data from
PayPal. The IPN url must be an absolute url. It must also allow
anonymous access from outside of your network. If you must open your
firewall to a specific host, please note the Sandbox sends IPNs from
ipn.sandbox.paypal.com. PayPal live site sends IPNs from
notify.paypal.com. Code:
<input type="hidden" name="notify_url" value="your_ipn_url_here">
- Auto Return = Enabled in account profile
- PDT = Disabled in account profile
- IPN = Enabled in account profile
Sample script: http://paypaltech.com/SG2/
Test your IPN listener: http://paypaltech.com/Stephen/test/ipntest3.htm
More info: https://www.paypal.com/IntegrationCenter/ic_ipn.html
I recommend this approach over the 2 options
above because there is less chance for breakage. It's independent of
the customer's action. If the customer closes the browser or navigates
away, you will still receive notifications from PayPal at your
notify_url. IPN also has built-in retry mechanism. If there's a problem
reaching your notify_url, PayPal will re-try for several days. With
either of the 2 options above, you only have one shot at getting the
payment data.
Option 4: PDT + IPN
This is a belt and suspenders strategy. You use PDT to get most of
your data but use IPN as a backup to catch the redirect breakage and
for receiving other event notifications. For each IPN you receive, you
will first check to see if you already got it from PDT.
Settings:
- Specify a return url in your account profile or in the return variable in your html form. The script there processes the GET request from PayPal as described under PDT above.Code:
<input type="hidden" name="return" value="your_pdt_url_here">
- Also specify an IPN url in your profile or in the notify_url
variable in your html form. This script processes the POST data from
PayPal as descirbed under IPN above. Note the data you received may
have already been processed by PDT. Code:
<input type="hidden" name="notify_url" value="your_ipn_url_here">
- Auto Return = Enabled in account profile
- PDT = Enabled in account profile
- IPN = Enabled in account profile
I also recommend this approach if you are able to deal with the duplicates coming from different channels. You get the best of both worlds.
Where are the Profile settings for all these?
- Auto Return and default return URL are in Profile -> Website Payment Preferences
- PDT and your Identity Token (at variable) are in Profile -> Website Payment Preferences
- IPN and the default notify_url are in Profile -> Instant Payment Notification Preferences
I welcome your questions, comments and corrections however please do
not post questions or problems specific to your scripts. You should be
able to resolve most of the problems by double checking what you have
against the approaches outlined above. If not, please create a separate
thread for your specific problem. Thank you.
Message Edited by PayPal_HarryX on 08-12-2006 08:05 PM
Posted by Anders Vindberg
in Lunarmedia Blog
on the 30 Sep. 2008
Scenario: Two websites (a main and a subdomain) are running on the same IIS but different app pools. CommunityServer is on a subdomain, eg. forum.lunarmedia.com, and is used as the primary membership provider. On the main site eg. lunarmedia.com, we want to show the logged in username etc. In order to do this we need to be sure the following are present in both web.config files.
1. In web.config add (Goto here to generate a machine key):
<system.web>
<machineKey validationKey="Your_Generated_Validation_Key_Goes_Here"
decryptionKey="Your_Generated_Decryption_Key_Goes_Here"
validation="SHA1" />
<!-- Other system.web elements -->
</system.web>
2. In web.config add a domain attribute to your <authentication mode="Forms"> node:
<authentication mode="Forms">
<forms name=".CommunityServer" domain=".lunarmedia.com" protection="All" timeout="60000" loginUrl="login.aspx" slidingExpiration="true"/>
</authentication>
3. Copy the Telligent.CommunityServer.SecurityModules.dll file to both "bin" folders of the two websites. You can get the dll from the Single Sign-on download at: get.communityserver.com
At lunarmedia.com we simply link to forum.lunarmedia.com/login.aspx, logout.aspx, etc. to take advantage of Community Server's membership flow.
P.S. the domain (lunarmedia.com) is only used as an example.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 24 Aug. 2008
When updating Community Server to the 2008 version several issues may arise. Using the accompanied Updater that Telligent has supplied helps a lot, but there are still idiosyncrasies to be aware of:
- Is your email not work? Giving an error: "Iterator Failed. Type CommunityServer.MailRoom.Components.EmailJob.
Method SendQueuedEmailJob Reason Object reference not set to an
instance of an object.. etc.". The Solution: Try and delete all waiting emails in the queue. Do a "DELETE FROM mg_EmailQueue" on the database. It seems that some "old" awaiting emails from the 2007 version was causing CS2008 email client to fail.
- The default blog theme may have reverted to CS's standard theme. Goto /controlpanel/BlogAdmin/Options/SkinOptions.aspx and change the default theme to your likings.
- Check that all custom controls are working with the new update. Some of the places that could reference a control are: the App_Browsers folder, Web.Config HttpHandlers and controls section, and CommunityServer.Config Tasks section.
- From earlier blog post about the subject: Upgrading CS2007 to CS2008 - DynamicStyle.aspx in IE6
- From earlier blog post about the subject: Upgrading CS2007 to CS2008 - Timeout expired
Good luck upgrading :)
Posted by Anders Vindberg
in Lunarmedia Blog
on the 19 Aug. 2008
When upgrading a website it is usual to setup a test site of the new version. In doing so, it is important to get all IIS settings moved aswell. When Http Compression (IIS6.0) is enabled at a website running Community Server it is crucial that you disable compression on the DynamicStyle.aspx file located in your Themes/[your theme]/style/ folder. An error in IE6 will make your website display wrongly when you click using the main navigation menu. It will only display correctly (and load the DynamicStyle.aspx file) when you do a hard ctrl+F5 refresh.
To disable HTTP compression on a single file, i've made the following simple batch file: IIS6 HTTP compression on single file.zip Remember to edit the file and change the "[Identifier number]" part to your website identifier number (can be found in IIS Manager when listing all sites).
For general information about IIS6 Compression check my earlier post: IIS6 Http Compression in four easy steps
Posted by Anders Vindberg
in Lunarmedia Blog
on the 15 Aug. 2008
If you are updating a Community Server 2007 to CS 2008 either manually or using the Updater Telligent has supplied and getting the "Timeout expired" error when posting a new topic/reply in the forums, it is most likely because the CS license hasn't been updated! A solution: be sure to check at: /controlpanel/tools/ManageLicenses.aspx and update your license with a CS2008 version.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 24 Jun. 2008
The increasingly visited website javascriptcompressor.com has been updated with the latest compression algorithm from Dean Edwards, now version 3.0. In addition, a forum for javascript discussion has been setup.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 24 Jun. 2008
The first initiative of Lunarmedia's move into the translation business is complete. Translatorbay is
online. It will feature tools and discussions relevant for translators.
It will be a supporting website of the parent site Lingbay, which is in
the first phase of development. Lingbay will be an auction house for translation jobs that freelance translators can bid on. It will be open and registration will be free.
A note on Divxstation, it has been archived due to old age. All activity has moved to Subscene.
Other news: A Graffiticms based website has been setup for a new Danish Sail Club - Sejlklubben Teglholmen. They still have available bådpladser ved Teglholmen.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 10 Jun. 2008
So today I upgraded to Firefox 3.0 RC2 - and what a wonderful idea that was. For anyone who is using Firefox 2.x and believes that it has become a bit bulky - shift to Firefox 3.0, it is fast, feels light, and rock solid!
In combination, I would also suggest that you tune in on FriskyRadio - the best technolounge in town!
Posted by Anders Vindberg
in Lunarmedia Blog
on the 27 May. 2008
I stumbled upon this great forum discussion today. It details different solutions to allowing anonymous users the option of choosing a website language - without being logged in. The best suggestion is to add new users to the Community Server database (setting "IsAnonymous" to true) one for each country, eg. AnonSpanish, AnonEnglish, etc. Then, adding the following code when the user selects a new language:
if (CSContext.Current.User.IsAnonymous)
{
HttpCookie formsAuthCookie;
if (CSContext.Current.User.Username.Equals("AnonymousSpanish"))
{
formsAuthCookie = FormsAuthentication.GetAuthCookie("Anonymous", false);
}
else
{
formsAuthCookie = FormsAuthentication.GetAuthCookie("AnonymousSpanish", false);
}
UserCookie userCookie = CSContext.Current.User.GetUserCookie();
userCookie.WriteCookie(formsAuthCookie, 365, false);
}
}
Posted by Anders Vindberg
in Lunarmedia Blog
on the 12 Feb. 2008
The first thought would be to use the CSControls:LinkData (or CSLinkData) control and specify the resourceName. The second logical solution would be using the ResourceControl defining that it should act as a link. None of this works.
The solution is to use the SiteUrl control and specify the UrlName:
<CSControl:SiteUrl UrlName="upload" Text="" runat="server" />
The example above refers to the SiteUrls/locations/location/url node in SiteUrls.Config with the name "upload".
Posted by Anders Vindberg
in Lunarmedia Blog
on the 04 Feb. 2008
Rightclick in the Scheduled Tasks area and choose "New" -> "Scheduled Task". Then in the run field add the following:
sqlcmd -S .\SQLExpress -i c:\expressmaint.sql
In the sql file you can simply write: EXEC dbname.dbo.sp_AnyStoredProcedure.
Why don't just use SqlAgent you may ask. In SqlExpress the SqlAgent has been feature cut - because express is free.
Posted by Anders Vindberg
in Lunarmedia Blog
on the 23 Jan. 2008
When using Full-Text Indexing in MS-Sql you may find that search results for "the" or "saw" doesn't return any results. To resolve the issue, go to "properties" of the Full-Text index select "Columns" and change the "Language for Word Breaker" setting to "Neutral". If "English" is selected, then common English words are not indexed.