예제 #1
0
        public BoundIncludeEx(BoundExpression target, InclusionTypes type)
            : base(ImmutableArray.Create(new BoundArgument(target)))
        {
            Debug.Assert(target.Access.IsRead);

            this.InclusionType = type;
        }
예제 #2
0
 public StaticInclusion(ScriptCompilationUnit /*!*/ includer, CompilationUnit /*!*/ includee, Scope scope,
                        bool isConditional, InclusionTypes inclusionType)
 {
     this.scope         = scope;
     this.inclusionType = inclusionType;
     this.includee      = includee;
     this.includer      = includer;
     this.isConditional = isConditional;
 }
예제 #3
0
        public IncludingEx(bool isConditional, Text.Span span,
                           InclusionTypes inclusionType, Expression /*!*/ fileName)
            : base(span)
        {
            Debug.Assert(fileName != null);

            this.inclusionType = inclusionType;
            this.fileNameEx    = fileName;
            this.isConditional = isConditional;
        }
예제 #4
0
		public IncludingEx(SourceUnit/*!*/ sourceUnit, Scope scope, bool isConditional, Text.Span span,
			InclusionTypes inclusionType, Expression/*!*/ fileName)
            : base(span)
		{
			Debug.Assert(fileName != null);

			this.inclusionType = inclusionType;
			this.fileNameEx = fileName;
			this.scope = scope;
			this.isConditional = isConditional;
			this.sourceUnit = sourceUnit;
		}
예제 #5
0
        public IncludingEx(SourceUnit /*!*/ sourceUnit, Scope scope, bool isConditional, Text.Span span,
                           InclusionTypes inclusionType, Expression /*!*/ fileName)
            : base(span)
        {
            Debug.Assert(fileName != null);

            this.inclusionType = inclusionType;
            this.fileNameEx    = fileName;
            this.scope         = scope;
            this.isConditional = isConditional;
            this.sourceUnit    = sourceUnit;
        }
예제 #6
0
        public object DynamicInclude(
            string includedFilePath,
            string includerFileRelPath,
            Dictionary <string, object> variables,
            DObject self,
            DTypeDesc includer,
            InclusionTypes inclusionType)
        {
            ApplicationConfiguration app_config = Configuration.Application;

            // determines inclusion behavior:
            FullPath includer_full_path = new FullPath(includerFileRelPath, app_config.Compiler.SourceRoot);

            // searches for file:
            FullPath included_full_path = SearchForIncludedFile(
                InclusionTypesEnum.IsMustInclusion(inclusionType) ? PhpError.Error : PhpError.Warning,
                includedFilePath, includer_full_path);

            if (included_full_path.IsEmpty)
            {
                return(false);
            }

            ScriptInfo info;
            bool       already_included = scripts.TryGetValue(included_full_path.ToString(), out info);

            // skips inclusion if script has already been included and inclusion's type is "once":
            if (already_included && InclusionTypesEnum.IsOnceInclusion(inclusionType))
            {
                return(ScriptModule.SkippedIncludeReturnValue);
            }

            if (!already_included)
            {
                // loads script type:
                info = LoadDynamicScriptType(new PhpSourceFile(app_config.Compiler.SourceRoot, included_full_path));

                // script not found:
                if (info == null)
                {
                    return(false);
                }

                // adds included file into the script list
                scripts.Add(included_full_path.ToString(), info /* = new ScriptInfo(script)*/);
            }

            return(info.Main(this, variables, self, includer, false));
        }
예제 #7
0
 public AccessControlListMember AddMember(int memberId, InclusionTypes inclusionType)
 {
     AccessControlListMember member2;
     if ((this.InclusionType == InclusionTypes.MemberDefined) && (inclusionType == InclusionTypes.Undefined))
     {
         throw new Exception("Cannot add a member whos inclusionType is Undefined to an ACL whos inclusion type is MemberDefined.");
     }
     if ((this.InclusionType != InclusionTypes.MemberDefined) && (inclusionType != InclusionTypes.Undefined))
     {
         ErrorLog.WriteLine("Ignoring member inclusion type because this ACL's inclusion type is not set to MemberDefined", new object[0]);
     }
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         System.Guid guid = System.Guid.NewGuid();
         if (new QuazalQuery("AddACLMember", new object[] { guid, this.ID, memberId, (int) inclusionType }).ExecuteNonQuery())
         {
             AccessControlListMember member = new QuazalQuery("GetACLUserMemberByGuid", new object[] { guid }).GetObject<AccessControlListMember>();
             DateTime now = DateTime.Now;
             while (member == null)
             {
                 Thread.Sleep(50);
                 member = new QuazalQuery("GetACLUserMemberByGuid", new object[] { guid }).GetObject<AccessControlListMember>();
                 if ((DateTime.Now - now) > TimeSpan.FromSeconds(5.0))
                 {
                     break;
                 }
             }
             if ((this.mMembers != null) && (member != null))
             {
                 Array.Resize<AccessControlListMember>(ref this.mMembers, this.mMembers.Length + 1);
                 this.mMembers[this.mMembers.Length - 1] = member;
             }
             return member;
         }
         member2 = null;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
     return member2;
 }
예제 #8
0
        public object DynamicInclude(
            string includedFilePath,
            string includerFileRelPath,//TODO: Now it's not relative because RelativePath class doesn't work properly with HTTP addresses
            Dictionary <string, object> variables,
            DObject self,
            DTypeDesc includer,
            InclusionTypes inclusionType)
        {
            ApplicationConfiguration app_config = Configuration.Application;

            // determines inclusion behavior:
            PhpError error_severity = InclusionTypesEnum.IsMustInclusion(inclusionType) ? PhpError.Error : PhpError.Warning;
            bool     once           = InclusionTypesEnum.IsOnceInclusion(inclusionType);


            System.Threading.AutoResetEvent downloadFinished = null;
            string eval = string.Empty;

            downloadFinished = new System.Threading.AutoResetEvent(false);

            WebClient webclient = new WebClient();

            webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(
                delegate(object sender, DownloadStringCompletedEventArgs downEventArgs)
            {
                if (downEventArgs.Error == null)
                {
                    eval = downEventArgs.Result;

                    // workaround for Firefox BrowserHttpWebRequest bug -
                    // assuming that we're downloading PHP source starting with '<?'
                    int srcStart = 0;
                    while (!(eval[srcStart] == '<' && eval[srcStart + 1] == '?') && (srcStart + 1 < eval.Length))
                    {
                        srcStart++;
                    }
                    eval = eval.Substring(srcStart);

                    downloadFinished.Set();
                }
            }
                );

            Uri baseUri = new Uri(app_config.Compiler.SourceRoot + "/", UriKind.Absolute);
            Uri uriFile = new Uri(includedFilePath, UriKind.RelativeOrAbsolute);
            Uri uri     = new Uri(baseUri, uriFile);

            webclient.DownloadStringAsync(uri);

            ThreadStart ts = new ThreadStart(() => {
                downloadFinished.WaitOne();

                try
                {
                    DynamicCode.EvalFile(eval, ScriptContext.CurrentContext, variables, self, null, includedFilePath, 0, 0, -1);
                }
                catch (Exception ex)
                {
                    var canvas = ((ClrObject)ScriptContext.CurrentContext.AutoGlobals.Canvas.Value).RealObject as System.Windows.Controls.Canvas;

                    canvas.Dispatcher.BeginInvoke(() =>
                    {
                        throw ex;
                    });
                }
            });

            if (inclusionType == InclusionTypes.RunSilverlight) // new thread have to be created
            {
                new Thread(ts).Start();
            }
            else
            {
                ts(); // just continue on this thread
            }

            return(null);
        }
예제 #9
0
		public bool StaticInclude(int level, string relativeSourcePath, RuntimeTypeHandle includee, InclusionTypes inclusionType)
		{
			ApplicationConfiguration app_config = Configuration.Application;

            var included_full_path =
            //PhpSourceFile source_file = new PhpSourceFile(
            //	app_config.Compiler.SourceRoot,
                new FullPath(app_config.Compiler.SourceRoot, new RelativePath((sbyte)level, relativeSourcePath));
			//);

            if (scripts.ContainsKey(included_full_path.ToString()))
			{
				// the script has been included => returns whether it should be included again:
				return !InclusionTypesEnum.IsOnceInclusion(inclusionType);
			}
			else
			{
				// the script has not been included yet:
                scripts.Add(included_full_path.ToString(), new ScriptInfo(Type.GetTypeFromHandle(includee)));

				// the script should be included:
				return true;
			}
		}
예제 #10
0
		public object DynamicInclude(
			string includedFilePath,
			string includerFileRelPath,
			Dictionary<string, object> variables,
			DObject self,
			DTypeDesc includer,
			InclusionTypes inclusionType)
		{
			ApplicationConfiguration app_config = Configuration.Application;

			// determines inclusion behavior:
			FullPath includer_full_path = new FullPath(includerFileRelPath, app_config.Compiler.SourceRoot);

			// searches for file:
			FullPath included_full_path = SearchForIncludedFile(
                InclusionTypesEnum.IsMustInclusion(inclusionType) ? PhpError.Error : PhpError.Warning,
                includedFilePath, includer_full_path);

			if (included_full_path.IsEmpty) return false;

			ScriptInfo info;
            bool already_included = scripts.TryGetValue(included_full_path.ToString(), out info);

			// skips inclusion if script has already been included and inclusion's type is "once":
            if (already_included && InclusionTypesEnum.IsOnceInclusion(inclusionType))
				return ScriptModule.SkippedIncludeReturnValue;

			if (!already_included)
			{
				// loads script type:
                info = LoadDynamicScriptType(new PhpSourceFile(app_config.Compiler.SourceRoot, included_full_path));

				// script not found:
				if (info == null) return false;

				// adds included file into the script list
                scripts.Add(included_full_path.ToString(), info/* = new ScriptInfo(script)*/);
			}

			return info.Main(this, variables, self, includer, false);
		}
예제 #11
0
 /// <summary>
 /// Returns whether a specified inclusion is auto-inclusion (auto-prepended/appended file).
 /// </summary>
 public static bool IsAutoInclusion(InclusionTypes inclusionType)
 {
     return(inclusionType == InclusionTypes.Prepended || inclusionType == InclusionTypes.Appended);
 }
예제 #12
0
 /// <summary>
 /// Returns whether a specified inclusion must succeed.
 /// </summary>
 public static bool IsMustInclusion(InclusionTypes inclusionType)
 {
     return(inclusionType != InclusionTypes.IncludeOnce && inclusionType != InclusionTypes.Include);
 }
예제 #13
0
 public virtual LangElement Inclusion(Span span, bool conditional, InclusionTypes type, LangElement fileNameExpression)
 {
     return(new IncludingEx(conditional, span, type, (Expression)fileNameExpression));
 }
예제 #14
0
 /// <summary>
 /// Returns whether a specified inclusion is "once-inclusion".
 /// </summary>
 public static bool IsOnceInclusion(InclusionTypes inclusionType)
 {
     return(inclusionType == InclusionTypes.IncludeOnce || inclusionType == InclusionTypes.RequireOnce);
 }
예제 #15
0
        public bool StaticInclude(int level, string relativeSourcePath, RuntimeTypeHandle includee, InclusionTypes inclusionType)
        {
            ApplicationConfiguration app_config = Configuration.Application;

            var included_full_path =
                //PhpSourceFile source_file = new PhpSourceFile(
                //	app_config.Compiler.SourceRoot,
                new FullPath(app_config.Compiler.SourceRoot, new RelativePath((sbyte)level, relativeSourcePath));

            //);

            if (scripts.ContainsKey(included_full_path.ToString()))
            {
                // the script has been included => returns whether it should be included again:
                return(!InclusionTypesEnum.IsOnceInclusion(inclusionType));
            }
            else
            {
                // the script has not been included yet:
                scripts.Add(included_full_path.ToString(), new ScriptInfo(Type.GetTypeFromHandle(includee)));

                // the script should be included:
                return(true);
            }
        }
예제 #16
0
		public StaticInclusion(ScriptCompilationUnit/*!*/ includer, CompilationUnit/*!*/ includee, Scope scope,
			bool isConditional, InclusionTypes inclusionType)
		{
			this.scope = scope;
			this.inclusionType = inclusionType;
			this.includee = includee;
			this.includer = includer;
			this.isConditional = isConditional;
		}
예제 #17
0
 public static AccessControlList Create(string name, string description, AccessControlListTypes listType, InclusionTypes inclusionType, string tag)
 {
     return Create(name, description, listType, inclusionType, 0, tag);
 }
예제 #18
0
		public object DynamicInclude(
			string includedFilePath,
            string includerFileRelPath,//TODO: Now it's not relative because RelativePath class doesn't work properly with HTTP addresses
			Dictionary<string, object> variables,
			DObject self,
			DTypeDesc includer,
			InclusionTypes inclusionType)
		{
			ApplicationConfiguration app_config = Configuration.Application;

			// determines inclusion behavior:
			PhpError error_severity = InclusionTypesEnum.IsMustInclusion(inclusionType) ? PhpError.Error : PhpError.Warning;
			bool once = InclusionTypesEnum.IsOnceInclusion(inclusionType);


            System.Threading.AutoResetEvent downloadFinished = null;
            string eval = string.Empty;

            downloadFinished = new System.Threading.AutoResetEvent(false);
             
            WebClient webclient = new WebClient();
            webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(
                delegate(object sender, DownloadStringCompletedEventArgs downEventArgs)
                {
                    if (downEventArgs.Error == null)
                    {
                        eval = downEventArgs.Result;

                        // workaround for Firefox BrowserHttpWebRequest bug - 
                        // assuming that we're downloading PHP source starting with '<?' 
                        int srcStart = 0;
                        while ( !(eval[srcStart] == '<' && eval[srcStart + 1] == '?') && (srcStart+1 < eval.Length)  ) srcStart++;
                        eval = eval.Substring(srcStart);

                        downloadFinished.Set();
                    }
                }
                );

            Uri baseUri = new Uri(app_config.Compiler.SourceRoot+"/", UriKind.Absolute);
            Uri uriFile = new Uri(includedFilePath, UriKind.RelativeOrAbsolute);
            Uri uri = new Uri(baseUri, uriFile);

            webclient.DownloadStringAsync(uri);

            ThreadStart ts = new ThreadStart(()=>{
                    downloadFinished.WaitOne();

                    try
                    {
                        DynamicCode.EvalFile(eval, ScriptContext.CurrentContext, variables, self, null, includedFilePath, 0, 0, -1);
                    }
                    catch (Exception ex)
                    {
                        var canvas = ((ClrObject)ScriptContext.CurrentContext.AutoGlobals.Canvas.Value).RealObject as System.Windows.Controls.Canvas;

                        canvas.Dispatcher.BeginInvoke(() =>
                        {
                            throw ex;
                        });
                    }
  

                });

            if (inclusionType == InclusionTypes.RunSilverlight) // new thread have to be created
                new Thread(ts).Start();
            else
            {
                ts(); // just continue on this thread
            }

            return null;
		}
예제 #19
0
 public static AccessControlList Create(string name, string description, AccessControlListTypes listType, InclusionTypes inclusionType, int access, string tag)
 {
     AccessControlList list2;
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         System.Guid guid = System.Guid.NewGuid();
         if (new QuazalQuery("CreateACL", new object[] { guid, name, description, (int) listType, (int) inclusionType, access, tag }).ExecuteNonQuery())
         {
             AccessControlList list = new QuazalQuery("GetACLByGuid", new object[] { guid }).GetObject<AccessControlList>();
             DateTime now = DateTime.Now;
             while (list == null)
             {
                 Thread.Sleep(50);
                 list = new QuazalQuery("GetACLByGuid", new object[] { guid }).GetObject<AccessControlList>();
                 if ((DateTime.Now - now) > TimeSpan.FromSeconds(5.0))
                 {
                     break;
                 }
             }
             if (list != null)
             {
                 All.Add(list.ID, list);
             }
             return list;
         }
         list2 = null;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
     return list2;
 }
예제 #20
0
		public object DynamicInclude(
			string includedFilePath,
			string includerFileRelPath,
			Dictionary<string, object> variables,
			DObject self,
			DTypeDesc includer,
			InclusionTypes inclusionType)
		{
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                // Fix for absolute-path-includes on Unix filesystems.
                // Example: include_once('/path/app\libs\include.php')
                // HACK: Translate "\" to "/"
                includerFileRelPath = includerFileRelPath.Replace('\\', '/');
            }

			ApplicationConfiguration app_config = Configuration.Application;

			// determines inclusion behavior:
			FullPath includer_full_path = new FullPath(includerFileRelPath, app_config.Compiler.SourceRoot);

			// searches for file:
			FullPath included_full_path = SearchForIncludedFile(
                InclusionTypesEnum.IsMustInclusion(inclusionType) ? PhpError.Error : PhpError.Warning,
                includedFilePath, includer_full_path);

			if (included_full_path.IsEmpty) return false;

			ScriptInfo info;
            bool already_included = scripts.TryGetValue(included_full_path.ToString(), out info);

			// skips inclusion if script has already been included and inclusion's type is "once":
            if (already_included && InclusionTypesEnum.IsOnceInclusion(inclusionType))
				return ScriptModule.SkippedIncludeReturnValue;

			if (!already_included)
			{
				// loads script type:
                info = LoadDynamicScriptType(new PhpSourceFile(app_config.Compiler.SourceRoot, included_full_path));

				// script not found:
				if (info == null) return false;

				// adds included file into the script list
                scripts.Add(included_full_path.ToString(), info/* = new ScriptInfo(script)*/);
			}

			return info.Main(this, variables, self, includer, false);
		}
예제 #21
0
 public override LangElement Inclusion(Span span, bool conditional, InclusionTypes type, LangElement fileNameExpression)
 => CountLE(base.Inclusion(span, conditional, type, fileNameExpression));