我有一个使用PHP会话的PHP注册/登录系统,它工作得很好,我希望用户能够记住我,然后他们会永远登录或至少一周或某事.
我猜我需要存储一个cookie并检查,我对我实际需要存储在cookie中的内容感到困惑.如果我存储用户标识或用户名,那么有人只能使用假cookie来查看其他用户数据吗?
任何进步都表示赞赏.
我试图在我用来下载文件的网站上登录我的useraccount,所以我可以自动获取文件而无需访问该网站.
这是形式:
<form method='post' action='/news.php'>
<div>
Username: <input class='tbox' type='text' name='username' size='15' value='' maxlength='20' />
Password: <input class='tbox' type='password' name='userpass' size='15' value='' maxlength='20' />
<input type='hidden' name='autologin' value='1' />
<input class='button' type='submit' name='userlogin' value='Login' />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这是迄今为止PHP的ive.
<?php
$username="my_user";
$password="my_passs";
$url="the_url";
$cookie="cookie.txt";
$postdata = "username=".$username."&userpass=".$password;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, …Run Code Online (Sandbox Code Playgroud) 我有一个文件管理器,我想尝试并鼓励用户下载.我已经看到网站做了类似的事情,但不知道它所谓的尝试和搜索类似的帖子.

这就像我想要的.如果勾选"使用经理",则会在取消勾选时为其提供不同的URL.
希望这是有道理的.
谢谢
当用户在我的网站上发布评论时,我正在使用sweetalert2脚本,它向下滚动到他们的评论并弹出甜蜜警报,但是当他们在甜蜜警报框中单击“确定”时,它将向上滚动回到顶部。
从我一直在阅读的书中,我需要某种preventdefault或类似的东西,但是我不知道那会去哪里?
这是我的脚本:
<!-- Sweet alert -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/6.6.8/sweetalert2.min.js"></script>
<script>
window.location.hash = "comment-<?php echo $newcommentid; ?>";
$(document).ready(function () {
swal({
title: "Comment Posted",
text: "Thanks, your comment has now been successfully posted.",
type: "success"
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我正在使用这个很棒的脚本来备份我的服务器上的文件夹,但是我想从备份中排除几个文件夹.我该如何排除他们?
谢谢
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
* contribution: Drew Toddsby
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
// Start the backup!
zipData('/var/www/html/uploaded', '/var/www/html/uploaded.zip');
echo 'Finished.';
// Here the magic happens :)
function zipData($source, $destination) {
if (extension_loaded('zip')) {
if (file_exists($source)) {
$zip = new ZipArchive();
if ($zip->open($destination, ZIPARCHIVE::CREATE)) {
$source = realpath($source);
if (is_dir($source)) {
$iterator = new RecursiveDirectoryIterator($source);
// …Run Code Online (Sandbox Code Playgroud) 我正在进行for循环计数从0001到0999
我怎么能用PHP做到这一点.我到目前为止所有这是一个正常的PHP for循环.
我试图检查我的文件夹中是否存在文件,但我只有一个部分文件名来检查它,有没有办法检查它?
例如,我有以下内容:
God_of_War
Run Code Online (Sandbox Code Playgroud)
文件名实际上是调用的:
God_of_War_PSP(USA).rar
Run Code Online (Sandbox Code Playgroud)
file_exists函数有某种LIKE吗?或者我能用某种方式使用str_pos吗?
谢谢
我有一堆电影正在尝试从我的 CentOS 服务器传输到我的 Windows PC 上。但是当我通过这个脚本运行它们时,它们最终会被损坏。是不是剧本有什么问题?
谢谢
$allFiles = glob("/var/www/html/ftp_pending/*");
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
foreach($allFiles as $singleFile)
{
// check if a file exist
$path = "/"; //the path where the file is located
$file = substr( $singleFile, strrpos( $singleFile, '/' )+1 );
$check_file_exist = $path.$file; //combine string for easy use
// Returns an array of filenames from the specified directory on success or
// …Run Code Online (Sandbox Code Playgroud) 我有一个使用mod_xsendfile的php下载脚本,可以很好地下载certian rar文件.
在Chrome和IE中下载很好,我得到的文件名如"0005 - Game Name.rar"
在Firefox中,它总是只下载一个文件,其名称有两个字符长,如"0005 - ",它永远不会有扩展名,因此用户可能无法理解如何重命名.
我可以在脚本中更改某些内容以允许firefox读取整个文件名.
以下是处理下载的脚本部分.
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=$filename");
header("X-Sendfile: $file");
Run Code Online (Sandbox Code Playgroud)
提前致谢!
我试图从这个网站获得所有4位数字,但是有些数字少于4位,例如阵列中的#20值是20.
Array ( [0] => 6280 [1] => 6279 [2] => 6278 [3] => 6277 [4] => 6276 [5] => 6275 [6] => 6274 [7] => 6273 [8] => 6272 [9] => 6271 [10] => 6270 [11] => 6269 [12] => 6268 [13] => 6267 [14] => 6266 [15] => 6265 [16] => 6264 [17] => 6263 [18] => 6262 [19] => 6261 [20] => 20 [21] => 6320 )
Run Code Online (Sandbox Code Playgroud)
这是我使用的脚本:
$pattern = '#<b>([0-9]+)</b>#';
preg_match_all($pattern,$website,$match_number);
Run Code Online (Sandbox Code Playgroud)
是否有可能只有4位数不能再得到它.
谢谢