/** Update the content of the file */ function Insert() { if (!$this->BuildId || !is_numeric($this->BuildId)) { add_log("BuildId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId); return false; } if (!$this->FileId || !is_numeric($this->FileId)) { add_log("FileId not set", "CoverageFileLog::Insert()", LOG_ERR, 0, $this->BuildId, CDASH_OBJECT_COVERAGE, $this->FileId); return false; } $log = ''; foreach ($this->Lines as $lineNumber => $code) { $log .= $lineNumber . ':' . $code . ';'; } foreach ($this->Branches as $lineNumber => $code) { $log .= 'b' . $lineNumber . ':' . $code . ';'; } if ($log != '') { $sql = "INSERT INTO coveragefilelog (buildid,fileid,log) VALUES "; $sql .= "(" . qnum($this->BuildId) . "," . qnum($this->FileId) . ",'" . $log . "')"; pdo_query($sql); add_last_sql_error("CoverageFileLog::Insert()"); } return true; }
function cdashmail($to, $subject, $body, $headers = false) { if (empty($to)) { add_log('Cannot send email. Recipient is not set.', 'cdashmail', LOG_ERR); return false; } global $CDASH_USE_SENDGRID; if ($CDASH_USE_SENDGRID) { return _cdashsendgrid($to, $subject, $body); } $to = explode(', ', $to); global $CDASH_EMAIL_FROM, $CDASH_EMAIL_REPLY; $message = Swift_Message::newInstance()->setTo($to)->setSubject($subject)->setBody($body)->setFrom(array($CDASH_EMAIL_FROM => 'CDash'))->setReplyTo($CDASH_EMAIL_REPLY)->setContentType('text/plain')->setCharset('UTF-8'); global $CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION, $CDASH_EMAIL_SMTP_LOGIN, $CDASH_EMAIL_SMTP_PASS; if (is_null($CDASH_EMAIL_SMTP_HOST)) { // Use the PHP mail() function. $transport = Swift_MailTransport::newInstance(); } else { // Use an SMTP server to send mail. $transport = Swift_SmtpTransport::newInstance($CDASH_EMAIL_SMTP_HOST, $CDASH_EMAIL_SMTP_PORT, $CDASH_EMAIL_SMTP_ENCRYPTION); if (!is_null($CDASH_EMAIL_SMTP_LOGIN) && !is_null($CDASH_EMAIL_SMTP_PASS)) { $transport->setUsername($CDASH_EMAIL_SMTP_LOGIN)->setPassword($CDASH_EMAIL_SMTP_PASS); } } $mailer = Swift_Mailer::newInstance($transport); return $mailer->send($message) > 0; }
/** * Do the various checks required for removing posts as well as removing it */ function handle_gb_post_delete($post_id, &$post_data, &$guestbook) { global $user, $db, $auth, $config; global $phpbb_root_path, $phpEx; // If moderator removing post or user itself removing post, present a confirmation screen if ($auth->acl_get('m_gb_delete') || $post_data['poster_id'] == $user->data['user_id'] && $user->data['is_registered'] && $auth->acl_get('u_gb_delete') && ($post_data['post_time'] > time() - $config['delete_time'] * 60 || !$config['delete_time'])) { $s_hidden_fields = build_hidden_fields(array('p' => $post_id, 'gbmode' => 'delete')); if (confirm_box(true)) { $data = array('post_time' => $post_data['post_time'], 'poster_id' => $post_data['poster_id']); $next_post_id = gb_delete_post($post_id, $data, $guestbook); $post_username = $post_data['poster_id'] == ANONYMOUS && !empty($post_data['post_username']) ? $post_data['post_username'] : $post_data['username']; add_log('mod', 0, 0, 'LOG_GB_DELETE_POST', $post_username); $member = $guestbook->getmember(); $meta_info = append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $member['user_id']); unset($member); $message = $user->lang['POST_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_PROFILE'], '<a href="' . $meta_info . '">', '</a>'); meta_refresh(3, $meta_info); trigger_error($message); } else { confirm_box(false, 'DELETE_POST', $s_hidden_fields); } redirect(append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . request_var('u', 0))); } // If we are here the user is not able to delete - present the correct error message if ($post_data['poster_id'] != $user->data['user_id'] && $auth->acl_get('u_gb_delete')) { trigger_error('DELETE_OWN_POSTS'); } trigger_error('USER_CANNOT_DELETE'); }
function main($id, $mode) { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); $captcha_vars = array('captcha_gd_x_grid' => 'CAPTCHA_GD_X_GRID', 'captcha_gd_y_grid' => 'CAPTCHA_GD_Y_GRID', 'captcha_gd_foreground_noise' => 'CAPTCHA_GD_FOREGROUND_NOISE', 'captcha_gd' => 'CAPTCHA_GD_PREVIEWED', 'captcha_gd_wave' => 'CAPTCHA_GD_WAVE', 'captcha_gd_3d_noise' => 'CAPTCHA_GD_3D_NOISE', 'captcha_gd_fonts' => 'CAPTCHA_GD_FONTS'); if (isset($_GET['demo'])) { $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $config[$captcha_var] = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var]; } if ($config['captcha_gd']) { include $phpbb_root_path . 'includes/captcha/captcha_gd.' . $phpEx; } else { include $phpbb_root_path . 'includes/captcha/captcha_non_gd.' . $phpEx; } $captcha = new captcha(); $captcha->execute(gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)), time()); exit; } $config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD'); $this->tpl_name = 'acp_captcha'; $this->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; add_form_key($form_key); $submit = request_var('submit', ''); if ($submit && check_form_key($form_key)) { $config_vars = array_keys($config_vars); foreach ($config_vars as $config_var) { set_config($config_var, request_var($config_var, '')); } $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = request_var($captcha_var, 0); if ($value >= 0) { set_config($captcha_var, $value); } } add_log('admin', 'LOG_CONFIG_VISUAL'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } else { if ($submit) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action)); } else { $preview_image_src = append_sid(append_sid("{$phpbb_admin_path}index.{$phpEx}", "i={$id}&demo=demo")); if (@extension_loaded('gd')) { $template->assign_var('GD', true); } foreach ($config_vars as $config_var => $template_var) { $template->assign_var($template_var, isset($_REQUEST[$config_var]) ? request_var($config_var, '') : $config[$config_var]); } foreach ($captcha_vars as $captcha_var => $template_var) { $var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); $preview_image_src .= "&{$captcha_var}=" . $var; } $template->assign_vars(array('CAPTCHA_PREVIEW' => $preview_image_src, 'PREVIEW' => isset($_POST['preview']))); } } }
function acp_page($id, &$module) { global $db, $user, $auth, $template; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/board'); $config_vars = array('enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', 'confirm_refresh' => 'CONFIRM_REFRESH', 'captcha_gd' => 'CAPTCHA_GD'); $module->tpl_name = 'captcha_gd_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; add_form_key($form_key); $submit = request_var('submit', ''); if ($submit && check_form_key($form_key)) { $captcha_vars = array_keys($this->captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = request_var($captcha_var, 0); if ($value >= 0) { set_config($captcha_var, $value); } } add_log('admin', 'LOG_CONFIG_VISUAL'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); } else { if ($submit) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); } else { foreach ($this->captcha_vars as $captcha_var => $template_var) { $var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, 0) : $config[$captcha_var]; $template->assign_var($template_var, $var); } $template->assign_vars(array('CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_class_name(), 'U_ACTION' => $module->u_action)); } } }
function Insert() { if (!$this->BuildId) { add_log('BuildId is not set', 'BuildTest::Insert()', LOG_ERR, 0, 0); return false; } if (!$this->TestId) { add_log('TestId is not set', 'BuildTest::Insert()', LOG_ERR, 0, $this->BuildId); return false; } if (empty($this->Time)) { $this->Time = 0; } if (empty($this->TimeMean)) { $this->TimeMean = 0; } if (empty($this->TimeStd)) { $this->TimeStd = 0; } if (empty($this->TimeStatus)) { $this->TimeStatus = 0; } $query = "INSERT INTO build2test (buildid,testid,status,time,timemean,timestd,timestatus)\n VALUES (" . qnum($this->BuildId) . "," . qnum($this->TestId) . ",'{$this->Status}'," . qnum($this->Time) . "," . qnum($this->TimeMean) . "," . qnum($this->TimeStd) . "," . qnum($this->TimeStatus) . ")"; if (!pdo_query($query)) { add_last_sql_error("BuildTest:Insert", 0, $this->BuildId); return false; } return true; }
function acp_page($id, &$module) { global $config, $db, $template, $user; $captcha_vars = array('recaptcha_pubkey' => 'RECAPTCHA_PUBKEY', 'recaptcha_privkey' => 'RECAPTCHA_PRIVKEY'); $module->tpl_name = 'captcha_recaptcha_acp'; $module->page_title = 'ACP_VC_SETTINGS'; $form_key = 'acp_captcha'; add_form_key($form_key); $submit = request_var('submit', ''); if ($submit && check_form_key($form_key)) { $captcha_vars = array_keys($captcha_vars); foreach ($captcha_vars as $captcha_var) { $value = request_var($captcha_var, ''); if ($value) { set_config($captcha_var, $value); } } add_log('admin', 'LOG_CONFIG_VISUAL'); trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($module->u_action)); } else { if ($submit) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($module->u_action)); } else { foreach ($captcha_vars as $captcha_var => $template_var) { $var = isset($_REQUEST[$captcha_var]) ? request_var($captcha_var, '') : (isset($config[$captcha_var]) ? $config[$captcha_var] : ''); $template->assign_var($template_var, $var); } $template->assign_vars(array('CAPTCHA_PREVIEW' => $this->get_demo_template($id), 'CAPTCHA_NAME' => $this->get_service_name(), 'U_ACTION' => $module->u_action)); } } }
/** End Element */ public function endElement($parser, $name) { $parent = $this->getParent(); // should be before endElement parent::endElement($parser, $name); if ($name == "STARTDATETIME" && $parent == 'COVERAGELOG') { $start_time = gmdate(FMT_DATETIME, $this->StartTimeStamp); $this->Build->ProjectId = $this->projectid; $this->BuildId = $this->Build->GetIdFromName($this->SubProjectName); if ($this->BuildId == 0) { $t = 'Cannot add a coverage log to a build that does not exist'; $f = 'CoverageLogHandler::endElement'; add_log($t, $f, LOG_ERR, $this->projectid); } } else { if ($name == 'LINE') { $this->CoverageFile->File .= '<br>'; // cannot be <br/> for backward compatibility } else { if ($name == 'FILE') { if ($this->BuildId != 0) { $this->CoverageFile->Update($this->BuildId); $this->CoverageFileLog->BuildId = $this->BuildId; $this->CoverageFileLog->FileId = $this->CoverageFile->Id; $this->CoverageFileLog->Insert(); } unset($this->CoverageFile); unset($this->CoverageFileLog); } } } }
function ProcessFile($projectid, $filename, $md5) { unset($fp); if (!file_exists($filename)) { // check in parent dir also $filename = "../{$filename}"; } if (file_exists($filename)) { $fp = fopen($filename, 'r'); } if (@$fp) { global $PHP_ERROR_SUBMISSION_ID; do_submit($fp, $projectid, $md5, false, $PHP_ERROR_SUBMISSION_ID); $PHP_ERROR_SUBMISSION_ID = 0; @fclose($fp); unset($fp); global $CDASH_BACKUP_TIMEFRAME; if ($CDASH_BACKUP_TIMEFRAME != '0') { // Delete the temporary backup file since we now have a better-named one. cdash_unlink($filename); } $new_status = 2; // done, did call do_submit, finished normally } else { add_log("Cannot open file '" . $filename . "'", 'ProcessFile', LOG_ERR, $projectid); $new_status = 3; // done, did *NOT* call do_submit } return $new_status; }
function main($id, $mode) { global $db, $user, $auth, $template, $cache; global $config, $src_root_path, $src_admin_path, $phpEx; include $src_root_path . 'includes/functions_user.' . $phpEx; $user->add_lang('acp/posting'); // Set up general vars $this->tpl_name = 'acp_disallow'; $this->page_title = 'ACP_DISALLOW_USERNAMES'; $form_key = 'acp_disallow'; add_form_key($form_key); $disallow = isset($_POST['disallow']) ? true : false; $allow = isset($_POST['allow']) ? true : false; if (($allow || $disallow) && !check_form_key($form_key)) { trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); } if ($disallow) { $disallowed_user = str_replace('*', '%', utf8_normalize_nfc(request_var('disallowed_user', '', true))); if (!$disallowed_user) { trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = 'SELECT disallow_id FROM ' . DISALLOW_TABLE . "\n\t\t\t\tWHERE disallow_username = '******'"; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if ($row) { trigger_error($user->lang['DISALLOWED_ALREADY'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = 'INSERT INTO ' . DISALLOW_TABLE . ' ' . $db->sql_build_array('INSERT', array('disallow_username' => $disallowed_user)); $db->sql_query($sql); $cache->destroy('_disallowed_usernames'); $message = $user->lang['DISALLOW_SUCCESSFUL']; add_log('admin', 'LOG_DISALLOW_ADD', str_replace('%', '*', $disallowed_user)); trigger_error($message . adm_back_link($this->u_action)); } else { if ($allow) { $disallowed_id = request_var('disallowed_id', 0); if (!$disallowed_id) { trigger_error($user->lang['NO_USERNAME_SPECIFIED'] . adm_back_link($this->u_action), E_USER_WARNING); } $sql = 'DELETE FROM ' . DISALLOW_TABLE . ' WHERE disallow_id = ' . $disallowed_id; $db->sql_query($sql); $cache->destroy('_disallowed_usernames'); add_log('admin', 'LOG_DISALLOW_DELETE'); trigger_error($user->lang['DISALLOWED_DELETED'] . adm_back_link($this->u_action)); } } // Grab the current list of disallowed usernames... $sql = 'SELECT * FROM ' . DISALLOW_TABLE; $result = $db->sql_query($sql); $disallow_select = ''; while ($row = $db->sql_fetchrow($result)) { $disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>'; } $db->sql_freeresult($result); $template->assign_vars(array('U_ACTION' => $this->u_action, 'S_DISALLOWED_NAMES' => $disallow_select)); }
function cdashmail($to, $subject, $body, $headers) { if (!empty($to)) { return mail("{$to}", "{$subject}", "{$body}", "{$headers}"); } add_log("Cannot send email. Receipient is not set"); return false; }
function _after_insert($data, $options) { $xid = $data["xid"]; $xmk = M("Xmk"); $xmk->where("id={$xid}")->setField("update_time", time()); $progress = $xmk->where("id={$xid}")->getField("progress"); add_log($xid, "进展", $progress); }
/** * Parse a tarball of JSON files. **/ public function Parse($filename) { // Create a new directory where we can extract our tarball. $dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME); mkdir($dirName); // Extract the tarball. $result = extract_tar($filename, $dirName); if ($result === false) { add_log('Could not extract ' . $filename . ' into ' . $dirName, 'JSCoverTarHandler::Parse', LOG_ERR); return false; } // Recursively search for .json files and parse them. $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST); $coverageSummary = $this->CoverageSummaries['default']; foreach ($iterator as $fileinfo) { // need the longest extension, so getExtension() won't do here. $ext = substr(strstr($fileinfo->getFilename(), '.'), 1); if ($ext === 'json') { $this->ParseJSCoverFile($fileinfo); } } // Record parsed coverage info to the database. foreach ($this->CoverageFileLogs as $path => $coverageFileLog) { $coverage = $this->Coverages[$path]; $coverageFile = $this->CoverageFiles[$path]; // Tally up how many lines of code were covered & uncovered. foreach ($coverageFileLog->Lines as $line) { if ($line == 0) { $coverage->LocUntested += 1; } else { $coverage->Covered = 1; $coverage->LocTested += 1; } } // Save these models to the database. $coverageFile->TrimLastNewline(); $coverageFile->Update($this->Build->Id); $coverageFileLog->BuildId = $this->Build->Id; $coverageFileLog->FileId = $coverageFile->Id; $coverageFileLog->Insert(); // Add this Coverage to our summary. $coverage->CoverageFile = $coverageFile; $coverageSummary->AddCoverage($coverage); } // Insert coverage summaries $completedSummaries = array(); foreach ($this->CoverageSummaries as $coverageSummary) { if (in_array($coverageSummary->BuildId, $completedSummaries)) { continue; } $coverageSummary->Insert(); $coverageSummary->ComputeDifference(); $completedSummaries[] = $coverageSummary->BuildId; } // Delete the directory when we're done. DeleteDirectory($dirName); return true; }
/** Remove the first builds that are at the beginning of the queue */ function removeFirstBuilds($projectid, $days, $maxbuilds, $force = false) { require 'config/config.php'; require_once 'include/pdo.php'; require_once 'include/common.php'; @set_time_limit(0); if (!$force && !isset($CDASH_AUTOREMOVE_BUILDS)) { return; } if (!$force && $CDASH_AUTOREMOVE_BUILDS != '1') { return; } if ($days < 2) { return; } // First remove the builds with the wrong date $currentdate = time() - 3600 * 24 * $days; $startdate = date(FMT_DATETIME, $currentdate); add_log('about to query for builds to remove', 'removeFirstBuilds'); $builds = pdo_query("SELECT id FROM build\n WHERE parentid IN (0, -1) AND\n starttime<'{$startdate}' AND\n projectid=" . qnum($projectid) . "\n ORDER BY starttime ASC LIMIT {$maxbuilds}"); add_last_sql_error('dailyupdates::removeFirstBuilds'); $buildids = array(); while ($builds_array = pdo_fetch_array($builds)) { $buildids[] = $builds_array['id']; } $s = 'removing old buildids for projectid: ' . $projectid; add_log($s, 'removeFirstBuilds'); echo ' -- ' . $s . "\n"; // for "interactive" command line feedback remove_build($buildids); // Remove any job schedules that are older than our cutoff date // and not due to repeat again. require_once 'models/constants.php'; require_once 'models/clientjobschedule.php'; $sql = 'SELECT scheduleid FROM client_job AS cj LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'\n AND (cjs.repeattime = 0.00 OR\n (cjs.enddate < '{$startdate}' AND cjs.enddate != '1980-01-01 00:00:00'))"; $job_schedules = pdo_query($sql); while ($job_schedule = pdo_fetch_array($job_schedules)) { $ClientJobSchedule = new ClientJobSchedule(); $ClientJobSchedule->Id = $job_schedule['scheduleid']; $ClientJobSchedule->Remove(); } // Remove any jobs that are older than our cutoff date. // This occurs when a job schedule is set to continue repeating, but // some of its past runs are older than our autoremove threshold. require_once 'models/clientjob.php'; $sql = 'SELECT cj.id FROM client_job AS cj LEFT JOIN client_jobschedule AS cjs ON cj.scheduleid = cjs.id WHERE cj.status > ' . CDASH_JOB_RUNNING . "\n AND cjs.projectid={$projectid} AND cj.startdate < '{$startdate}'"; $jobs = pdo_query($sql); while ($job = pdo_fetch_array($jobs)) { $ClientJob = new ClientJob(); $ClientJob->Id = $job['id']; $ClientJob->Remove(); } }
/** * Run Tool * * Does the actual stuff we want the tool to do after submission */ function run_tool(&$error) { global $auth, $cache; $cache->purge(); // Clear permissions $auth->acl_clear_prefetch(); cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); trigger_error('PURGE_CACHE_COMPLETE'); }
/** Get version */ function GetVersion() { if (!$this->Id) { add_log("ClientOS::GetVersion()", "Id not set"); return; } $name = pdo_query("SELECT version FROM client_os WHERE id=" . qnum($this->Id)); $row = pdo_fetch_array($name); return $row[0]; }
/** Get version */ public function GetVersion() { if (!$this->Id) { add_log('ClientOS::GetVersion()', 'Id not set'); return; } $name = pdo_query('SELECT version FROM client_os WHERE id=' . qnum($this->Id)); $row = pdo_fetch_array($name); return $row[0]; }
public function Insert() { if (!$this->BuildId) { add_log('BuildId not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Time) { add_log('Time not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Name) { add_log('Name not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } if (!$this->Text) { add_log('Text not set', 'BuildNote::Insert()', LOG_ERR, 0, $this->Id); return false; } // Check if the note already exists $crc32 = $this->GetCrc32(); $text = pdo_real_escape_string($this->Text); $timestamp = pdo_real_escape_string($this->Time); $name = pdo_real_escape_string($this->Name); $notecrc32 = pdo_query("SELECT id FROM note WHERE crc32='{$crc32}'"); if (pdo_num_rows($notecrc32) == 0) { if ($this->Id) { $query = "INSERT INTO note (id,text,name,crc32) VALUES ('{$this->Id}','{$text}','{$name}','{$crc32}')"; } else { $query = "INSERT INTO note (text,name,crc32) VALUES ('{$text}','{$name}','{$crc32}')"; } if (!pdo_query($query)) { add_last_sql_error('BuildNote:Insert', 0, $this->BuildId); return false; } if (!$this->Id) { $this->Id = pdo_insert_id('note'); } } else { // already there $notecrc32_array = pdo_fetch_array($notecrc32); $this->Id = $notecrc32_array['id']; } if (!$this->Id) { echo 'BuildNote::Insert(): No NoteId'; return false; } $query = "INSERT INTO build2note (buildid,noteid,time)\n VALUES ('{$this->BuildId}','{$this->Id}','{$this->Time}')"; if (!pdo_query($query)) { add_last_sql_error('BuildNote:Insert', 0, $this->BuildId); return false; } return true; }
/** endElement function */ public function endElement($parser, $name) { parent::endElement($parser, $name); if ($name == 'NOTE') { if ($this->BuildId > 0) { // Insert the note $this->Note->BuildId = $this->BuildId; $this->Note->Insert(); } else { add_log("note_handler.php", "Trying to add a note to an unexisting build"); } } }
function InsertLabelAssociations($id) { if (empty($this->Labels)) { return; } if ($id) { foreach ($this->Labels as $label) { $label->BuildFailureId = $id; $label->Insert(); } } else { add_log('No BuildFailure id - cannot call $label->Insert...', 'BuildFailure::InsertLabelAssociations', LOG_ERR, 0, $this->BuildId); } }
function main($id, $mode) { global $template, $user, $db, $config, $phpEx, $phpbb_root_path, $ultimate_points, $points_config, $points_values, $auth, $check_auth; $adm_points = request_var('adm_points', false); $u_id = request_var('user_id', 0); $post_id = request_var('post_id', 0); if (empty($u_id)) { $message = $user->lang['EDIT_NO_ID_SPECIFIED'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $user_id = $u_id; add_form_key('bank_edit'); if ($adm_points != false && ($auth->acl_get('a_points') || $auth->acl_get('m_chg_bank'))) { $template->assign_block_vars('administer_bank', array()); if (isset($_POST['submit'])) { if (!check_form_key('bank_edit')) { trigger_error('FORM_INVALID'); } $new_points = round(request_var('points', 0.0), 2); set_bank($u_id, $new_points); $sql_array = array('SELECT' => 'user_id, username, user_points, user_colour', 'FROM' => array(USERS_TABLE => 'u'), 'WHERE' => 'user_id = ' . (int) $u_id); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $points_user = $db->sql_fetchrow($result); add_log('admin', 'LOG_MOD_BANK', $points_user['username']); $message = $post_id ? sprintf($user->lang['EDIT_P_RETURN_POST'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", "p=" . $post_id) . '">', '</a>') : sprintf($user->lang['EDIT_P_RETURN_INDEX'], '<a href="' . append_sid("{$phpbb_root_path}index.{$phpEx}") . '">', '</a>'); trigger_error(sprintf($user->lang['EDIT_POINTS_SET'], $config['points_name']) . $message); } else { $sql_array = array('SELECT' => 'u.user_id, u.username, u.user_points, u.user_colour, b.holding', 'FROM' => array(USERS_TABLE => 'u'), 'LEFT_JOIN' => array(array('FROM' => array(POINTS_BANK_TABLE => 'b'), 'ON' => 'u.user_id = b.user_id')), 'WHERE' => 'u.user_id = ' . (int) $u_id); $sql = $db->sql_build_query('SELECT', $sql_array); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); if (empty($u_id)) { $message = $user->lang['EDIT_USER_NOT_EXIST'] . '<br /><br /><a href="' . append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit") . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>'; trigger_error($message); } $hidden_fields = build_hidden_fields(array('user_id' => $u_id, 'post_id' => $post_id)); $template->assign_vars(array('USER_NAME' => get_username_string('full', $u_id, $row['username'], $row['user_colour']), 'BANK_POINTS' => sprintf(number_format_points($row['holding'])), 'POINTS_NAME' => $config['points_name'], 'CURRENT_VALUE' => $row['holding'], 'L_POINTS_MODIFY' => sprintf($user->lang['EDIT_BANK_MODIFY'], $config['points_name']), 'L_P_BANK_TITLE' => sprintf($user->lang['EDIT_P_BANK_TITLE'], $config['points_name']), 'L_USERNAME' => $user->lang['USERNAME'], 'L_SET_AMOUNT' => $user->lang['EDIT_SET_AMOUNT'], 'U_USER_LINK' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", "mode=viewprofile&u=" . $u_id), 'S_ACTION' => append_sid("{$phpbb_root_path}points.{$phpEx}", "mode=bank_edit&adm_points=1"), 'S_HIDDEN_FIELDS' => $hidden_fields)); } } else { $message = $user->lang['NOT_AUTHORISED']; trigger_error($message); } // Generate the page page_header($user->lang['EDIT_POINTS_ADMIN']); // Generate the page template $template->set_filenames(array('body' => 'points/points_bank_edit.html')); page_footer(); }
/** Put labels for coverage */ function InsertLabelAssociations($buildid) { if ($buildid && isset($this->CoverageFile) && $this->CoverageFile->Id) { if (empty($this->Labels)) { return; } foreach ($this->Labels as $label) { $label->CoverageFileId = $this->CoverageFile->Id; $label->CoverageFileBuildId = $buildid; $label->Insert(); } } else { add_log('No buildid or coveragefile', 'Coverage::InsertLabelAssociations', LOG_ERR, 0, $buildid, CDASH_OBJECT_COVERAGE, $this->CoverageFile->Id); } }
function CreateRSSFeed($projectid) { // Checks if (!isset($projectid) || !is_numeric($projectid)) { echo 'Not a valid projectid!'; return; } // Find the project name $project = pdo_query("SELECT public,name FROM project WHERE id='{$projectid}'"); $project_array = pdo_fetch_array($project); $projectname = $project_array['name']; // Don't create RSS feed for private projects if ($project_array['public'] != 1) { return; } global $CDASH_ROOT_DIR; $filename = $CDASH_ROOT_DIR . '/public/rss/SubmissionRSS' . $projectname . '.xml'; $currentURI = get_server_URI(); $currenttime = time(); $feed = new Feed(); $channel = new Channel(); $channel->title("CDash for {$projectname}")->url("{$currentURI}/index.php?project={$projectname}")->description("Recent CDash submissions for {$projectname}")->language('en-US')->lastBuildDate($currenttime)->appendTo($feed); // Get the last 24hrs submissions $beginning_timestamp = $currenttime - 24 * 3600; $end_timestamp = $currenttime; $builds = pdo_query("SELECT * FROM build\n WHERE UNIX_TIMESTAMP(starttime)<{$end_timestamp} AND UNIX_TIMESTAMP(starttime)>{$beginning_timestamp}\n AND projectid='{$projectid}'\n "); while ($build_array = pdo_fetch_array($builds)) { $siteid = $build_array['siteid']; $buildid = $build_array['id']; $site_array = pdo_fetch_array(pdo_query("SELECT name FROM site WHERE id='{$siteid}'")); // Find the number of errors and warnings $nerrors = $build_array['builderrors']; $nwarnings = $build_array['buildwarnings']; $nnotrun = $build_array['testnotrun']; $nfail = $build_array['testfailed']; $title = 'CDash(' . $projectname . ') - ' . $site_array['name'] . ' - ' . $build_array['name'] . ' - ' . $build_array['type']; $title .= ' - ' . $build_array['submittime'] . ' - ' . $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.'; // Should link to the errors... $link = $currentURI . '/buildSummary.php?buildid=' . $buildid; $description = 'A new ' . $build_array['type'] . ' submission from ' . $site_array['name'] . ' - ' . $build_array['name'] . ' is available: '; $description .= $nerrors . ' errors, ' . $nwarnings . ' warnings, ' . $nnotrun . ' not run, ' . $nfail . ' failed.'; $item = new Item(); $item->guid($currentURI . '/buildSummary.php?buildid=' . $buildid)->title($title)->url($link)->description($description)->pubDate($currenttime)->appendTo($channel); } if (file_put_contents($filename, $feed) === false) { add_log('Cannot write file ' . $filename, 'CreateRSSFeed', LOG_ERR, $projectid); } }
/** * 执行登陆产生SESSION * @author Yusure http://yusure.cn * @date 2016-02-03 * @param [param] * @return [type] [description] */ private function _LoginPost() { $user_model = D('User'); $condition = array(); $condition['user_name'] = I('post.user_name', '', 'trim'); $user_info = $user_model->get_info($condition); $user_passwd = I('post.user_passwd', '', 'md5'); if ($user_passwd != $user_info['user_passwd']) { $this->error('密码错误!'); } else { session('user_info', $user_info); /* 记录日志 */ add_log('登陆系统'); $this->success('登陆成功!', U('Index/index')); } }
/** * Get the last pdo error or empty string in the case of no error. * @param CDash\Database|null $link_identifier * @return string containing error message (or not in the case of production) */ function pdo_error($link_identifier = null, $log_error = true) { global $CDASH_PRODUCTION_MODE; $error_info = get_link_identifier($link_identifier)->getPdo()->errorInfo(); if (isset($error_info[2]) && $error_info[0] !== '00000') { if ($log_error) { add_log($error_info[2], 'pdo_error', LOG_ERR); } if ($CDASH_PRODUCTION_MODE) { return 'SQL error encountered, query hidden.'; } return $error_info[2]; } else { return ''; // no error; } }
function main($id, $mode) { global $config, $db, $user, $auth, $template; global $phpbb_root_path, $phpEx; // Quick var-checking and var setup. $submit = isset($_POST['submit']) ? true : false; $action = request_var('action', ''); $errors = array(); $merge = $action == 'merge' ? true : false; $old_username = utf8_normalize_nfc(request_var('old_username', '', true)); $new_username = utf8_normalize_nfc(request_var('new_username', '', true)); // Setup some things for the module. $user->add_lang(array('mods/info_acp_user_merge', 'mods/lang_user_merge')); $this->tpl_name = 'acp_user_merge'; $form_key = 'acp_user_merge'; add_form_key($form_key); // Hath we an invalid form key? if ($submit && !check_form_key($form_key)) { $errors[] = $user->lang['FORM_INVALID']; } if ($submit || $merge) { $old_user_id = $this->check_user($old_username, $errors, true); $new_user_id = $this->check_user($new_username, $errors, false); } // Make sure we have submitted the form, and that we do not have errors if (($submit || $merge) && !sizeof($errors)) { // Have we confirmed this change? if (confirm_box(true)) { // Let's roll! user_merge($old_user_id, $new_user_id); add_log('admin', 'LOG_USERS_MERGED', $old_username . ' » ' . $new_username); trigger_error($user->lang['USERS_MERGED'] . adm_back_link($this->u_action)); } else { $hidden_fields = array('i' => $id, 'mode' => $mode, 'old_username' => $old_username, 'new_username' => $new_username, 'action' => 'merge'); // Be annoying. Are you suuuuuuuuuuuure? No, really, are you sure? confirm_box(false, $user->lang['MERGE_USERS_CONFIRM'], build_hidden_fields($hidden_fields)); } } $user_merge_version = !empty($config['user_merge_version']) ? $config['user_merge_version'] : ''; // Assign template stuffs now. $this->page_title = $user->lang['ACP_USER_MERGE_TITLE']; $template->assign_vars(array('S_ERROR' => sizeof($errors) ? true : false, 'ERROR_MSG' => implode('<br />', $errors), 'USER_MERGE_VERSION' => $user_merge_version, 'U_FIND_OLD_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=user_merge&field=old_username&select_single=true'), 'U_FIND_NEW_USERNAME' => append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=searchuser&form=user_merge&field=new_username&select_single=true'), 'OLD_USERNAME' => !empty($old_user_id) ? $old_username : '', 'NEW_USERNAME' => !empty($new_user_id) ? $new_username : '', 'L_TITLE' => $user->lang['ACP_USER_MERGE_TITLE'], 'L_EXPLAIN' => $user->lang['ACP_USER_MERGE_EXPLAIN'], 'U_ACTION' => $this->u_action)); }
function update_multi($db, $query, $statut, $id_att, $att_sel, $table, $id) { if (!empty($query)) { $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); $i = 0; while ($row = pg_fetch_array($result, NULL, PGSQL_ASSOC)) { $att[$i] = $row["{$id_att}"]; $i++; } } /*déclaration quand la variable est vide*/ $att = empty($att) ? array() : $att; $att_sel = empty($att_sel) ? array() : $att_sel; // echo "<br>".$query; // echo "$statut 1 :";var_dump($att); // echo "$statut 2 :";var_dump($att_sel); if ($table == "eee.reponse") { $att3 = 'zone'; } else { $att3 = 'statut'; } $query = ""; $supp = array_diff($att, $att_sel); $add = array_diff($att_sel, $att); if (!empty($supp)) { foreach ($supp as $field => $val) { $query = $query . "DELETE FROM {$table} WHERE (uid,{$id_att},{$att3}) = ({$id},{$val},'{$statut}'); "; } // echo "<br>".$query; $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); } if (!empty($add)) { foreach ($add as $field => $val) { $query = $query . "INSERT INTO {$table} VALUES ({$id},{$val},'{$statut}'); "; } // echo "<br>".$query; $result = pg_query($db, $query) or die("Erreur pgSQL : " . $query); } /*Log*/ add_log("log", 5, $id_user, getenv("REMOTE_ADDR"), "Saisie edit fiche", $id, "eee"); pg_free_result($result); }
/** * Parse a tarball of JSON files. **/ public function Parse($filename) { // Create a new directory where we can extract our tarball. $dirName = sys_get_temp_dir() . '/' . pathinfo($filename, PATHINFO_FILENAME); mkdir($dirName); // Extract the tarball. $result = extract_tar($filename, $dirName); if ($result === false) { add_log('Could not extract ' . $filename . ' into ' . $dirName, 'JavaJSONTarHandler::Parse', LOG_ERR); return false; } // Check if this submission included a package_map.json file. // This tells us how Java packages correspond to CDash subprojects. $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST); foreach ($iterator as $fileinfo) { if ($fileinfo->getFilename() == 'package_map.json') { $this->ParsePackageMap($fileinfo); } } // Recursively search for .java.json files and parse them. $iterator->rewind(); foreach ($iterator as $fileinfo) { // need the longest extension, so getExtension() won't do here. $ext = substr(strstr($fileinfo->getFilename(), '.'), 1); if ($ext === 'java.json') { $this->ParseJavaJSONFile($fileinfo); } } // Insert coverage summaries $completedSummaries = array(); foreach ($this->CoverageSummaries as $coverageSummary) { if (in_array($coverageSummary->BuildId, $completedSummaries)) { continue; } $coverageSummary->Insert(); $coverageSummary->ComputeDifference(); $completedSummaries[] = $coverageSummary->BuildId; } // Delete the directory when we're done. DeleteDirectory($dirName); return true; }
/** * {@inheritDoc} */ public function run() { // Remove old temporary file (perhaps failed uploads?) $last_valid_timestamp = time() - $this->max_file_age; try { $iterator = new \DirectoryIterator($this->plupload_upload_path); foreach ($iterator as $file) { if (strpos($file->getBasename(), $this->config['plupload_salt']) !== 0) { // Skip over any non-plupload files. continue; } if ($file->getMTime() < $last_valid_timestamp) { @unlink($file->getPathname()); } } } catch (\UnexpectedValueException $e) { add_log('critical', 'LOG_PLUPLOAD_TIDY_FAILED', $this->plupload_upload_path, $e->getMessage(), $e->getTraceAsString()); } $this->config->set('plupload_last_gc', time(), true); }
/** * 修改密码 * @author Yusure http://yusure.cn * @date 2016-02-15 * @param [param] * @return [type] [description] */ public function up_passwd() { if (IS_POST) { $user_model = D('User'); $old_res = $this->_check_oldpwd(I('post.old_pwd')); $old_res ?: $this->error('旧密码错误'); /* 检查数据规范 */ $this->_check_passwd_data(); $condition['user_id'] = session('user_info.user_id'); $data['user_passwd'] = I('post.new_pwd', '', 'md5'); $up_res = $user_model->update($condition, $data); if ($up_res !== false) { add_log('修改密码'); $this->success('操作成功!', U('Login/logout')); } else { $this->error('操作失败!'); } } else { $this->display(); } }