Why doesn’t this javascript code for a basic canvas operation work?

Why does the following code not display a black box on the screen. It titles the page Chatroom so at least the beginning part works…

<canvas id=“chatroom” width=“240 height=“400”></canvas>

const canvas= document.getElementById('chatroom');
const context=canvas.getContext('2d');

context.fillStyle ='#000';


Thank you!

Source: stackoverflow-javascript

Error installing PHP using Web Platform Installer on Windows 10/IIS 10

I am developing an ASP MVC website… I have bought a plugin which uses PHP files and I want to use it within my site.

I am trying to install PHP 7.1.1 on Windows 10, IIS 10, using Web Platform Installer 5.0.

I am getting an error:

[error message]
I have already tried these:
1> set this key value to 8

.Net 3.5 installed and WCF TTP Activation is enabled for .Net Framework 3.

What’s the best way to get the PHP files working on my machine?


Source: stackoverflow-php

vsCode gives a warning on apparently valid code from vue.js docs

following vue.js guide for lazi-loading , when i’m writing this line of code:

import Vue from 'vue'
import Router from 'vue-router'
const Health = () => import('@/components/health')

vscode throws the following problems:

file: 'file:///c%3A/projects/vue-lazy-loading/src/router/index.js'
severity: 'Error'
message: 'Expression expected.'
at: '3,22'
source: 'js'

file: 'file:///c%3A/projects/vue-lazy-loading/src/router/index.js'
severity: 'Error'
message: 'Variable declaration expected.'
at: '3,28'
source: 'js'

visually, that’s how it looks:
enter image description here

is there something wrong with the code, or with VS-code?
what is the correct way to write it?

Source: stackoverflow-javascript

callback not working in self-repeating function

Currently I am writing a user-script which aims to insert a trailer video into the webpage. In the script I wrote a function to filter the real source for the video as the url has few kinds of format, but the callback within the function just won’t work.

function test_url(preview,list,callback) {
if (list.length) {
    preview.src = list[0][0];
preview.onerror = function() {
    if (list.length) {
        test_url(preview,list);   // the function will be re-executed until the passed list is empty
    else {
        console.log('No more url available!');
        if (callback && typeof(callback) === "function") { callback(); }
        else {console.log('callback is : '+ typeof callback);}
if (!list[0].length) {
else {

test_url(Preview,URLs,function() {console.log('This is a callback.')})

The callback above won’t work and it shows that callback is undefined.

The list passed in is like


I really don’t know where the problem is as I am still a newbie to JavaScript. Any advice would be greatly appreciated.

Source: stackoverflow-javascript

Why Ext.webKitVersion = 0 on Safari 10.11.1 and Google Chrome 59 and Firefox 54.0?

I am using Ext JS 6.5 . I am reading: http://docs.sencha.com/extjs/6.5.0/modern/Ext.html#property-webKitVersion

When I use script


Result on Google Chrome, Safari is true. Result on Firefox is false.

I use script


The result is 0. Is it means Safari, Chrome, Firefox doesn’t use WebKit?

Question: Why Ext.webKitVersion = 0 on Safari 10.11.1 and Google Chrome 59 and Firefox 54.0? Is it a bug?

Source: stackoverflow-javascript

Setting a PHP cookie value to be intentionally vulnerable

First of all, I’m new to PHP and coding in general.

I’m currently creating a web application which is intentionally vulnerable to teach students about web based vulnerabilities. The web app consists of levels with each level containing a different vulnerability.

On the current level, I am trying to set a cookie name “Authenticated” with a value of “0” when a user successfully logs into the level. When they reach the page, they receive a PHP error that they are not authenticated. I want them to be able to intercept the page request, change the value to “1”, and then as a result of this changed value, receive a PHP echo containing the password for the next level.

Here is my main page (level6.php):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <meta charset='utf-8'>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1">
   <link rel="stylesheet" href="../css/wargames.css">
   <title>Generic Web App Title</title>
</head> <body background="../images/background.jpg"> <br />

Welcome to Level 6!

<br />

Can’t get XDEBUG to send back information: phpstorm+xdebug+ec2-linux

So according to my php.ini and phpstorm(validate debugger configuration on web server) xdebug is perfectly installed and configured and phpstorm is able to receive and send info to xdebug on the remote server. YET, when i add break points and clearly reached those break points, I don’t get any debugger info like variables and their contents. I have no idea what I’m still missing but here is my phpinfo() screenshot:

enter image description here

Source: stackoverflow-php

Reverse CSS @keyframes animation, WITHOUT JavaScript. At all. Possible?

What is annoying me is that when you define @keyframes, to do the opposite/reverse you have declare the thing twice!

Sure, transitions reverse themselves but then you have the problem with initial state.

See this example:

.class {
   animation-timing-function: ease-in-out;
   animation-direction: alternate;
   animation-fill-mode: both;
   animation-name: slideInLeft;

.class:hover, .class.hide {
  // F*****G reverse and retrigger the keyframe animation

@keyframes slideInLeft {
    from {
        transform: translate3d(-100%, 0%, 0%);

    to {
        transform: translate3d(0%, 0%, 0%);

Rather than also being forced to do:

@keyframes slideOutLeft {
    from {
        transform: translate3d(0%, 0%, 0%);
    to {
        transform: translate3d(-100%, 0%, 0%);

I would like to say that on:

.class:hover, .class.hide { 
       // REVERSE THE slideInLeft animation without using slideOutLeft: 

       animation-name: slideOutLeft;

       // Rather I would like to say

      animation-name:slideInLeft ; // the same as .class really

      // but 

      // do not work because they don't retrigger the animation if it has the same name. Only if I change the name and declare a totally new keyframe can I do what I want. 

Meaning I’m not interested in repeating the declaration, which is just the opposite of slideInLeft.

For complex animations, this is extremely annoying to do.

Source: stackoverflow-javascript

How to get all users from laravel api?

I ma building an admin dashboard for my app with angular as frontend framework and Laravel API as a backend.

I want to manage all registered users from the user’s table. I am using a passport for user authentication and giving token to each user.

What I know is, without the token, I cannot access the individual user. But i need access to all users ,perform [edit,delete] .

Without middleware i can get all registered user [but this is not a secure way in my opinion] Route::get('/users','AuthRegisterController@index')->middleware('auth');

can I get access to all users ? or there are other methods to achieve this?
I need suggestion. what is the appropriate method to get all users [which in normal way can only be accessed when the user is logged in and gives single user information]?

Source: stackoverflow-php

PHP, Yii framework RBAC: write rule to create posts

I have tried to implement RBAC in my yii2 application, and I’ve followed this tutorial: http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#rbac.

I have created an “admin” role, and assigned it the “createPost” permission, but my “admin” user can still not create posts. If I understood this correctly, now I have to implement a rule for creating posts and assign it to this permission. I can see that there is already an “AuthorRule”:

public function execute($user, $item, $params)
   return isset($params['post']) ? $params['post']->createdBy == $user : false;

but I’m completely new to PHP and Yii and don’t know how to make another rule for creating posts.

Source: stackoverflow-php