protected function saveModel(ActiveRecord $model, $web_url) { if ($model->save()) { $model->grabImages($web_url); $model->grabTagsFromText(); $this->log("Сохранена модель #{$model->id}"); } else { $this->log("Не могу сохранить модель: ", impode("<br/>", $model->errors_flat_array)); } return $model; }
protected function _createReference(jDbReference $ref) { $conn = $this->schema->getConn(); $sql = 'ALTER TABLE ' . $conn->encloseName($this->name) . ' ADD CONSTRAINT '; $sql .= $conn->encloseName($ref->name) . ' FOREIGN KEY ('; $cols = array(); $fcols = array(); foreach ($ref->columns as $c) { $cols[] = $conn->encloseName($c); } foreach ($ref->fColumns as $c) { $fcols[] = $conn->encloseName($c); } $sql .= impode(',', $cols) . ') REFERENCES ' . $conn->encloseName($ref->fTable) . '('; $sql .= implode(',', $fcols) . ')'; if ($ref->onUpdate) { $sql .= 'ON UPDATE ' . $ref->onUpdate . ' '; } if ($ref->onDelete) { $sql .= 'ON DELETE ' . $ref->onDelete . ' '; } $conn->exec($sql); }
/** * Is the given page a valid type for this class? * * @param Page $page * @return bool * */ public function isValid(Page $page) { // quick exit when possible if ($this->template->id == $page->template->id && $this->parent_id == $page->parent_id) { return true; } $validTemplate = false; foreach ($this->templates as $template) { if ($page->template->id == $template->id) { $validTemplate = true; break; } } if (!$validTemplate && count($this->templates)) { $validTemplates = implode(', ', array_keys($this->templates)); $this->error("Page {$page->path} must have template: {$validTemplates}"); return false; } $validParent = false; foreach ($this->parents as $parent_id) { if ($parent_id == $page->parent_id) { $validParent = true; break; } } if (!$validParent && count($this->parents)) { $validParents = impode(', ', $this->parents); $this->error("Page {$page->path} must have parent: {$validParents}"); return false; } return true; }
public function send_mail($to,$subject,$body,$from=NULL,$reply_to=NULL,$xmailer=NULL,$cc=NULL,$bcc=NULL,$mime=NULL,$content_type=NULL) { // will send emails one at a time if passed multiple addresses. // can send a single email, or a bunch of emails provided a list of emails with commas $to = (is_string($to) && strpos(',',$to) !== FALSE ?explode(',',trim($to)):(is_array($to)?$to:$to)); $header['MIME-Version: '] = (!$mime?'1.0':$mime); $header['Content-type: '] = (!$content_type?'text/html; charset=iso-8859-1':$content_type); if ($from) $header ['From: ']= $from; if ($reply_to) $header ['Reply-To: ']= $reply_to; if ($xmailer) $header ['X-Mailer: ']= $xmailer; if ($cc) $header ['CC: ']= $cc; if ($bcc) $header ['BCC: ']= $bcc; if ($xmailer) $header ['X-Mailer: ']= ($xmailer == 'php'?'PHP/'.phpversion():$xmailer); //$header= implode("\r\n",$header); // yikes we don't have a key in the header to use implode bad php! bad php.. foreach($header as $key=>$value) $headers .= "$key$value\r\n"; unset($header); if(is_array($to)){ foreach($to as $r) if(!mail($r, $subject, $body,$headers)) $result[] = $email; } elseif(!mail($to,$subject,$body,$headers)) $result = $to; unset($headers,$to,$from,$reply_to,$xmailer,$cc,$bcc); return (!$result?'Everyone received the message.':(count($result)==1? "$result[0] did not get the message.":impode(', ',$result) . " did not get the message.")); }
function param_set($param, $value = false, $url = false) { if ($url == false) { $url = $this->string(); } $site = $this->site_url(); $url = str_ireplace($site, '', $url); $segs = explode('/', $url); $segs_clean = array(); $found = false; foreach ($segs as $segment) { $origsegment = $segment; $segment = explode(':', $segment); if ($segment[0] == $param) { $segment[1] = $value; $origsegment = impode(':', $segment); $found = true; $segs_clean[] = $origsegment; } else { $segs_clean[] = $origsegment; } } if ($found == false) { $segment = array(); $segment[] = $param; $segment[] = $value; $origsegment = impode(':', $segment); $segs_clean[] = $origsegment; } $segs_clean = implode('/', $segs_clean); $site = $segs_clean; return $site; }
/** * Removes flags from a player * * Accepts either a string with the flag value or a array with the falg values as parameter * The player_ckey needs to be set * * The adminname needs to be set or the admin needs to be logged in * * @param $flag_input * @param $adminname * * @return bool|null */ public function strip_player_whitelist_flag($flag_input, $adminname) { if ($this->ckey == NULL) { return NULL; } //Check if its a string or a arrray if (is_integer($flag_input)) { $this->whitelist_status -= $flag_input; $this->save(); //Write Log DB::connection('server')->table('whitelist_log')->insert(['datetime' => date("Y-m-d H:i:s", time()), 'user' => $adminname, 'action_method' => 'Website2', 'action' => 'Removed whitelistflag: ' . $flag_input . ' from player: ' . $this->ckey]); return TRUE; } elseif (is_array($flag_input)) { foreach ($flag_input as $flag_value) { $this->whitelist_status -= $flag_value; } $this->save(); //Write Log DB::connection('server')->table('whitelist_log')->insert(['datetime' => date("Y-m-d H:i:s", time()), 'user' => $adminname, 'action_method' => 'Website2', 'action' => 'Removed whitelist flags: ' . impode(";", $flag_input) . ' from player: ' . $this->ckey]); return TRUE; } elseif (is_string($flag_input)) { //Get Whitelist ID for Whitelist Name $whitelists = array_flip($this->get_available_whitelists()); $whitelist_flag = $whitelists[$flag_input]; $this->whitelist_status -= $whitelist_flag; $this->save(); //Write Log DB::connection('server')->table('whitelist_log')->insert(['datetime' => date("Y-m-d H:i:s", time()), 'user' => $adminname, 'action_method' => 'Website2', 'action' => 'Remove whitelist: ' . $flag_input . ' from player: ' . $this->ckey]); return TRUE; } else { return NULL; } }