小编her*_*ron的帖子

设置PHP项目的自动GIT部署

我想要做的是,从FTP部署切换到GIT.我的意思是,我想保持自动保持同步我的Bitbucket私人仓库和我的共享虚拟主机.我用Google搜索并找到以下脚本来部署我的网络服务器(基于这篇文章).

// Set these dependant on your BB credentials    
$username = 'username';
$password = 'password';

// Grab the data from BB's POST service and decode
$json = stripslashes($_POST['payload']);
$data = json_decode($json);

// Set some parameters to fetch the correct files
$uri   = $data->repository->absolute_url;
$node  = $data->commits[0]->node;
$files = $data->commits[0]->files;

// Foreach through the files and curl them over    
foreach ($files as $file) {
    if ($file->type == "removed") {
        unlink($file->file);
    } else {
        $url  = "https://api.bitbucket.org/1.0/repositories"
            . $uri . …
Run Code Online (Sandbox Code Playgroud)

php git deployment bitbucket web

7
推荐指数
1
解决办法
4131
查看次数

如何通过变量获取定义的值

我的数据库表1行看起来像那样

在此输入图像描述

我正在存储在body中使用的所有变量,在另一列中命名vars.然后获取所有变量.如果它们是多个,则按","符号爆炸.

我想要做的是,从db获取所有使用过的变量,然后通过第二个函数过滤它们filter.如你所见,过滤器有3个输入:$content, $needle, $replacement.

$ content - 消息正文,

$ needle - %.我们正在寻找什么.%

$ replacement - 是我们从数据库获得的var,由php定义.例如,如果我从数据库获得wsurl,它已经在我的settings.php中定义,如DEFINE("wsurl","www.yourdomain.com").

问题是,如何将定义值作为第三个输入发送 - $replacement

public function genMsg($id) {
    $msgid = $id;
    $stmt = $db->prepare('SELECT `body`, `status`, `vars` FROM `messages` WHERE `id`=?') or die(htmlspecialchars($this->db->error));
    $stmt->bind_param("i", $msgid) or die(htmlspecialchars($stmt->error));
    $stmt->execute() or die(htmlspecialchars($stmt->error));
    $stmt->bind_result($message, $status, $vars) or die($stmt->error);
    $stmt->fetch() or die($stmt->error);
    $stmt->close();
    $image = ($status == -1) ? "fail" : "success";
    if (isset($vars) && !empty($vars)) {
        if (strpos($vars, …
Run Code Online (Sandbox Code Playgroud)

php mysql mysqli prepared-statement

6
推荐指数
1
解决办法
7801
查看次数

如何在$ .post jQuery中等待响应

PHP以1-2秒延迟返回值jQuery.post不等待响应.

您如何看待,是否有可能解决该问题并等待响应?

    $.post( sSource, aoData, function (data) {    
        oCache.lastJson = jQuery.extend(true, {}, data);
        if ( oCache.iCacheLower != oCache.iDisplayStart )
        {
            data.aaData.splice( 0, oCache.iDisplayStart-oCache.iCacheLower );
        }
        data.aaData.splice( oCache.iDisplayLength, data.aaData.length );
         abc(oCache);
        fnCallback(data); 
    },"json" );
Run Code Online (Sandbox Code Playgroud)

请注意相同的功能与get工作正常

    $.getJSON( sSource, aoData, function (json) { 
        /* Callback processing */
        oCache.lastJson = jQuery.extend(true, {}, json);

        if ( oCache.iCacheLower != oCache.iDisplayStart )
        {
            json.aaData.splice( 0, oCache.iDisplayStart-oCache.iCacheLower );
        }
        json.aaData.splice( oCache.iDisplayLength, json.aaData.length );

        fnCallback(json)
    } );
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery post

6
推荐指数
1
解决办法
2万
查看次数

C#:水平翻转图像

我要做的是,在单选按钮上水平翻转图像.

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
    arrow.Image.RotateFlip(RotateFlipType.RotateNoneFlipX);
}
Run Code Online (Sandbox Code Playgroud)

上面的代码不会翻转图像:图像保持不变.我错过了什么?

c# image rotation visual-studio-2010 visual-studio

6
推荐指数
1
解决办法
6375
查看次数

遇到MySQL查询问题

需要生成课程列表和计数

  1. 所有
  2. 悬而未决
  3. 回答但未经检查

问题.

这是我的查询

SELECT c.id, 
    c.name, 
    COUNT(allq.id) 'All', 
    COUNT(unanswered.id) 'Unanswered',
    COUNT(unchecked.id) 'Unchecked'
FROM courses c
LEFT JOIN `courses-lessons` cl 
    ON c.id = cl.cid
LEFT JOIN lesson_questions allq 
    ON cl.id = allq.lid
LEFT JOIN
(
    SELECT q.id, a.qid, q.lid
    FROM lesson_questions q
    LEFT JOIN 
    (
        SELECT id, qid
        FROM answers
        WHERE id NOT IN (SELECT aid FROM answer_chk_results)
    ) a 
        ON q.id = a.qid 
) unchecked 
    ON cl.id = unchecked.lid
LEFT JOIN
(
    SELECT id
    FROM lesson_questions
    WHERE …
Run Code Online (Sandbox Code Playgroud)

mysql sql database

6
推荐指数
1
解决办法
165
查看次数

PHP递归删除功能

我为删除文件夹编写了递归PHP函数.我想知道,我如何修改此功能以删除webhosting中的所有文件和文件夹,不包括给定的文件和文件夹名称数组(例如cgi-bin,.htaccess)?

BTW

使用此函数完全删除这样调用的目录

recursive_remove_directory('path/to/directory/to/delete');
Run Code Online (Sandbox Code Playgroud)

使用此函数清空调用目录,如下所示:

recursive_remove_directory('path/to/full_directory',TRUE);
Run Code Online (Sandbox Code Playgroud)

现在功能是

function recursive_remove_directory($directory, $empty=FALSE)
{
    // if the path has a slash at the end we remove it here
    if(substr($directory,-1) == '/')
    {
        $directory = substr($directory,0,-1);
    }

    // if the path is not valid or is not a directory ...
    if(!file_exists($directory) || !is_dir($directory))
    {
        // ... we return false and exit the function
        return FALSE;

    // ... if the path is not readable
    }elseif(!is_readable($directory))
    {
        // ... we return false and exit the function …
Run Code Online (Sandbox Code Playgroud)

php recursion dir unlink delete-file

5
推荐指数
1
解决办法
1616
查看次数

如何使用JS设置占位符

请看一下这个小提琴:

http://jsfiddle.net/KA85s/3/

JQ-UI将第一个选项设置为默认选项。我不希望发生这种情况:相反,我想设置HTML5占位符。

如何<option>为这些JS生成的输入设置HTML 5占位符(而不是first available )?

在此处输入图片说明

javascript jquery jquery-ui placeholder jquery-plugins

5
推荐指数
1
解决办法
2万
查看次数

从互联网上获取汇率

我想做的是,从互联网上获取汇率.经过长时间的研究,我发现了这个功

protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
        string xmlResult = null;
        string url;
        url = "http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=" + TextBox1.Text + "&ToCurrency=" + TextBox2.Text + "";
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        StreamReader resStream = new StreamReader(response.GetResponseStream());
        XmlDocument doc = new XmlDocument();
        xmlResult = resStream.ReadToEnd();
        doc.LoadXml(xmlResult);
        Label1.Text = "Current Exchange Rate for " + TextBox1.Text.ToUpper() + " ---> " + TextBox2.Text.ToUpper() + " value " + doc.GetElementsByTagName("double").Item(0).InnerText;
        }
        catch(Exception ex)
        {
            Label1.Text="Not a valid Currency or Try …
Run Code Online (Sandbox Code Playgroud)

c# windows visual-studio-2010 visual-studio winforms

5
推荐指数
1
解决办法
1万
查看次数

Google文档查看器禁用下载

请看一下这个链接

http://jsfiddle.net/C7Py6/3/

谷歌浏览器工具栏上的最后一个图标 - 在此输入图像描述使用户能够在新的浏览器窗口上查看并下载PDF.问题是,如何才能使其仅查看并禁用下载(至少禁用此工具栏项).这可能与谷歌浏览器?或者是否有任何其他查看器像Google Viewer一样但只能查看?

html pdf iframe google-docs

5
推荐指数
1
解决办法
2万
查看次数

从Google Maps Embed iframe删除黑色标题

请看这个例子。

http://jsfiddle.net/Lscxuyhe/

代码如下:

<iframe src="https://www.google.com/maps/d/u/0/embed?mid=zUN79N8r2n1E.kLstghIFzhKU" width="640" height="480"></iframe>
Run Code Online (Sandbox Code Playgroud)

我创建了自定义的谷歌地图。现在无法从地图iframe的顶部删除黑色标题(已写无标题地图)。谷歌搜索很多。没有发现。

有什么建议么?

iframe google-maps google-maps-embed

5
推荐指数
2
解决办法
1万
查看次数