7 – Where do I check whether the logged-in user is administrator, moderator, or just an authenticated user?

I have two separate login pages for users and administrators: /users/login and backend/login.

I have created a new function in my custom theme.

  function customtheme_theme() {
    $items = array(); 
    $items('user_login') = array(
      'render element' => 'form',
      'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',
      'template' => 'user-login',
    );

    $items('user_pass') = array(
      'render element' => 'form',
      'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',
      'template' => 'user-pass',
    );

    return $items;
  }

In /sites/all/themes/customtheme/templates/user, I created 2 files, user-login.tpl.php and user-pass.tpl.php. In user-login.tpl.php, I put the following code.

<?php $login_form = drupal_get_form("user_login"); ?>

<?php print $messages; ?>

<input autocomplete="off" type="text" 
value="<?php echo $login_form('name')('#value'); ?>" 
id="<?php echo $login_form('name')('#id'); ?>" 
name="<?php echo $login_form('name')('#name'); ?>" 
placeholder="Enter your username" required="" 
oninvalid="this.setCustomValidity('Username id is required')" 
oninput="setCustomValidity('')"/>

// password field..
// actions ..

So, I used the same setup for the admin login as well.

I created a new template at /sites/all/themes/customtheme/templates/page/page–backend.tpl.php. In that page, I just rendered the user_login form.

$elements = drupal_get_form("user_login"); 
$form = drupal_render($elements);   
echo ($form);

Now, both pages are working fine, but I need to show some message saying you are not allowed here if normal users logged in through the backend form.

I am not able to figure out at which place/file/path I need to check for the user role and display the message (push to $messages).

authentication authorization – Where do I check whether logged in user in administrator, moderator or just authenticated user in Drupal 7?

I have 2 separate login pages for users and administrators userslogin and backendlogin.

I have created a new function in my custom theme as follows,

  function customtheme_theme() {

  $items = array(); 

  $items('user_login') = array(

    'render element' => 'form',

    'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',

    'template' => 'user-login',

  );

  $items('user_pass') = array(

    'render element' => 'form',

    'path' => drupal_get_path('theme', 'customtheme') . '/templates/user',

    'template' => 'user-pass',

  );

  return $items;
}

and in /sites/all/themes/customtheme/templates/user I have created 2 files, user-login.tpl.php and user-pass.tpl.php.

Now in the user-login.tpl.php, I have put the following code,

<?php $login_form = drupal_get_form("user_login"); ?>

<?php print $messages; ?>

<input autocomplete="off" type="text" 
value="<?php echo $login_form('name')('#value'); ?>" 
id="<?php echo $login_form('name')('#id'); ?>" 
name="<?php echo $login_form('name')('#name'); ?>" 
placeholder="Enter your username" required="" 
oninvalid="this.setCustomValidity('Username id is required')" 
oninput="setCustomValidity('')"/>

// password field..
// actions ..

So, I used the same setup for the admin login as well.

Created a new template at /sites/all/themes/customtheme/templates/page/page--backend.tpl.php

So in that page, I just called the user_loin form as below,

$elements = drupal_get_form("user_login"); 

$form = drupal_render($elements);   
echo ($form);

Now, both pages are working fine, But I need to show some message saying you are not allowed here if normal users logged in through backend form.

Am not able to figure out at which place/file/path I need to check for the user role and display the message(push to $mesages).

magento2 – Magento 2: Check if product has catalog rule applied to it

I’m very new to M2.

I have a block that is being added to front-end if there is no Mail In Rebate or Special Price applied to the product.

Class looks something like this:

<?php

declare(strict_types = 1);

namespace CompanyCatalogBlockProductView;

use MagentoCatalogBlockProductViewDescription;

class ListedPrice extends Description
{
    /**
     * @return bool
     */
    public function isListedPrice(): bool
    {
        $product = $this->getProduct();

        if ($product->getSpecialPrice() || $product->getMnlMailInRebate()) {
            return false;
        }

        return true;
    }
}

How can I add a check a product for Catalog Price rules?

We have a Group of customers that gets discounts based on Catalog Price rules and this block is being shown to them which destroys the layout.

Thanks in advance!

unity – How can I check if the text string is not equal and then to do something?

using UnityEngine;

public class DrawLines : MonoBehaviour
{
    public LineRenderer lineRenderer;
    public string text;

    private Vector3() positions;
    private string oldText;

    private void Start()
    {
        if (lineRenderer == null)
        {
            lineRenderer = GetComponent<LineRenderer>();

            lineRenderer.startWidth = 0.3f;
            lineRenderer.endWidth = 0.3f;
        }

        // 0,  0, 0
        // 5,  0, 0
        // 5, -5, 0
        // 0, -5, 0

        positions = new Vector3(5) { new Vector3(0, 0, 0), new Vector3(5, 0, 0),
            new Vector3(5, -5, 0), new Vector3(0, -5, 0), new Vector3(0, 0, 0)};
        DrawLine(positions, Color.red, 0.2f);
    }

    void DrawLine(Vector3() positions, Color color, float duration = 0.2f)
    {
        GameObject myLine = new GameObject();

        myLine.transform.position = positions(0);
        myLine.AddComponent<LineRenderer>();
        LineRenderer lr = myLine.GetComponent<LineRenderer>();
        lr.positionCount = positions.Length;
        lr.startColor = color;
        lr.endColor = color;
        lr.startWidth = 0.1f;
        lr.endWidth = 0.1f;
        lr.useWorldSpace = false;
        lr.SetPositions(positions);
    }

    void DrawText()
    {
        for (int i = 0; i < positions.Length; i++)
        {
            if (oldText != text)
            {
                var pos = Camera.main.WorldToScreenPoint(positions(i));
                text = positions(i).ToString();
                var textSize = GUI.skin.label.CalcSize(new GUIContent(text));
                GUI.contentColor = Color.red;
                GUI.Label(new Rect(pos.x, Screen.height - pos.y, textSize.x, textSize.y), text);
                GUI.contentColor = Color.green;
                GUI.Label(new Rect(pos.x, Screen.height - pos.y - 20, textSize.x, textSize.y), i.ToString());
            }
        }
    }

    private void OnGUI()
    {
        if (positions != null)
        {
            if (positions.Length > 0)
            {
                DrawText();
            }
        }
    }
}

I added oldText variable but not sure how use it more then I did so far.
I want that if the text is the same in the loop then don’t show this text not in red not in green.
Each time show the text once if it’s not equal.

penetration test – Tools that check TLS client side

They are not difficult to check, it’s just that TLS clients are lower priority to pentesters compared to servers. To check the client, e.g. for supported TLS versions, you would write a utility that starts the server with a TLS version (openssl s_server -accept 443 -tls1_1 -CAfile ca.pem -cert server.pem -key server.key), and examines traffic capture file for presence of “application data” string, which would indicate that the TLS handshake was a success.

[WTS] Super Fast Dedicated Server in Thailand, check thaihosting.asia special deals!

Thaihosting.asia is an IT service company and has since 1995 dealt with the Internet, operation and development. Our product areas include commercial web hosting, server hosting, domain registration, shopping systems, payment solutions, content management systems and IT outsourcing. Thaihosting.asia have always, and will always be known for service, quality and stability. It is our mission to provide quality services at reasonable prices, as well as provide our customers with a personal and unique service. We will not just be an anonymous supplier, but a professional partner.

Get a dedicated server in Thailand, hosted in a modern data center in Bangkok. Choose between Intel Core i3 and Xeon processors and get up to 32 GB of RAM – with no monthly traffic limit on your connection. We use the latest generation Supermicro hardware to deliver dedicated servers here in Thailand, which enables us to deliver dedicated servers with excellent performance and reliability. Bandwidth for our Thai servers is provided by a number of different domestic and international ISPs. This means you get a fast and stable connection 24/7. Our Danish and Thai team will help you get your Thai server up and running fast. We provide 24/7 support for all of our dedicated server products. Read more about our Hostingcenter in Bangkok.

Features of our Dedicated Servers in Thailand:

  • Supports all popular operating systems such as CentOS, Ubuntu, Debian and Windows
  • All Thai servers come with IPMI interface for remote management and console access
  • Directly connected to the biggest Thai ISPs for blazing fast national transfers
  • Full Root or Administrator access
  • Support is available 24/7 by chat and e-mail.
  • Gigabit Ethernet support


30-day money back guarantee on all Thai servers!

Server Thai Basic
฿3,900/ mo

Intel Core i3-6100 @ 3.70GHz 2 cores
100 Mbps network
1 TB SATA3 HD
Unlimited Bandwidth
8 GB RAM
Configure

Server Thai Business
฿4,900/ mo

Intel Xeon E3–1240v5 @ 3.50GHz 4 cores
100 Mbps network
2 TB SATA3 HD
Unlimited Bandwidth
16 GB RAM
Configure

Server Thai RAID
฿5,900/ mo

Intel Xeon E3–1240v5 @ 3.50GHz 4 cores
100 Mbps network
2×2 TB SATA3 HD
Unlimited Bandwidth
32 GB RAM
Configure

– Add 1 Extra IP Address for 150 Baht / month
– Upgrade to 1 Gbps shared line for 1,000 Baht / month

Strong hosting services in green data center:

  • Free support, daily backups and effective protection against viruses and spam.
  • We build your server, manage your IT and keeps technology running.

What you see above are the servers we always have in stock. However, should you have any special hardware requirements, you are more than welcome to Contact us. You can also catch us on the live chat (bottom of every page) around the clock. You are never alone if you choose Thaihosting.asia as your partner.

.(tagsToTranslate)webmaster forum(t)internet marketing(t)search engine optimization(t)web designing(t)seo(t)ppc(t)affiliate marketing(t)search engine marketing(t)web hosting(t)domain name(t)social media

performance – Is there any program to check how many my program eat resources?

Is there a program to check how my program is resource-hungry? It’s very simple, two loops with other functions inside. On my and my friends computers it works good, but I got info from other users they got frame-dropps while using my program. So, there is program to check how many resource my program eat on that low scale?