function handleTextSingleWord($word) { $magic_words = array('jajaja' => '%haha%', 'JAJA' => 'JAJAJAJAJJA', 'bimbo' => 'que te pasa pelotudo', 'gracias' => 'de nada ameo', 'mct' => 'viva el mct', 'hola' => 'holis', 'holi' => 'holis', '/unmute' => 'SOY LIBREEEEEEE', '/mute' => '', 'nada' => 'AH BUENJO mejor asi hijo deputa', 'pelado' => 'sticker:260429632665289106', 'tkm' => "❤"); foreach ($magic_words as $needle => $message) { if (strpos($word, $needle) !== FALSE) { if ($needle === "/mute") { mute(); } elseif ($needle === "/unmute") { unmute(); } elseif ($message === "%haha%") { $haha = array('jajajaja', 'jjajajajaj', 'hahahahaha', 'jiji', 'JAJAJAJAJ AH RE LOKO', 'jajajaj ah re', 'haha', 'jajajjaj', 'basat', 'basta no es gracioso'); shuffle($haha); $message = $haha[0]; } return $message; } } return false; }
function admin_import() { global $rooms_import; global $user; $html = ""; $step = "input"; if (isset($_REQUEST['step']) && in_array($step, ['input', 'check', 'import'])) { $step = $_REQUEST['step']; } if ($test_handle = fopen('../import/tmp', 'w')) { fclose($test_handle); unlink('../import/tmp'); } else { error(_('Webserver has no write-permission on import directory.')); } $import_file = '../import/import_' . $user['UID'] . '.xml'; $shifttype_id = null; $shifttypes_source = ShiftTypes(); if ($shifttypes_source === false) { engelsystem_error('Unable to load shifttypes.'); } $shifttypes = []; foreach ($shifttypes_source as $shifttype) { $shifttypes[$shifttype['id']] = $shifttype['name']; } switch ($step) { case 'input': $ok = false; if (isset($_REQUEST['submit'])) { $ok = true; if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { $ok = false; error(_('Please select a shift type.')); } if (isset($_FILES['xcal_file']) && $_FILES['xcal_file']['error'] == 0) { if (move_uploaded_file($_FILES['xcal_file']['tmp_name'], $import_file)) { libxml_use_internal_errors(true); if (simplexml_load_file($import_file) === false) { $ok = false; error(_('No valid xml/xcal file provided.')); unlink($import_file); } } else { $ok = false; error(_('File upload went wrong.')); } } else { $ok = false; error(_('Please provide some data.')); } } if ($ok) { redirect(page_link_to('admin_import') . "&step=check&shifttype_id=" . $shifttype_id); } else { $html .= div('well well-sm text-center', [_('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))]) . div('row', [div('col-md-offset-3 col-md-6', [form(array(form_info('', _("This import will create/update/delete rooms and shifts by given FRAB-export file. The needed file format is xcal.")), form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id), form_file('xcal_file', _("xcal-File (.xcal)")), form_submit('submit', _("Import"))))])]); } break; case 'check': if (!file_exists($import_file)) { error(_('Missing import file.')); redirect(page_link_to('admin_import')); } if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { error(_('Please select a shift type.')); redirect(page_link_to('admin_import')); } list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id); $html .= div('well well-sm text-center', ['<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import'))]) . form([div('row', [div('col-sm-6', ['<h3>' . _("Rooms to create") . '</h3>', table(_("Name"), $rooms_new)]), div('col-sm-6', ['<h3>' . _("Rooms to delete") . '</h3>', table(_("Name"), $rooms_deleted)])]), '<h3>' . _("Shifts to create") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_new, $shifttypes)), '<h3>' . _("Shifts to update") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_updated, $shifttypes)), '<h3>' . _("Shifts to delete") . '</h3>', table(array('day' => _("Day"), 'start' => _("Start"), 'end' => _("End"), 'shifttype' => _('Shift type'), 'title' => _("Title"), 'room' => _("Room")), shifts_printable($events_deleted, $shifttypes)), form_submit('submit', _("Import"))], page_link_to('admin_import') . '&step=import&shifttype_id=' . $shifttype_id); break; case 'import': if (!file_exists($import_file)) { error(_('Missing import file.')); redirect(page_link_to('admin_import')); } if (!file_exists($import_file)) { redirect(page_link_to('admin_import')); } if (isset($_REQUEST['shifttype_id']) && isset($shifttypes[$_REQUEST['shifttype_id']])) { $shifttype_id = $_REQUEST['shifttype_id']; } else { error(_('Please select a shift type.')); redirect(page_link_to('admin_import')); } list($rooms_new, $rooms_deleted) = prepare_rooms($import_file); foreach ($rooms_new as $room) { $result = Room_create($room, true, true); if ($result === false) { engelsystem_error('Unable to create room.'); } $rooms_import[trim($room)] = sql_id(); } foreach ($rooms_deleted as $room) { sql_query("DELETE FROM `Room` WHERE `Name`='" . sql_escape($room) . "' LIMIT 1"); } list($events_new, $events_updated, $events_deleted) = prepare_events($import_file, $shifttype_id); foreach ($events_new as $event) { $result = Shift_create($event); if ($result === false) { engelsystem_error('Unable to create shift.'); } } foreach ($events_updated as $event) { $result = Shift_update_by_psid($event); if ($result === false) { engelsystem_error('Unable to update shift.'); } } foreach ($events_deleted as $event) { $result = Shift_delete_by_psid($event['PSID']); if ($result === false) { engelsystem_error('Unable to delete shift.'); } } engelsystem_log("Pentabarf import done"); unlink($import_file); $html .= div('well well-sm text-center', ['<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Validation') . glyph('ok-circle') . '</span>' . mute(glyph('arrow-right')) . '<span class="text-success">' . _('Import') . glyph('ok-circle') . '</span>']) . success(_("It's done!"), true); break; default: redirect(page_link_to('admin_import')); } return page_with_title(admin_import_title(), [msg(), $html]); }
undoImage($post); error(sprintf($config['error']['fileexists'], ($post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root']) . ($board['dir'] . $config['dir']['res'] . ($p['thread'] ? $p['thread'] . '.html#' . $p['id'] : $p['id'] . '.html')))); } } else { if (!$post['op'] && $config['image_reject_repost_in_thread']) { if ($p = getPostByHashInThread($post['filehash'], $post['thread'])) { undoImage($post); error(sprintf($config['error']['fileexistsinthread'], ($post['mod'] ? $config['root'] . $config['file_mod'] . '?/' : $config['root']) . ($board['dir'] . $config['dir']['res'] . ($p['thread'] ? $p['thread'] . '.html#' . $p['id'] : $p['id'] . '.html')))); } } } } if (!hasPermission($config['mod']['postunoriginal'], $board['uri']) && $config['robot_enable'] && checkRobot($post['body_nomarkup'])) { undoImage($post); if ($config['robot_mute']) { error(sprintf($config['error']['muted'], mute())); } else { error($config['error']['unoriginal']); } } // Remove board directories before inserting them into the database. if ($post['has_file']) { foreach ($post['files'] as $key => &$file) { $file['file_path'] = $file['file']; $file['thumb_path'] = $file['thumb']; $file['file'] = mb_substr($file['file'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['img'])); if ($file['is_an_image'] && $file['thumb'] != 'spoiler') { $file['thumb'] = mb_substr($file['thumb'], mb_strlen($config['dir']['img_root'] . $board['dir'] . $config['dir']['thumb'])); } } }
} // リクエスト用のコンテキスト $context = array('http' => array('method' => 'GET', 'header' => array('Authorization: Bearer ' . $bearer_token))); // cURLを使ってリクエスト $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $request_url); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $context['http']['method']); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $context['http']['header']); curl_setopt($curl, CURLOPT_TIMEOUT, 5); $res1 = curl_exec($curl); $res2 = curl_getinfo($curl); curl_close($curl); // 取得したデータ $json = substr($res1, $res2['header_size']); $header = substr($res1, 0, $res2['header_size']); // JSONをオブジェクトに変換 $obj = json_decode($json); // エラー判定 if (!$json || !$obj) { echo "<h2>エラー内容</h2>"; echo "<p>データを取得することができませんでした…。設定を見直して下さい。</p>"; } if (strpos($json, $yourid) != 0) { mute(); } else { not_mute(); } }