_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q8600 | Net_SmartIRC.reconnect | train | public function reconnect()
{
// remember in which channels we are joined
$channels = array();
foreach ($this->_channels as $value) {
if (empty($value->key)) {
$channels[] = array('name' => $value->name);
} else {
$channels[] = array('name' => $value->name, 'key' => $value->key);
}
}
$this->disconnect(true);
while ($this->_autoretry === true
&& ($this->_autoretrymax == 0 || $this->_autoretrycount < $this->_autoretrymax)
&& $this->_updatestate() != SMARTIRC_STATE_CONNECTED
) {
$this->_autoretrycount++;
if ($this->_reconnectdelay > 0) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: delaying '
.'reconnect for '.$this->_reconnectdelay.' ms',
__FILE__, __LINE__
);
for ($i = 0; $i < $this->_reconnectdelay; $i++) {
$this->_callTimeHandlers();
usleep(1000);
| php | {
"resource": ""
} |
q8601 | Net_SmartIRC.login | train | public function login($nick, $realname, $usermode = 0, $username = null,
$password = null
) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: logging in',
__FILE__, __LINE__
);
$this->_nick = str_replace(' ', '', $nick);
$this->_realname = $realname;
if ($username !== null) {
$this->_username = str_replace(' ', '', $username);
} else {
$this->_username = str_replace(' ', '', exec('whoami'));
}
if ($password !== null) {
$this->_password = $password;
$this->send('PASS '.$this->_password, SMARTIRC_CRITICAL);
}
if (!is_numeric($usermode)) {
$ipos = strpos($usermode, 'i');
$wpos = strpos($usermode, 'w');
$val = 0;
if ($ipos) $val += 8;
if ($wpos) $val += 4;
if ($val == 0) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'DEBUG_NOTICE: login() usermode ('
.$usermode.') is not valid, using 0 instead',
| php | {
"resource": ""
} |
q8602 | Net_SmartIRC.send | train | public function send($data, $priority = SMARTIRC_MEDIUM)
{
switch ($priority) {
case SMARTIRC_CRITICAL:
$this->_rawsend($data);
break;
case SMARTIRC_HIGH:
case SMARTIRC_MEDIUM:
case SMARTIRC_LOW:
$this->_messagebuffer[$priority][] = $data;
break;
default:
$this->log(SMARTIRC_DEBUG_NOTICE, "WARNING: message ($data) "
| php | {
"resource": ""
} |
q8603 | Net_SmartIRC.isJoined | train | public function isJoined($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if (!isset($this->_channels[strtolower($channel)])) {
if ($nickname !== null) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called'
.' on a user in a channel we are not | php | {
"resource": ""
} |
q8604 | Net_SmartIRC.isFounder | train | public function isFounder($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isFounder() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
| php | {
"resource": ""
} |
q8605 | Net_SmartIRC.isAdmin | train | public function isAdmin($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isAdmin() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
| php | {
"resource": ""
} |
q8606 | Net_SmartIRC.isOpped | train | public function isOpped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isOpped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
| php | {
"resource": ""
} |
q8607 | Net_SmartIRC.isHopped | train | public function isHopped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isHopped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
| php | {
"resource": ""
} |
q8608 | Net_SmartIRC.isVoiced | train | public function isVoiced($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isVoiced() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
| php | {
"resource": ""
} |
q8609 | Net_SmartIRC.isBanned | train | public function isBanned($channel, $hostmask)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isBanned() is called '
.'and the required Channel Syncing is | php | {
"resource": ""
} |
q8610 | Net_SmartIRC.listenFor | train | public function listenFor($messagetype, $regex = '.*')
{
$listenfor = new Net_SmartIRC_listenfor();
$this->registerActionHandler($messagetype, | php | {
"resource": ""
} |
q8611 | Net_SmartIRC.registerActionHandler | train | public function registerActionHandler($handlertype, $regexhandler, $object,
$methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to registerActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$id = $this->_actionhandlerid++;
$this->_actionhandler[] = | php | {
"resource": ""
} |
q8612 | Net_SmartIRC.unregisterActionHandler | train | public function unregisterActionHandler($handlertype, $regexhandler,
$object, $methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to unregisterActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['type'] == $handlertype
| php | {
"resource": ""
} |
q8613 | Net_SmartIRC.unregisterActionId | train | public function unregisterActionId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterActionId($each);
}
return $this;
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_actionhandler[$i]);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') unregistered', __FILE__, __LINE__
);
| php | {
"resource": ""
} |
q8614 | Net_SmartIRC.registerTimeHandler | train | public function registerTimeHandler($interval, $object, $methodname = '')
{
$id = $this->_timehandlerid++;
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$this->_timehandler[] = array(
'id' => $id,
| php | {
"resource": ""
} |
q8615 | Net_SmartIRC.unregisterTimeId | train | public function unregisterTimeId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterTimeId($each);
}
return $this;
}
foreach ($this->_timehandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_timehandler[$i]);
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: '
.'timehandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_timehandler = array_values($this->_timehandler);
$timerarray = array();
foreach ($this->_timehandler as $values) {
$timerarray[] = $values->interval;
}
$this->_mintimer = (
| php | {
"resource": ""
} |
q8616 | Net_SmartIRC.unloadModule | train | public function unloadModule($name)
{
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: unloading module: '
."$name...", __FILE__, __LINE__
);
if (isset($this->_modules[$name])) {
if (in_array('module_exit',
get_class_methods(get_class($this->_modules[$name]))
)) {
$this->_modules[$name]->module_exit($this);
}
unset($this->_modules[$name]);
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: successfully' | php | {
"resource": ""
} |
q8617 | Net_SmartIRC._adduser | train | protected function _adduser(&$channel, &$newuser)
{
$lowerednick = strtolower($newuser->nick);
if ($this->isJoined($channel->name, $newuser->nick)) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'updating user: '.$newuser->nick.' on channel: '
.$channel->name, __FILE__, __LINE__
);
// lets update the existing user
$currentuser = &$channel->users[$lowerednick];
$props = array('ident', 'host', 'realname', 'ircop', 'founder',
'admin', 'op', 'hop', 'voice', 'away', 'server', 'hopcount'
);
foreach ($props as $prop) {
if ($newuser->$prop !== null) {
$currentuser->$prop = $newuser->$prop;
}
}
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'adding user: '.$newuser->nick.' to channel: '.$channel->name,
__FILE__, __LINE__
| php | {
"resource": ""
} |
q8618 | Net_SmartIRC._callTimeHandlers | train | protected function _callTimeHandlers()
{
foreach ($this->_timehandler as &$handlerinfo) {
$microtimestamp = microtime(true);
if ($microtimestamp >= $handlerinfo['lastmicrotimestamp']
+ ($handlerinfo['interval'] / 1000.0)
) {
$callback = $handlerinfo['callback'];
$handlerinfo['lastmicrotimestamp'] = $microtimestamp;
$cbstring = (is_array($callback))
? (is_object($callback[0])
? get_class($callback[0])
: $callback[0]
) . '->' . $callback[1]
: '(anonymous function)';
if (is_callable($callback)) {
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: calling "'.$cbstring.'"', | php | {
"resource": ""
} |
q8619 | Net_SmartIRC._pingcheck | train | protected function _pingcheck()
{
$time = time();
if ($time - $this->_lastrx > $this->_rxtimeout) {
$this->reconnect();
$this->_lastrx = $time;
| php | {
"resource": ""
} |
q8620 | Net_SmartIRC._rawsend | train | protected function _rawsend($data)
{
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
$this->log(SMARTIRC_DEBUG_IRCMESSAGES, 'DEBUG_IRCMESSAGES: sent: "'
.$data.'"', __FILE__, __LINE__
);
$result = fwrite($this->_socket, $data.SMARTIRC_CRLF);
if (!$result) | php | {
"resource": ""
} |
q8621 | Net_SmartIRC._removeuser | train | protected function _removeuser($ircdata)
{
if ($ircdata->type & (SMARTIRC_TYPE_PART | SMARTIRC_TYPE_QUIT)) {
$nick = $ircdata->nick;
} else if ($ircdata->type & SMARTIRC_TYPE_KICK) {
$nick = $ircdata->params[1];
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'unknown TYPE ('.$ircdata->type
.') in _removeuser(), trying default', __FILE__, __LINE__
);
$nick = $ircdata->nick;
}
$lowerednick = strtolower($nick);
if ($this->_nick == $nick) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: we left channel: '.$ircdata->channel
.' destroying...', __FILE__, __LINE__
);
unset($this->_channels[strtolower($ircdata->channel)]);
} else {
$lists = array('founders', 'admins', 'ops', 'hops', 'voices');
if ($ircdata->type & SMARTIRC_TYPE_QUIT) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: user '.$nick
.' quit, removing him from all channels', __FILE__, __LINE__
);
// remove the user from all channels
$channelkeys = array_keys($this->_channels);
foreach ($channelkeys as $channelkey) {
// loop through all channels
$channel = &$this->getChannel($channelkey);
| php | {
"resource": ""
} |
q8622 | Net_SmartIRC_listenfor.handler | train | public function handler(&$irc, &$ircdata)
{
$irc->log(SMARTIRC_DEBUG_ACTIONHANDLER,
| php | {
"resource": ""
} |
q8623 | MelisFrontShowListFromFolderPlugin.createOptionsForms | train | public function createOptionsForms()
{
// construct form
$factory = new \Zend\Form\Factory();
$formElements = $this->getServiceLocator()->get('FormElementManager');
$factory->setFormElementManager($formElements);
$formConfig = $this->pluginBackConfig['modal_form'];
$response = [];
$render = [];
if (!empty($formConfig)) {
foreach ($formConfig as $formKey => $config) {
$form = $factory->createForm($config);
$request = $this->getServiceLocator()->get('request');
$parameters = $request->getQuery()->toArray();
if (!isset($parameters['validate'])) {
$form->setData($this->getFormData());
$viewModelTab = new ViewModel();
$viewModelTab->setTemplate($config['tab_form_layout']);
$viewModelTab->modalForm = $form;
$viewModelTab->formData = $this->getFormData();
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$html = $viewRender->render($viewModelTab);
array_push($render, [
'name' => $config['tab_title'],
'icon' => $config['tab_icon'],
'html' => $html | php | {
"resource": ""
} |
q8624 | Safeurl.make | train | public function make($text, $options = null)
{
$this->setUserOptions($options); // set user defined options
$text = $this->decode($text); // decode UTF-8 chars
$text = trim($text); // trim
$text = $this->lower($text); // convert to lowercase
$text = $this->strip($text); // strip HTML
$text = $this->filter($text); // filter the input
//chop?
if (strlen($text) > $this->maxlength) {
$text = substr($text, 0, $this->maxlength);
if ($this->whole_word) {
/*
* If maxlength is small and leaves us with only part of one
* word ignore the "whole_word" filtering.
*/
$words = explode($this->separator, $text);
$temp = | php | {
"resource": ""
} |
q8625 | Safeurl.setUserOptions | train | private function setUserOptions($options)
{
if (is_array($options)) {
foreach ($options as $property => $value) {
| php | {
"resource": ""
} |
q8626 | Safeurl.convertCharacters | train | public function convertCharacters($text)
{
$text = html_entity_decode($text, ENT_QUOTES, $this->decode_charset);
| php | {
"resource": ""
} |
q8627 | Safeurl.filter | train | private function filter($text)
{
$text = preg_replace("/[^&a-z0-9-_\s']/i", '', $text);
$text = str_replace(' ', $this->separator, $text);
| php | {
"resource": ""
} |
q8628 | BackupListener.onBackupStarted | train | public function onBackupStarted(BackupEvent $event)
{
$database = $event->getDatabase();
| php | {
"resource": ""
} |
q8629 | BackupListener.onBackup | train | public function onBackup(BackupEvent $event)
{
$plugin = $this->pluginRegistry->getPlugin($event->getOption('plugin'));
$optionsResolver = new OptionsResolver();
$plugin->configureOptionsResolver($optionsResolver);
$parameter = $optionsResolver->resolve($event->getOption('parameter'));
try {
$plugin->backup($event->getSource(), $event->getDestination(), $event->getDatabase(), $parameter);
| php | {
"resource": ""
} |
q8630 | BackupListener.onBackupFinished | train | public function onBackupFinished(BackupEvent $event)
{
$database = $event->getDatabase();
$database->set('finished', (new \DateTime())->format(\DateTime::RFC3339));
$database->set('state', $event->getStatus());
| php | {
"resource": ""
} |
q8631 | BackupListener.serializeException | train | private function serializeException(\Exception $exception)
{
return [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'trace' => $exception->getTrace(),
'file' => $exception->getFile(),
| php | {
"resource": ""
} |
q8632 | DoctrineMigrationRepository.repositoryExists | train | public function repositoryExists()
{
$schema = $this->em->getConnection()->getSchemaManager();
$tables = array_filter($schema->listTables(), function ($value) {
| php | {
"resource": ""
} |
q8633 | Gdaemon.writeAndReadSocket | train | protected function writeAndReadSocket($buffer)
{
$this->writeSocket($buffer . self::SOCKET_MSG_ENDL);
| php | {
"resource": ""
} |
q8634 | AuthClient.AuthEnable | train | public function AuthEnable(AuthEnableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthEnable',
| php | {
"resource": ""
} |
q8635 | AuthClient.AuthDisable | train | public function AuthDisable(AuthDisableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthDisable',
| php | {
"resource": ""
} |
q8636 | AuthClient.Authenticate | train | public function Authenticate(AuthenticateRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/Authenticate',
| php | {
"resource": ""
} |
q8637 | AuthClient.UserAdd | train | public function UserAdd(AuthUserAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserAdd',
$argument, | php | {
"resource": ""
} |
q8638 | AuthClient.UserGet | train | public function UserGet(AuthUserGetRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserGet',
$argument, | php | {
"resource": ""
} |
q8639 | AuthClient.UserList | train | public function UserList(AuthUserListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserList',
| php | {
"resource": ""
} |
q8640 | AuthClient.UserDelete | train | public function UserDelete(AuthUserDeleteRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserDelete',
| php | {
"resource": ""
} |
q8641 | AuthClient.UserChangePassword | train | public function UserChangePassword(AuthUserChangePasswordRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserChangePassword',
| php | {
"resource": ""
} |
q8642 | AuthClient.UserGrantRole | train | public function UserGrantRole(AuthUserGrantRoleRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserGrantRole',
| php | {
"resource": ""
} |
q8643 | AuthClient.UserRevokeRole | train | public function UserRevokeRole(AuthUserRevokeRoleRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserRevokeRole',
| php | {
"resource": ""
} |
q8644 | AuthClient.RoleAdd | train | public function RoleAdd(AuthRoleAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleAdd',
$argument, | php | {
"resource": ""
} |
q8645 | AuthClient.RoleGet | train | public function RoleGet(AuthRoleGetRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleGet',
$argument, | php | {
"resource": ""
} |
q8646 | AuthClient.RoleList | train | public function RoleList(AuthRoleListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleList',
| php | {
"resource": ""
} |
q8647 | AuthClient.RoleDelete | train | public function RoleDelete(AuthRoleDeleteRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleDelete',
| php | {
"resource": ""
} |
q8648 | AuthClient.RoleGrantPermission | train | public function RoleGrantPermission(AuthRoleGrantPermissionRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleGrantPermission',
| php | {
"resource": ""
} |
q8649 | AuthClient.RoleRevokePermission | train | public function RoleRevokePermission(AuthRoleRevokePermissionRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/RoleRevokePermission',
| php | {
"resource": ""
} |
q8650 | Model.load | train | public function load($relations)
{
$query = $this->newQuery()->with(
is_string($relations) ? func_get_args() : $relations
);
| php | {
"resource": ""
} |
q8651 | Model.freshTimestamp | train | public function freshTimestamp()
{
$t = microtime(true);
$micro = sprintf("%06d",($t - floor($t)) * 1000000);
| php | {
"resource": ""
} |
q8652 | FileDescriptorProto.addDependency | train | public function addDependency($value)
{
if ($this->dependency === null) { | php | {
"resource": ""
} |
q8653 | FileDescriptorProto.addPublicDependency | train | public function addPublicDependency($value)
{
if ($this->public_dependency === null) { | php | {
"resource": ""
} |
q8654 | FileDescriptorProto.addWeakDependency | train | public function addWeakDependency($value)
{
if ($this->weak_dependency === null) { | php | {
"resource": ""
} |
q8655 | FileDescriptorProto.addMessageType | train | public function addMessageType(\google\protobuf\DescriptorProto $value)
{
if ($this->message_type === null) {
$this->message_type = new | php | {
"resource": ""
} |
q8656 | FileDescriptorProto.addEnumType | train | public function addEnumType(\google\protobuf\EnumDescriptorProto $value)
{
if ($this->enum_type === null) {
$this->enum_type = new | php | {
"resource": ""
} |
q8657 | FileDescriptorProto.addService | train | public function addService(\google\protobuf\ServiceDescriptorProto $value)
{
if ($this->service === null) {
$this->service = new | php | {
"resource": ""
} |
q8658 | FileDescriptorProto.addExtension | train | public function addExtension(\google\protobuf\FieldDescriptorProto $value)
{
if ($this->extension === null) {
$this->extension = new | php | {
"resource": ""
} |
q8659 | SshConnection.execute | train | public function execute($command, callable $callback = null)
{
$this->login();
| php | {
"resource": ""
} |
q8660 | SshConnection.executeNanbando | train | public function executeNanbando($command, array $parameter, callable $callback = null)
{
$this->login();
$parameterString = [];
foreach ($parameter as $key => $value) {
if (!is_array($value)) {
$value = [$value];
}
foreach ($value as $item) {
$parameterString[] = trim((is_string($key) ? $key . ' ' : '') . $item);
| php | {
"resource": ""
} |
q8661 | SshConnection.get | train | public function get($remoteFile, $localFile)
{
$this->login();
if (!isset($this->ssh)) {
return false;
}
if (!$this->ssh->exec('scp -f ' . escapeshellarg($remoteFile), false)) { // -f = from
return false;
}
$this->sendPacket("\0");
if (!preg_match('#(?<perms>[^ ]+) (?<size>\d+) (?<name>.+)#', rtrim($this->receivePacket()), $info)) {
return false;
}
$this->sendPacket("\0");
$size = 0;
$fp = null;
if ($localFile !== false) {
$fp = @fopen($localFile, 'wb');
if (!$fp) {
return false;
}
}
$progressBar = new ProgressBar($this->output, $info['size']);
$progressBar->setFormat(' %message% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%');
$progressBar->start();
$byteFormatter = new ByteFormatter();
$content = '';
while ($size < $info['size']) {
$data = $this->receivePacket();
// SCP usually seems to split stuff out into 16k chunks
| php | {
"resource": ""
} |
q8662 | SshConnection.login | train | private function login()
{
if ($this->loggedIn) {
return;
}
if (array_key_exists('rsakey', $this->sshConfig)) {
$this->loginWithRsaKey();
| php | {
"resource": ""
} |
q8663 | SshConnection.loginWithPassword | train | private function loginWithPassword()
{
$password = $this->sshConfig['password'];
if (!is_string($password)) {
$password = $this->askForPassword(
sprintf(
'Password for %s@%s:%s: ',
$this->sshConfig['username'],
$this->sshConfig['host'],
$this->sshConfig['port']
| php | {
"resource": ""
} |
q8664 | SshConnection.loginWithRsaKey | train | private function loginWithRsaKey()
{
$key = new RSA();
$password = $this->sshConfig['rsakey']['password'];
if ($password) {
if (!is_string($password)) {
$password = $this->askForPassword(
sprintf('Password for file "%s": ', | php | {
"resource": ""
} |
q8665 | SshConnection.askForPassword | train | private function askForPassword($question)
{
$questionHelper = new QuestionHelper();
$question = new Question($question);
$question->setHidden(true);
$question->setHiddenFallback(false);
| php | {
"resource": ""
} |
q8666 | SshConnection.validate | train | private function validate()
{
if (!$this->testServer($this->ssh, sprintf('-d "%s"', $this->directory))) {
throw new SshValidateException('Directory does not exists');
}
| php | {
"resource": ""
} |
q8667 | AmaranHandler.create | train | public function create()
{
$script = "<script>\n\t$(function(){ \n\t\t";
if ($this->click) {
$script .= "\t$('".$this->click[0]."').on('".$this->click[1]."',function(){ \n\t\t\t\t $.amaran(". json_encode($this->amaran).") \n\t\t\t}); \n\t\t});\n\t</script>\n";
} else {
$script .= "$.amaran(".json_encode($this->amaran)."); \n\t });\n</script>\n";
| php | {
"resource": ""
} |
q8668 | Builder.whereSub | train | protected function whereSub($column, $operator, Closure $callback, $boolean)
{
$type = 'Sub';
$query = $this->newQuery();
// Once we have the query instance we can simply execute it so it can add all
// of the sub-select's conditions to itself, and then we can cache it off
// in the array of where clauses for the "main" parent query instance.
| php | {
"resource": ""
} |
q8669 | Builder.whereInSub | train | protected function whereInSub($column, Closure $callback, $boolean, $not)
{
$type = $not ? 'NotInSub' : 'InSub';
// To create the exists sub-select, we will actually create a query and call the
// provided callback with the query so the developer may set any of the query
// conditions they want for the in clause, then we'll put it in this array.
| php | {
"resource": ""
} |
q8670 | Builder.whereTime | train | public function whereTime($column, $operator, $value, $boolean = 'and')
{
| php | {
"resource": ""
} |
q8671 | Builder.backupFieldsForCount | train | protected function backupFieldsForCount()
{
foreach (['orders', 'limit', 'offset', 'columns'] as $field) {
$this->backups[$field] = $this->{$field};
$this->{$field} = null;
}
foreach (['order', | php | {
"resource": ""
} |
q8672 | UploadListener.createFileHistory | train | protected function createFileHistory(PostPersistEvent $event)
{
// Find original filename in request uploaded file
$files = $event->getRequest()->files->all();
$uploadedFile = array_pop($files);
| php | {
"resource": ""
} |
q8673 | Builder.mergeConstraintsFrom | train | public function mergeConstraintsFrom(Builder $from)
{
$whereBindings = array_get(
$from->getQuery()->getRawBindings(), 'where', []
);
// Here we have some other query that we want to merge the where constraints from. We will
// copy over any where constraints on the query as well as remove any global scopes the
| php | {
"resource": ""
} |
q8674 | Builder.firstOr | train | public function firstOr($columns = ['*'], callable $callback = null)
{
if (is_callable($columns)) {
$callback = $columns;
$columns = ['*'];
}
| php | {
"resource": ""
} |
q8675 | ModelFactory.map | train | public function map($row){
$class = $this->modelClass;
$model = new $class($this->db, $row, false);
| php | {
"resource": ""
} |
q8676 | ModelFactory.mapModels | train | public function mapModels($rows){
$rst = array();
foreach($rows as | php | {
"resource": ""
} |
q8677 | ModelFactory.create | train | public function create($row = array()){
$class = $this->modelClass;
$model = new $class($this->db, $row);
| php | {
"resource": ""
} |
q8678 | ModelFactory.count | train | public function count($conditions = '', $params = array()){
return | php | {
"resource": ""
} |
q8679 | ModelFactory.findOne | train | public function findOne($conditions, $params = array()){
$row = $this->db->builder()->select()->from($this->table)->where($conditions, $params)->limit(1)->queryRow();
| php | {
"resource": ""
} |
q8680 | ModelFactory.findByPK | train | public function findByPK($pk){
$pkConditions = $this->buildPKConditions($this->pk, $pk);
| php | {
"resource": ""
} |
q8681 | ModelFactory.findMany | train | public function findMany($conditions = '', $params = array(), $orderBy = null, $limit = null, $offset = null){
$cmd = $this->db->builder()->select()->from($this->table)->where($conditions, $params);
if($orderBy){
$cmd->orderBy($orderBy);
}
| php | {
"resource": ""
} |
q8682 | ModelFactory.findManyBy | train | public function findManyBy($key, $value, $orderBy = null, $limit = null, $offset = null){
| php | {
"resource": ""
} |
q8683 | ModelFactory.update | train | public function update($values, $conditions, $params = array()){
return | php | {
"resource": ""
} |
q8684 | ModelFactory.updateByPK | train | public function updateByPK($pk, $values){
$pkConditions = $this->buildPKConditions($this->pk, $pk);
| php | {
"resource": ""
} |
q8685 | ModelFactory.delete | train | public function delete($conditions, $params = array()){
| php | {
"resource": ""
} |
q8686 | ModelFactory.deleteByPK | train | public function deleteByPK($pk){
$pkConditions = $this->buildPKConditions($this->pk, $pk);
| php | {
"resource": ""
} |
q8687 | BelongsToMany.findMany | train | public function findMany($ids, $columns = ['*'])
{
return empty($ids) ? | php | {
"resource": ""
} |
q8688 | curlMaster.Array2string | train | private function Array2string($arr, $glue = '&') {
if (!is_array($arr)) {
throw new Exception('Argument arr must be | php | {
"resource": ""
} |
q8689 | curlMaster.getHeaders | train | private function getHeaders($str) {
$str = explode(self::LE . self::LE, $str);
$str = reset($str);
$str = explode(self::LE, $str);
$new = array();
$s = 1;
foreach ($str as $line) {
$pos = strpos($line, ': ');
if ($pos !== false) {
| php | {
"resource": ""
} |
q8690 | curlMaster.getBody | train | private function getBody($str) {
$str = substr($str, | php | {
"resource": ""
} |
q8691 | curlMaster.ParseCachingHeader | train | private function ParseCachingHeader($arr) {
if (!empty($arr['cache-control'])) {
if (strpos('no-cache', $arr['cache-control']) !== false) {
return 0;
}
if (strpos('no-store', $arr['cache-control']) !== false) {
return 0;
}
if (strpos('max-age=0', $arr['cache-control']) !== false) {
| php | {
"resource": ""
} |
q8692 | curlMaster.GetCookieFileName | train | private function GetCookieFileName($url) {
$temp = parse_url($url);
$ext = (string) $this->CookieMaxAge;
return | php | {
"resource": ""
} |
q8693 | curlMaster.DeleteChacheFile | train | public function DeleteChacheFile($filename) {
if (preg_match('/^\/CURL_RESPON-[0-9a-f]{40}\.\d+$/', $filename)) {
$filename = $this->CacheDir . $filename;
| php | {
"resource": ""
} |
q8694 | curlMaster.FilePutContents | train | private function FilePutContents($file, $str) {
$fileObj = new SplFileObject($file, 'w');
while (!$fileObj->flock(LOCK_EX)) {
usleep(1);
}
| php | {
"resource": ""
} |
q8695 | curlMaster.FileGetContents | train | private function FileGetContents($file) {
$fileObj = new SplFileObject($file, 'r');
while (!$fileObj->flock(LOCK_EX)) {
usleep(1);
}
$str | php | {
"resource": ""
} |
q8696 | PWEModule.getBaseLink | train | protected function getBaseLink()
{
$res = '.';
$res .= str_repeat("/..", | php | {
"resource": ""
} |
q8697 | App.addRoute | train | public function addRoute(string $method, string $route, ...$callback)
{
$method = strtolower($method);
$route = ltrim($route, '/');
$group = rtrim($this->group, '/') . '/';
$route = $group . $route;
$scope = $this->middleware->count();
$this->layer[$method][] | php | {
"resource": ""
} |
q8698 | App.import | train | public function import(array $loader)
{
$this->loader = $loader;
foreach ($loader as $alias => $namespace) {
$alias = $this->alias($alias);
$this->container->set($alias, function ($c) use ($alias, $namespace) {
if (is_callable([$namespace, 'make'])) {
| php | {
"resource": ""
} |
q8699 | ApplicationData.getData | train | public function getData()
{
$data = [];
foreach ($this->providerList as | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.