Thursday, September 13, 2012

My answer to "Updating LampCMS"

This is my answer to a Question on Support site for LampCMS project


It's not automatic. The easiest way is to start using the phar based installation.
With phar based installation you get one lampcms.phar file and also contents on the www directory which includes all templates and also a config directory with config files.

In 90% of updates changes are made only to the library classes and not to templates. Since all libraries are included in the lampcms.phar you will only need to replace the lampcms.phar with the new file. Also you will have to upload the new minified javascript file because every update to .phar file has slightly different version number and program will look for minified javascript that matches that version.

If you write custom plugins to Lampcms you don't have to worry about overriding them because plugins are stored in the config/plugins directory.

Tuesday, January 24, 2012

My answer to "Change Password Encryption"

This is my answer to a Question on Support site for LampCMS project


OK, so you want to be able to use already encrypted passwords?
Then you can just use the same hashing as was used on SMF.

I mean, you can just use md5(username.password), it will work. It's usually a good idea to add salt to hashing but if you absolutely must be sure that existing users can login without any problems you may keep using the old hashing technique. It's still OK.

md5($string); is the same as hash('md5', $string);
the reason I use the second option is because in older version of php the hash('md5', $string) was faster than md5($string). I think there is no speed difference in the latest version of php, I just use it as a habit.

I am not sure what the data.username does? First of all what is data? This is php you know, it needs at least a dollar sign in front of variable. There is no dot notation in php also.

As for returning blank page, I am not sure why. If you enable debugging and have enabled logging, then you can look in the log file. You can quickly add anything to a log by just using the "d" function, like this:

d("log this line with this $variable");

It will automatically add a file name and line number where you added this line.

Saturday, May 7, 2011

My answer to "Added Sticky thread feature"

This is my answer to a Question on Support site for LampCMS project


Just a
test answer

Tumblr support added

My Question on Support site for LampCMS project

This is a text post rrrr
f to test blogger API

Click here to post your reply


Tumblr support added

My question on Support site for LampCMS project

This is a text post
f to test blogger API

Click here to post your reply


Tuesday, December 7, 2010

Per user tags and recent tags display

TODO: need per-user tags table
that will have uid -> array tag => count
update on every question user posts

===============================

How to find all questions AND answers per user per tag?

If we have tags in answers then it's easy just search for tag $in + $uid
then the same in QUESTIONS

So we really must have tags in ANSWERS!

===================================

Every time a user posts an answer we must also update PER_USER_TAGS collection

=====================================

It would be cool to have PER_USER_VIEWS table

question_id, uid, hts (i_ts not necessary because we can just sort by _id)

Can also collect "interesting tags" based on user views, questions, answers!

======================

Handling "save draft": best is to save draft into USER object under 'q_draft' as array
of title, body, tags

And for answer is a_draft and alo draft_c for comment!

Then after submit answer/question/comment but delete the value from user object

====================================

TODO: when showing "recent tags" Stack does sneaky thing:
it ALWAYS show "YOUR INTERESTING" tags first, even if they are not most recent
and THEN append block with recent tags.

In order to do this we cannot cache recent tags, actually we can for guests
and those who does not yet have "interesting tags"

Then we do 2 selects from RECENT_TAGS: first one with $in => "Interesting tags"
and the second one we get the usual 'recent tags' but remove "my tags" from result
OR specifically in find() pass $not and specify array of "interesting" tags.

It's probably easier to do the usual select, then array_diff
and then append one array to another or merge then so that "MY TAGS" are
always on top!

It actually goes one step beyond this: it also uses per-user tags stats, looks like it
picks some tags from there as well.

So 3 arrays: "My tags", "My stats tags" and "recent tags"
then filters out duplicates and uses them in order of "My tags", "Stat tags", "Recent tags"

Also, how are recent tags updated? Does the new answer trigger update or only new question?
In other words, recent activity for the tag, meaning answer/question/edit/comment (maybe?)
OR just new question?

==========================================

Monday, December 6, 2010

Processing of question

Handling Processing of QForm

Title, body, tags run through utf-8 string first

Run title, tags, body through htmlspecialchars or htmlentities()
or even through string_tags!

In the future if we allow tags then...we will run through safe_html instead!

Make intro
Parse markdown
store [html], [plain]
or just body?

We need something like messageAdapter that will accept
submittedQuestion object

SubmittedQuestion will have:
getBody (UTF8 object is fine, it's even better because we will be able to get num-lines, num-words)
getTitle Utf8String
getTags array
getUser <- UserObject
getIP string

////

tokenize title

record:
PER_USER_TAGS
TITLE_TAGS
QUESTION_TAGS
USER_STATS... not sure what it is but we need to update count_questions of user, right?
Ideally this will be in mongo USER collection
We can have separate collection USER_STATS, it's fine and it's small...


We can also keep reputation there? Maybe but it's really inconvenient because we
need reputation in clsUserObject of oViewer.


Also... we still want similar elist items!

We also want a way to get similar questions (later)
Also need a way to check for duplicate using q_hash uid + body

Need a way to test for floodcheck per uid, per ip

so we need a flood check class that would act as a filter via observer?

It's cool

The similar creation should be done as post-echo call.
also some emailing to subscribers will be done via post-echo thingy

///

Need a way to validate and set form errors.
validate title, validateBody, validateTags

If there are errors in validation we will return the same form.

Otherwise do redirect via meta tag with 2 seconds delay
How to do meta redirect? Basically we need to still show result page
with link to view new question and will say 'you will be redirected in 3 seconds"