working on it ...

Filters

Explore Public Snippets

Sort by

Found 7,633 snippets matching: protect

    public by AysadKozanoglu modified Sep 12, 2016  128606  1  2  0

    request flood protection rate limiting nginx

    request flood protection rate limiting nginx: nginx-rate_limit_flood_protect.conf
    # To enable rate limiting simply add the following line to the top-level of your config file:
    
    # 1 request / second
    limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s;
    
    # Then apply it to a location by adding a rate  limiting burst to your server block:
    
    location /account/login/ {
        # apply rate limiting
        limit_req zone=login burst=5;
    
        # boilerplate copied from location /
        proxy_pass http://myapp;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
    }
    
    
    

    public by johansonkatherine modified Jun 19, 2014  2851  3  6  1

    PHP Code to Protect a Word Document Using Aspose for Cloud API

    The following technical tip shows how php developers can protect their word documents in cloud using Aspose for Cloud SDK in php.
    use Aspose\Cloud\Common\AsposeApp;
    use Aspose\Cloud\Common\Product;
    use Aspose\Cloud\Common\Utils;
    use Aspose\Cloud\Words\Document;
    
    /**** Section 1 ****/
    Product::$baseProductUri = 'http://api.aspose.com/v1.1';
    AsposeApp::$appSID = "xxxxxxxxxxxxxxxxxxxxxxxx";
    AsposeApp::$appKey = "xxxxxxxxxxxxxxxxxxxxxxxx";
    AsposeApp::$outPutLocation = getcwd() . "/output/";
    /**** End Section 1 ****/
    
    /**** Section 2 ****/
    $fileName = "Test.docx";
    $password = "123456";
    $protectionType = "AllowOnlyComments";
    
    $doc = new Document($fileName);
    $result = $doc->protectDocument($password, $protectionType);
    /**** End Section 2 ****/
    			

    public by msdn modified Jan 12, 2015  1057  0  7  0

    Protect

    using System;
    using System.Security.Cryptography;
    using System.Text;
    
    public static string Protect(this string sourceString)
    {
        var sourceBytes = Encoding.Unicode.GetBytes(sourceString);
    
        var encryptedBytes = ProtectedData.Protect(sourceBytes, null, DataProtectionScope.CurrentUser);
    
        return Convert.ToBase64String(encryptedBytes);
    }

    public by msdn modified Jan 12, 2015  753  0  5  0

    UpdateServiceKey: Update the service key value and the protection password.

    Update the service key value and the protection password.
    /// <summary>
    /// Update the service key value and the protection password.
    /// </summary>
    private static void UpdateServiceKey(string displayName, byte[] keyValue, string protectionPassword, ServiceKeyType keyType)
    {
        UTF8Encoding enc = new UTF8Encoding();
        ManagementService svc = ManagementServiceHelper.CreateManagementServiceClient();
    
        ServiceKey serviceKey = svc.ServiceKeys.Where(sk => sk.DisplayName == displayName && sk.Type == keyType.ToString()).First();
    
        serviceKey.Value = keyValue;
        serviceKey.Password = string.IsNullOrEmpty(protectionPassword) ? null : enc.GetBytes(protectionPassword);
    
        svc.UpdateObject(serviceKey);
        svc.SaveChangesBatch();
    }

    public by msdn modified Jan 12, 2015  1132  0  6  0

    GenerateSelfSignedToken: Generates a JWT token for the given tenant, scope

    Generates a JWT token for the given tenant, scope Issuer App principal id. Tenant context id. Service host name Principal id of the protected resource or audience Not valid before time. Token validity duration. A JWT token initialized with the basic claims.
    /// <summary>
    /// Generates a JWT token for the given tenant, scope
    /// </summary>
    /// <param name="issuerPrincipalId">Issuer App principal id.</param>
    /// <param name="tenantRealm">Tenant context id.</param>
    /// <param name="audienceHostName">Service host name</param>
    /// <param name="audiencePrincipalId">Principal id of the protected resource or audience</param>
    /// <param name="nbfTime">Not valid before time.</param>
    /// <param name="validityInSeconds">Token validity duration.</param>
    /// <returns>A JWT token initialized with the basic claims.</returns>
    public static JsonWebToken GenerateSelfSignedToken(
        string issuerPrincipalId,
        string tenantRealm,
        string audienceHostName,
        string audiencePrincipalId,
        DateTime nbfTime,
        long validityInSeconds)
    {
        string issuer = JWTTokenHelper.GetFormattedPrincipal(issuerPrincipalId, string.Empty, tenantRealm);
        string audience = JWTTokenHelper.GetFormattedPrincipal(audiencePrincipalId, audienceHostName, tenantRealm);
        DateTime expirationTime = DateTime.Now.ToUniversalTime().AddSeconds(validityInSeconds);
        return new JsonWebToken(issuer, audience, nbfTime, expirationTime);
    }

    public by msdn modified Jan 12, 2015  990  0  5  0

    IngestSingleMP4File: Uploads a single file.

    Uploads a single file. The location of the files. You can specify the following encryption options for the AssetCreationOptions. None: no encryption. StorageEncrypted: storage encryption. Encrypts a clear input file before it is uploaded to Azure storage. CommonEncryptionProtected: for Common Encryption Prote
    using Microsoft.WindowsAzure.MediaServices.Client;
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Xml.Linq;
    
    private static CloudMediaContext _context = null;
    
    /// <summary>
    /// Uploads a single file.
    /// </summary>
    /// <param name="fileDir">The location of the files.</param>
    /// <param name="assetCreationOptions">
    ///  You can specify the following encryption options for the AssetCreationOptions.
    ///      None:  no encryption.  
    ///      StorageEncrypted: storage encryption. Encrypts a clear input file 
    ///        before it is uploaded to Azure storage. 
    ///      CommonEncryptionProtected: for Common Encryption Protected (CENC) files. 
    ///        For example, a set of files that are already PlayReady encrypted. 
    ///      EnvelopeEncryptionProtected: for HLS with AES encryption files.
    ///        NOTE: The files must have been encoded and encrypted by Transform Manager. 
    ///     </param>
    /// <returns>Returns an asset that contains a single file.</returns>
    /// </summary>
    /// <returns></returns>
    private static IAsset IngestSingleMP4File(string fileDir, AssetCreationOptions assetCreationOptions)
    {
        // Use the SDK extension method to create a new asset by 
        // uploading a mezzanine file from a local path.
        IAsset asset = _context.Assets.CreateFromFile(
            fileDir,
            assetCreationOptions,
            (af, p) =>
            {
                Console.WriteLine("Uploading '{0}' - Progress: {1:0.##}%", af.Name, p.Progress);
            });
     
    
        return asset;
    
    }

    public by msdn modified Jan 9, 2015  925  0  6  0

    ConvertToDisplayDateTime

    //protected void setPassword_Click(object sender, EventArgs e) //{ // if (IsValid) // { // var result = OpenAuth.AddLocalPassword(User.Identity.Name, password.Text); // if (result.IsSuccessful) // { // Response.Redirect("~/Account/Manage.aspx?m=SetPwdSuccess"); // } // else // {
    //protected void setPassword_Click(object sender, EventArgs e)
    //{
    //    if (IsValid)
    //    {
    //        var result = OpenAuth.AddLocalPassword(User.Identity.Name, password.Text);
    //        if (result.IsSuccessful)
    //        {
    //            Response.Redirect("~/Account/Manage.aspx?m=SetPwdSuccess");
    //        }
    //        else
    //        {
    
    //            ModelState.AddModelError("NewPassword", result.ErrorMessage);
    
    //        }
    //    }
    //}
    
    //public IEnumerable<OpenAuthAccountData> GetExternalLogins()
    //{
    //    var accounts = OpenAuth.GetAccountsForUser(User.Identity.Name);
    //    CanRemoveExternalLogins = CanRemoveExternalLogins || accounts.Count() > 1;
    //    return accounts;
    //}
    
    //public void RemoveExternalLogin(string providerName, string providerUserId)
    //{
    //    var m = OpenAuth.DeleteAccount(User.Identity.Name, providerName, providerUserId)
    //        ? "?m=RemoveLoginSuccess"
    //        : String.Empty;
    //    Response.Redirect("~/Account/Manage.aspx" + m);
    //}
    
    
    protected static string ConvertToDisplayDateTime(DateTime? utcDateTime)
    {
        // You can change this method to convert the UTC date time into the desired display
        // offset and format. Here we're converting it to the server timezone and formatting
        // as a short date and a long time string, using the current thread culture.
        return utcDateTime.HasValue ? utcDateTime.Value.ToLocalTime().ToString("G") : "[never]";
    }

    public by msdn modified Jan 12, 2015  875  0  5  0

    IngestMultipleFiles: Uploads multiple files. If the set of files contains an .ism file, sets it as a primary.

    Uploads multiple files. If the set of files contains an .ism file, sets it as a primary. The location of the files. You can specify the following encryption options for the AssetCreationOptions. None: no encryption. StorageEncrypted: storage encryption. Encrypts a clear input file before it is uploaded to Azure st
    using Microsoft.WindowsAzure.MediaServices.Client;
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading;
    using System.Threading.Tasks;
    using System.Xml.Linq;
    
    private static CloudMediaContext _context = null;
    
    /// <summary>
    /// Uploads multiple files. If the set of files contains an .ism file, 
    /// sets it as a primary.
    /// </summary>
    /// <param name="multiFileDir">The location of the files.</param>
    /// <param name="assetCreationOptions">
    ///  You can specify the following encryption options for the AssetCreationOptions.
    ///      None:  no encryption.  
    ///      StorageEncrypted: storage encryption. Encrypts a clear input file 
    ///        before it is uploaded to Azure storage. 
    ///      CommonEncryptionProtected: for Common Encryption Protected (CENC) files. 
    ///        For example, a set of files that are already PlayReady encrypted. 
    ///      EnvelopeEncryptionProtected: for HLS with AES encryption files.
    ///        NOTE: The files must have been encoded and encrypted by Transform Manager. 
    ///     </param>
    /// <returns></returns>
    private static IAsset IngestMultipleFiles(string multiFileDir, AssetCreationOptions assetCreationOptions)
    {
        // Use the SDK extension method to create a new asset by 
        // uploading files from a local directory.
        IAsset asset = _context.Assets.CreateFromFolder(
            multiFileDir,
            assetCreationOptions,
            (af, p) =>
            {
                Console.WriteLine("Uploading '{0}' - Progress: {1:0.##}%", af.Name, p.Progress);
            });            
    
        return asset;
    }

    external by eighty20results modified Mar 26, 2016  200  0  2  0

    Protect all child pages of a page protected by the "Protect Add-on Pages" add-on

    Protect all child pages of a page protected by the "Protect Add-on Pages" add-on: pmpro-apply-addon-access-to-all-child-pages.php
    <?php
    /*
    Plugin Name: PMPro Protect Child Pages
    Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
    Description: Apply protection to all child pages of a Add-on Page that's protected.
    Version: .1
    Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
    Author URI: https://eighty20results.com/thomas-sjolshagen/
    */
    /**
     * Apply protection of parent page to child pages.
     *
     * @param $hasaccess
     * @param $thepost
     * @param $theuser
     * @param $post_membership_levels
     * @return bool
     *
     * @since v.1
     */
    function hide_child_posts( $hasaccess, $thepost, $theuser, $post_membership_levels)
    {
        global $wpdb;
        global $pmpro_inaccessible_parent;
        global $pmpro_pages;
    
        if (in_array($thepost->ID, $pmpro_pages)) {
            return $hasaccess;
        }
    
        $pmpro_inaccessible_parent = null;
    
        //if PMPro says false already, return false
        if (!$hasaccess)
            return false;
    
        //if PMPro Addon Packages is not installed, return
        if (!function_exists('pmproap_hasAccess'))
            return $hasaccess;
    
        // this post/page doesn't have a parent so nothing to check.
        if (empty( $thepost->post_parent ) ) {
            return $hasaccess;
        }
    
        if ( ! pmproap_hasAccess($theuser->ID, $thepost->post_parent) ) {
            $pmpro_inaccessible_parent = $thepost->post_parent;
            $hasaccess = false;
        }
    
        return $hasaccess;
    }
    add_filter("pmpro_has_membership_access_filter", "hide_child_posts", 10, 4);
    
    /**
     * Show a link to checkout for the addon package for child-posts of a Add-on protected parent page
     * @param $text
     * @return string
     */
    function pmproap_pmpro_text_filter_for_child_posts($text)
    {
        global $wpdb, $current_user, $post, $pmpro_currency_symbol;
        global $pmpro_inaccessible_parent;
        global $pmpro_pages;
    
        if (empty($post->post_parent) || ( !empty($post->post_parent) && in_array( $post->post_parent, $pmpro_pages) )) {
            error_log("No parent post configured, so exiting");
            return $text;
        }
    
        if ( ! pmproap_hasAccess($current_user->ID, $post->post_parent) ) {
    
            //which level to use for checkout link?
            $text_level_id = pmproap_getLevelIDForCheckoutLink($post->post_parent, $current_user->ID);
    
            //what's the price
            $pmproap_price = get_post_meta($post->post_parent, "_pmproap_price", true);
    
            //check for all access levels
            $all_access_levels = apply_filters("pmproap_all_access_levels", array(), $current_user->ID, $post->post_parent);
    
                //update text
            if (!empty($all_access_levels)) {
                $level_names = array();
                foreach ($all_access_levels as $level_id) {
                    $level = pmpro_getLevel($level_id);
                    $level_names[] = $level->name;
                }
    
                error_log("Set additional access text for all access levels");
                $text = "<p>This content requires that you purchase additional access. The price is " . $pmpro_currency_symbol . $pmproap_price . " or free for our " . pmpro_implodeToEnglish($level_names) . " members.</p>";
                $text .= "<p><a href=\"" . pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->post_parent) . "\">Purchase this Content (" . pmpro_formatPrice($pmproap_price) . ")</a> <a href=\"" . pmpro_url("levels") . "\">Choose a Membership Level</a></p>";
            } elseif( !empty($text_level_id)) {
                error_log("Set additional access text for all level: {$text_level_id}");
                $text = "<p>This content requires that you purchase additional access. The price is " . pmpro_formatPrice($pmproap_price) . ".</p>";
                $text .= "<p><a href=\"" . pmpro_url("checkout", "?level=" . $text_level_id . "&ap=" . $post->post_parent) . "\">Click here to checkout</a></p>";
            }
        }
    
        return $text;
    }
    add_filter("pmpro_non_member_text_filter", "pmproap_pmpro_text_filter_for_child_posts", 15);
    add_filter("pmpro_not_logged_in_text_filter", "pmproap_pmpro_text_filter_for_child_posts", 15);
    
    
    

    external by Github modified Feb 20, 2016  11  0  1  0

    How long have you lived here? <a href=" http://www.ocmedicare.com/ranitidine-omeprazole-comparison.pptx ">prilosec 20 mg twice a day</a> A quarter-inch of armor plate protecting the base of the vehicle and other safety features helped protect the car ...

    How long have you lived here? prilosec 20 mg twice a day A quarter-inch of armor plate protecting the base of the vehicle and other safety features helped protect the car and stopped the fire from spreading quickly, Musk added in his defense of electric car technology. : Eduardo
    How long have you lived here? <a href=" http://www.ocmedicare.com/ranitidine-omeprazole-comparison.pptx ">prilosec 20 mg twice a day</a>  A quarter-inch of armor plate protecting the base of the vehicle and other safety features helped protect the car and stopped the fire from spreading quickly, Musk added in his defense of electric car technology.
     
    
    
    • Public Snippets
    • Channels Snippets