我们有一个Wordpress网站,需要一种特殊的Facebook身份验证.WP站点需要使用不同的应用程序对用户进行身份验证,然后将用户登录到应用程序.Web应用程序由我们构建,它具有WP站点用于与其交互的API.在我们都得到吵闹之前,整个身份验证过程使用正常的登录表单.使用API,我们可以很容易地看到用户是否登录到应用程序,并在WP站点上显示该用户.
如上所述,我们需要Facebook身份验证.我正在使用Facebook的PHP SDK v4并将其内置到自定义插件中,以便将代码与主题分开.当用户单击FB图标时,它会显示带有正确重定向URL的弹出窗口.过了一会儿,这个弹出窗口关闭,但结果中没有任何内容.一些好位置var_dumps显示我没有得到任何回报FacebookRedirectLoginHelper.这意味着我无法获得会话,而这意味着没有用户信息.
如上所述,我创建了一个ns-social.php处理所有内容的插件().这是该文件:
/**
* Plugin Name: NS Social Plugin
*/
require_once 'ns-social-init.php';
require_once 'ns-callback-functions.php';
require_once 'ns-facebook.php' ;
$fb = null;
add_action('plugins_loaded','load_fb');
function load_fb() {
global $fb;
$fb = new WP_Facebook();
}
/**
* SOCIAL LOGIN CHECK
*/
function get_fb_url()
{
global $fb;
return $fb->login_url();
}
Run Code Online (Sandbox Code Playgroud)
ns-social-init.php 启动FB可以使用的会话:
/**
* Any functions that are required during initialisation of Wordpress or this plugin
*/
add_action('plugins_loaded', 'start_session');
function start_session()
{
if …Run Code Online (Sandbox Code Playgroud) 我想看看我从数据库中读取的时间是否与用户提供的时间重叠.
我的数据库看起来像这样:
-----------------------------------------------
|organiser|meeting_start|meeting_end|boardroom|
-----------------------------------------------
| John Doe| 1340193600 | 1340195400| big |
-----------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
date_default_timezone_set('Africa/Johannesburg');
$from = strtotime($_GET['meeting_date'] . ' ' . $_GET['meeting_start']);
$to = strtotime($_GET['meeting_date'] . ' ' . $_GET['meeting_end']);
$another_meeting = false;
$meeting_date = strtotime($_GET['meeting_date']);
$meeting_next = $meeting_date + 86400;
$result = mysql_query("SELECT meeting_start, meeting_end FROM admin_boardroom_booking WHERE boardroom = '" . $_GET['boardroom'] . "' AND meeting_start >= '" . $meeting_date . "' AND meeting_end < '" . $meeting_next . "'")or die(mysql_error());
while($row = mysql_fetch_array($result)) {
$from_compare …Run Code Online (Sandbox Code Playgroud) 我有一个iframe进行图片上传,给人一种错误的Ajax上传感.
这个iframe的内容有javascript,可以检查各种内容并发送状态.几乎将其视为进度报告.无论如何,我的包含iframe的页面是显示数据的页面,但是我想要在iframe中更改父页面上的数据.这是我的代码:
<div id="iframe_response"></div>
<iframe style="border:none" src="someurl" width="100%" height="350px" id="iframe"></iframe>
Run Code Online (Sandbox Code Playgroud)
这是我在iframe中的jQuery:
$('#iframe_response', "#iframe").append('this should go there but it\'s not...');
Run Code Online (Sandbox Code Playgroud)
但是它不会给那个div写任何东西.我已经在document.ready上调用了它,但是唉......
我究竟做错了什么?
我想知道这是否只能使用CSS:
Black White
White Black
Black White
White Black
Run Code Online (Sandbox Code Playgroud)
名称代表我想要的颜色背景.在这个jsfiddle中,我已经硬编码以准确显示我想要的是什么,但div的数量将是动态的,所以我不知道会有多少.
我该如何实现这一目标?
我已阅读文档,并努力了解该怎么做.另外,我已经阅读了有关stackoverflow的问题,并且没有尝试过任何帮助.
我有一个下拉列表,我想列出公司的所有员工.列表应该显示如下:
Name Surname (Job Title)
Run Code Online (Sandbox Code Playgroud)
在我的模型中,我有这段代码:
public $virtualFields = array(
'fullname' => 'CONCAT(HrEmployee.name, " ", HrEmployee.surname, " (", HrEmployee.jobTitle, ")")'
);
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我有这个:
$hrEmployees = $this->User->HrEmployee->find('fullname',
array(
'fields' => array('HrEmployee.name','HrEmployee.surname','HrEmployee.jobTitle'),
'order' => array('HrEmployee.name'=>'ASC','HrEmployee.surname'=>'ASC')
));
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
Error: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `User__fullname` FROM `intraweb_db`.`users` AS `User` WHERE `User`.`hr_emp' at line 1
Run Code Online (Sandbox Code Playgroud)
我该改变什么?我可以看到它正在构建查询,但它正在改变它非常糟糕... …
我有一个用户编辑视图.当人们访问此视图时,密码块中包含哈希密码.
如果单击"保存",它(显然)会再次哈希密码,因为这是在我的用户模型中.
public function beforeSave($options = array()) {
if(!empty($this->data['User']['password'])) {
$this->data['User']['password'] = AuthComponent::password($this->data['User']['password']);
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
但是我不希望它有两次哈希(因为这意味着密码已经改变).我更改了编辑视图并添加array('value' => '','autocomplete'=>'off')到密码字段.现在当我保存它时,它会在数据库中保存一个空白字符串.我认为它阻止它使用函数中的if(!empty($this->data['User']['password']))语句执行此操作beforeSave.
如何防止密码被双重哈希?
我有一个具有以下结构的标题:
<header>
<div class="container-fluid login-div">
<div class="col-lg-1"></div>
<div class="col-lg-10"></div>
<div class="col-lg-1"></div>
</div>
<div class="container-fluid register-div">
<div class="col-lg-1"></div>
<div class="col-lg-10"></div>
<div class="col-lg-1"></div>
</div>
<div class="container-fluid nav-header middle">
<div class="col-lg-3"></div>
<div class="col-lg-1 line-right"></div>
<div class="col-lg-1"></div>
<div class="col-lg-2 logo"><img src="images/logo.jpg" alt=" LOGO" id="img_logo"> </div>
<div class="col-lg-1 line-right"></div>
<div class="col-lg-1"></div>
<div class="col-lg-3"></div>
</div>
</header>
Run Code Online (Sandbox Code Playgroud)
当页面加载时,login-div并被register-div隐藏。当用户单击某个按钮时,这些 div 的显示(好吧,取决于单击的按钮)。我遇到的问题是我无法让 div 显示所有内容。
我在这里创建了一个小提琴,所以你可以查看它。
现在就在每个人都告诉我设置高度之前,我不能,因为我不知道高度会是多少。根据用户选择的内容,内容的高度会发生变化。
我有一个 PHP 脚本,可以根据在网站上输入的详细信息生成名片模板。
我们最近决定将二维码电子名片添加到名片中,作为保存联系信息的一种简单方法。我使用本教程作为起点。
但是,我的二维码不起作用。它一直给我没有结果和格式为文本。
这是创建 vcard 并显示二维码的脚本:
$vcard = "BEGIN:VCARD\r\nVERSION:3.0\r\n
N:" . $_POST['surname'] . ";" . $_POST['name'] . "\r\n
FN:" . $_POST['name'] . " " . $_POST['surname'] . "\r\n
ORG:Example Organisation\r\n
TITLE:" . $_POST['position'] . " [" . $_POST['qualification'] . "]\r\n
TEL;TYPE=work,voice:" . $_POST['telephone'] . "\r\n
TEL;TYPE=cell,voice:" . $_POST['cellno'] . "\r\n
TEL;TYPE=work,fax:" . $_POST['fax'] . "\r\n
URL;TYPE=work:www.example.com\r\n
EMAIL;TYPE=internet,pref:" . $_POST['email'] . "\r\n
REV:" . date('Ymd') . "T195243Z\r\n
END:VCARD";
echo '<img src="http://chart.apis.google.com/chart?chs=500x500&cht=qr&chld=H&chl="' . urlencode($vcard) . '"/>';
Run Code Online (Sandbox Code Playgroud)
任何帮助?
我有一个用户选择文档的表单.然后,控制器将该文档保存到webroot文件夹中.
但是,在它显示表单之前,它给了我一个错误:
Missing Database Table
Error: Table office_layouts for model OfficeLayout was not found in datasource default.
Run Code Online (Sandbox Code Playgroud)
哪个是正确的,office_layouts没有数据库表.但它不是必需的.这就是没有桌子的原因.表单刚刚上传到服务器.
我已阅读创建表单,并尝试了以下内容:
// file: View/OfficeLayout/upload.ctp
echo $this->Form->create( null ,array('type' => 'file')); ?>
<fieldset>
<legend><?php echo __(' Add Layout for ' . $branch); ?></legend>
<?php
echo $this->Form->input('layout',array('type'=>'file'));
?>
</fieldset>
<?php echo $this->Form->end(__('Submit')); ?>
Run Code Online (Sandbox Code Playgroud)
以及null转换到控制器名称(在这种情况下OfficeLayout).我也删除了所有参数(thus creating it like so: $this->Form->create())
在我的控制器中,我有以下内容:
public function upload($branch = null) {
$this->set('branch',$branch);
if(isset($this->request->data['OfficeLayout'])) {
$file = $this->request->data['OfficeLayout']['layout'];
if($file['error'] === UPLOAD_ERR_OK && move_uploaded_file($file['tmp_name'],APP . 'docs' …Run Code Online (Sandbox Code Playgroud) 我有以下类为我处理 JSON 响应:
<?php
namespace BulkTransactionalSMS\Http\Handlers\Response;
use Symfony\Component\HttpFoundation\Response;
class JsonResponseHandler implements ResponseHandlerInterface
{
/**
* @param string $message
* @return Response
*/
public function errorResponse(string $message): Response
{
return response()->json([
'status' => 'error',
'message' => $message
]);
}
/**
* @param array $successDetails
* @return Response
*/
public function successResponse(array $successDetails = []): Response
{
$response = array_merge(['status' => 'success'], $successDetails);
return response()->json($response);
}
}
Run Code Online (Sandbox Code Playgroud)
所有 JSON 响应都由此类处理,因为它是统一的且易于更改。我已经尝试过这个类,因为它和 withResponse::json()都产生了相同的结果。
正在发回 JSON 标头,这与 jQuery 处理响应有关。这是一个示例调用,我要返回的是:
// Example call
$jsonResponseHandler …Run Code Online (Sandbox Code Playgroud) php ×6
cakephp-2.0 ×2
css ×2
jquery ×2
mysql ×2
cakephp-2.3 ×1
css3 ×1
facebook ×1
html ×1
iframe ×1
json ×1
laravel ×1
laravel-5.8 ×1
overlapping ×1
php-7 ×1
qr-code ×1
session ×1
time ×1
vcf-vcard ×1
wordpress ×1