Ejemplo n.º 1
0
 /**
  *
  *
  *
  *
  * @param QueryBuilder $queryBuilder
  * @param array $params
  * @return array
  *
  * @version 20130211, d10n:
  */
 function MultiQuery(QueryBuilder $queryBuilder, $params = array())
 {
     //die();
     // 20130211 d10n :
     $str = $queryBuilder->Prepare($params);
     //print_r($str);
     $timer = Timer::Start();
     $mqresult = mysqli_multi_query($this->connection, $str);
     //print_r($mqresult);
     //die();
     if (!$mqresult) {
         print_r("Error executing query<br><b>{$str}</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str);
         trigger_error("Error executing multi query (rowset #1) <br><b>{$str}</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str, E_USER_ERROR);
         //print_r("Error executing multi query (rowset #1) <br><b>$str</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str);
         //print_r("Error executing multi query (rowset #1) <br><b>$str</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str, E_USER_ERROR);
         _503('Error');
     }
     $res = array();
     $counter = 1;
     do {
         $counter++;
         if ($result = mysqli_store_result($this->connection)) {
             $set = array();
             while ($row = mysqli_fetch_assoc($result)) {
                 $set[] = $row;
             }
             mysqli_free_result($result);
             $res[] = $set;
         }
         $more_result = mysqli_more_results($this->connection);
         if ($more_result) {
             if (!mysqli_next_result($this->connection)) {
                 //print_r("Error executing query<br><b>$str</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str);
                 trigger_error("Error executing multi query (rowset #{$counter}) <br><b>{$str}</b><br>" . mysqli_errno($this->connection) . ": " . mysqli_error($this->connection) . "\n" . $str, E_USER_ERROR);
                 _503('Error');
             }
         }
     } while ($more_result);
     //
     //
     // CUT_LOG yes/no
     // MAX_LENGTH_PER_PARAM > 100
     if (CUT_LOG == 'yes') {
         foreach ($params['values'] as $key => $value) {
             $value = (string) $value;
             if (mb_strlen($value) > MAX_LENGTH_PER_PARAM) {
                 $params['values'][$key] = mb_strcut($value, 0, MAX_LENGTH_PER_PARAM) . ' ...';
             }
         }
         $str = $queryBuilder->Prepare($params);
     }
     $this->_log_query($str, $timer->Stop());
     //print_r('1');
     return $res;
 }
Ejemplo n.º 2
0
        $clone_url = $payload['repository'][$app_conf['is_private'] ? 'ssh_url' : 'clone_url'];
        $ref = $payload['ref'];
        $git_hash = $payload['head_commit']['id'];
        if ($clone_url && $ref) {
            $ok = deploy_git($ref, $path, $clone_url, $app_conf);
        }
        !$ok && _503();
        echo strtoupper($event) . ' ' . $app_conf['name'] . ' ' . basename($ref) . ' ' . ($ok ? 'OK' : 'ERROR');
    } elseif ($event == 'ping') {
        echo 'PONG';
    } else {
        echo 'EVENT NOT SUPPORTED';
    }
} elseif ($provider === 'bitbucket') {
    $event = strtolower($_SERVER['HTTP_X_EVENT_KEY']);
    if (in_array($event, array('repo:push'))) {
        $clone_url = 'git@bitbucket.org:' . $payload['repository']['full_name'] . '.git';
        $ref = $payload['push']['changes'][0]['new']['name'];
        $git_hash = $payload['push']['changes'][0]['new']['target']['hash'];
        if ($clone_url && $ref) {
            $ok = deploy_git($ref, $path, $clone_url, $app_conf);
        }
        !$ok && _503();
        echo strtoupper($event) . ' ' . $app_conf['name'] . ' ' . basename($ref) . ' ' . ($ok ? 'OK' : 'ERROR');
    } else {
        echo 'EVENT NOT SUPPORTED';
    }
}
$msg = implode(PHP_EOL, ['[' . date('Y-m-d H:i:s') . ']', 'deployed in: ' . round(microtime(true) - $ts, 3) . ' seconds', 'provider: ' . $provider, 'event: ' . $event, 'branch: ' . basename($ref), 'hash: ' . $git_hash, 'clone_url: ' . $clone_url, 'path: ' . $path, 'host: ' . $_SERVER['HTTP_HOST']]);
echo PHP_EOL . $msg;
send_to_slack($app_conf, $msg, '#github');