public function show() { if ($this->params()->name) { $this->user = User::where(['name' => $this->params()->name])->first(); } else { $this->user = User::find($this->params()->id); } if (!$this->user) { $this->redirectTo("/404"); } else { if ($this->user->id == current_user()->id) { $this->set_title('My profile'); } else { $this->set_title($this->user->name . "'s profile"); } } if (current_user()->is_mod_or_higher()) { # RP: Missing feature. // $this->user_ips = $this->user->user_logs->order('created_at DESC').pluck('ip_addr').uniq $this->user_ips = array_unique(UserLog::where(['user_id' => $this->user->id])->order('created_at DESC')->take()->getAttributes('ip_addr')); } $tag_types = CONFIG()->tag_types; foreach (array_keys($tag_types) as $k) { if (!preg_match('/^[A-Z]/', $k) || $k == 'General' || $k == 'Faults') { unset($tag_types[$k]); } } $this->tag_types = $tag_types; $this->respondTo(array('html')); }
function envia_archivo_via_ftp($cadena, $nombre_archivo_remoto = "", $mensajes = 0) { $fp = fopen("temp.txt", "w"); if (fwrite($fp, utf8_encode($cadena))) { $ftp_sitio = CONFIG("FE_RESPALDO_SITIO"); $ftp_usuario = CONFIG("FE_RESPALDO_SITIO_USUARIO"); $ftp_pass = CONFIG("FE_RESPALDO_SITIO_CLAVE"); $conn = ftp_connect($ftp_sitio) or die("Acceso incorrecto.. " . $ftp_sitio); ftp_login($conn, $ftp_usuario, $ftp_pass); ftp_chdir($conn, CONFIG("FE_RESPALDO_SITIO_DIR")); //echo $ftp_sitio."--".$ftp_usuario."--".$ftp_pass."--".CONFIG("FE_RESPALDO_SITIO_DIR"); if (ftp_size($conn, $nombre_archivo_remoto) != -1) { if ($mensajes) { echo "Ya existe este envio, no se realizo nuevamente.."; } } else { if (ftp_put($conn, $nombre_archivo_remoto, "temp.txt", FTP_ASCII)) { if ($mensajes) { echo "Envio exitoso.... ok"; } else { if ($mensajes) { echo "Hubo un problema durante la transferencia ..."; } } } } ftp_close($conn); } fclose($fp); }
public function index() { if (CONFIG()->skip_homepage) { $this->redirectTo('post#index'); } else { $this->post_count = Post::fast_count(); } }
public function update_last_commented_at() { # return if self.do_not_bump_post $comment_count = self::connection()->selectValue("SELECT COUNT(*) FROM comments WHERE post_id = ?", $this->post_id); if ($comment_count <= CONFIG()->comment_threshold) { self::connection()->executeSql(["UPDATE posts SET last_commented_at = (SELECT created_at FROM comments WHERE post_id = :post_id ORDER BY created_at DESC LIMIT 1) WHERE posts.id = :post_id", 'post_id' => $this->post_id]); } }
public function store_sample_url() { if (CONFIG()->use_pretty_image_urls) { $path = "/sample/" . $this->_post->md5 . "/" . urlencode($this->_post->pretty_file_name(array('type' => 'sample'))) . ".jpg"; } else { $path = "/data/sample/" . CONFIG()->sample_filename_prefix . $this->_post->md5 . ".jpg"; } return CONFIG()->url_base . $path; }
/** * 构造函数 * @param mixed $path 放置文件夹 * @param mixed $usedate 是否生成日期目录 * @access public */ public function __construct($path = 'upload', $usedate = TRUE, $otherpath = '') { $this->path = CONFIG('otherconfig/static/dataurl') . $path; $this->path = $otherpath ? $this->path . '/' . $otherpath . '/' : $this->path . '/'; if (!helper_file::checkdir($this->path)) { helper_file::makedir($this->path); } $this->usedate = $usedate; }
/** * * @param type $dbType * @return db_AdapterMysqli */ public static function getInstance(string $dbType = 'mysqli') { if (is_null(self::$instance)) { if ($dbType == 'mysqli') { self::$instance = new db_AdapterMysqli(CONFIG('1')); } } return self::$instance; }
public function dmail($recipient, $sender, $msg_title, $msg_body) { $recipients = self::normalize_address($recipient->email); $subject = CONFIG()->app_name . " - Message received from " . $sender->name; $this->body = $msg_body; $this->sender = $sender; $this->subject = $msg_title; $this->to = $recipients; $this->subject = $subject; }
public function run() { Rails::systemExit()->register(function () { if (!$this->finished) { $this->active = false; $this->data->success = false; $this->data->error = "Couldn't finish successfuly"; $this->save(); } }); # Ugly: set the current user ID to the one set in the batch, so history entries # will be created as that user. // $old_thread_user = Thread::current["danbooru-user"]; // $old_thread_user_id = Thread::current["danbooru-user_id"]; // $old_ip_addr = Thread::current["danbooru-ip_addr"]; // Thread::current["danbooru-user"] = User::find_by_id(self.user_id) // Thread::current["danbooru-user_id"] = $this->user_id // Thread::current["danbooru-ip_addr"] = $this->ip $this->active = true; $this->save(); $post = Post::create(['source' => $this->url, 'tags' => $this->tags, 'updater_user_id' => $this->user_id, 'updater_ip_addr' => $this->ip, 'user_id' => $this->user_id, 'ip_addr' => $this->ip, 'status' => "active"]); if ($post->errors()->blank()) { if (CONFIG()->dupe_check_on_upload && $post->image() && !$post->parent_id) { $options = ['services' => SimilarImages::get_services("local"), 'type' => 'post', 'source' => $post]; $res = SimilarImages::similar_images($options); if (!empty($res['posts'])) { $post->tags = $post->tags() . " possible_duplicate"; $post->save(); } } $this->data->success = true; $this->data->post_id = $post->id; } elseif ($post->errors()->on('md5')) { // $p = $post->errors(); $p = Post::where(['md5' => $post->md5])->first(); $this->data->success = false; $this->data->error = "Post already exists"; $this->data->post_id = $p->id; } else { // p $post.errors $this->data->success = false; $this->data->error = $post->errors()->fullMessages(", "); } if ($this->data->success) { $this->status = 'finished'; } else { $this->status = 'error'; } $this->active = false; $this->save(); $this->finished = true; // Thread::current["danbooru-user"] = old_thread_user // Thread::current["danbooru-user_id"] = old_thread_user_id // Thread::current["danbooru-ip_addr"] = old_ip_addr }
public static function get_service_icon($service) { if ($service == CONFIG()->local_image_service) { $url = "/favicon.ico"; } elseif ($service == "gelbooru.com") { # hack $url = "/favicon-" . $service . ".png"; } else { $url = "/favicon-" . $service . ".ico"; } return $url; }
private static function coreRun() { define('CHARSET', CONFIG('charset')); define('DEBUGSET', CONFIG('opendebug')); ini_set('date.timezone', 'Asia/Shanghai'); header('Content-Type: text/html; charset=' . CHARSET); spl_autoload_register('newAutoModel::autoload'); register_shutdown_function('newAutoModel::appSystemError'); set_error_handler('newAutoModel::errorExcption'); set_exception_handler('newAutoModel::errorExcption'); self::cacheCore(); }
public function create() { $this->response()->headers()->setContentType('text/javascript'); $this->setLayout(false); if ($this->request()->isPost()) { if (current_user()->tag_subscriptions->size() >= CONFIG()->max_tag_subscriptions) { $this->tag_subscription = null; } else { $this->tag_subscription = TagSubscription::create(['user_id' => current_user()->id, 'tag_query' => '']); } } }
public static function create_instance(Post $post) { $image_store = Rails::services()->get('inflector')->camelize(CONFIG()->image_store); $file = dirname(__FILE__) . '/' . $image_store . '.php'; if (!is_file($file)) { throw new Exception(sprintf("File not found for image store configuration '%s'.", CONFIG()->image_store ?: '[empty value]')); } require_once $file; $class = 'Post_ImageStore_' . $image_store; $object = new $class(); $object->_post = $post; return $object; }
public function numbers_to_imoutos($number) { if (!CONFIG()->show_homepage_imoutos) { return; } $number = str_split($number); $output = '<div style="margin-bottom: 1em;">' . "\r\n"; foreach ($number as $num) { $output .= ' <img alt="' . $num . '" src="/images/' . $num . ".gif\" />\r\n"; } $output .= " </div>\r\n"; return $output; }
public function __construct() { $this->cache_config = CONFIG('cache/memory'); if ($this->cache_config['type']) { $cache_name = strtolower('cache_' . $this->cache_config['type']); $this->cacheObj = $cache_name::getInstance(); $this->cacheset = $this->cacheObj->check(); if (!$this->cacheset) { debug("Can't not use this cache :" . $cache_name, '9999'); } } $this->pre = SA . '_'; return $this; }
public static function runWithApi() { self::$var = array('starttime' => RUNFIRSTTIME, 'clientip' => self::_get_client_ip(), 'PHP_SELF' => htmlspecialchars(self::_get_script_url())); define('SAFEKEY', self::$var['safekey']); define('QHASH', self::acthash()); define('STATIC_URL', CONFIG('static/resurl')); self::runModel(); $coreLast = returnClass('corelast'); $coreLast->coreLastRunWithApi(); $className = 'Api_' . SA; $model = returnClass($className); $model->getInput = self::v('get|post', '*', array('addslashes', 'htmlspecialchars')); $model->coreModel(); }
public function vote($score, $user, array $options = array()) { $score < CONFIG()->vote_record_min && ($score = CONFIG()->vote_record_min); $score > CONFIG()->vote_record_max && ($score = CONFIG()->vote_record_max); if ($user->is_anonymous()) { return false; } $vote = PostVote::where(['user_id' => $user->id, 'post_id' => $this->id])->first(); if (!$vote) { $vote = PostVote::create(array('post_id' => $this->id, 'user_id' => $user->id, 'score' => $score)); } $vote->updateAttributes(array('score' => $score)); $this->recalculate_score(); return true; }
public function update() { !is_array($this->params()->aliases) && ($this->params()->aliases = []); $ids = array_keys($this->params()->aliases); switch ($this->params()->commit) { case "Delete": $validate_all = true; foreach ($ids as $id) { $ta = TagAlias::find($id); if (!$ta->is_pending || $ta->creator_id != current_user()->id) { $validate_all = false; break; } } if (current_user()->is_mod_or_higher() || $validate_all) { foreach ($ids as $x) { if ($ta = TagAlias::find($x)) { $ta->destroy_and_notify(current_user(), $this->params()->reason); } } $this->notice("Tag aliases deleted"); $this->redirectTo("#index"); } else { $this->access_denied(); } break; case "Approve": if (current_user()->is_mod_or_higher()) { foreach ($ids as $x) { if (CONFIG()->is_job_task_active('approve_tag_alias')) { JobTask::create(['task_type' => "approve_tag_alias", 'status' => "pending", 'data' => ["id" => $x, "updater_id" => current_user()->id, "updater_ip_addr" => $this->request()->remoteIp()]]); } else { $ta = TagAlias::find($x); $ta->approve(current_user()->id, $this->request()->remoteIp()); } } $this->notice("Tag alias approval jobs created"); $this->redirectTo('job_task#index'); } else { $this->access_denied(); } break; default: $this->access_denied(); break; } }
public function set_parent($post_id, $parent_id, $old_parent_id = null, $side_updates_only = false) { if (!CONFIG()->enable_parent_posts) { return; } if ($old_parent_id === null) { $old_parent_id = self::connection()->selectValue("SELECT parent_id FROM posts WHERE id = ?", $post_id); } if ($parent_id == $post_id || $parent_id == 0) { $parent_id = null; } if (!$side_updates_only) { self::connection()->executeSql("UPDATE posts SET parent_id = ? WHERE id = ?", $parent_id, $post_id); } $this->update_has_children($old_parent_id); $this->update_has_children($parent_id); }
public function update() { !is_array($this->params()->implications) && ($this->params()->implications = []); $ids = array_keys($this->params()->implications); switch ($this->params()->commit) { case "Delete": $can_delete = true; # iTODO: # 'creator_id' column isn't, apparently, filled when creating implications or aliases. foreach ($ids as $x) { $ti = TagImplication::find($x); $can_delete = $ti->is_pending && $ti->creator_id == current_user()->id; $tis[] = $ti; } if (current_user()->is_mod_or_higher() || $can_delete) { foreach ($tis as $ti) { $ti->destroy_and_notify(current_user(), $this->params()->reason); } $this->notice("Tag implications deleted"); $this->redirectTo("#index"); } else { $this->access_denied(); } break; case "Approve": if (current_user()->is_mod_or_higher()) { foreach ($ids as $x) { if (CONFIG()->is_job_task_active('approve_tag_implication')) { JobTask::create(['task_type' => "approve_tag_implication", 'status' => "pending", 'data' => ["id" => $x, "updater_id" => current_user()->id, "updater_ip_addr" => $this->request()->remoteIp()]]); } else { $ti = TagImplication::find($x); $ti->approve(current_user(), $this->request()->remoteIp()); } } $this->notice("Tag implication approval jobs created"); $this->redirectTo('job_task#index'); } else { $this->access_denied(); } break; default: $this->access_denied(); break; } }
public static function getInstance(int $type) : object { if (isset(self::$cacheInstance[$type])) { return self::$cacheInstance[$type]; } switch ($type) { case self::CACHE_NAME_MEMCACHED: self::$cacheInstance[self::CACHE_NAME_MEMCACHED] = new Cache_Memcached(CONFIG('cache/memcached')); break; case self::CACHE_NAME_APCU: self::$cacheInstance[self::CACHE_NAME_APCU] = new Cache_Apcu(); break; case self::CACHE_NAME_REDIS: self::$cacheInstance[self::CACHE_NAME_REDIS] = new Cache_Redis(CONFIG('cache/redis')); break; } return self::$cacheInstance[$type]; }
public function create() { if (current_user()->is_member_or_lower() && $this->params()->commit == "Post" && Comment::where("user_id = ? AND created_at > ?", current_user()->id, strtotime('-1 hour'))->count() >= CONFIG()->member_comment_limit) { # TODO: move this to the model $this->respond_to_error("Hourly limit exceeded", '#index', array('status' => 421)); return; } $user_id = current_user()->id; $comment = new Comment(array_merge($this->params()->comment, array('ip_addr' => $this->request()->remoteIp(), 'user_id' => $user_id))); if ($this->params()->commit == "Post without bumping") { $comment->do_not_bump_post = true; } if ($comment->save()) { $this->respond_to_success("Comment created", '#index'); } else { $this->respond_to_error($comment, '#index'); } }
public function create() { if (Dmail::where('from_id = ? AND created_at > ?', $this->current_user->id, date('Y-m-d H:i:s', time() - 3600))->count() >= CONFIG()->max_dmails_per_hour) { $this->notice("You can't send more than " . CONFIG()->max_dmails_per_hour . " dmails per hour."); $this->redirectTo('#inbox'); return; } $dmail = $this->params()->dmail; if (empty($dmail['parent_id'])) { $dmail['parent_id'] = null; } $this->dmail = Dmail::create(array_merge($dmail, ['from_id' => $this->current_user->id, 'ip_addr' => $this->request()->remoteIp()])); if ($this->dmail->errors()->none()) { $this->notice("Message sent to " . $dmail['to_name']); $this->redirectTo("#inbox"); } else { $this->notice("Error: " . $this->dmail->errors()->fullMessages(", ")); $this->render('compose'); } }
public static function mobileCheckCode($phone) { $code = mt_rand(10000, 99999); $lastCode = app::d()->getOne('mobile_code', array('mobile' => $phone, 'time' => '>=' . (TIMESTAMP - 15 * 60))); if ($lastCode['count'] > 2) { return control_returnCode::SMS_CHECK_CODE_TOOMORE; } else { $code = $lastCode['code']; } $message = sprintf(CONFIG('sms/template/regtext'), $code); $return = self::send($phone, $message); if ($return && !$lastCode) { app::d()->insert('mobile_code', array('mobile' => $phone, 'count' => '1', 'code' => $code, 'time' => TIMESTAMP)); } elseif ($return) { app::d()->update('mobile_code', array('count' => '+1'), array('mobile' => $phone, 'code' => $lastCode['code'])); } else { return $return == false ? control_returnCode::SMS_CHECK_PHONEERROR : control_returnCode::SMS_CHECK_CODE_NOTURE; } return control_returnCode::SMS_CHECK_TRUE; }
public static function process_all() { foreach (self::all() as $tag_subscription) { if ($tag_subscription->user->is_privileged_or_higher()) { try { self::transaction(function () use($tag_subscription) { $tags = preg_split('/\\s+/', $tag_subscription->tag_query); $post_ids = []; foreach ($tags as $tag) { $post_ids = array_merge($post_ids, Post::find_by_tags($tag, ['limit' => ceil(CONFIG()->tag_subscription_post_limit / 3), 'select' => 'p.id', 'order' => 'p.id desc'])->getAttributes('id')); } sort($post_ids); $tag_subscription->updateAttribute('cached_post_ids', join(',', array_unique(array_slice(array_reverse($post_ids), 0, CONFIG()->tag_subscription_post_limit)))); }); } catch (Exception $e) { # fail silently Rails::log()->exception($e); } sleep(1); } } }
protected function setRating($r) { if (!$r && !$this->isNewRecord()) { return; } if ($this->is_rating_locked) { return; } $r = strtolower(substr($r, 0, 1)); if (in_array($r, array('q', 'e', 's'))) { $new_rating = $r; } else { $new_rating = CONFIG()->default_rating_upload ?: 'q'; } # Moved the order of the next line because # it would just return on new posts, without # setting the rating. $this->setAttribute('rating', $new_rating); if ($r == $new_rating) { return; } $this->old_rating = $r; $this->touch_change_seq(); }
</a></li> <?php } ?> <?php if (!$this->post->is_deleted()) { ?> <li id="set-avatar"><?php echo $this->linkTo($this->t('.set_avatar'), array('user#set_avatar', 'id' => $this->post->id)); ?> </li> <?php } ?> <li><?php echo $this->linkTo($this->t('.history'), array('history#index', 'search' => 'post:' . $this->post->id)); ?> </li> <?php if (CONFIG()->enable_find_external_data && current_user()->is_mod_or_higher()) { ?> <li><?php echo $this->linkTo('Search external data', array('post#search_external_data', 'ids' => $this->post->id)); ?> </li> <?php } ?> </ul> </div>
<p>Hello, <?php echo $this->h($this->user->pretty_name()); ?> . Your password has been reset to <code><?php echo $this->password; ?> </code>.</p> <p>You can login to <?php echo $this->linkTo(CONFIG()->app_name, ["user#login", 'only_path' => false, 'host' => CONFIG()->server_host]); ?> and change your password to something else.</p>
public function action_page() { $subject = FYTOOL::get_gp_value('s'); $config = CONFIG('system'); $this->render('page/' . $subject, array('version' => $config)); }
<?php define(TEImagesPath, "../TableEditor\\TEditorSkins\\Default/"); ?> <table border="0" align="center" width="100%" cellpadding="10"> <tr> <td><img src="../images/<?php echo CONFIG("EMP_LOGO"); ?> " width="200"></td> <td width="400" class="titulo" align="center"><?php echo $titulo_name; ?> </td> <td ><?php echo $criterios; ?> </td> <td align="center" class="titulo_barra"> Fecha del reporte : <?php echo mysql_to_fecha(CurrentDate()); ?> <br> <?php echo "Usuario " . $_SESSION["TEditorAdminSesUser"]; ?> <br /> <?php if ($_POST['mode'] != "excel") { ?>