WordPress插件激活触发致命错误

bwntbbo3  于 12个月前  发布在  WordPress
关注(0)|答案(1)|浏览(223)

我知道有很多这样的问题,但我找不到任何与我的案件相关的具体问题,要么就是没有答案。
我写了一个非常简单的PHP脚本,并上传到一个WordPress网站的zip文件夹,当我试图激活插件,WordPress给我一个消息阅读:“插件无法激活,因为它触发了一个致命错误。”它实际上并没有给予我任何错误消息。我有WP_DEBUG,WP_DEBUG_BLOG和WP_DEBUG_BLOG都设置为true,但这些都没有更新后,假定的错误。似乎我没有办法找出到底是什么致命的错误。
我不知道如何处理这个问题,任何帮助都是有用的。

<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

  $j_username = "Denrile";
  $j_password = "*************";
  $login_url ="https://titlereporter.direct.pruvan.com/v2/login";
  $last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";

  function loginToJulian($url, $username, $password){
    $curl = curl_init();
    $header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
    $header[] = "Cache-Control: max-age=0";
    $header[] = "Connection: keep-alive";
    $header[] = "Content-Type: application/x-www-form-urlencoded";
    $header[] = "Keep-Alive: 300";
    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $header[] = "Accept-Language: en-us,en;q=0.5";
    $verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_STDERR, $verbose);
    // Make the errors visible in a new file

    $payload_username = '"'.$username.'"';
    $payload_password = '"'.$password.'"';
    $payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
    $payload = "payload=".$payloadtext;
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $store = curl_exec($curl);
    curl_close($store);
  }

  if(isset($_GET['prvn_login'])){
    loginToJulian($login_url, $j_username, $j_password);
    header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
    exit();
  }
  else{

    exit();
  }

?>

字符串
这个插件的一般想法是,它将钩到WordPress网站上的JavaScript生成的A标记,CURL发布到另一个网站登录,然后重定向到该网站,希望绕过用户身份验证,因为用户已经登录感谢CURL。

zqry0prt

zqry0prt1#

这段代码为我工作.但有一个问题,为什么你添加exit();在else条件内,它破坏了插件激活过程.
请检查并让我知道。

<?php

/*
Plugin Name: Denrile's Plogger
Plugin URI: http://my-awesomeness-emporium.com
description: >- a plugin to that takes the user to the Pruvan website,
after using CURL to log them in so that the redirect doesn't hit a user authentication wall.
Version: 1.0
Author: John Mauran
Author URI: http://github.com/jmauran91
License: GPL2
*/

  $j_username = "Denrile";
  $j_password = "*************";
  $login_url ="https://titlereporter.direct.pruvan.com/v2/login";
  $last_url = "https://titlereporter.direct.pruvan.com/v2/pmgr";

  function loginToJulian($url, $username, $password){
    $curl = curl_init();
    $header[0]= "Accept: application/json, text/javascript, */*; q=0.01";
    $header[] = "Cache-Control: max-age=0";
    $header[] = "Connection: keep-alive";
    $header[] = "Content-Type: application/x-www-form-urlencoded";
    $header[] = "Keep-Alive: 300";
    $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
    $header[] = "Accept-Language: en-us,en;q=0.5";
    $verbose = fopen(dirname(__FILE__).'/errorlog.txt', 'w');
    curl_setopt($curl, CURLOPT_VERBOSE, true);
    curl_setopt($curl, CURLOPT_STDERR, $verbose);
    // Make the errors visible in a new file

    $payload_username = '"'.$username.'"';
    $payload_password = '"'.$password.'"';
    $payloadtext=urlencode('{"username":'.$payload_username.',"password":'.$payload_password.'}');
    $payload = "payload=".$payloadtext;
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
    curl_setopt($curl, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $store = curl_exec($curl);
    curl_close($store);
  }

  function default_wordpress_hook(){
    if(isset($_GET['prvn_login'])){
      loginToJulian($login_url, $j_username, $j_password);
      header("Location: https://titlereporter.direct.pruvan.com/v2/pmgr");
      exit();
    } else {

    }  
  }
  add_action("init","default_wordpress_hook");

?>

字符串

相关问题