Entries for month: October 2013

Mura CMS: Hide menus for restricted pages

ColdFusion , Railo 5 Comments »

I have just recently been playing with mura in the last 2 days which I decided to use for the new CFLIVE website.

One function I need is to have menus/pages which will only be visible to logged in users. While Mura does allow you to restrict access to pages, it still displays the menus/links and allows access to the page but gives a login prompt instead of the page content, I could not find any way to hide the menu links as well.
On the Mura forums even BlueRiver themselves have suggested the only option is to create a hard coded menu instead, which really seems like a terrible work around to me, although that reply was 5 years old, so perhaps there was no better way to do it back then.

Anyway  I found a better solution, but please be aware as I said, I have only been using Mura for 2 days, and have no more than a few hours experience with Mura code at this point, so if there is a better way of doing this, feel free to let me know.

Open the file /requirements/mura/content/contentRenderer.cfc

find the "allowlink function, around line 287 and copy this function to your site's contentRenderer.cfm
e.g.
[site root]/default/includes/contentRenderer.cfc

now simply add the <cfelseif> block below, this will stop restricted pages showing in the menu if the user is not logged in.

 




<cfif  arguments.loggedIn and (arguments.restrict)>

                        <cfif arguments.restrictgroups eq '' or listFind(session.mura.memberships,'S2IsPrivate;#application.settingsManager.getSite(variables.event.getValue('siteID')).getPrivateUserPoolID()#') or listFind(session.mura.memberships,'S2')>

                                    <cfset allowLink=True>

                            <cfelseif arguments.restrictgroups neq ''>

                                    <cfset allowLink=False>

                                    <cfloop list="#arguments.restrictgroups#" index="G">

                                        <cfif listFind(session.mura.memberships,'#G#;#application.settingsManager.getSite(variables.event.getValue('siteID')).getPublicUserPoolID()#;1')>

                                        <cfset allowLink=true>

                                        </cfif>

                                    </cfloop>

                            </cfif>

            <!--- add this bit --->            



            <cfelseif !arguments.loggedin and arguments.restrict>

                <cfset allowLink=false>

            </cfif>



Executing a web page/url from a windows scheduled task

Windows 2008 Server No Comments »

How often do you get a PHP app that requires you to setup a cron job to run some automated task each day.
This has always been a bit of a chore with windows as there is no obviousl built in method for doing this, and the common method was to use wget. Or in my case as I use ColdFusion/Railo I would setup a scheduled task in the ColdFusion/Railo admin instead.

Today I decided to find out if there was a better way to do this this since windows 2008, and discovered that yes there is, using powershell.

Via CMD

You can use the “Schtasks” command from the CMD window.

schtasks /create /tn "my scheduled task" /tr "powershell -ExecutionPolicy unrestricted -Command \"(New-Object Net.WebClient).DownloadString(\\\http://url .to.be.executed/cron.php\\\")\" /sc DAILY /st 07:00:00 /ru System

  • /sc  schedule : Specifies the schedule type. Valid values are MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.
  • /st StartTime : Specifies the time of day that the task starts in HH:MM:SS 24-hour format. The default value is the current local time when the command completes. The /st parameter is valid with MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, and ONCE schedules. It is required with a ONCE schedule.
  • /tn TaskName : Specifies a name for the task.
  • /tr TaskRun : Specifies the program or command that the task runs. Type the fully qualified path and file name of an executable file, script file, or batch file. If you omit the path, SchTasks.exe assumes that the file is in theSystemroot\System32 directory.
  • /ru {[Domain\]User | "System"} : Runs the tasks with the permission of the specified user account. By default, the task runs with the permissions of the user logged on to the computer running SchTasks.

The docs and list of commands can be found here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/schtasks.mspx?mfr=true

Here is how to do it via GUI.


Just create a task in the normal way, under “Action” choose “start a program” –> powershell
And then under arguments you specify the following

-ExecutionPolicy unrestricted -Command "(New-Object Net.WebClient).DownloadString(\"http://www.yoururl.com/cron.php\")"

 

scheduled_task_url

Powered by Mango Blog. Design and Icons by N.Design Studio
RSS Feeds