function edit_post($f3) { // Update Tool Locations $this->D->sharedLocationsList = array(); if ($f3->exists('POST.locations')) { foreach ($f3->get('POST.locations') as $id) { $this->D->sharedLocationsList[] = \R::load('locations', $id); } } $f3->clear('POST.locations'); $this->D->import($f3->get('POST')); $this->D->training_levels or $this->D->training_levels = json_encode($f3->get('TRAINING_LEVELS')); \R::begin(); try { $id = \R::store($this->D); \R::commit(); } catch (\Exception $e) { \R::rollback(); if ($e->getSQLState() == 23000) { } throw new \Exception($this->D->name . ' is not a unique name.'); throw new \Exception(); } if ($f3->get('dry')) { logger($f3, 'added ' . $this->class_name() . ', id=' . $id); } else { logger($f3, 'modified ' . $this->class_name() . ', id=' . $id); } $f3->reroute($this->redirect()); }
function update_field($id, $field, $value) { $client = R::load('client', $id); $client->{$field} = $value; R::store($client); return $id; }
/** * Test tainted. * * @return void */ public function testTainted() { testpack('Original Tainted Tests'); $redbean = R::$redbean; $spoon = $redbean->dispense("spoon"); asrt($spoon->getMeta("tainted"), TRUE); $spoon->dirty = "yes"; asrt($spoon->getMeta("tainted"), TRUE); testpack('Tainted List test'); $note = R::dispense('note'); $note->text = 'abc'; $note->ownNote[] = R::dispense('note')->setAttr('text', 'def'); $id = R::store($note); $note = R::load('note', $id); asrt($note->isTainted(), FALSE); // Shouldn't affect tainted $note->text; asrt($note->isTainted(), FALSE); $note->ownNote; asrt($note->isTainted(), TRUE); testpack('Tainted Test Old Value'); $text = $note->old('text'); asrt($text, 'abc'); asrt($note->hasChanged('text'), FALSE); $note->text = 'xxx'; asrt($note->hasChanged('text'), TRUE); $text = $note->old('text'); asrt($text, 'abc'); testpack('Tainted Non-exist'); asrt($note->hasChanged('text2'), FALSE); testpack('Misc Tainted Tests'); $bean = R::dispense('bean'); $bean->hasChanged('prop'); $bean->old('prop'); }
public function show_ChatMessage() { $msg = trim($_POST["message"]); if (empty($msg) || strlen($msg) > 255) { $this->error('Die Chat Nachricht darf nicht leer und nicht länger als 255 Zeichen sein!'); } $message = R::dispense('chat_message'); if (preg_match('#^/private "([^"]*)" (.*)$#i', $msg, $m)) { $msg = $m[2]; $usr = R::findOne('user', ' username = ?', array($m[1])); if (!$usr) { $this->error('Der angegebene Benutzer konnte nicht gefunden werden.'); } $targetPos = R::findOne('map_position', ' user_id = ?', array($usr->getID())); if ($targetPos[$usr->getID()]->map != $this->mapPosition->map) { $this->error('Der angegebene Benutzer ist nicht in deiner Nähe! '); } $message->type = 'private'; $message->visible_for = $usr; } else { $message->type = 'public'; } $message->map = $this->mapPosition->map; $message->time = time(); $message->author = $this->user->username; $message->player = $this->user; $message->text = $msg; R::store($message); }
/** * creates a user with the $data provided in local DB * * @param array $data [description] * @return [type] [description] */ function create($data = array(), &$errorMessage) { // require password hashing library require_once ROOT . '/lib/passwordHash.php'; $bungieData = file_get_contents('http://www.bungie.net/Platform/User/SearchUsersPaged/' . $data['gamerid'] . '/1/'); $bungie = json_decode($bungieData, true); // provided we get results if ($bungie['Response']['totalResults'] > 0) { // get user from bungie $buser = $bungie['Response']['results'][0]; // create user in ocd $user = R::dispense('users'); // collate data $user['bungie'] = $buser['membershipId']; $user['gamerid'] = $data['gamerid']; $user['platform'] = $data['platform']; $user['email'] = $data['email']; $user['password'] = lib\PasswordHash::create_hash($data['password']); $user['level'] = 100; $user['avatar'] = 'https://www.bungie.net' . $buser['profilePicturePath']; $uid = R::store($user); if ($uid != null) { return true; } } else { $errorMessage = "We couldn't find you in Bungie's Destiny DB - there may be an update to the DB in progress, please try again later!"; } return false; }
public function save() { if ($this->is_validated()) { if ($this->isDublicateUser($this->validated_data['user_name'])) { $this->setError('Duplicate username,Please choose another'); } elseif ($this->isNotStrongPassword($this->validated_data['user_password'])) { $this->setError('Please choose strong password'); } else { $clientreseller = R::dispense("user"); $clientreseller->fullname = $this->validated_data['reseller_user_id']; $clientreseller->linetitle = $this->validated_data['reseller_line_id']; $clientreseller->currencyrate = $this->validated_data['reseller_currency_conversion_rate']; $clientreseller->username = $this->validated_data['reseller_cpanel_user_name']; $clientreseller->password = md5(SALT . $this->validated_data['reseller_cpanel_password']); $clientreseller->resellerlevel = $this->validated_data['reseller_level']; $clientreseller->note = $this->validated_data['reseller_notes']; $clientreseller->type = 4; $clientreseller->createdate = CURRENT_DTT; $clientreseller->updatedate = CURRENT_DTT; $clientreseller->createby = 1001; $clientreseller->isactive = 1; $clientresellerid = R::store($clientreseller); } } if ($this->getError() == "") { $this->fails = FALSE; } else { $this->fails = TRUE; } }
function douban_callback() { OAuthRequester::requestAccessToken(DOUBAN_KEY, $_SESSION['oauth_token'], 0, 'POST', $options = array('oauth_verifier' => $_SESSION['oauth_token'])); $req = new OAuthRequester('http://api.douban.com/people/' . urlencode('@me'), 'get'); $res = $req->doRequest(); $user_data = new SimpleXMLElement($res['body']); $uid = array_pop(explode('/', $user_data->id)); $auth_type = 'douban'; $auth = R::findOne('oauth', "uid=? AND type=?", array($uid, $auth_type)); if (!$auth) { $auth = R::dispense('oauth'); $auth->uid = $uid; $auth->type = $auth_type; $encrypt_key = rand(100000, 999999); $auth->secret = $encrypt_key; } else { $encrypt_key = $auth->secret; } $cookie_str = sha1(implode('', array($uid, $auth_type, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $encrypt_key))); $expire = time() + 3600 * 24 * 365; setcookie('s', $cookie_str, $expire); setcookie('auth_type', $auth_type, $expire); setcookie('uid', $uid, $expire); $auth->setMeta('buildcommand.unique', array(array('uid', 'type'))); $auth->setMeta('buildcommand.indexes', array('uid' => 'uid')); R::store($auth); }
public function dologinAction() { Db::connect(); $bean = R::dispense('user'); // the redbean model $required = ['Name' => 'name', 'Email' => 'email', 'User_Name' => ['rmnl', 'az_lower'], 'Password' => 'password_hash']; \RedBeanFVM\RedBeanFVM::registerAutoloader(); // for future use $fvm = \RedBeanFVM\RedBeanFVM::getInstance(); $fvm->generate_model($bean, $required); //the magic R::store($bean); $val = new validation(); $val->addSource($_POST)->addRule('email', 'email', true, 1, 255, true)->addRule('password', 'string', true, 10, 150, false); $val->run(); if (count($val->errors)) { Debug::r($val->errors); foreach ($val->errors as $error) { Notification::setMessage($error, Notification::TYPE_ERROR); } $this->redirect(Request::createUrl('login', 'login')); } else { Notification::setMessage("Welcome back !", Notification::TYPE_SUCCESS); Debug::r($val->sanitized); session::set('user', ['sanil']); $this->redirect(Request::createUrl('index', 'index')); } }
function newarticles() { global $app; try { $request = $app->request(); $mediaType = $request->getMediaType(); $body = $request->getBody(); $input = json_decode($body); if ($input) { $article = R::dispense('articles'); $article->title = (string) $input->title; $article->url = (string) $input->url; $article->date = (string) $input->date; $id = R::store($article); $app->response()->header('Content-Type', 'application/json'); echo json_encode(R::exportAll($article)); } else { throw new ResourceNotFoundException(); } } catch (ResourceNotFoundException $e) { $app->response()->status(404); } catch (Exception $e) { $app->response()->status(400); $app->response()->header('X-Status-Reason', $e->getMessage()); } }
public function Save() { if (!$this->Verify()) { return -1; } return R::store($this->GetEvent()); }
public function process(array $documents, &$context) { $franchiseIds = []; $franchiseIds[] = self::mediaToKey($context->media); foreach ($context->relationData as $relation) { if ($relation['media'] != $context->media->media) { continue; } if ($relation['type'] == MediaRelation::Character) { continue; } if (BanHelper::isFranchiseCouplingBanned($relation['media'], $relation['mal_id'], $context->media->media, $context->media->mal_id)) { continue; } $franchiseIds[] = self::mediaToKey($relation); } foreach (R::findAll('media', 'media||mal_id IN (' . R::genSlots($franchiseIds) . ')', $franchiseIds) as $relatedMedia) { $franchiseIds[] = $relatedMedia->franchise; } $franchiseId = reset($franchiseIds); $media =& $context->media; $media->franchise = $franchiseId; R::store($media); $query = 'UPDATE media SET franchise = ? WHERE franchise IN (' . R::genSlots($franchiseIds) . ')'; R::exec($query, array_merge([$franchiseId], $franchiseIds)); }
public function handle($context) { # Ensure that the user is staff at least $context->mustbestaff(); # Load the publication RESTfully $pub = R::load('publication', $context->rest()[0]); # Check if the staff is allowed to edit it. if ($context->user()->id != $pub->uploaderId) { $context->local()->addval('error', 'You must be the staff who uploaded this to edit it.'); return 'editpub.twig'; } # Check if it's a post if ($_SERVER['REQUEST_METHOD'] === 'POST') { # Set up a new publication handler. $pubcreator = new Manipulatepub($pub, 'editpub.twig'); $returnerr = $pubcreator->manipulatepublication($context); # If it's a non-empty string a error occured. if (!empty($returnerr)) { $context->local()->addval('error', $returnerr); return 'editpub.twig'; } $pub = $pubcreator->getpub(); # Otherwise it is a publication, so store it. R::store($pub); # The publication has been sucessfully edited, let's divert the user to the view page using REST. $context->divert("/viewpub/" . $pub->id); } $context->local()->addval(['pub' => $pub, 'auths' => $pub->sharedAuthor]); return 'editpub.twig'; }
private function __probe($filename, $prettify) { // Start time $init = microtime(true); // Default options $options = '-loglevel quiet -show_format -show_streams -print_format json'; if ($prettify) { $options .= ' -pretty'; } // Avoid escapeshellarg() issues with UTF-8 filenames setlocale(LC_CTYPE, 'en_US.UTF-8'); //$command = sprintf('ffprobe %s %s ', $options, escapeshellarg($filename)); $command = sprintf('./ffprobe %s "%s" ', $options, $filename); // Run the ffprobe, save the JSON output then decode $json = json_decode(shell_exec($command), true); //if (!isset($json->format)) if (!isset($json['format'])) { //throw new Exception('Unsupported file type: '.$filename."\r\nCommand:\r\n".$command."\r\n"); $output = 'ffprobe: Unsupported file type: ' . $filename . "\r\nCommand:\r\n" . $command . "\r\n"; $colors = new Colors(); $colors->getColoredString($output, 'black', 'red'); //The command finished with an error. $error = R::dispense('error'); //$video->ownError = array($error); $error->raw_output = $output; $error->repaired = false; $id = R::store($error); } // Save parse time (milliseconds) $this->parse_time = round((microtime(true) - $init) * 1000); return $json; }
/** * Test Chill mode. * * @return void */ public function testChill() { $bean = R::dispense('bean'); $bean->col1 = '1'; $bean->col2 = '2'; R::store($bean); asrt(count(R::$writer->getColumns('bean')), 3); $bean->col3 = '3'; R::store($bean); asrt(count(R::$writer->getColumns('bean')), 4); R::freeze(array('umbrella')); $bean->col4 = '4'; R::store($bean); asrt(count(R::$writer->getColumns('bean')), 5); R::freeze(array('bean')); $bean->col5 = '5'; try { R::store($bean); fail(); } catch (Exception $e) { pass(); } asrt(count(R::$writer->getColumns('bean')), 5); R::freeze(array()); $bean->col5 = '5'; R::store($bean); asrt(count(R::$writer->getColumns('bean')), 6); }
public function process(array $documents, &$context) { $doc = $documents[self::URL_MEDIA]; $dom = self::getDOM($doc); $xpath = new DOMXPath($dom); //chapter count preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Chapters:\']/following-sibling::node()[self::text()]'), $matches); $chapterCount = Strings::makeInteger($matches[0][0]); //volume count preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Volumes:\']/following-sibling::node()[self::text()]'), $matches); $volumeCount = Strings::makeInteger($matches[0][0]); //serialization $serializationMalId = null; $serializationName = null; $q = $xpath->query('//span[text() = \'Serialization:\']/../a'); if ($q->length > 0) { $node = $q->item(0); preg_match('#/magazine/([0-9]+)$#', $node->getAttribute('href'), $matches); $serializationMalId = Strings::makeInteger($matches[1]); $serializationName = Strings::removeSpaces($q->item(0)->nodeValue); } $media =& $context->media; $media->chapters = $chapterCount; $media->volumes = $volumeCount; $media->serialization_id = $serializationMalId; $media->serialization_name = $serializationName; R::store($media); }
public function save() { if ($this->is_validated()) { if ($this->isDublicateVendor($this->validated_data['user_name'])) { $this->setError('Duplicate vendor username, Please choose another'); } elseif ($this->isNotStrongPassword($this->validated_data['user_password'])) { $this->setError('Please choose strong password'); } elseif ($this->validated_data['user_password'] != $this->validated_data['user_confirm_password']) { $this->setError('Password is not matched'); } else { $vendor = R::dispense("user"); $vendor->fullname = $this->validated_data['vendor_title']; $vendor->basecurrency = $this->validated_data['user_currency']; $vendor->username = $this->validated_data['user_name']; $vendor->password = md5(SALT . $this->validated_data['user_password']); $vendor->contactperson = $this->validated_data['vendor_contact_person']; $vendor->mobile = $this->validated_data['user_mobile']; $vendor->email = $this->validated_data['user_email']; $vendor->vendorwebsite = $this->validated_data['vendor_website']; $vendor->note = $this->validated_data['user_notes']; $vendor->type = 2; $vendor->createdate = CURRENT_DTT; $vendor->updatedate = CURRENT_DTT; $vendor->createby = 1001; $vendor->isactive = 1; $id = R::store($vendor); } } if ($this->getError() == "") { $this->fails = FALSE; } else { $this->fails = TRUE; } }
/** * @return int|string * @throws \RedBeanPHP\RedException */ function insertUser() { $users = R::dispense('users'); $users->fname = 'Abhishek'; $users->lname = 'Saha'; return R::store($users); }
/** * Test foreign keys with SQLite. * * @return void */ public function testForeignKeysWithSQLite() { $book = R::dispense('book'); $page = R::dispense('page'); $cover = R::dispense('cover'); list($g1, $g2) = R::dispense('genre', 2); $g1->name = '1'; $g2->name = '2'; $book->ownPage = array($page); $book->cover = $cover; $book->sharedGenre = array($g1, $g2); R::store($book); $fkbook = R::getAll('pragma foreign_key_list(book)'); $fkgenre = R::getAll('pragma foreign_key_list(book_genre)'); $fkpage = R::getAll('pragma foreign_key_list(page)'); asrt($fkpage[0]['from'], 'book_id'); asrt($fkpage[0]['to'], 'id'); asrt($fkpage[0]['table'], 'book'); asrt(count($fkgenre), 2); if ($fkgenre[0]['from'] == 'book') { asrt($fkgenre[0]['to'], 'id'); asrt($fkgenre[0]['table'], 'book'); } if ($fkgenre[0]['from'] == 'genre') { asrt($fkgenre[0]['to'], 'id'); asrt($fkgenre[0]['table'], 'genre'); } asrt($fkbook[0]['from'], 'cover_id'); asrt($fkbook[0]['to'], 'id'); asrt($fkbook[0]['table'], 'cover'); }
function nav_save() { G2_User::init(); if (G()->logged_in() && !empty($_POST)) { if (!empty($_POST['items']) && !empty($_POST['identity'])) { // Delete all current navigation details $navitems = R::findAll('navitem', 'identity=:id', ['id' => $_POST['identity']]); R::trashAll($navitems); foreach ($_POST['items'] as $new_item) { $nav = R::dispense('navitem'); $nav->identity = $_POST['identity']; $nav->label = $new_item['label']; $nav->href = !$new_item['href'] ? null : $new_item['href']; $nav->order = $new_item['order']; //@todo parent node support R::store($nav); } echo json_encode(['success' => true, 'message' => 'Content Saved Successfully']); } else { echo json_encode(['success' => false, 'message' => 'Data sent not correct']); } } else { echo json_encode(['success' => false, 'message' => 'Not Logged in']); } die; }
function do_stuff() { /* 26.9|0.0|0.0|31.4|0.00|0.00|0.00|0.00 */ $result = file_get_contents('http://ourproject.dyndns-server.com:8099/&'); echo $result; $rs = explode('|', $result); echo "\n"; $now = new DateTime(); $b = R::dispense('timedate'); $b->time = $now->format('Y-m-d H:i:s'); $b->T1 = $rs[0]; $b->T2 = $rs[1]; $b->T3 = $rs[2]; $b->T4 = $rs[3]; $b->V1 = $rs[4]; $b->V2 = $rs[5]; $b->V3 = $rs[6]; $b->V4 = $rs[7]; R::store($b); echo $b->time; echo "\n"; // MySQL datetime format sleep(10); // wait 20 seconds do_stuff(); // call this function again }
function saveControle($data) { $success = false; R::setup('mysql:host=' . Database::HOST . ';dbname=' . Database::NAME, Database::USERNAME, Database::PASSWORD); $controle = R::dispense('controle'); $controle->date = $data['date']; $controle->traitement = $data['traitement'] == "true" ? 1 : 0; if ($controle->traitement) { $controle->traitement_type = $data['traitement_type']; } $controle->nourrissement = $data['nourrissement'] == "true" ? 1 : 0; if ($controle->nourrissement) { $controle->nourrissement_quantite = $data['nourrissement_quantite']; } $controle->nombre_cadres_couvains = $data['nombre_cadres_couvains']; $controle_id = R::store($controle); $ruche = R::load('ruche', $data['ruche_id']); if ($ruche->id) { $ruche->ownControle[] = $controle; $saved_ruche_id = R::store($ruche); if (isset($controle_id) && isset($saved_ruche_id)) { $success = true; } } return $success; }
function register($data) { try { include_once 'dbcon.php'; } catch (Exception $e) { ?> <script type="text/javascript"> alert("Unable to connect to DB, Please contact Administrator"); </script> <?php } $admin->uname = $username; $admin->password = $password; $admin->sh_name = $shName; $admin->full_name = $fullName; $admin->desc = $desc; $admin->location = $location; $admin->address = $address; $admin->date_added = $dateAdded; $admin->estd_year = $estddate; try { R::store($admin); } catch (Exception $e) { ?> <script type="text/javascript"> alert("Unable to save to DB, Please contact Administrator"); </script> <?php } }
function addFollower($userid) { $following = R::dispense('following'); $following->userid = $_SESSION['user_id']; $following->follows = $userid; $id = R::store($following); }
function view($args) { $id = array_shift($args); $permission = R::load('permission', $id); if (!is_numeric($id) && !$permission->getID()) { $this->redirect(PACKAGE_URL); } $allgroups = R::findAll('group'); foreach ($allgroups as $key => $group) { foreach ($permission->sharedGroup as $group_c) { if ($group->id == $group_c->id) { $allgroups[$key]->checked = true; } } } // echo $permission->name;exit; $view = new G2_TwigView('pages/view'); $view->permission = $permission; $view->allGroups = $allgroups; $form = new G2_FormMagic($view->get_render()); if ($form->is_posted()) { $groups = R::loadAll('group', array_keys($form->data()['groups'])); $permission->sharedGroup = $groups; R::store($permission); Admin_Alert::add_message("\"{$permission->name}\" permission was updated"); $this->redirect(PACKAGE_URL); } echo $form->parse(); }
public function actionAuthenticate() { $objValidator = new helpers\Validation(); $params = array('email', 'password', 'devicetoken', 'devicetype'); try { $isRequestValid = $objValidator->validateRequest($params); if ($isRequestValid) { $userName = $this->_request->getPost('email'); $password = $this->_request->getPost('password'); $deviceToken = $this->_request->getPost('devicetoken'); $deviceType = $this->_request->getPost('devicetype'); $objUserAuthMdl = new \models\Users(); // check if user is valid or not $userRow = $objUserAuthMdl->authenticate($userName, $password); if ($userRow) { // update user device token and type $userRow->device_token = $deviceToken; $userRow->device_type = $deviceType; \R::store($userRow); $this->_request->sendSuccessResponse('User successfully logged in', array('token' => $userRow->token)); } else { $this->_request->sendErrorResponse(404, 404, 'Invalid username or password'); } } else { $this->_request->sendErrorResponse(403, 403, 'Request cannot be validated'); } } catch (\Exception $e) { echo $e->getMessage(); $this->_request->sendErrorResponse(404, 404, $e->getMessage()); } }
public function create_group($name) { $group = R::dispense('group'); $group->name = $name; R::store($group); return $group; }
public function save() { if ($this->is_validated()) { if ($this->isDublicateBillingUser($this->validated_data['user_name'])) { $this->setError('Duplicate Username, Please choose another'); } elseif ($this->isNotStrongPassword($this->validated_data['user_password'])) { $this->setError('Please choose strong password'); } else { if ($this->validated_data['user_password'] != $this->validated_data['user_confirm_password']) { $this->setError('Confirm password is not matched'); } else { $client = R::dispense("user"); $client->fullname = $this->validated_data['user_full_name']; $client->username = $this->validated_data['user_name']; $client->password = md5(SALT . $this->validated_data['user_password']); $client->duelimit = $this->validated_data['user_credit_limit']; $client->extralimit = $this->validated_data['user_extra_credit']; $client->type = 'client'; $client->email = $this->validated_data['user_email']; $client->mobile = $this->validated_data['user_mobile']; $client->note = $this->validated_data['user_notes']; $client->createdate = CURRENT_DTT; $client->updatedate = CURRENT_DTT; $client->createby = 1001; $client->isactive = 1; $clientid = R::store($client); } } if ($this->getError() == "") { $this->fails = FALSE; } else { $this->fails = TRUE; } } }
public function init() { // check if logged in session is valid, if not redir to main page if (!isset($_SESSION['loginHash'])) { Framework::Redir("site/index"); die; } $activeSession = R::findOne('session', ' hash = ? AND ip = ? AND expires > ?', array($_SESSION['loginHash'], $_SERVER['REMOTE_ADDR'], time())); if (!$activeSession) { unset($_SESSION['loginHash']); Framework::Redir("site/index/main/session_expired"); die; } $activeSession->expires = time() + SESSION_MAX_AGE * 2; R::store($activeSession); $this->session = $activeSession; $this->user = R::load('user', $this->session->user->getId()); Framework::TPL()->assign('user_premium', $this->user->hasPremium()); // check needed rights if any foreach ($this->_rights as $r) { if (!$this->user->hasRight($r)) { Framework::Redir("game/index"); die; } } }
function _log_focus($openid, $operation, $user_info = NULL) { R::addDatabase('wechat_csc', $GLOBALS['db_wechat_csc_url'], $GLOBALS['db_wechat_csc_user'], $GLOBALS['db_wechat_csc_pass']); R::selectDatabase('wechat_csc'); if (!R::testConnection()) { exit('DB failed' . PHP_EOL); } R::freeze(true); try { $user = R::getRedBean()->dispense('wxcsc_focus'); $user->openid = $openid; $user->operation = $operation; if ($operation == 'focus' && $user_info != NULL) { $user->nickname = $user_info['nickname']; $user->sex = $user_info['sex']; $user->language = $user_info['language']; $user->city = $user_info['city']; $user->province = $user_info['province']; $user->country = $user_info['country']; } $user_id = R::store($user); } catch (Exception $e) { header('Content-type:text/json;charset=utf-8'); echo json_encode(['result' => 'failed', 'error' => 'db error wechat', 'details' => $e->getMessage()]); die; } R::close(); }
static function execute($number = 5) { if (!is_numeric($number)) { throw new Exception('Number must be numeric'); } $callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number); $c = 0; foreach (array_values($callables) as $index => $calleble) { $c++; if ($calleble->done) { $c--; continue; } if ($c >= $number) { break; } $serializer = new Serializer(); $closure = $serializer->unserialize($calleble->callser); //// $calleble->status = 'busy'; // R::store($calleble); $closure(); $calleble->status = 'done'; $calleble->done = true; $calleble->doneat = time(); R::store($calleble); } return; }