rejetto forum
May 25, 2012, 10:40:57 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: cookie and new files  (Read 501 times)
0 Members and 2 Guests are viewing this topic.
pstar
Occasional poster
*
Offline Offline

Posts: 4


View Profile
« on: November 08, 2009, 12:06:33 AM »

i'm new to hfs and here is my 2nd question:
could i use cookie to remember how many new files have been uploaded since my last logon?
now what i see from hfs is the function which can set a timer to mark the new files.
but it cant meet my condition.

thx in advance!
Logged
bacter
Operator
Insane poster
*****
Offline Offline

Spain Spain

Posts: 679


View Profile
« Reply #1 on: November 08, 2009, 03:32:50 AM »

welcome pstar!

Your question is not clear.

1) Cookies are used to store data of ONE user. This means, you could store in each users pc a cookie with the number he uploaded.

2) If i understand the question in the manner, that you login as the boss and want to control how many uploads where done by all users since your las login, then you should not use a cookie, but a counter in s static variable ( #upload_cnt) that will increment with each upload completed, or add for example the filename and user to a list. Then every time you login, you can look at his counter and list and then clear it.

Logged

your computer has no brain - use your own !
pstar
Occasional poster
*
Offline Offline

Posts: 4


View Profile
« Reply #2 on: November 08, 2009, 10:37:27 PM »

thx bacter for  your reply.
what i need is something more like your condition 2.
i'm the admin and i wanna know how many new files have been uploaded to some folders every my logon.
the case is not only one folder.
it's also for time saving, if i find no updating to some folders, i dont have to check it by click the folder's name and to see its sub files.

but, could you give me more info on the static variable?
can the variable keep an eye on a special folder and all its sub-folers for file uploading?

thanks, again!
Logged
bacter
Operator
Insane poster
*****
Offline Offline

Spain Spain

Posts: 679


View Profile
« Reply #3 on: November 09, 2009, 06:51:50 AM »

Hi pstar

here goes one possible solution for your needs. It uses a counter that says how many files were uploaded since last reset, and creates a file you can load to see all new uploads.

1. Include this at the beginning of the [uppload-sucess] section:
Code:
{.inc|#uploadcnt.}
{.append|newuploads.htm|<tr><td>
   <a href ="%folder%{.filename|%item-resource%.}">{.filename|%item-resource%.}</a>
   </td><td>{.if|%user%|%user%|%ip%.}</td><td>%timestamp%</td></tr>.}

2.Add this two new sections somewhere in your template:
Code:
[uploadctrlclear]
{.if|{.=|%user%|admin.}|
{:{.save|newuploads.htm|.}{.set|#uploadcnt|0.}{.$upload-adm.}:}.}

[upload-adm]
{.if|{.=|%user%|admin.}|
{:
<html><head />
<body>
{.if |{.^#uploadcnt.}|
{:
Uploads since last reset: {.^#uploadcnt.}
<table>
<tr><th>Filename</th><th>Uploaded by</th><th>date</th></tr>
{.load|newuploads.htm.}
</table>
<a href="/" style="background-color:darkblue;color:white;">&nbsp;continue&nbsp;</a>{.repeat|4|&nbsp;.}
<a href="~uploadctrlclear" style="background-color:darkblue;color:white;">&nbsp;clear&nbsp; </a>
:}|
{: No new uploads available
<a href="/" style="background-color:darkblue;color:white;">&nbsp;continue&nbsp;</a
:}
.}
</body></html>
:}.}

3. You can then put somwhere in your page a link that is only visible tu you (supposed you are the user 'admin') or invoke that page when you are in root adding ~upload-adm to your url (example: http://localhost/~upload-adm)

In this admin page, once you have seen what you want, you push the clear button and the list will be cleared and the counter reset.

This works as long as your server is not shut down, as then #uploadcnt will be lost. If you need it, you can also save your counter in a file, instead of using a #static variable.


Follow members gave a thank to your post:

pstar

For this post, 1 member gave a thank you!
« Last Edit: November 09, 2009, 07:29:30 AM by bacter » Logged

your computer has no brain - use your own !
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11830


View Profile
« Reply #4 on: November 14, 2009, 10:55:29 AM »

Very nice job Bacter,
And you are doing it for the good of people, not for you. Very noble.

To go a step further, i think we can pack such solution in a handier way.

1.
instead of suggesting to append the text to an existing section, you can ask to append this whole text at the end of the template

Code:
[+upload-success]
...here goes the rest...

so that appending needs less care by the user.

But even more! you should rely on event scripts, since they would not be overwritten in case the user change template for a matter of pure style Wink
So, it would go for  [+upload completed] in Events file.

2.
i think another good point would be to put the rest of your script inside the diff template of a virtual folder named "upload-adm"
this always to avoid overwritings of the template.


I think we should go in a way to make autoinstalling plugins, like for the solution you made. To make it easy to install, similar to the installing procedures we already have for the templates.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 15, 2012, 12:17:19 AM
anything