Esempio n. 1
0
        /// <summary>
        /// Registers a resource that should be disposed of when the request is over.
        /// </summary>
        /// <param name="res">The resource.</param>
        internal static LinkedListNode<WeakReference> RegisterResource(PhpResource/*!*/res)
        {
            Debug.Assert(res != null);
            //Debug.Assert(this method can only be called on the request thread)

            return StaticInfo.Get.Resources.AddFirst(new WeakReference(res));
        }
Esempio n. 2
0
		internal static PhpSqlDbProcedure ValidProcedure(PhpResource handle)
		{
			PhpSqlDbProcedure result = handle as PhpSqlDbProcedure;
			if (result != null && result.IsValid) return result;

			PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_stored_procedure_resource"));
			return null;
		}
Esempio n. 3
0
		internal static PhpSqlDbResult ValidResult(PhpResource handle)
		{
			PhpSqlDbResult result = handle as PhpSqlDbResult;
			if (result != null && result.IsValid) return result;

			PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_result_resource"));
			return null;
		}
Esempio n. 4
0
 public static void Close(PhpResource linkIdentifier)
 {
     PhpSQLiteDbConnection connection = PhpSQLiteDbConnection.ValidConnection(linkIdentifier);
     if (connection != null)
     {
         connection.Close();
     }
 }
Esempio n. 5
0
		/// <summary>
		/// Validates whether the specified handler is instance of PhpDbConnection type.
		/// </summary>
		/// <param name="handle"></param>
		/// <returns></returns>
		internal static PhpSqlDbConnection ValidConnection(PhpResource handle)
		{
			PhpSqlDbConnection connection = handle as PhpSqlDbConnection;
			if (connection != null && connection.IsValid) return connection;

			PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_connection_resource"));
			return null;
		}
Esempio n. 6
0
        public static void Close(PhpResource ch)
        {
            PhpCurlResource curlHandle = ch as PhpCurlResource;

            if (curlHandle == null)
                return;

            curlHandle.Close();
        }
Esempio n. 7
0
		/// <summary>
		/// Registers a resource that should be disposed of when the request is over.
		/// </summary>
		/// <param name="res">The resource.</param>
		internal LinkedListNode<PhpResource> RegisterResource(PhpResource/*!*/res)
		{
            Debug.Assert(res != null);

            if (resources == null)
                resources = new LinkedList<PhpResource>();

            return resources.AddFirst(res);
		}
Esempio n. 8
0
        /// <summary>
        /// Registers a resource that should be disposed of when the request is over.
        /// </summary>
        /// <param name="res">The resource.</param>
        internal static LinkedListNode<PhpResource> RegisterResource(PhpResource/*!*/res)
        {
            Debug.Assert(res != null);
            //Debug.Assert(this method can only be called on the request thread)

            if (resources == null)
                resources = new LinkedList<PhpResource>();

            return resources.AddFirst(res);
        }
Esempio n. 9
0
        public static object Errno(PhpResource ch)
        {
            //PhpException.FunctionNotSupported(PhpError.Warning);

            PhpCurlResource curlHandle = ch as PhpCurlResource;

            if (curlHandle == null)
                return null;

            return (int)curlHandle.ErrorCode;

        }
Esempio n. 10
0
 public object __construct(ScriptContext context, object argFileName, object argMode, object error)
 {
     string filename = PHP.Core.Convert.ObjectToString(argFileName);
     int mode = PHP.Core.Convert.ObjectToInteger(argMode);
     if (mode == 0)
     {
         mode = SQLite.DEFAULT_FILE_MODE;
     }
     this.m_filename = filename;
     this.m_con = SQLite.Open(this.m_filename, mode, error as PhpReference);
     return null;
 }
Esempio n. 11
0
		internal static PhpProcessHandle Validate(PhpResource resource)
		{
			PhpProcessHandle result = resource as PhpProcessHandle;

			if (result == null || !result.IsValid)
			{
				PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_process_resource"));
				return null;
			}

			return result;
		}
Esempio n. 12
0
        internal static PhpSQLiteDbConnection ValidConnection(PhpResource handle)
        {
            PhpSQLiteDbConnection connection;

            if (handle != null && handle.GetType() == typeof(PhpSQLiteDbConnection))
                connection = (PhpSQLiteDbConnection)handle;
            else
                connection = null;

            if (connection != null && connection.IsValid)
                return connection;

            PhpException.Throw(PhpError.Warning, LibResources.GetString("invalid_connection_resource"));
            return null;
        }
Esempio n. 13
0
		public static string ReceiveFrom(PhpResource socket, int length, SendReceiveOptions flags,
		  out string address)
		{
			address = null;

			SocketStream stream = SocketStream.GetValid(socket);
			if (stream == null) return null;

			PhpException.FunctionNotSupported();
			return null;
		}
Esempio n. 14
0
		public static string ReceiveFrom(PhpResource socket, int length, SendReceiveOptions flags)
		{
			string address;
			return ReceiveFrom(socket, length, flags, out address);
		}
Esempio n. 15
0
		public static bool Accept(PhpResource serverSocket, int timeout, out string peerName)
		{
			peerName = "";

			SocketStream stream = SocketStream.GetValid(serverSocket);
			if (stream == null) return false;

			PhpException.FunctionNotSupported();
			return false;
		}
Esempio n. 16
0
		public static bool Accept(PhpResource serverSocket, int timeout)
		{
			string peerName;
			return Accept(serverSocket, timeout, out peerName);
		}
Esempio n. 17
0
		public static bool Accept(PhpResource serverSocket)
		{
			string peerName;
			return Accept(serverSocket, Configuration.Local.FileSystem.DefaultSocketTimeout, out peerName);
		}
Esempio n. 18
0
		public static PhpResource ConnectServer(string localSocket, out int errno, out string errstr,
		  double timeout, SocketOptions flags, PhpResource context)
		{
			StreamContext sc = StreamContext.GetValid(context);
			if (sc == null)
			{
				errno = -1;
				errstr = null;
				return null;
			}

			int port;
			SplitSocketAddressPort(ref localSocket, out port);
			return Connect(localSocket, port, out errno, out errstr, timeout, flags, sc);
		}
Esempio n. 19
0
		public static string SocketGetName(PhpResource handle, bool wantPeer)
		{
			PhpException.FunctionNotSupported();
			return null;
		}
Esempio n. 20
0
 public static void SetStreamContexts(PhpResource streams_context)
 {
 }
Esempio n. 21
0
		public static bool SetBlocking(PhpResource stream, int mode)
		{
			return PhpStreams.SetBlocking(stream, mode);
		}
Esempio n. 22
0
        internal static XmlParserResource ValidResource(PhpResource handle)
        {
            if (handle != null && handle.GetType() == typeof(XmlParserResource))
                return (XmlParserResource)handle;

            PhpException.Throw(PhpError.Warning, Strings.invalid_xmlresource);
            return null;
        }
Esempio n. 23
0
		public static int SendTo(PhpResource socket, string data, SendReceiveOptions flags)
		{
			return SendTo(socket, data, flags, null);
		}
Esempio n. 24
0
		public static int SendTo(PhpResource socket, string data, SendReceiveOptions flags,
		  string address)
		{
			SocketStream stream = SocketStream.GetValid(socket);
			if (stream == null) return -1;

			PhpException.FunctionNotSupported();
			return -1;
		}
Esempio n. 25
0
        private static bool CopyImageTransparent(PhpResource dst_im, PhpResource src_im,
            int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct)
        {
            PhpGdImageResource dst_img = PhpGdImageResource.ValidImage(dst_im);
            if (dst_img == null)
                return false;

            PhpGdImageResource src_img = PhpGdImageResource.ValidImage(src_im);
            if (src_img == null)
                return false;

            if (pct <= 0 || src_w <= 0 || src_h <= 0)
                return true;

            ImageAttributes ia = null;

            if (pct < 100)
            {
                // prepare transformation matrix if needed
                ColorMatrix cm = new ColorMatrix();
                cm.Matrix00 = cm.Matrix11 = cm.Matrix22 = cm.Matrix44 = 1.0f;
                cm.Matrix33 = (float)pct * 0.01f;

                ia = new ImageAttributes();
                ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
            }

            try
            {
                // draw the image
                using (Graphics g = Graphics.FromImage(dst_img.Image))
                {
                    g.DrawImage(src_img.Image,
                        new Rectangle(dst_x, dst_y, src_w, src_h),
                        src_x, src_y, src_w, src_h,
                        GraphicsUnit.Pixel, ia);
                }
            }
            catch (Exception ex)
            {
                // output the warning
                PhpException.Throw(PhpError.Warning, ex.Message);
                return false;
            }
            finally
            {
                if (ia != null)
                {
                    ia.Dispose();
                    ia = null;
                }
            }

            return true;
        }
Esempio n. 26
0
		public static PhpArray GetStatus(PhpResource stream)
		{
			return PhpStreams.GetMetaData(stream);
		}
Esempio n. 27
0
 public static bool imagecopymergegray(PhpResource src_im, PhpResource dst_im,
     int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h, int pct)
 {
     //PhpException.FunctionNotSupported(PhpError.Warning);
     return false;
 }
Esempio n. 28
0
		public static bool SetTimeout(PhpResource stream, int seconds, int microseconds)
		{
			return PhpStreams.SetTimeout(stream, seconds, microseconds);
		}
Esempio n. 29
0
 public static bool imagecopyresampled(PhpResource dst_im, PhpResource src_im,
     int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h)
 {
     return ImageCopyAndResize(dst_im, src_im, dst_x, dst_y, src_x, src_y, dst_w, dst_h,
         src_w, src_h, InterpolationMode.HighQualityBicubic);
 }
Esempio n. 30
0
		new public static SocketStream GetValid(PhpResource handle)
		{
			SocketStream result = handle as SocketStream;
			if (result == null)
				PhpException.Throw(PhpError.Warning, CoreResources.GetString("invalid_socket_stream_resource"));
			return result;
		}
Esempio n. 31
0
 /// <summary>
 /// Create a new instance of a given Type and Name.
 /// The instance Id is auto-incrementing starting from 1.
 /// </summary>
 /// <param name="resourceTypeName">The type to be reported to use when dumping a resource.</param>
 /// <param name="registerInReqContext">Whether to register this instance in current <see cref="RequestContext"/>. Should be <c>false</c> for static resources.</param>
 public PhpResource(String resourceTypeName, bool registerInReqContext)
     : this(PhpResource.RegisterInternalInstance(), resourceTypeName, registerInReqContext)
 {
 }