<file_sep>﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Text;
using System.IO;
using System.Xml;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Services;
using it.itryframework.managers.mail;
using System.Text.RegularExpressions;
using it.aquest.baseobjects;


public partial class Ajax : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    [WebMethod]
    public static string getContentSection(string lang, string type, string view )
    {
        Page page = new System.Web.UI.Page();
        Control c = (Control)page.LoadControl("~/ascx/" + type + "/" + view + ".ascx");

        //((ContentUserControl)c).Lang = lang;

        if (c.GetType().GetInterface("IUserControl") != null)
        {
            ((IUserControl)c).load();
        }

        page.Controls.Add(c);

        StringWriter writer = new System.IO.StringWriter();
        HttpContext.Current.Server.Execute(page, writer, false);
        return _cleanUselessHiddenFields(writer.ToString());
    }

    //public static string getLavori(string lang, string work, int workIndex, string nextWork, int nextWorkIndex)
    [WebMethod]
    public static string getLavori(string work, int workIndex, string nextWork, int nextWorkIndex)
    {
        Page page = new System.Web.UI.Page();

        string pathWork = "~/ascx/projects/" + work + ".ascx";
        Control c = (Control)page.LoadControl(pathWork);
        ((IWorkUserControl)c).Index = workIndex;
        ((IWorkUserControl)c).View = work;
        ((IWorkUserControl)c).load();
        page.Controls.AddAt(0, c);

        // viene caricato il secondo work solo e solo se il parametro nextWork è valorizzato
        // se è vuoto, non carica
        if (!string.IsNullOrEmpty(nextWork))
        {
            string pathNextWork = "~/ascx/projects/" + nextWork + ".ascx";
            Control nextC = (Control)page.LoadControl(pathNextWork);
            ((IWorkUserControl)nextC).Index = nextWorkIndex;
            ((IWorkUserControl)nextC).View = nextWork;
            ((IWorkUserControl)nextC).load();
            page.Controls.AddAt(1, nextC);
        }

        StringWriter writer = new System.IO.StringWriter();
        HttpContext.Current.Server.Execute(page, writer, false);
        return _cleanUselessHiddenFields(writer.ToString());
    }

    [WebMethod]
    public static string inviaForm(string company, string person, string telephone, string email, string message)
    {
        int esito = 0;

        System.Text.StringBuilder s = new System.Text.StringBuilder();
        s.Append("E' stata inviata una richiesta informazioni dal sito Aquest");
        s.Append("<br><br>Company: <b>" + company + "</b>");
        s.Append("<br><br>Person: <b>" + person + "</b>");
        s.Append("<br><br>Telephone: <b>" + telephone + "</b>");
        s.Append("<br><br>Email: <a href=mailto:" + email + "><b>" + email + "</b></a>");
        s.Append("<br><br>Messaggio:<br>" + message);

        MailManager mailMng = new MailManager("localhost");
        try
        {
            //mailMng.send("<EMAIL>", "<EMAIL>", new string[] { "<EMAIL>" }, "Richiesta informazioni sito Aquest", s.ToString());
            mailMng.send("<EMAIL>", "<EMAIL>", new string[] { "<EMAIL>", "<EMAIL>"}, "Richiesta informazioni sito Aquest", s.ToString());
            esito = 1;
        }
        catch { }

        return esito.ToString();
    }


    private static string _cleanUselessHiddenFields(string inputString)
    {
        string regex = @"<input type=""hidden"" name=""__VIEWSTATE"" id=""__VIEWSTATE"" value=""(.*)"" />";
        string regex2 = @"<input type=""hidden"" name=""__EVENTVALIDATION"" id=""__EVENTVALIDATION"" value=""(.*)"" />";

        string valueToReturn = Regex.Replace(inputString, regex, "");
        valueToReturn = Regex.Replace(valueToReturn, regex2, "");

        return valueToReturn;
    }


    private static string _getCodLang(string codLingua) 
    {
        string codLang = "it-IT";
        if (codLingua.Equals("en")) codLang = "en-US";
        else if (codLingua.Equals("de")) codLang = "de-DE";
        return codLang;
    }

    private static void _setCulture(string codLang)
    {
        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(codLang);
        System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(codLang);
    }

            
}
<file_sep>﻿using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Mail di notifica errore
/// </summary>
public class MailErrore : MailGenerica
{
    private Exception _e;

    public MailErrore() { }

    public MailErrore(Exception e)
	{
        _e = e;
        _from = "<EMAIL>";
        _to = "<EMAIL>";
        _subject = "[lanordica-extraflame.it] errore";
        _body = getBody();
    }

    public MailErrore(string soggetto)
    {
        _e = null;
        _from = "<EMAIL>";
        _to = "<EMAIL>";
        _subject = soggetto;
        _body = getBody();
    }


    public MailErrore(Exception e, string soggetto)
    {
        _e = e;
        _from = "<EMAIL>";
        _to = "<EMAIL>";
        _subject = soggetto;
        _body = getBody();
    }

    private string getBody()
    {
        StringBuilder body = new StringBuilder();

        body.Append("Errore aquest.it<br><br>");
        if (_e != null)
        {
            body.Append(_e.ToString());
        }

        return body.ToString();
	}
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// IUserControl
/// </summary>
public interface IUserControl
{
    void load();
}<file_sep>﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Net;

public class Logger
{
    private string _logFilePath;
    public string logFilePath
    {
        get { return _logFilePath; }
        set { _logFilePath = value; }
    }

    public Logger(string path)
    {
        logFilePath = path;
    }

    public void log(Exception ex, string msg)
    {
        StreamWriter f = null;

        //try
        //{
        f = (!File.Exists(logFilePath)) ? File.CreateText(logFilePath) : File.AppendText(logFilePath);
        if (ex != null)
        {
            f.WriteLine("-------------------------------------");
            f.WriteLine("Exception: " + Environment.NewLine + ex.Message + Environment.NewLine + "Stack trace: " + Environment.NewLine + ex.StackTrace);
            if (ex.InnerException != null) f.WriteLine("Inner exception: " + Environment.NewLine + ex.InnerException.Message);
        }
        if (!string.IsNullOrEmpty(msg)) f.WriteLine(msg);
        //}
        //catch (Exception ex1)
        //{
        //EventLog.WriteEntry("RunnerService", ex1.Message + Environment.NewLine + ex1.StackTrace, EventLogEntryType.Error, 1);
        //}
        //finally
        //{
        if (f != null)
        {
            f.Close();
            f.Dispose();
        }
        //}
    }
}<file_sep>﻿using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Mail generica
/// </summary>
public class MailGenerica
{
    protected string _from;
    public string from
    {
        get { return _from; }
    }

    protected string _to;
    public string to
    {
        get { return _to; }
    }

    protected string _subject;
    public string subject
    {
        get { return _subject; }
    }

    protected string[] _bcc;
    public string[] bcc
    {
        get { return _bcc; }
    }

    protected string _body;
    public string body
    {
        get { return _body; }
    }

    public MailGenerica() { }

    public MailGenerica(string from, string to, string[] bcc, string subject, string body)
    {
        _from = from;
        _to = to;
        _subject = subject;
        _bcc = bcc;
        _body = body;
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    public string Lang { get; set; }
    public string View { get; set; }
    public string Type { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        
        Lang = String.IsNullOrEmpty(Request.QueryString["lang"]) ? "it" : Request.QueryString["lang"];
        View = String.IsNullOrEmpty(Request.QueryString["view"]) ? "home" : Request.QueryString["view"];
        Type = String.IsNullOrEmpty(Request.QueryString["type"]) ? "pages" : Request.QueryString["type"];


        Control c = (Control)LoadControl("~/ascx/" + Type + "/" + View + ".ascx");


        if (c.GetType().GetInterface("IUserControl") != null)
        {
            ((IUserControl)c).load();
        }
        phPage.Controls.Add(c);


        string js = "<script>var lang='" + Lang + "', view = '" + View + "';</script>";
        litJs.Text = js;

    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using it.aquest.baseobjects;
using System.Text;

public partial class Homepage : ContentUserControl, IUserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void load()
    {

    }
}<file_sep>﻿(function () {

    module.exports.name = 'router';



    // --- --- --- --- 
    // module obj
    // --- --- --- --- 
    var router = {};



    // --- --- --- --- 
    // START private vars and functions declaration
    // --- --- --- --- 

    var _humanize = function (s) {
        var arr, humanized, word, _i, _len;
        humanized = "";
        if (s.charAt(0) === '/') {
            s = s.slice(1);
        }
        arr = s.split('-');
        if (s.length > 0) {
            if (arr.length > 0) {
                _len = arr.length;
                for (_i = 0; _i < _len; _i++) {
                    word = arr[_i];
                    //humanized += _capitalize(word);
                    humanized += word;
                }
            } else {
                //humanized = _capitalize(s);
                humanized = s;
            }
        } else {
            //humanized = "Homepage";
            humanized = "homepage";
        }
        return humanized;
    };

    var _capitalize = function (s) {
        return s.charAt(0).toUpperCase() + s.slice(1);
    };

    // --- --- --- --- 
    // END private vars and functions declaration
    // --- --- --- --- 



    // --- --- --- --- 
    // START exported functions
    // --- --- --- --- 

    router.route = function (url) {
        if (typeof url === 'undefined') {
            url = "";
        }
        return _humanize(url);
    };

    // --- --- --- --- 
    // END exported functions
    // --- --- --- --- 



    // --- --- --- --- 
    // exports module obj
    // --- --- --- --- 
    module.exports = router;

}());<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Descrizione di riepilogo per IWorkUserControl
/// </summary>
public interface IWorkUserControl
{
    int Index { get; set; }
    string View { get; set; }
    void load();
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace it.aquest.baseobjects
{
    public class BasePage : System.Web.UI.Page
    {
        private string m_codLingua;
        public string CodLingua
        {
            get { return m_codLingua; }
        }

        private string m_page;
        public string Pagina
        {
            get { return m_page; }
            set { m_page = value; }
        }

        public BasePage()
        {

        }

        protected override void InitializeCulture()
        {

            HttpCookie ckLinguaSito = new HttpCookie("lingua_sito");

            if (!string.IsNullOrEmpty(Request["lang"]))
            {
                if (Request["lang"].Equals("it", StringComparison.InvariantCultureIgnoreCase)
                    || Request["lang"].Equals("en", StringComparison.InvariantCultureIgnoreCase))
                {
                    m_codLingua = Request["lang"].ToLower();
                    ckLinguaSito.Value = m_codLingua;
                    Response.Cookies.Add(ckLinguaSito);
                }
            }

            string codLang = "it-IT";
            if (m_codLingua.Equals("en")) codLang = "en-US";

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(codLang);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(codLang);

            base.InitializeCulture();
            
            /*
            HttpCookie ckLinguaSito = Request.Cookies["lingua_sito"];
            if (ckLinguaSito == null)
            {
                ckLinguaSito = new HttpCookie("lingua_sito");
                ckLinguaSito.Value = "IT";
                m_codLingua = "it";
            }
            else
            {
                m_codLingua = ckLinguaSito.Value;
                //ckLinguaSito.Value = "IT";
            }
            Response.Cookies.Add(ckLinguaSito);

            if (!string.IsNullOrEmpty(Request["lang"]))
            {
                if (Request["lang"].Equals("it", StringComparison.InvariantCultureIgnoreCase) || 
                    Request["lang"].Equals("en", StringComparison.InvariantCultureIgnoreCase))
                {
                    m_codLingua = Request["lang"].ToLower();
                    ckLinguaSito.Value = m_codLingua;
                    Response.Cookies.Add(ckLinguaSito);
                }
            }

            string codLang = "it-IT";
            if (m_codLingua.Equals("en")) codLang = "en-US";

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(codLang);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(codLang);
            base.InitializeCulture();
            */
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            Pagina = Request.QueryString["view"];
            //Pagina = Pagina.Trim().Length == 0 ? "home" : Pagina;
            Pagina = Pagina == null || (Pagina != null && Pagina.Trim().Length == 0) ? "home" : Pagina;

            if (!IsPostBack)
            {
                if (Request.QueryString["ref"] != null && Request.QueryString["ref"].ToString().Length > 0)
                {
                    _initializeAqRef(Request.QueryString["ref"]);
                }
            }
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }
        
        protected string getSessionLingua()
        {
            return "";
        }

        protected void setTitle(string title)
        {
            Page.Title = title;
        }

        protected void setDescription(string testo)
        {
            if (string.IsNullOrEmpty(testo)) return;
            string shorDesc = (testo.Length > 200 ? testo.Substring(0, 200) : testo);
            HtmlMeta description = new HtmlMeta();
            description.Name = "Description";
            description.Content = shorDesc;
            Page.Header.Controls.Add(description);
        }

        public void setRegisterJs(string fileName)
        {
            HtmlGenericControl js = new HtmlGenericControl("script");
            js.Attributes.Add("type", "text/javascript");
            js.Attributes.Add("language", "javascript");
            js.Attributes.Add("src", "/js/" + fileName);
            Page.Header.Controls.Add(js);
        }

        private void _initializeAqRef(string val)
        {
            DateTime ora = DateTime.Now;
            Response.Cookies["aqref"].Value = val;
            Response.Cookies["aqref"].Expires = ora.AddMonths(1);
        }
    }
}<file_sep>﻿(function () {

    module.exports.name = 'config';



    // --- --- --- --- 
    // module obj
    // --- --- --- --- 
    var config = {
		ROUTE_BY_URL: true,
        MAX_CACHE_LENGTH: 5, // -1 cache illimitata
        HAS_INFO: false,
        PRELOAD: true,
        MOBILE_THRESHOLD: 767,
        TABLET_THRESHOLD: 1025,
        POLLING_TIMER: 100,
        STANDARD_ANIM_TIMING: 100,
        SCROLL_EVENT_HANDLERS: 'mousewheel touchmove wheel',
        CLICK_EVENT_HANDLERS: 'click touchend'
    };

    // --- --- --- --- 
    // exports module obj
    // --- --- --- --- 
    module.exports = config;

}());
<file_sep>﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using it.aquest.managers;

namespace it.aquest.baseobjects
{
    public class ContentUserControl : BaseUserControl
    {
        //public string Brand { get; set; }
        //public string Season { get; set; }
        //public string Year { get; set; }

        public ContentUserControl()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
        }


    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Descrizione di riepilogo per InitializeCulture
/// </summary>
public class UrlMapper
{
    public UrlMapper()
    {
        //
        // TODO: aggiungere qui la logica del costruttore
        //
    }

    public string map(string langCode, string page)
    {
        string valueToReturn = "";

        if (langCode.ToLower().Equals("it"))
        {
            switch (page)
            {
                case "home":
                    valueToReturn = "/en";
                    break;
                case "gruppo":
                    valueToReturn = "/en/group";
                    break;
                case "dovesiamo":
                    valueToReturn = "/en/where";
                    break;
                case "servizi":
                    valueToReturn = "/en/services";
                    break;
                case "etica":
                    valueToReturn = "/en/ethics";
                    break;
                case "contatti":
                    valueToReturn = "/en/contact";
                    break;
            }

        }
        else 
        {
            switch (page)
            {
                case "home":
                    valueToReturn = "/";
                    break;
                case "en/group":
                case "group":
                    valueToReturn = "/gruppo";
                    break;
                case "en/where":
                case "where":
                    valueToReturn = "/dovesiamo";
                    break;
                case "en/services":
                case "services":
                    valueToReturn = "/servizi";
                    break;
                case "en/ethics":
                case "ethics":
                    valueToReturn = "/etica";
                    break;
                case "en/contact":
                case "contact":
                    valueToReturn = "/contatti";
                    break;
            }
        }

        return valueToReturn;
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.HtmlControls;

namespace it.aquest.baseobjects
{
    public class BaseUserControl : System.Web.UI.UserControl
    {
        public BaseUserControl()
        {
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            //if (Session[it.brugi.costanti.cosGenerali.ADMIN] == null)
            //{
            //    if (!Page.IsCallback)
            //    {
            //        Response.Redirect("~/backoffice/login.aspx", true);
            //    }
            //    else
            //    {
            //        string script = string.Format("http://{0}/backoffice/login.aspx", Request.ServerVariables["SERVER_NAME"]);
            //        base.ClientScript.RegisterClientScriptBlock(typeof(string), "redirect", script, true);
            //    }
            //}
            
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

        }

        protected string getSessionLingua()
        {
            return "";
        }

        protected void setRegisterCss(string path)
        {
            HtmlLink css = new HtmlLink();
            css.Attributes.Add("rel", "stylesheet");
            css.Attributes.Add("type", "text/css");
            css.Href= path;
            Page.Header.Controls.Add(css);
        }
        protected void setRegisterJs(string path)
        {
            HtmlGenericControl js = new HtmlGenericControl();
            js.TagName = "script";
            js.Attributes.Add("type", "text/javascript");
            js.Attributes.Add("language", "javascript");
            js.Attributes.Add("src", path);
            Page.Header.Controls.Add(js);
        }



    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Elem
/// </summary>
public class Elem : System.Collections.IComparer, IComparable
{
    #region properties
    private string _title;
    public string title
    {
        get { return _title; }
        set { _title = value; }
    }

    private string _abstractText;
    public string abstractText
    {
        get { return _abstractText; }
        set { _abstractText = value; }
    }

    private string _id;
    public string id
    {
        get { return _id; }
        set { _id = value; }
    }

    private string _type;
    public string type
    {
        get { return _type; }
        set { _type = value; }
    }

    private string _allegato;
    public string allegato
    {
        get { return _allegato; }
        set { _allegato = value; }
    }

    private string _data;
    public string data
    {
        get { return _data; }
        set { _data = value; }
    }

    private string _dataid;
    public string dataid
    {
        get { return _dataid; }
        set { _dataid = value; }
    }


    #endregion

    public Elem()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    public int Compare(object x, object y)
    {
        return _compare(x, y);
    }

    public int CompareTo(object y)
    {
        return _compare(this, y);
    }

    private int _compare(object x, object y)
    {
        Elem xElem = (Elem)x, yElem = (Elem)y;
        int valueToReturn = 0, xData = Convert.ToInt32(xElem.dataid), yData = Convert.ToInt32(yElem.dataid);

        if (xData < yData)
        {
            valueToReturn = -1;
        }
        else
        {
            if (xData > yData)
            {
                valueToReturn = 1;
            }
        }

        return valueToReturn;
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;
using System.Xml;
using System.Text;
using Newtonsoft.Json.Linq;
using System.Text.RegularExpressions;
using System.Security.Cryptography;

namespace it.aquest
{
    public class Utils
    {
        public string toUrl(string inputString)
        {
            string s = String.Empty;

            if (!String.IsNullOrEmpty(inputString))
            {
                s = inputString.Trim().ToLower();

                s = Regex.Replace(s, " - ", "-");
                s = Regex.Replace(s, "à", "a");
                s = Regex.Replace(s, "â", "a");
                s = Regex.Replace(s, "è", "e");
                s = Regex.Replace(s, "ì", "i");
                s = Regex.Replace(s, "ò", "o");
                s = Regex.Replace(s, "ù", "u");
                s = Regex.Replace(s, "é", "e");
                s = Regex.Replace(s, "ó", "o");
                s = Regex.Replace(s, "ö", "o");
                s = Regex.Replace(s, "õ", "o");
                s = Regex.Replace(s, "ü", "u");
                s = Regex.Replace(s, "ä", "a");
                s = Regex.Replace(s, "Ü", "u");
                s = Regex.Replace(s, "ñ", "n");
                s = Regex.Replace(s, "ç", "c");
                s = Regex.Replace(s, "!", "");
                s = Regex.Replace(s, "®", "");
                s = Regex.Replace(s, "™", "");
                s = Regex.Replace(s, ",", "-");

                s = Regex.Replace(s, @"([@°""./&()’+*”øØ<>=$:?£ ])", "-");
                s = Regex.Replace(s, @"(-&-|' | '|')", "-");
                s = Regex.Replace(s, @"(---|--)", "-");
                s = Regex.Replace(s, "--", "-");

                if (s.StartsWith("-"))
                {
                    s = s.Substring(1, s.Length - 1);
                }

                if (s.EndsWith("-"))
                {
                    s = s.Substring(0, s.Length - 1);
                }
            }
            else
            {
                s = inputString;
            }

            return s;
        }

        public static string generateRandomString(int len)
        {
            char[] cr = "123456789abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUWXYZ".ToCharArray();
            string result = string.Empty;
            Random r = new Random();
            for (int i = 0; i < len; i++)
            {
                result += cr[r.Next(0, cr.Length - 1)].ToString();
            }
            return result;
        }

        public static void insertStartupJsOnPageReady(string testo)
        {
            System.Web.UI.Page currentPage = (System.Web.UI.Page)HttpContext.Current.Handler;
            string randString = generateRandomString(5);

            if (!currentPage.ClientScript.IsClientScriptBlockRegistered(randString))
            {
                string tmp = "<script type=\"text/javascript\">\n $(function() { \n " + testo + " \n });</script>";

                currentPage.ClientScript.RegisterStartupScript
                (currentPage.GetType(),
                 randString,
                 tmp);
            }
        }

        public static void insertStartupJavascript(string testo)
        {
            System.Web.UI.Page currentPage = (System.Web.UI.Page)HttpContext.Current.Handler;
            string randString = generateRandomString(5);

            if (!currentPage.ClientScript.IsClientScriptBlockRegistered(randString))
            {
                currentPage.ClientScript.RegisterStartupScript
                (currentPage.GetType(),
                 randString,
                 "<script type=\"text/javascript\">\n " + testo + " \n</script>");
            }
        }

        public static string Abbreviate(string sIn, int len)
        {
            string newString = Regex.Replace(sIn, @"<[^>]*>", " ");
            int lastSpace = 0;
            newString = newString.Replace("\r", "").Replace("\n", "").Replace("\'", "'");

            if (newString.Length > len)
            {
                newString = newString.Substring(0, len - 2);
                if (newString.Contains(" "))
                {
                    lastSpace = newString.LastIndexOf(' ');
                }
                else
                {
                    lastSpace = newString.Length;
                }
                newString = newString.Substring(0, lastSpace) + " ...";
            }
            return newString;
        }

        public static string stripLastCharOfString(string sIn)
        {
            return stripNCharsFromEndOfString(sIn, 1);
        }

        public static string stripNCharsFromEndOfString(string sIn, int n)
        {
            if (sIn != null && sIn.Length > 0)
            {
                sIn = sIn.Substring(0, sIn.Length - n);
            }

            return sIn;
        }

        public static DateTime UnixTimeStampToDateTime(double unixTimeStamp)
        {
            // Unix timestamp is seconds past epoch
            System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
            return dtDateTime;
        }

        public static string GetMessageDateDiffFromNow(DateTime d)
        {
            string valueToReturn = "";

            TimeSpan span = (DateTime.Now - d);
            if (span.Days > 0)
            {
                valueToReturn += span.Days.ToString() + " day";
                if (span.Days > 1)
                {
                    valueToReturn += "s";
                }
                valueToReturn += " ago";
            }
            else
            {
                if (span.Hours > 0)
                {
                    valueToReturn += span.Hours.ToString() + " hour";
                    if (span.Hours > 1)
                    {
                        valueToReturn += "s";
                    }
                    valueToReturn += " ago";
                }
                else
                {
                    valueToReturn += span.Minutes.ToString() + " min ago";
                }
            }

            return valueToReturn;
        }


        /// <summary>
        /// see http://pigeoncms.codeplex.com/SourceControl/latest#projects/PigeonCms.Core/Helpers/Utility.cs
        /// useful crypt decript methods using AES (modified)
        /// </summary>
        public class Encryption
        {
            const string SKIP_KEY = "nn";

            public static string Decrypt(string textToDecrypt, string key)
            {
                byte[] encryptedData = Convert.FromBase64String(textToDecrypt);
                if (key == SKIP_KEY)
                {
                    return Encoding.UTF8.GetString(encryptedData);
                }
                else
                {
                    RijndaelManaged rijndaelCipher = new RijndaelManaged(); //AES
                    rijndaelCipher.Mode = CipherMode.CBC;
                    rijndaelCipher.Padding = PaddingMode.PKCS7;

                    rijndaelCipher.KeySize = 0x80;
                    rijndaelCipher.BlockSize = 0x80;
                    //byte[] encryptedData = Convert.FromBase64String(textToDecrypt);
                    byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
                    byte[] keyBytes = new byte[0x10];
                    int len = pwdBytes.Length;
                    if (len > keyBytes.Length)
                    {
                        len = keyBytes.Length;
                    }
                    Array.Copy(pwdBytes, keyBytes, len);
                    rijndaelCipher.Key = keyBytes;
                    rijndaelCipher.IV = keyBytes;
                    byte[] plainText = rijndaelCipher.CreateDecryptor().TransformFinalBlock(encryptedData, 0, encryptedData.Length);
                    return Encoding.UTF8.GetString(plainText);
                }
            }

            public static string Encrypt(string textToEncrypt, string key)
            {
                byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
                if (key == SKIP_KEY)
                {
                    return Convert.ToBase64String(plainText);
                }
                else
                {
                    RijndaelManaged rijndaelCipher = new RijndaelManaged();
                    rijndaelCipher.Mode = CipherMode.CBC;
                    rijndaelCipher.Padding = PaddingMode.PKCS7;

                    rijndaelCipher.KeySize = 0x80;
                    rijndaelCipher.BlockSize = 0x80;
                    byte[] pwdBytes = Encoding.UTF8.GetBytes(key);
                    byte[] keyBytes = new byte[0x10];
                    int len = pwdBytes.Length;
                    if (len > keyBytes.Length)
                    {
                        len = keyBytes.Length;
                    }
                    Array.Copy(pwdBytes, keyBytes, len);
                    rijndaelCipher.Key = keyBytes;
                    rijndaelCipher.IV = keyBytes;
                    ICryptoTransform transform = rijndaelCipher.CreateEncryptor();
                    //byte[] plainText = Encoding.UTF8.GetBytes(textToEncrypt);
                    return Convert.ToBase64String(transform.TransformFinalBlock(plainText, 0, plainText.Length));
                }
            }
        }



    }
}
<file_sep>// ------------------------------------------------------ // 
//
// TOKI by Aquest
// v. 1.1.0
// Authors: <NAME>, <NAME>
//
// 24/10/2014
//
// Libreries and Tools used:
// - Node.js with Browserify Modules
// - Util node.js code modules
// - Builded with Grunt.js / Gulp.js
// - LoDash.js
// - Velocity.js
// - Events Emitter
// - Jquery
// - Masonry, Modernizr
// ------------------------------------------------------ //

"use strict";

// --- --- --- --- 
// START TOKI declaration
// --- --- --- --- 

var TOKI = TOKI || {}; 
var is_chromeWin = (navigator.userAgent.toLowerCase().indexOf('chrome') > -1) && (navigator.userAgent.indexOf("Mac OS X") == -1);

global._ = require('lodash');
global.util = require('util');
global.TOKI  = TOKI; 

// --- --- --- --- 
// START jQuery plugins require
// --- --- --- --- 


require('./vendor/velocity.min.js');
require('./vendor/velocity.ui.min.js');


// --- --- --- --- 
// START TOKI fields declarations
// --- --- --- --- 

TOKI.inView = true;
TOKI.CurrentModule = null;
TOKI.isInsideDetail = false;
TOKI.isAjax = false;
TOKI.Events = [];

var TokiEmitter = require("./app/components/toki-emitter.js");
TOKI.emitter = new TokiEmitter();
TOKI.emitter.setMaxListeners(0); // listeners illimitati


// --- --- --- --- 
// START require components 
// --- --- --- --- 

TOKI.config 	= require("./app/components/config.js");
TOKI.screen 	= require("./app/components/screen.js");
TOKI.router 	= require("./app/components/router.js");
TOKI.cache 		= require("./app/components/cache.js");

// --- --- --- --- 
// START require views 
// --- --- --- --- 

TOKI.baseview 	= require("./app/views/base-view.js");
TOKI.homepage 	= require("./app/views/homepage.js");


// --- --- --- --- 
// START require regions 
// --- --- --- --- 
/*
TOKI.loader 	= require('./app/regions/loader.js');
TOKI.nav 		= require('./app/regions/nav.js');
TOKI.hyperlinks = require('./app/regions/hyperlinks.js');
TOKI.content 	= require('./app/regions/content.js');
TOKI.body 		= require('./app/regions/body.js');
*/



// --- --- --- --- 
// START adding regions
// --- --- --- --- 

TOKI.init_shared_regions = function() {
    /*
	TOKI.hyperlinks.init();
	TOKI.body.init();
	TOKI.nav.init();
    TOKI.content.init();
    TOKI.loader.init();
    */
	TOKI.init();
};


// --- --- --- --- 
// START project's heart
// --- --- --- --- 

TOKI.init = function (url) {
	// router
	if (typeof url === 'undefined') {
		//TOKI.isAjax 	= false;
        url = TOKI.config.ROUTE_BY_URL ? location.href : $("body").data("page");
    }

    var splittedUrl 	= url.split('/');
    var urlTokenCount 	= splittedUrl.length; 
    var page 			= splittedUrl[urlTokenCount - 1].split('?')[0];
    

    // setto prev e current module
    TOKI.CurrentModule 	= TOKI.router.route(page);

    // chiamo init di ogni modulo
    TOKI[TOKI.CurrentModule].init(TOKI.isAjax); // es. Toki[About].init(true);
	


    TOKI.emitter.emit('TOKI:init');
    
    _.delay(function(){
        TOKI.emitter.emit(TOKI.CurrentModule + ":ready");
    },1000);
	
};


// --- --- --- --- --- ---
// START emitting dom and window events
// --- --- --- --- --- ---


$(document).on('ready', function(e){
    TOKI.emitter.emit('TOKI:document:ready', e); 
});

$(window).on('orientationchange', function(e){
    TOKI.emitter.emit('TOKI:window:orientationchange', e);
});

$(window).on('resize', function(e){
    TOKI.emitter.emit('TOKI:window:resize', e); 
});

$(window).on(TOKI.config.SCROLL_EVENT_HANDLERS, function (e) {
    TOKI.emitter.emit('TOKI:window:scroll', e);
});


// --- --- --- --- 
// FIRST START ON DOCUMENT READY
// --- --- --- --- 

TOKI.init_shared_regions();

// --- --- --- --- 
// RECALL TOKI INIT ON AJAX CALL
// --- --- --- --- 

TOKI.emitter.on("layout:content:contentFilled", function(href) { 
    TOKI.init(href); 
});
