这个PHP验证码脚本有什么问题?(What is wrong with this PHP captcha script?)

我已经使用这个脚本很长一段时间了,它完美地工作在99%。 这对用户来说简单明了,我想继续使用它。

但是,偶尔稀疏用户告诉我系统在数字正确时不接受他的验证码(错误的代码)。 每次我都经过他们的cookie设置,清除缓存等,但在这些情况下似乎没有任何作用。

我的问题是,这个脚本的代码中是否有任何理由可以解释特殊情况下的故障?

session_start();

$randomnr = rand(1000, 9999);
$_SESSION['randomnr2'] = md5($randomnr);

$im = imagecreatetruecolor(100, 28);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0,0,0);

imagefilledrectangle($im, 0, 0, 200, 35, $black);

$font = '/img/captcha/font.ttf';

imagettftext($im, 30, 0, 10, 40, $grey, $font, $randomnr);
imagettftext($im, 20, 3, 18, 25, $white, $font, $randomnr);

// Prevent caching
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past3
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header ("Content-type: image/gif");

imagegif($im);
imagedestroy($im);

在我的表单中,我然后将此脚本称为验证码图像的来源。 发送表单后,以这种方式检查验证码:

if(md5($_POST['norobot']) != $_SESSION['randomnr2']) {
    echo 'Wrong captcha!';
}

请注意session_start(); 在表单页面和表单结果页面上调用。

如果有人能够在此脚本中查明潜在的错误原因,我将不胜感激!

PS:我知道验证码脚本的缺点。 我知道某些机器人仍然可以读出它们。 我不想使用Recaptcha,因为它对我的用户来说太难了(不同的语言+很多次老用户)。 我也知道md5很容易解密。


编辑编辑编辑编辑编辑编辑编辑编辑编辑编辑编辑编辑编辑编辑


在UgoMéda的评论之后,我一直在做一些实验。 这就是我创建的(为方便起见而简化):

表格

// Insert a random number of four digits into database, along with current time
$query   = 'INSERT INTO captcha (number, created_date, posted) VALUES ("'.rand(1000, 9999).'", NOW(),0)';
$result  = mysql_query($query);

// Retrieve the id of the inserted number
$captcha_uid = mysql_insert_id();

$output .= '<label for="norobot"> Enter spam protection code';
// Send id to captcha script
$output .= '<img src="/img/captcha/captcha.php?number='.$captcha_uid.'" />'; 
// Hidden field with id 
$output .= '<input type="hidden" name="captcha_uid" value="'.$captcha_uid.'" />'; 
$output .= '<input type="text" name="norobot" class="norobot" id="norobot" maxlength="4" required  />';
$output .= '</label>';

echo $output;

验证码脚本

$font = '/img/captcha/font.ttf';

connect();
// Find the number associated to the captcha id
$query = 'SELECT number FROM captcha WHERE uid = "'.mysql_real_escape_string($_GET['number']).'" LIMIT 1';
$result = mysql_query($query) or trigger_error(__FUNCTION__.'<hr />'.mysql_error().'<hr />'.$query);
if (mysql_num_rows($result) != 0){          
    while($row = mysql_fetch_assoc($result)){
        $number = $row['number'];
    }
} 
disconnect();

$im     = imagecreatetruecolor(100, 28);
$white  = imagecolorallocate($im, 255, 255, 255);
$grey   = imagecolorallocate($im, 128, 128, 128);
$black  = imagecolorallocate($im, 0,0,0);

imagefilledrectangle($im, 0, 0, 200, 35, $black);
imagettftext($im, 30, 0, 10, 40, $grey, $font, $number);
imagettftext($im, 20, 3, 18, 25, $white, $font, $number);

// Generate the image from the number retrieved out of database
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past3
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header ("Content-type: image/gif");

imagegif($im);
imagedestroy($im);

表格的结果

function get_captcha_number($captcha_uid) {
    $query = 'SELECT number FROM captcha WHERE uid = "'.mysql_real_escape_string($captcha_uid).'" LIMIT 1';
    $result = mysql_query($query);
    if (mysql_num_rows($result) != 0){          
        while($row = mysql_fetch_assoc($result)){
            return $row['number'];
        }
    } 
    // Here I would later also enter the DELETE QUERY mentioned above...
}
if($_POST['norobot'] != get_captcha_number($_POST['captcha_uid'])) {
    echo 'Captcha error'
    exit;
}

这非常有效,所以非常感谢这个解决方案。

但是,我看到了一些潜在的缺点。 我注意到至少有4个查询,并且对我们正在做的事情感到有点资源密集。 此外,当用户多次重新加载同一页面时(只是为了混蛋),数据库会很快填满。 当然,这将在下一个表单提交时删除,但是,你能不能和我一起讨论这个可能的替代方案?

我知道通常不应该加密/解密。 但是,由于验证码本质上是有缺陷的(因为机器人的图像读数),我们难道不能通过加密和解密发送到captcha.php脚本的参数来简化过程吗?

如果我们这样做了(遵循Alix Axel的加密/解密说明 ):

1)加密一个随机的四位数字符,如下所示:

$key = 'encryption-password-only-present-within-the-application';
$string = rand(1000,9999);
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

2)将带有参数的加密号码发送到图像脚本并将其存储在隐藏字段中

<img src="/img/captcha.php?number="'.$encrypted.'" />
<input type="hidden" name="encrypted_number" value="'.$encrypted.'" />

3)解密验证码脚本中的数字(通过$ _GET发送)并从中生成图像

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); 

4)再次解密表单上的数字以与用户输入进行比较$ decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256,md5($ key),base64_decode($ encrypted),MCRYPT_MODE_CBC,md5(md5($ key))),“\ 0 “);
if($ _ POST ['norobot']!= $ decrypted){echo'Capscha error!'; 出口; }

同意,这有点“通过默默无闻”,但它似乎提供了一些基本的安全性,并且仍然相当简单。 或者这种加密/解密操作本身是否过于耗费资源?

有没有人对此有任何评论?


I've been using this script for a long time and it works perfectly in 99%. It's easy and clear to users and I would like to continue using it.

However, once in a while a sparse user tells me that the system doesn't accept his captcha (wrong code) while the numbers are correct. Each time I've been going over their cookies settings, clearing cache etc, but in these cases nothing seems to work.

My question thus is, is there any reason in the code of this script that would explain malfunctioning in exceptional cases?

session_start();

$randomnr = rand(1000, 9999);
$_SESSION['randomnr2'] = md5($randomnr);

$im = imagecreatetruecolor(100, 28);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0,0,0);

imagefilledrectangle($im, 0, 0, 200, 35, $black);

$font = '/img/captcha/font.ttf';

imagettftext($im, 30, 0, 10, 40, $grey, $font, $randomnr);
imagettftext($im, 20, 3, 18, 25, $white, $font, $randomnr);

// Prevent caching
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past3
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

header ("Content-type: image/gif");

imagegif($im);
imagedestroy($im);

In my form, I then call this script as the source of the captcha image. After sending the form, the captcha is checked this way:

if(md5($_POST['norobot']) != $_SESSION['randomnr2']) {
    echo 'Wrong captcha!';
}

Please note that session_start(); is called on the form page and the form result page.

If anyone could pinpoint potential error causes in this script, I would appreciate it!

P.S.: I am aware of the drawbacks of captcha scripts. I am aware that certain bots could still read them out. I do not wish to use Recaptcha, because it is too difficult for my users (different language + lots of times older users). I also am aware of the fact that md5 is easily decryptable.


EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT EDIT


Following the remarks of Ugo Méda, I've been doing some experiments. This is what I've created (simplified for your convenience):

The form

// Insert a random number of four digits into database, along with current time
$query   = 'INSERT INTO captcha (number, created_date, posted) VALUES ("'.rand(1000, 9999).'", NOW(),0)';
$result  = mysql_query($query);

// Retrieve the id of the inserted number
$captcha_uid = mysql_insert_id();

$output .= '<label for="norobot"> Enter spam protection code';
// Send id to captcha script
$output .= '<img src="/img/captcha/captcha.php?number='.$captcha_uid.'" />'; 
// Hidden field with id 
$output .= '<input type="hidden" name="captcha_uid" value="'.$captcha_uid.'" />'; 
$output .= '<input type="text" name="norobot" class="norobot" id="norobot" maxlength="4" required  />';
$output .= '</label>';

echo $output;

The captcha script

$font = '/img/captcha/font.ttf';

connect();
// Find the number associated to the captcha id
$query = 'SELECT number FROM captcha WHERE uid = "'.mysql_real_escape_string($_GET['number']).'" LIMIT 1';
$result = mysql_query($query) or trigger_error(__FUNCTION__.'<hr />'.mysql_error().'<hr />'.$query);
if (mysql_num_rows($result) != 0){          
    while($row = mysql_fetch_assoc($result)){
        $number = $row['number'];
    }
} 
disconnect();

$im     = imagecreatetruecolor(100, 28);
$white  = imagecolorallocate($im, 255, 255, 255);
$grey   = imagecolorallocate($im, 128, 128, 128);
$black  = imagecolorallocate($im, 0,0,0);

imagefilledrectangle($im, 0, 0, 200, 35, $black);
imagettftext($im, 30, 0, 10, 40, $grey, $font, $number);
imagettftext($im, 20, 3, 18, 25, $white, $font, $number);

// Generate the image from the number retrieved out of database
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past3
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header ("Content-type: image/gif");

imagegif($im);
imagedestroy($im);

The result of the form

function get_captcha_number($captcha_uid) {
    $query = 'SELECT number FROM captcha WHERE uid = "'.mysql_real_escape_string($captcha_uid).'" LIMIT 1';
    $result = mysql_query($query);
    if (mysql_num_rows($result) != 0){          
        while($row = mysql_fetch_assoc($result)){
            return $row['number'];
        }
    } 
    // Here I would later also enter the DELETE QUERY mentioned above...
}
if($_POST['norobot'] != get_captcha_number($_POST['captcha_uid'])) {
    echo 'Captcha error'
    exit;
}

This works very well, so thanks very much for this solution.

However, I'm seeing some potential drawbacks here. I'm noting at least 4 queries and feels somewhat resource intensive for what we're doing. Also, when a user would reload the same page several times (just to be an asshole), the database would quickly fill up. Of course this would all be deleted upon the next form submit, but nonetheless, could you go over this possible alternative with me?

I'm aware that one should generally not encrypt / decrypt. However, since captchas are flawed by nature (because of image readouts of bots), couldn't we simplify the process by encrypting and decrypting a parameter that is being sent to the captcha.php script?

What if we did this (following the encrypt/decrypt instructions of Alix Axel):

1) Encrypt a random four digit character like so:

$key = 'encryption-password-only-present-within-the-application';
$string = rand(1000,9999);
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

2) Send the encrypted number with a parameter to the image script and store it in a hidden field

<img src="/img/captcha.php?number="'.$encrypted.'" />
<input type="hidden" name="encrypted_number" value="'.$encrypted.'" />

3) Decrypt the number (that was sent via $_GET) inside the captcha script and generate an image from it

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); 

4) Decrypt the number on form submit again to compare to user input $decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
if($_POST['norobot'] != $decrypted) { echo 'Captcha error!'; exit; }

Agreed, this is a little bit "security-through-obscurity", but it seems to provide some basic security and remains fairly simple. Or would this encrypt/decrypt action be too resource intensive on its own?

Does anyone have any remarks on this?


原文:https://stackoverflow.com/questions/11341666
2020-02-01 04:27

满意答案

ArrayAdapter的方法是remove(int index)

list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(final AdapterView<?> arg0, View arg1,
                final int position, long arg3) {
            AlertDialog.Builder alert = new AlertDialog.Builder(DeleteItem.this);
            alert.setMessage("Are you sure you want to delete this?");
            alert.setCancelable(false);
            alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ArrayAdapter yourArrayAdapter = (ArrayAdapter) arg0.getAdapter();
                    yourArrayAdapter.remove(position);
                    yourArrayAdapter.notifyDataSetChanged();
                }
            });
            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();

                }
            });


            return false;

        }
    });

使用适配器的通用类型调整演员表。 仅当您向适配器提供元素集合时,它才有效。 如果你提供了一个数组,它将抛出异常


ArrayAdapter has the method remove(int index):

list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(final AdapterView<?> arg0, View arg1,
                final int position, long arg3) {
            AlertDialog.Builder alert = new AlertDialog.Builder(DeleteItem.this);
            alert.setMessage("Are you sure you want to delete this?");
            alert.setCancelable(false);
            alert.setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ArrayAdapter yourArrayAdapter = (ArrayAdapter) arg0.getAdapter();
                    yourArrayAdapter.remove(position);
                    yourArrayAdapter.notifyDataSetChanged();
                }
            });
            alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();

                }
            });


            return false;

        }
    });

Adjust the cast with the generic type of your adapter. It works only if you provide a Collection of elements to the adapter. If you provided an Array it will throw an exception

相关问答

更多

onItemLongClickListener工作很奇怪(onItemLongClickListener is working weird)

问题是您在setChoiceMode()调用setChoiceMode()和setMultiChoiceModeListener() ,这意味着在您对列表项执行长按之前,不会调用这些方法。 在您的OnItemLongClickListener之外放置editListView.setChoiceMode()和editListView.setMultiChoiceModeListener() : editListView.setChoiceMode(ListView.CHOICE_MODE_MULTI...

OnItemLongClicklistner上的ListView - 检索信息(ListView on OnItemLongClicklistener - retrieving information)

好吧,我有它的工作。 这是我改变的: OnItemLongClickListener listener = new OnItemLongClickListener(){ @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long id){ Toast.makeText(getApplicati...

如何使用OnItemLongClickListener覆盖OnItemClickListener(How to override OnItemClickListener with OnItemLongClickListener)

我认为你应该在你的onItemLongClick方法中返回true以消耗点击。 查看Android文档http://developer.android.com/reference/android/widget/AdapterView.OnItemLongClickListener.html I think you should return true in your onItemLongClick method to consume the click. Check Android documen...

由listview OnItemLongClickListener创建的Android开放式微调器(Android open spinner by listview OnItemLongClickListener)

我认为最好使用弹出菜单或对话框进行弹出选择,而不是在运行时制作微调器。 对于对话框,它看起来像这样: listView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { ...

使用OnItemLongClickListener删除项目后,使用自定义adater刷新列表(Refresh list with custom adater after delete an item with OnItemLongClickListener)

我发现了问题,我忘了从用于构建ListView的ArrayList中删除该项: codeList.remove(position); I found the problem, I forgot to remove the item from the ArrayList which I use to build the ListView: codeList.remove(position);

来自JSONParser的方法OnItemClickListener重写来自另一个活动的OnItemLongClickListener(Method OnItemClickListener from JSONParser override OnItemLongClickListener from another activity)

在我的方式中,我从FavoriteFragment中删除了两个方法的定义,并在MainActivity中定义了它: Json Array listView = (ListView) findViewById(R.id.list); adapterAirlines = new AirlinesAdapter(this, airlinesList); listView.setAdapter(adapterAirlines); ...

使用OnItemLongClickListener删除项目(Delete an item using an OnItemLongClickListener)

ArrayAdapter的方法是remove(int index) : list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(final AdapterView<?> arg0, View arg1, final int position, long ar...

OnItemLongClickListener太长了。(OnItemLongClickListener too long. How to listen for a bit shorter click in listview?)

好的,所以我对DynamicListView.java进行了三次重大更改 1)我在下面将setter更改为setOnItemClickListener public void init(Context context) { setOnItemClickListener(mOnItemClickListener); //setOnScrollListener(mScrollListener); DisplayMetrics metrics = context.getR...

我如何在Android的Activity中使用onItemLongClickListener?(How do I use a onItemLongClickListener in my Activity in Android?)

在{recyclerView, position, v -> true} , recyclerView, position, v是onItemLongClick回调的参数。 你会像这样使用它: ItemClickSupport.addTo(recyclerView3).setOnItemLongClickListener { recyclerView, view, position, id -> // Use position here true // False if not ...

相关文章

更多

简单验证码生成——Java版

验证码大家都知道,它的作用也不用我多说了吧。如果不太清楚请参见百度百科中的解释,一般验证码的生成就是随 ...

jsp 验证码刷新无反应 怎么回事

我用的生成验证码为 authcode.jsp 在 login.jsp 中使用: &lt;form ...

PHP简介

PHP PHP是运行在服务器端的脚本,可以运行在UNIX、LINUX、WINDOWS、Mac OS下 ...

Script.NET Perl解释器代码已经在GitHub开源发布

Script.NET Perl解释器的代码已经提交到GitHub网站。GitHub项目地址: http ...

PHP基础教程一:基本语法

本节的主要内容是:1.为什么要学php?2.怎样添加php语句,让网页成为动态的呢?3.代码的注释

php匹配问题

文章内容:我是中国人,我喜欢上javaeye 填写的标签:中国 显示的效果是:我是 &lt;a h ...

PHP基础(002)---特殊字符和开发工具

PHP的使用细节: PHP5 内置标准扩展库(如XML扩展库等);在PECL中有大量的PHP扩展库 ...

php模拟微信公众平台之我见

近期在研究微信公众平台的相关内容,介于网上资料不是很充足,本人使用PHP整理了一下,下面贴出具体的代码 ...

PHP如何调用搜索引擎接口

php如何实现调用搜索引擎接口;这里有两个方案; 一:PHP自带的curl,当然首先要开启curl,这 ...

Solr PHP support

Solr PHP support Contents Solr PHP support ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本