How to password protect (play password) a video file (a downloadable video file) on server side? [closed]

I want to set “PLAY PASSWORD” for a video file on server side of a website, so that a client after downloading video need to enter “play password” to play it every time. I emphasize that I dont mean “online video stream protection or set password for download link or encrypt a webpage! I want to lock video file with a password and client can download it but when plays video, need enter password. I dont know what to do and how to start so the key questions for me:
1- which server side language can I use PHP or PYTHON?
2- How can I do this.

<php?>
   # I just want help and dont know have an Idea what to do
<php>

Replace img tag with text

I have a text that contains html tags, such as:

    $html = '<td width="71%" valign="top"><img src="https://path/mobilPay.jpg" alt="" width="100%" border="0" style="display:block" /></td><td width="15%"><img src="https://path/mobilPay2.jpg" alt="" width="100%" border="0" style="display:block" /><img src="https://path/mobilPay.jpg" alt="" width="100%" border="0" style="display:block"/></td>';
preg_match_all('/<img[^>]+>/i',$html, $imgTags); 


   for ($i = 0; $i < count($imgTags[0]); $i++) {
          // get the source string
          preg_match('/src="([^"]+)/i',$imgTags[0][$i], $imgage);
      
          // remove opening 'src=' tag, can`t get the regex right
          $origImageSrc[] = str_ireplace( 'src="', '',  $imgage[0]);
        }
//echo '<pre>';
print_r($origImageSrc);
//echo '</pre>';

In $origImageSrc are returned all the src from all tags.
I want to replace the tag containing a src with a specific text (for all src=”https://path/mobilPay.jpg” I need TEXT1, for src=”https://path/mobilPay2.jpg” i need TEXT2).

For example, I want to display something like:

<td width="71%" valign="top">TEXT1</td><td width="15%">TEXT2 TEXT1</td>

In $imgTags are returned the tags, but not with the proper termination ( > instead of />, or it can be a space before /> ), therefore I cannot use that array.

Please help! How can I replace the whole tag with a specific text ?

Cannot modify header information in functions.php for wp_list_comments()

In comments.php I use wp_list_comments() and in callback I refrence a function called ‘aseman_list_comments’ that I created in functions.php and I just copy – paste the code that are in [https://developer.wordpress.org/reference/functions/wp_list_comments/]

function aseman_list_comments($comment, $args, $depth) {
    if ( 'div' === $args['style'] ) {
        $tag       = 'div';
        $add_below = 'comment';
    } else {
        $tag       = 'li';
        $add_below = 'div-comment';
    }?>
    <<?php echo $tag; ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ); ?> id="comment-<?php comment_ID() ?>"><?php 
    if ( 'div' != $args['style'] ) { ?>
        <div id="div-comment-<?php comment_ID() ?>" class="comment-body"><?php
    } ?>
        <div class="comment-author vcard"><?php 
            if ( $args['avatar_size'] != 0 ) {
                echo get_avatar( $comment, $args['avatar_size'] ); 
            } 
            printf( __( '<cite class="fn">%s</cite> <span class="says">says:</span>' ), get_comment_author_link() ); ?>
        </div><?php 
        if ( $comment->comment_approved == '0' ) { ?>
            <em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em><br/><?php 
        } ?>
        <div class="comment-meta commentmetadata">
            <a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"><?php
                /* translators: 1: date, 2: time */
                printf( 
                    __('%1$s at %2$s'), 
                    get_comment_date(),  
                    get_comment_time() 
                ); ?>
            </a><?php 
            edit_comment_link( __( '(Edit)' ), '  ', '' ); ?>
        </div>

        <?php comment_text(); ?>

        <div class="reply"><?php 
                comment_reply_link( 
                    array_merge( 
                        $args, 
                        array( 
                            'add_below' => $add_below, 
                            'depth'     => $depth, 
                            'max_depth' => $args['max_depth'] 
                        ) 
                    ) 
                ); ?>
        </div><?php 
    if ( 'div' != $args['style'] ) : ?>
        </div><?php 
    endif;
}

I just change function name 😉

I works great on comment section but in admin dashboard I get some errors:

“Cannot modify header information – headers already sent by….. “

I know what the problem is for:

<<?php echo $tag; ?> 

is not closed before the final }.
if I use

</<?= $tag; ?>> 

before the final } errors gone but commnet structure is mess up

How can I fix this problem?

Trying to send mails from a php script with PHPMailer and using outlook / SMTP

I’m currently working on a script in php for sending emails via outlook SMTP .
I am using PHPMailer

exemple :

use PHPMailerPHPMailerPHPMailer;

require './vendor/autoload.php';
$mail = new PHPMailer(true);
try {
    $mail->isSMTP();
    $mail->Host = "smtp.live.com"; // smtp.office365.com doesn't work as well
    $mail->SMTPAuth = true;
    $mail->Username = "myoutlook365Email";
    $mail->Password = "xxx";
    $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
    $mail->Port = 587; 
    $mail->setFrom('myoutlook365Email', 'My name');
    $mail->addAddress('[email protected]', 'test');
    $mail->isHTML(true);
    $mail->Subject = 'Subject';
    $mail->Body = 'Body';
    $mail->AltBody = 'AltBody';

    $mail->send();

} catch (Exception $e) {
    echo 'Can't send.' . $mail->ErrorInfo;

The error : SMTP Error: Could not connect to SMTP host. Failed to connect to serverSMTP server error: Failed to connect to server SMTP code: 10060 Additional SMTP info

When I try with google and gmail smtp / email the error :
SMTP Error: Could not authenticate.

I’m sure this is the good password and email. I tried to allow less secure apps but it is not available anymore.

What can I do ?
Am I doing something wrong ?

I tried to send mail with Outlook SMTP. But it always result in an error

How detect Encrypted String?

I received many password from a data base in a php script.
I don’t know if received password is encrypted or not.

To use data i have to decrypt the encrypted pass and let pass in clear format the clear password.
But how can i detect encrypted string?

(i know the ciphering, decryption_iv, decryption_key.)
Thank you for your advice.

An Internal Error has Occured. Please report following error to the webmaster [closed]

I am working in a PHP Script where a Form is submitted in same file. I am using Linux Mint Operating System. My Script is like below.

<?php

require_once "../codelibrary/inc/variables.php";
require_once "../codelibrary/inc/functions.php";
?>
<!doctype html>
<!--[if lte IE 9]> <html class="lte-ie9" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en"> <!--<![endif]-->

<head>
    <?php

    if (!isset($_SESSION['num1']) && !isset($_SESSION['num2'])) {
        $_SESSION['num1'] = rand(1, 5);
        $_SESSION['num2'] = rand(1, 5);
    }

    if (!empty($_SESSION['boat_admin_id'])) {
        //   header("location:dashboard.php");
        header("location:main_courses.php");
    }

    if (1 == $submitfrm) {
        $techfetch  = mysql_query_db("select * from tbl_teacher where email='$username' and password='$password' and status=1");
        $ntectfetch = mysql_num_db($techfetch);

        if ($ntectfetch > 0) {
            $fntectfetch                 = mysql_fetch_db($techfetch);
            $_SESSION['boat_teacher_id'] = $fntectfetch['id'];
    ?>
            <script>
                location.href = "teacher/profile.php";
            </script>
            <?php } else {
            //echo "select * from tbl_admin where email='$username' and password='$password' and status=1";
            $dt  = mysql_query_db("select * from tbl_admin where (username='$username' || email='$username') and password='$password' and status=1");
            $ndt = mysql_num_db($dt);

            if ($ndt > 0) {
                $fdt                       = mysql_fetch_db($dt);
                $_SESSION['boat_admin_id'] = $fdt['id'];
                $_SESSION['user_type']     = $fdt['user_type'];

                if (2 == $_SESSION['user_type']) {
                    $_SESSION['impersonate'] = true;
            ?>
                    <script>
                        location.href = "manager_dashboard.php";
                    </script>
                <?php } else { ?>
                    <script>
                        //  location.href="dashboard.php";
                        location.href = "main_courses.php";
                    </script>
                <?php }
                ?>
    <?php //header('location: dashboard.php');
            } else {
                header('location:index.php?msg=error');
            }
        }
    }

    ?>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <link rel="icon" type="image/png" href="assets/img/favicon-16x16.png" sizes="16x16">
    <link rel="icon" type="image/png" href="assets/img/favicon-32x32.png" sizes="32x32">

    <title><?php echo SITE_TITLE; ?> - Secure Admin Panel</title>

    <link href='https://fonts.googleapis.com/css?family=Roboto:300,400,500' rel='stylesheet' type='text/css'>

    <!-- uikit -->
    <link rel="stylesheet" href="<?php echo SITE_PATH; ?>admin/admincj/uikit.almost-flat.min.css" media="all">

    <!-- altair admin login page -->
    <link rel="stylesheet" href="<?php echo SITE_PATH; ?>admin/admincj/login_page.min.css" />

    <style type="text/css">
        input.error,
        textarea.error {
            border: 1px solid red;
            box-shadow: 0 0 4px red;
        }

        label.error {
            display: none !important;
        }

        input.error,
        textarea.error {
            -moz-animation: glow ease-in infinite alternate 500ms;
            -webkit-animation: glow ease-in infinite alternate 500ms;
            -ms-animation: glow ease-in infinite alternate 500ms;
            animation: glow ease-in infinite alternate 500ms;
        }

        @-moz-keyframes glow {
            0% {
                box-shadow: 0 0 4px red;
            }

            100% {
                box-shadow: 0 0 9px red;
            }
        }

        @-webkit-keyframes glow {
            0% {
                box-shadow: 0 0 4px red;
            }

            100% {
                box-shadow: 0 0 9px red;
            }
        }

        @-ms-keyframes glow {
            0% {
                box-shadow: 0 0 4px red;
            }

            100% {
                box-shadow: 0 0 9px red;
            }
        }

        @keyframes glow {
            0% {
                box-shadow: 0 0 4px red;
            }

            100% {
                box-shadow: 0 0 9px red;
            }
        }
    </style>

</head>

<body class="login_page">
    <div class="login_page_wrapper">
        <div class="md-card" id="login_card">
            <div class="md-card-content large-padding" id="login_form">
                <div class="login_heading">
                    <h2>ADMIN LOGIN</h2>
                    <!--<div class="user_avatar"></div>-->
                </div>
                <form action="" name="loginForm" id="loginForm" method="post">
                    <input type="hidden" name="submitfrm" value="1">

                    <div class="uk-form-row">
                        <label for="login_username">Email</label>
                        <input class="md-input" type="text" required id="username" name="username" />
                    </div>
                    <div class="uk-form-row">
                        <label for="login_username">Password</label>
                        <input class="md-input" type="password" required id="password" name="password" />
                    </div>
                    <!--<div class="uk-form-row">
                        <label for="login_username"><div style="background-image: url(jquery/captha_bg.jpg); padding: 0 10px;
width: 48px; font-weight: bold; color: #E0C8C8;" ><?php //echo $_SESSION['num1']; ;
                                                    ?>+ <?php //echo $_SESSION['num2']; ;
                                                                                        ?> ?</div></label>
                        <input class="md-input" type="text" id="captcha" name="captcha" />
                    </div>-->
                    <div class="uk-margin-medium-top">
                        <button type="submit" class="md-btn md-btn-primary md-btn-block md-btn-large">Sign In</button>
                    </div>
                    <!--<div class="uk-margin-top">
                        <span class="icheck-inline">
                            <input type="checkbox" name="login_page_stay_signed" id="login_page_stay_signed" data-md-icheck />
                            <label for="login_page_stay_signed" class="inline-label">Stay signed in</label>
                        </span>
                    </div>-->
                    <?php

                    if (isset($_GET['msg'])) {
                    ?>
                        <div class="uk-margin-top">
                            <span class="icheck-inline">
                                <label style="color:red;" for="login_page_stay_signed" class="inline-label">Email or password dosenot match</label>
                            </span>
                        </div>
                    <?php
                    }

                    ?>
                </form>
            </div>
            <div class="md-card-content large-padding uk-position-relative" id="login_help" style="display: none">
                <button type="button" class="uk-position-top-right uk-close uk-margin-right uk-margin-top" id="login_help_close"></button>
                <h2 class="heading_b uk-text-success">Can't log in?</h2>
                <p>Here’s the info to get you back in to your account as quickly as possible.</p>
                <p>First, try the easiest thing: if you remember your password but it isn’t working, make sure that Caps Lock is turned off, and that your username is spelled correctly, and then try again.</p>
                <p>If your password still isn’t working, it’s time to <a href="#" id="login_password_reset_show">reset your password</a>.</p>
            </div>
            <div class="md-card-content large-padding" id="login_password_reset" style="display: none">
                <h2 class="heading_a uk-margin-large-bottom">Reset password</h2>
                <form action="">
                    <div class="uk-form-row">
                        <label for="login_email_reset">Your email address</label>
                        <input class="md-input" type="text" id="login_email_reset" name="login_email_reset" />
                    </div>
                    <div class="uk-margin-medium-top">
                        <button class="md-btn md-btn-primary md-btn-block">Reset password</button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <!-- common functions -->
    <script src="<?php echo SITE_PATH; ?>admin/admincj/js/common.min.js"></script>
    <!-- altair core functions -->

    <!-- altair login page functions -->
    <script src="assets/js/pages/login_page.min.js"></script>

    <script src="<?php echo SITE_PATH; ?>admin/admincj/js/altair_admin_common.min.js"></script>
    <!--<script src="jquery/jQuery1.8.3.js"></script>-->
    <script src="<?php echo SITE_PATH; ?>admin/admincj/jQuery.validation.1.10.0.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $.validator.addMethod("nourl", function(value, element) {
                return !/https://|www.|link=|url=/.test(value);
            }, "No URL's");

            $("form").validate({
                rules: {
                    username: {
                        required: true,
                        //email: true
                    },
                    password: {
                        required: true
                    }

                },
                messages: {
                    username: "",
                    password: "",
                }
            });
        });
    </script>
</body>

</html>

It is a Login Form. When I am submitting the form I am getting error An Internal Error has Occured. Please report following error to the webmaster. select * from tbl_teacher where email='' and password='' and status=1

enter image description here

I checked /var/log/apache2/error.log file. It is empty. There is no error.

Why I am getting this error ?

how remove .php extension just one file nginx

My Nginx config is:

location ~ .php$ {
    try_files $uri = 404;
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass php-fpm:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_read_timeout 300;
}

`
Now I remove .php from my page for example: exmaple.com/course.php to exmaple.com/course

add

location ~ /course {
 rewrite ^ /course.php
}

but any page url has course redirect to course.php

Trying to test my php file on my local host but a blank white page just appears with no error messages

I have Apache and mySQL running, there doesn’t appear to be any syntax errors or any errors for that matter and I’ve literally exhausted all possible solutions, can someone please help me with this

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $firstName = $_POST['firstName'];
    $lastName = $_POST['lastName'];
    $email = $_POST['email'];
    $checkbox = implode(', ', $_POST['checkbox']);
    $message = $_POST['message'];

    // Send email with form data
    $to = '[email protected]';
    $subject = 'Made In Havan - New Contact Form Submission';
    $body = "Name: $firstName $lastNamenEmail: $emailnCheckbox: $checkboxnMessage: $message";
    $headers = "From: $email";

    if (mail($to, $subject, $body, $headers)) {
        echo 'Message sent successfully';
    } else {
        echo 'Error sending message';
    }
}
?>

I saved this file in my htdocs folder of my XAMPP installation folder as suggested

I inputted the php file into my react project as such:

axios.post('http://localhost/mihcontactform.php', formData)
            .then(response => {
                console.log(response);
            })
            .catch(error => {
                console.log(error);
            });

I am trying to test this (I created a dummy php file with echo Hello World and it showed up so there isnt any config issues) but a white blank page just shows up when I try to access localhost/mihcontactform.php

Domain redirects to HTTPS without SSL certificate in Laravel project

I have no SSL certificate so I just trying to run the website on the http://. My website is running well with the IP address but it is redirecting to https:// instead of sticking with http:// when I am trying to access it through the Domain name.

Also my website is not running without .htaccess at root path which contains follwing lines. As per my knowledge, Laravel will run through public/index.php and public/.htaccess

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Server: Hostinger VPS,
Domain provider: Godaddy

Website: http://suud.app

PHP – Callable argument restricted to non-anonymous only

I need a method/function that takes “callable” as one of the parameters, but this argument must be restricted to only non-anonymous.

So, when you pass anonymous method/function/invokable class must be thrown InvalidArgumentException;

The effect should be as follows:

class MyClass {
    public static function staticMethod() {}
    public function method(){}
    public function __invoke() {}
}
$anonClass = new class {
    public static function staticMethod() {}
    public function method(){}
    public function __invoke() {}
};

function myFunction() {};
$anonFunction = function() {};

// Function results:
checkCallable('myFunction'); // Ok
checkCallable($anonFunction); // throw InvalidArgumentException('Function cannot be anonymous');
checkCallable(fn() => "Something n"); // throw InvalidArgumentException('Function cannot be anonymous');

// Class results:
$obj = new MyClass();
$anonObj = new $anonClass();

checkCallable(array($obj, 'method')); // Ok
checkCallable(array('MyClass', 'staticMethod')); // Ok
checkCallable($obj); // Ok

checkCallable(array($anonObj, 'method')); // throw InvalidArgumentException('Class cannot be anonymous');
checkCallable(array($anonClass, 'staticMethod')); // throw InvalidArgumentException('Class cannot be anonymous');
checkCallable($anonObj); // throw InvalidArgumentException('Class cannot be anonymous');
  1. Question: Do my test cases cover all possibilities?
    (Excluding create_function() as it is deprecated since 7.2)

I’ve tried to use Reflection, but i don’t know how to get class from array callable using ReflectionMethod since then the property class is string not ReflectionClass.

public static function checkCallable(callable $method)
{
    if ($method instanceof Closure) {
        $ref = new ReflectionFunction($method);
        
        // @todo As of 8.0+ use ->isAnonymous() instead
        if ($ref->name == '{closure}') {
            // throw new InvalidArgumentException('Callable method cannot be an anonymous');                
        }
    } else {
        if (is_object($method)) {
            $ref = new ReflectionClass($method);
            self::checkClass($ref);
        } else {
            $ref = new ReflectionMethod($method[0], $method[1]);
            // Since then $ref has 2 properties: $class and $name.
            
            // Both are string, i could assume (Can I?) that method isn't anonymous since is declared in class, but how to check the Class, i Cannot use my checkClass method, since property is string instead of ReflectionClass()
            self::checkClass($ref->class); // ERROR :C
        }
    }
}

private static function checkClass(ReflectionClass $class) 
{
    if ($class->isAnonymous()) {
        throw new InvalidArgumentException('Callable class cannot be an anonymous');     
    }
}

Any suggestion will be appreciated.

Routes not working properly in codeigniter 4

I am working with Codeigniter 4, Right now i want to execute simple function but i am getting following error

404 page not found

Here is my routes.php

$routes->post('login', 'Form::login');

Here is my “Form Controller”,Where i am wrong ?

public function login()
   {
     echo "Hello world";
   }

In browser i type following url

localhost:8080/login

How can I make a group page that I can add a user from my database using php?

I want to make a school profiling website for our thesis and I want to know how can I make a “add” button that whenever you click it, it will create a page(class) and inside that page there is another “add” button were I can add a user(student) on that page(class).

I already try making the add button were it creates the page(class) and I just did know how can I add the user(student) in it

PHP Arrays, trying to fix double array

I am new to arrays but I’m trying to achieve the following:

{
    "Basic": "91919191",
    "Info": [
            {
                "ID": 1,
                "Extra": 3
            },
            {
                "ID": 2,
                "Extra": 6
            }, etc etc..
    ]
}

But instead I get double array like this:

{
    "Basic": "91919191",
    "Info": [
        [
            {
                "ID": 1,
                "Extra": 3
            },
            {
                "ID": 2,
                "Extra": 6
            }, etc etc..
        ]
    ]
}

Here is the code I am currently using

$first = array();
$first['Basic'] = "91919191";

$x = 1;
while ($x <= 3) {
    $y = $x * 3;
    $second[] = array('ID' => $x, 'Extra' => $y);
    $x++;
}
$first['Info'] = array($second);

echo json_encode($first, JSON_PRETTY_PRINT);

I’ve tried using array_merge but the results are not as expected. Any ideas/suggestions?