Example #1
0
 function Insert()
 {
     if (!$this->BuildId) {
         echo "BuildTestDiff::Insert(): BuildId is not set<br>";
         return false;
     }
     if ($this->Type != 0 && empty($this->Type)) {
         echo "BuildTestDiff::Insert(): Type is not set<br>";
         return false;
     }
     if (!is_numeric($this->DifferenceNegative)) {
         echo "BuildTestDiff::Insert(): DifferenceNegative is not set<br>";
         return false;
     }
     if (!is_numeric($this->DifferencePositive)) {
         echo "BuildTestDiff::Insert(): DifferencePositive is not set<br>";
         return false;
     }
     $query = "INSERT INTO testdiff (buildid,type,difference_negative,difference_positive) \n              VALUES ('{$this->BuildId}','{$this->Type}','{$this->DifferenceNegative}','{$this->DifferencePositive}')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildTestDiff Insert", 0, $this->BuildId);
         return false;
     }
     return true;
 }
Example #2
0
 public function doMobileForwardlove()
 {
     global $_W, $_GPC;
     $re = "";
     $ops = array('forward', 'praise');
     $op = in_array($_GPC['op'], $ops) ? $_GPC['op'] : 'forward';
     if ($op == 'forward') {
         $id = intval($_GPC['id']);
         $re = pdo_query("update " . tablename($this->tb_lovehelper_msg) . " set forward=forward+1 where id=:id and uniacid=:uniacid ", array(":id" => $id, ':uniacid' => $_W['uniacid']));
         if ($re) {
             echo "0";
         } else {
             echo '-1';
         }
     }
     if ($op == 'praise') {
         $id = intval($_GPC['id']);
         $re = pdo_query("update " . tablename($this->tb_lovehelper_msg) . " set praise=praise+1 where id=:id and uniacid=:uniacid ", array(":id" => $id, ':uniacid' => $_W['uniacid']));
         if ($re) {
             $praise = pdo_fetchcolumn('SELECT praise FROM ' . tablename($this->tb_lovehelper_msg) . 'where id=:id and uniacid=:uniacid', array(":id" => $id, ':uniacid' => $_W['uniacid']));
             echo $praise;
         } else {
             echo '-1';
         }
     }
 }
Example #3
0
 /** Get the number of tests that are failing */
 function GetNumberOfFailures($checktesttiming, $testtimemaxstatus)
 {
     if (!$this->BuildId) {
         echo "BuildTest::GetNumberOfFailures(): BuildId not set";
         return false;
     }
     $sql = "SELECT testfailed,testnotrun,testtimestatusfailed FROM build WHERE id=" . qnum($this->BuildId);
     $query = pdo_query($sql);
     if (!$query) {
         add_last_sql_error("BuildTest:GetNumberOfFailures", 0, $this->BuildId);
         return false;
     }
     $nfail_array = pdo_fetch_array($query);
     $sumerrors = 0;
     if ($nfail_array['testfailed'] > 0) {
         $sumerrors += $nfail_array['testfailed'];
     }
     if ($nfail_array['testnotrun'] > 0) {
         $sumerrors += $nfail_array['testnotrun'];
     }
     // Find if the build has any test failings
     if ($checktesttiming) {
         if ($nfail_array['testtimestatusfailed'] > 0) {
             $sumerrors += $nfail_array['testtimestatusfailed'];
         }
     }
     return $sumerrors;
 }
Example #4
0
 public function testAccountLockout()
 {
     // Enable our config settings.
     $this->addLineToConfig($this->AttemptsConfig);
     $this->addLineToConfig($this->LengthConfig);
     // Get the id for the simpletest user.
     $user = new User();
     $user->Email = 'simpletest@localhost';
     if (!$user->Exists()) {
         $this->fail("simpletest user does not exist");
         return false;
     }
     $userid = $user->Id;
     // Lock the account out by specifying the wrong password multiple times.
     $this->login('simpletest@localhost', 'asdf');
     $this->login('simpletest@localhost', 'asdf');
     // Make sure we get the same error message when we attempt to login
     // whether or not we use the correct password.
     $this->login('simpletest@localhost', 'asdf');
     $this->assertText('Your account is locked');
     $this->login('simpletest@localhost', 'simpletest');
     $this->assertText('Your account is locked');
     // Manually set the lock to expire.
     pdo_query("UPDATE lockout SET unlocktime = '1980-01-01 00:00:00'\n            WHERE userid={$userid}");
     // Make sure we can successfully log in now.
     $this->login('simpletest@localhost', 'simpletest');
     $this->assertText('Log Out');
     $this->removeLineFromConfig($this->AttemptsConfig);
     $this->removeLineFromConfig($this->LengthConfig);
     $this->pass('Test passed');
 }
Example #5
0
 function testDeleteDailyUpdate()
 {
     //double check that it's the testing database before doing anything hasty...
     if ($this->databaseName !== "cdash4simpletest") {
         $this->fail("can only test on a database named 'cdash4simpletest'");
         return 1;
     }
     //remove the daily update entry for some projects so that subsequent tests
     //will cover dailyupdate.php more thoroughly
     $cvsID = get_project_id("InsightExample");
     if (!($query = pdo_query("DELETE FROM dailyupdate WHERE projectid='{$cvsID}'"))) {
         $this->fail("pdo_query returned false");
         return 1;
     }
     $svnID = get_project_id("EmailProjectExample");
     if (!($query = pdo_query("DELETE FROM dailyupdate WHERE projectid='{$svnID}'"))) {
         $this->fail("pdo_query returned false");
         return 1;
     }
     $gitID = get_project_id("PublicDashboard");
     if (!($query = pdo_query("DELETE FROM dailyupdate WHERE projectid='{$gitID}'"))) {
         $this->fail("pdo_query returned false");
         return 1;
     }
     $this->pass("Passed");
 }
Example #6
0
 function Insert()
 {
     $text = pdo_real_escape_string($this->Text);
     // Get this->Id from the database if text is already in the label table:
     $this->Id = pdo_get_field_value("SELECT id FROM label WHERE text='{$text}'", 'id', 0);
     // Or, if necessary, insert a new row, then get the id of the inserted row:
     if (0 == $this->Id) {
         $query = "INSERT INTO label (text) VALUES ('{$text}')";
         if (!pdo_query($query)) {
             add_last_sql_error('Label::Insert');
             return false;
         }
         $this->Id = pdo_insert_id('label');
     }
     // Insert relationship records, too, but only for those relationships
     // established by callers. (If coming from test.php, for example, TestId
     // will be set, but none of the others will. Similarly for other callers.)
     $this->InsertAssociation('label2build', 'buildid', $this->BuildId);
     $this->InsertAssociation('label2buildfailure', 'buildfailureid', $this->BuildFailureId);
     $this->InsertAssociation('label2coveragefile', 'buildid', $this->CoverageFileBuildId, 'coveragefileid', $this->CoverageFileId);
     $this->InsertAssociation('label2dynamicanalysis', 'dynamicanalysisid', $this->DynamicAnalysisId);
     $this->InsertAssociation('label2test', 'buildid', $this->TestBuildId, 'testid', $this->TestId);
     // TODO: Implement this:
     //
     //$this->InsertAssociation($this->UpdateFileKey,
     //  'label2updatefile', 'updatefilekey');
     return true;
 }
Example #7
0
 /** Save the group */
 public function Save()
 {
     if (!$this->DailyUpdateId) {
         echo 'DailyUpdateFile::Save(): DailyUpdateId not set!';
         return false;
     }
     if (!$this->Filename) {
         echo 'DailyUpdateFile::Save(): Filename not set!';
         return false;
     }
     if (!$this->CheckinDate) {
         echo 'DailyUpdateFile::Save(): CheckinDate not set!';
         return false;
     }
     if ($this->Exists()) {
         // Update the project
         $query = 'UPDATE dailyupdatefile SET';
         $query .= " checkindate='" . $this->CheckinDate . "'";
         $query .= ",author='" . $this->Author . "'";
         $query .= ",log='" . $this->Log . "'";
         $query .= ",revision='" . $this->Revision . "'";
         $query .= ",priorrevision='" . $this->PriorRevision . "'";
         $query .= " WHERE dailyupdateid='" . $this->DailyUpdateId . "' AND filename='" . $this->Filename . "'";
         if (!pdo_query($query)) {
             add_last_sql_error('DailyUpdateFile Update');
             return false;
         }
     } else {
         if (!pdo_query("INSERT INTO dailyupdatefile (dailyupdateid,filename,checkindate,author,log,revision,priorrevision)\n                     VALUES ('{$this->DailyUpdateId}','{$this->Filename}','{$this->CheckinDate}','{$this->Author}','{$this->Log}',\n                     '{$this->Revision}','{$this->PriorRevision}')")) {
             add_last_sql_error('DailyUpdateFile Insert');
             return false;
         }
     }
     return true;
 }
 private function expectedTest($buildname, $projectname)
 {
     // Mark an old build as expected.
     $query = "\n            SELECT b.siteid, b.type, g.id AS groupid FROM build AS b\n            INNER JOIN build2group AS b2g ON (b.id=b2g.buildid)\n            INNER JOIN buildgroup AS g ON (b2g.groupid=g.id)\n            WHERE b.name='{$buildname}'";
     if ($projectname === 'Trilinos') {
         $query .= ' AND b.parentid=-1';
     }
     $build_row = pdo_single_row_query($query);
     $groupid = $build_row['groupid'];
     $buildtype = $build_row['type'];
     $siteid = $build_row['siteid'];
     if (!pdo_query("\n                    INSERT INTO build2grouprule(groupid,buildtype,buildname,siteid,expected,starttime,endtime)\n                    VALUES ('{$groupid}','{$buildtype}','{$buildname}','{$siteid}','1','2013-01-01 00:00:00','1980-01-01 00:00:00')")) {
         $this->fail("Error marking {$buildname} as expected");
         return 1;
     }
     // Verify that our API lists this build even though it hasn't submitted today.
     $this->get($this->url . "/api/v1/index.php?project={$projectname}");
     $content = $this->getBrowser()->getContent();
     $jsonobj = json_decode($content, true);
     $buildgroup = array_pop($jsonobj['buildgroups']);
     $found = false;
     foreach ($buildgroup['builds'] as $build) {
         if ($build['buildname'] == $buildname && $build['expectedandmissing'] == 1) {
             $found = true;
         }
     }
     // Make it unexpected again.
     pdo_query("DELETE FROM build2grouprule WHERE buildname='{$buildname}'");
     if (!$found) {
         $this->fail("Expected missing build '{$buildname}' not included");
         return 1;
     }
     $this->pass('Passed');
     return 0;
 }
Example #9
0
 public function doMobilecoupon()
 {
     global $_GPC, $_W;
     $op = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
     if ($op == 'display') {
         $id = $_GPC['id'];
         if (empty($id)) {
             message('参数错误');
         }
         $code = pdo_fetch("SELECT * FROM " . tablename('choose_order') . " WHERE uniacid = '{$_W['uniacid']}' AND openid = '{$_W['openid']}' ");
         $codemess = pdo_fetch("SELECT * FROM " . tablename('choose_pro') . " WHERE uniacid = '{$_W['uniacid']}' AND id = '{$id}' ");
         include $this->template('code');
     }
     if ($op == 'post') {
         $id = $_GPC['id'];
         $code = pdo_fetch("SELECT * FROM " . tablename('choose_order') . " WHERE uniacid = '{$_W['uniacid']}' AND openid = '{$_W['openid']}' AND mobile = '{$_GPC['mobile']}' ");
         if (!empty($code['code'])) {
             $status = false;
             $msg = '您已经领取过优惠券,请勿重复领取!';
         } elseif (!empty($code)) {
             $carttotal = random(4, 1) . random(4, 1) . random(4, 1);
             $data = array('uniacid' => $_W['uniacid'], 'ordersn' => date('md') . random(4, 1), 'openid' => $_W['openid'], 'mobile' => $_GPC['mobile'], 'code' => $carttotal, 'pro_id' => $id, 'createtime' => TIMESTAMP);
             pdo_update('choose_order', $data, array('id' => $code['id']));
             pdo_query("update " . tablename('choose_pro') . " set youhui_num=youhui_num+1 where id = '{$_GPC['huodong_id']}' ");
         } else {
             $carttotal = random(4, 1) . random(4, 1) . random(4, 1);
             $data = array('uniacid' => $_W['uniacid'], 'ordersn' => date('md') . random(4, 1), 'openid' => $_W['openid'], 'mobile' => $_GPC['mobile'], 'code' => $carttotal, 'pro_id' => $id, 'createtime' => TIMESTAMP);
             pdo_insert('choose_order', $data);
             pdo_query("update " . tablename('choose_pro') . " set youhui_num=youhui_num+1 where id = '{$_GPC['huodong_id']}' ");
         }
         $result = array('status' => $status, 'msg' => $msg, 'coupon_bn' => $carttotal);
         die(json_encode($result));
     }
 }
Example #10
0
 public function ruleDeleted($rid)
 {
     global $_W;
     //删除规则时调用,这里 $rid 为对应的规则编号
     $sql = 'DELETE FROM ' . tablename('slotmac_rep') . " WHERE id='{$rid}' AND weid='{$_W['weid']}'";
     pdo_query($sql);
 }
Example #11
0
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     // 分享量
     if ($_W['isajax'] && $_GPC['op'] == 'share') {
         pdo_query("UPDATE " . tablename('qiyue_qiuqian') . " SET sharenum=sharenum+1 WHERE uniacid=:uniacid", array(':uniacid' => $_W['uniacid']));
         message(array('error_code' => 0), '', 'ajax');
     }
     $qian_r = pdo_fetch("SELECT * FROM " . tablename('qiyue_qiuqian') . " WHERE uniacid=:uniacid", array(':uniacid' => $_W['uniacid']));
     $morepic = array();
     $imgcount = 0;
     if ($qian_r['morepic']) {
         $f_exp = "::::::";
         $r_exp = PHP_EOL;
         $rr = explode($r_exp, $qian_r['morepic']);
         $imgcount = count($rr);
         for ($i = 0; $i < $imgcount; $i++) {
             $fr = explode($f_exp, $rr[$i]);
             $morepic[] = array('title' => $fr['1'], 'url' => tomedia($fr['0']));
         }
     }
     $_share = $this->module['config'];
     unset($_share['cnzzid']);
     // 去掉CNZZ
     $cnzzid = $this->module['config']['cnzzid'];
     // 增加浏览量
     pdo_query("UPDATE " . tablename('qiyue_qiuqian') . " SET viewnum=viewnum+1 WHERE uniacid=:uniacid", array(':uniacid' => $_W['uniacid']));
     include $this->template('index');
 }
Example #12
0
function get_related_dates($projectname, $basedate)
{
    include "cdash/config.php";
    require_once "cdash/pdo.php";
    $dates = array();
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    pdo_select_db("{$CDASH_DB_NAME}", $db);
    $dbQuery = pdo_query("SELECT nightlytime FROM project WHERE name='{$projectname}'");
    if (pdo_num_rows($dbQuery) > 0) {
        $project = pdo_fetch_array($dbQuery);
        $nightlytime = $project['nightlytime'];
        //echo "query result nightlytime: " . $nightlytime . "<br/>";
    } else {
        $nightlytime = "00:00:00";
        //echo "default nightlytime: " . $nightlytime . "<br/>";
    }
    if (!isset($basedate) || strlen($basedate) == 0) {
        $basedate = gmdate(FMT_DATE);
    }
    // Convert the nightly time into GMT
    $nightlytime = gmdate(FMT_TIME, strtotime($nightlytime));
    $nightlyhour = time2hour($nightlytime);
    $nightlyminute = time2minute($nightlytime);
    $nightlysecond = time2second($nightlytime);
    $basemonth = date2month($basedate);
    $baseday = date2day($basedate);
    $baseyear = date2year($basedate);
    $dates['nightly+2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 2, $baseyear);
    $dates['nightly+1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday + 1, $baseyear);
    $dates['nightly-0'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday, $baseyear);
    $dates['nightly-1'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 1, $baseyear);
    $dates['nightly-2'] = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $basemonth, $baseday - 2, $baseyear);
    // Snapshot of "now"
    //
    $currentgmtime = time();
    $currentgmdate = gmdate(FMT_DATE, $currentgmtime);
    // Find the most recently past nightly time:
    //
    $todaymonth = date2month($currentgmdate);
    $todayday = date2day($currentgmdate);
    $todayyear = date2year($currentgmdate);
    $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear);
    while ($currentnightly > $currentgmtime) {
        $todayday = $todayday - 1;
        $currentnightly = gmmktime($nightlyhour, $nightlyminute, $nightlysecond, $todaymonth, $todayday, $todayyear);
    }
    $dates['now'] = $currentgmtime;
    $dates['most-recent-nightly'] = $currentnightly;
    $dates['today_utc'] = $currentgmdate;
    $dates['basedate'] = gmdate(FMT_DATE, $dates['nightly-0']);
    // CDash equivalent of DART1's "last rollup time"
    if ($dates['basedate'] === $dates['today_utc']) {
        // If it's today, it's now:
        $dates['last-rollup-time'] = $dates['now'];
    } else {
        // If it's not today, it's the nightly time on the basedate:
        $dates['last-rollup-time'] = $dates['nightly-0'];
    }
    return $dates;
}
Example #13
0
 function Insert()
 {
     if (!$this->BuildId) {
         echo "BuildUserNote::Insert(): BuildId is not set<br>";
         return false;
     }
     if (!$this->UserId) {
         echo "BuildUserNote::Insert(): UserId is not set<br>";
         return false;
     }
     if (!$this->Note) {
         echo "BuildUserNote::Insert(): Note is not set<br>";
         return false;
     }
     if (!$this->TimeStamp) {
         echo "BuildUserNote::Insert(): TimeStamp is not set<br>";
         return false;
     }
     if (!$this->Status) {
         echo "BuildUserNote::Insert(): Status is not set<br>";
         return false;
     }
     $query = "INSERT INTO buildnote (buildid,userid,note,timestamp,status)\n              VALUES ('{$this->BuildId}','{$this->UserId}','{$this->Note}','{$this->TimeStamp}','{$this->Status}')";
     if (!pdo_query($query)) {
         add_last_sql_error("BuildUserNote Insert", 0, $this->BuildId);
         return false;
     }
     return true;
 }
Example #14
0
/**
 * [WeEngine System] Copyright (c) 2014 WE7.CC
 * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
 */
function site_cover($coverparams = array())
{
    $where = '';
    $params = array(':uniacid' => $coverparams['uniacid'], ':module' => $coverparams['module']);
    if (!empty($coverparams['multiid'])) {
        $where .= " AND multiid = :multiid";
        $params[':multiid'] = $coverparams['multiid'];
    }
    $cover = pdo_fetch("SELECT * FROM " . tablename('cover_reply') . " WHERE `module` = :module AND uniacid = :uniacid {$where}", $params);
    if (empty($cover['rid'])) {
        $rule = array('uniacid' => $coverparams['uniacid'], 'name' => $coverparams['title'], 'module' => 'cover', 'status' => 1);
        pdo_insert('rule', $rule);
        $rid = pdo_insertid();
    } else {
        $rule = array('name' => $coverparams['title']);
        pdo_update('rule', $rule, array('id' => $cover['rid']));
        $rid = $cover['rid'];
    }
    if (!empty($rid)) {
        $sql = 'DELETE FROM ' . tablename('rule_keyword') . ' WHERE `rid`=:rid AND `uniacid`=:uniacid';
        $pars = array();
        $pars[':rid'] = $rid;
        $pars[':uniacid'] = $coverparams['uniacid'];
        pdo_query($sql, $pars);
        $keywordrow = array('rid' => $rid, 'uniacid' => $coverparams['uniacid'], 'module' => 'cover', 'status' => 1, 'displayorder' => 0, 'type' => 1, 'content' => $coverparams['keyword']);
        pdo_insert('rule_keyword', $keywordrow);
    }
    $entry = array('uniacid' => $coverparams['uniacid'], 'multiid' => $coverparams['multiid'], 'rid' => $rid, 'title' => $coverparams['title'], 'description' => $coverparams['description'], 'thumb' => $coverparams['thumb'], 'url' => $coverparams['url'], 'do' => '', 'module' => $coverparams['module']);
    if (empty($cover['id'])) {
        pdo_insert('cover_reply', $entry);
    } else {
        pdo_update('cover_reply', $entry, array('id' => $cover['id']));
    }
    return true;
}
Example #15
0
 public function doPassword()
 {
     global $_W, $_GPC;
     if (checksubmit('submit')) {
         if (!empty($_GPC['title-new'])) {
             foreach ($_GPC['title-new'] as $index => $row) {
                 $data = array('weid' => $_W['weid'], 'name' => $_GPC['title-new'][$index], 'password' => member_hash($_GPC['password-new'][$index], ''));
                 pdo_insert('card_password', $data);
             }
         }
         if (!empty($_GPC['title'])) {
             foreach ($_GPC['title'] as $index => $row) {
                 $data = array('name' => $_GPC['title'][$index]);
                 if (!empty($_GPC['password'][$index])) {
                     $data['password'] = member_hash($_GPC['password'][$index], '');
                 }
                 pdo_update('card_password', $data, array('id' => $index));
             }
         }
         if (!empty($_GPC['delete'])) {
             pdo_query("DELETE FROM " . tablename('card_password') . " WHERE id IN (" . implode(',', $_GPC['delete']) . ")");
         }
         message('消费密码更新成功!', referer(), 'success');
     }
     $list = pdo_fetchall("SELECT * FROM " . tablename('card_password') . " WHERE weid = :weid", array(':weid' => $_W['weid']));
     include $this->template('password');
 }
Example #16
0
/**
 * Copy table rows by assigning them a new buildid.
 **/
function copy_build_table($old_buildid, $new_buildid, $table)
{
    $result = pdo_query("SELECT * FROM {$table} WHERE buildid={$old_buildid}");
    while ($result_array = pdo_fetch_array($result)) {
        // Remove the old buildid from our SELECT results, as we will be replacing
        // that with the new buildid.
        unset($result_array['buildid']);
        // Generate an INSERT query by listing all of the table columns
        // and their values.  This is slightly complicated by the fact that
        // our array has both string and integer keys.
        $keys = array();
        $values = array();
        foreach ($result_array as $key => $val) {
            if (!is_int($key)) {
                $keys[] = $key;
                $values[] = $val;
            }
        }
        $insert_query = "INSERT INTO {$table} (buildid,";
        $insert_query .= implode(",", $keys) . ")";
        $insert_query .= " VALUES ('{$new_buildid}','";
        $insert_query .= implode("','", $values) . "')";
        pdo_query($insert_query);
    }
}
Example #17
0
 public function fieldsFormSubmit($rid)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'weid' => $this->weid, 'title' => $_GPC['title'], 'kptime' => strtotime($_GPC['kptime']), 'rztime' => strtotime($_GPC['rztime']), 'kfs' => $_GPC['kfs'], 'price' => $_GPC['price'], 'lpaddress' => $_GPC['lpaddress'], 'sltel' => $_GPC['sltel'], 'zxtel' => $_GPC['zxtel'], 'news_title' => $_GPC['news_title'], 'news_icon' => $_GPC['news_icon'], 'news_content' => $_GPC['news_content'], 'share_title' => $_GPC['share_title'], 'share_icon' => $_GPC['share_icon'], 'share_content' => $_GPC['share_content'], 'order_title' => $_GPC['order_title'], 'order_remark' => $_GPC['order_remark'], 'cover_img' => $_GPC['cover_img'], 'overview_img' => $_GPC['overview_img'], 'intro_img' => $_GPC['intro_img'], 'dt_img' => $_GPC['dt_img'], 'dt_intro' => htmlspecialchars_decode($_GPC['dt_intro']), 'intro' => htmlspecialchars_decode($_GPC['intro']), 'createtime' => TIMESTAMP);
     if (empty($id)) {
         $id = pdo_insert($this->table_hosue, $insert);
     } else {
         pdo_update($this->table_hosue, $insert, array('id' => $id));
     }
     ///说明项处理
     $house_ids = $_GPC['house_ids'];
     $house_names = $_GPC['house_iname'];
     $house_conents = $_GPC['house_icontent'];
     $house_sorts = $_GPC['house_sort'];
     pdo_query("delete from " . tablename($this->table_house_item) . " where hid=:hid", array(":hid" => $id));
     if (is_array($house_ids)) {
         foreach ($house_ids as $key => $value) {
             $value = intval($value);
             $d = array("rid" => $rid, "hid" => $id, "iname" => $house_names[$key], "icontent" => $house_conents[$key], "sort" => $house_sorts[$key]);
             pdo_insert($this->table_house_item, $d);
         }
     }
     return true;
 }
Example #18
0
 /**
  * Authenticate to the web API as a project admin
  * @param project the name of the project
  * @param key the web API key for that project
  */
 function Authenticate()
 {
     include_once '../cdash/common.php';
     if (!isset($this->Parameters['project'])) {
         return array('status' => false, 'message' => "You must specify a project parameter.");
     }
     $projectid = get_project_id($this->Parameters['project']);
     if (!is_numeric($projectid) || $projectid <= 0) {
         return array('status' => false, 'message' => 'Project not found.');
     }
     if (!isset($this->Parameters['key']) || $this->Parameters['key'] == '') {
         return array('status' => false, 'message' => "You must specify a key parameter.");
     }
     $key = $this->Parameters['key'];
     $query = pdo_query("SELECT webapikey FROM project WHERE id={$projectid}");
     if (pdo_num_rows($query) == 0) {
         return array('status' => false, 'message' => "Invalid projectid.");
     }
     $row = pdo_fetch_array($query);
     $realKey = $row['webapikey'];
     if ($key != $realKey) {
         return array('status' => false, 'message' => "Incorrect API key passed.");
     }
     $token = create_web_api_token($projectid);
     return array('status' => true, 'token' => $token);
 }
Example #19
0
 function SetText($text)
 {
     if ($this->ProjectId == -1) {
         echo "Banner::SetText(): no ProjectId specified";
         return false;
     }
     $this->Text = pdo_real_escape_string($text);
     // Check if the project is already
     if ($this->Exists()) {
         // Update the project
         $query = "UPDATE banner SET";
         $query .= " text='" . $this->Text . "'";
         $query .= " WHERE projectid='" . $this->ProjectId . "'";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     } else {
         $query = "INSERT INTO banner (projectid,text)\n                VALUES (" . qnum($this->ProjectId) . ",'" . $this->Text . "')";
         if (!pdo_query($query)) {
             add_last_sql_error("Banner:SetText", $this->ProjectId);
             echo $query;
             return false;
         }
     }
     return true;
 }
Example #20
0
 /** 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;
 }
Example #21
0
 /** Delete this BuildFile */
 function Delete()
 {
     if (!$this->BuildId || !$this->md5) {
         return false;
     }
     pdo_query("DELETE FROM buildfile WHERE buildid={$this->BuildId} AND md5='{$this->md5}'");
 }
Example #22
0
 /** Get all the authors of a file */
 public function GetAuthors($filename, $onlylast = false)
 {
     if (!$this->ProjectId) {
         echo 'DailyUpdate::GetAuthors(): ProjectId is not set<br>';
         return false;
     }
     // Check if the note already exists
     $filename = pdo_real_escape_string($filename);
     // Remove
     if (substr($filename, 0, 2) == './') {
         $filename = substr($filename, 2);
     }
     $sql = '';
     if ($onlylast) {
         $sql = ' ORDER BY dailyupdate.id DESC LIMIT 1';
     }
     $query = pdo_query('SELECT DISTINCT up.userid,dailyupdate.id FROM user2project AS up,user2repository AS ur,dailyupdatefile,dailyupdate
                     WHERE dailyupdatefile.dailyupdateid=dailyupdate.id
                     AND dailyupdate.projectid=up.projectid
                     AND ur.credential=dailyupdatefile.author
                     AND up.projectid=' . qnum($this->ProjectId) . '
                     AND up.userid=ur.userid
                     AND (ur.projectid=0 OR ur.projectid=' . qnum($this->ProjectId) . ")\n                        AND dailyupdatefile.filename LIKE '%" . $filename . "'" . $sql);
     if (!$query) {
         add_last_sql_error('DailyUpdate GetAuthors', $this->ProjectId);
         return false;
     }
     $authorids = array();
     while ($query_array = pdo_fetch_array($query)) {
         $authorids[] = $query_array['userid'];
     }
     return $authorids;
 }
Example #23
0
 /** Save in the database */
 public function Save()
 {
     if (!$this->BuildId) {
         echo 'BuildConfigureErrorDiff::Save(): BuildId not set';
         return false;
     }
     if ($this->Exists()) {
         // Update
         $query = 'UPDATE configureerrordiff SET';
         $query .= ' type=' . qnum($this->Type);
         $query .= ',difference=' . qnum($this->Difference);
         $query .= ' WHERE buildid=' . qnum($this->BuildId);
         if (!pdo_query($query)) {
             add_last_sql_error('BuildConfigureErrorDiff:Update', 0, $this->BuildId);
             return false;
         }
     } else {
         // insert
         $query = 'INSERT INTO configureerrordiff (buildid,type,difference)
              VALUES (' . qnum($this->BuildId) . ',' . qnum($this->Type) . ',' . qnum($this->Difference) . ')';
         if (!pdo_query($query)) {
             add_last_sql_error('BuildConfigureErrorDiff:Create', 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Example #24
0
 /** Save in the database */
 function Save()
 {
     if (!$this->BuildId) {
         echo "BuildConfigureErrorDiff::Save(): BuildId not set";
         return false;
     }
     if ($this->Exists()) {
         // Update
         $query = "UPDATE configureerrordiff SET";
         $query .= " type=" . qnum($this->Type);
         $query .= ",difference=" . qnum($this->Difference);
         $query .= " WHERE buildid=" . qnum($this->BuildId);
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureErrorDiff:Update", 0, $this->BuildId);
             return false;
         }
     } else {
         $query = "INSERT INTO configureerrordiff (buildid,type,difference)\n                 VALUES (" . qnum($this->BuildId) . "," . qnum($this->Type) . "," . qnum($this->Difference) . ")";
         if (!pdo_query($query)) {
             add_last_sql_error("BuildConfigureErrorDiff:Create", 0, $this->BuildId);
             return false;
         }
     }
     return true;
 }
Example #25
0
 public function testTestHistory()
 {
     // Submit our testing data.
     $rep = dirname(__FILE__) . '/data/TestHistory';
     if (!$this->submission('InsightExample', "{$rep}/Test_1.xml")) {
         $this->fail('Failed to submit Test_1.xml');
         return 1;
     }
     if (!$this->submission('InsightExample', "{$rep}/Test_2.xml")) {
         $this->fail('Failed to submit Test_1.xml');
         return 1;
     }
     // Get the IDs for the two builds that we just created.
     $result = pdo_query("SELECT id FROM build WHERE name='TestHistory'");
     $num_builds = pdo_num_rows($result);
     if ($num_builds != 2) {
         $this->fail("Expected 2 builds, found {$num_builds}");
         return 1;
     }
     $buildids = array();
     while ($row = pdo_fetch_array($result)) {
         $buildids[] = $row['id'];
     }
     // Verify that testing history matches what we expect.
     $content = $this->connect($this->url . '/api/v1/viewTest.php?groupid=15&previous_builds=' . $buildids[1] . ',+' . $buildids[0] . '&projectid=5&tests%5B%5D=fails&tests%5B%5D=notrun&tests%5B%5D=flaky&tests%5B%5D=passes&time_begin=2015-11-16T01:00:00&time_end=2015-11-17T01:00:00');
     $jsonobj = json_decode($content, true);
     $success = true;
     $error_message = '';
     foreach ($jsonobj['tests'] as $test) {
         $history = $test['history'];
         if ($test['name'] == 'fails' && $history != 'Broken') {
             $error_message = "Expected history for test 'fails' to be 'Broken', instead found '{$history}'";
             $success = false;
         }
         if ($test['name'] == 'notrun' && $history != 'Inactive') {
             $error_message = "Expected history for test 'notrun' to be 'Inactive', instead found '{$history}'";
             $success = false;
         }
         if ($test['name'] == 'flaky' && $history != 'Unstable') {
             $error_message = "Expected history for test 'flaky' to be 'Unstable', instead found '{$history}'";
             $success = false;
         }
         if ($test['name'] == 'passes' && $history != 'Stable') {
             $error_message = "Expected history for test 'passes' to be 'Stable', instead found '{$history}'";
             $success = false;
         }
     }
     // Delete the builds that we created during this test.
     remove_build($buildids[0]);
     remove_build($buildids[1]);
     if ($success) {
         $this->pass('Test passed');
         return 0;
     } else {
         $this->fail($error_message);
         return 1;
     }
 }
Example #26
0
 /** Return the coverage per directory with the number of lines
  * covered and not covered */
 private function CoveragePerDirectory()
 {
     include_once '../cdash/common.php';
     if (!isset($this->Parameters['project'])) {
         echo "Project not set";
         return;
     }
     $projectid = get_project_id($this->Parameters['project']);
     if (!is_numeric($projectid) || $projectid <= 0) {
         echo "Project not found";
         return;
     }
     // Select the last build that has coverage from the project
     $query = pdo_query("SELECT buildid FROM coveragesummary,build WHERE build.id=coveragesummary.buildid\n                              AND build.projectid='{$projectid}' ORDER BY buildid DESC LIMIT 1");
     echo pdo_error();
     if (pdo_num_rows($query) == 0) {
         echo "No coverage entries found for this project";
         return;
     }
     $query_array = pdo_fetch_array($query);
     $buildid = $query_array['buildid'];
     // Find the coverage files
     $query = pdo_query("SELECT cf.fullpath,c.loctested,c.locuntested FROM coverage as c,coveragefile as cf\n                 WHERE c.fileid=cf.id AND c.buildid='" . $buildid . "' ORDER BY cf.fullpath ASC");
     echo pdo_error();
     $coveragearray = array();
     while ($query_array = pdo_fetch_array($query)) {
         $fullpath = $query_array['fullpath'];
         $paths = explode('/', $fullpath);
         $current = array();
         for ($i = 1; $i < count($paths) - 1; $i++) {
             if ($i == 1) {
                 if (!isset($coveragearray[$paths[$i]])) {
                     $coveragearray[$paths[$i]] = array();
                 }
                 $current =& $coveragearray[$paths[$i]];
             } else {
                 if ($i == count($paths) - 2) {
                     if (isset($current[$paths[$i]])) {
                         $v = $current[$paths[$i]]['locuntested'];
                         $current[$paths[$i]]['locuntested'] = (int) $v + $query_array['locuntested'];
                         $v = $current[$paths[$i]]['loctested'];
                         $current[$paths[$i]]['loctested'] = (int) $v + $query_array['loctested'];
                     } else {
                         @($current[$paths[$i]]['locuntested'] = $query_array['locuntested']);
                         @($current[$paths[$i]]['loctested'] = $query_array['loctested']);
                     }
                     unset($current);
                 } else {
                     $current[$paths[$i]] = array();
                     $current[$paths[$i]]['locuntested'] = 0;
                     $current[$paths[$i]]['loctested'] = 0;
                     $current =& $current[$paths[$i]];
                 }
             }
         }
     }
     return $coveragearray;
 }
Example #27
0
 public function ruleDeleted($rid)
 {
     global $_W;
     //删除规则时调用,这里 $rid 为对应的规则编号
     $sql = 'DELETE FROM ' . tablename('timeaxis_rep') . " WHERE id='{$rid}' AND weid='{$_W['weid']}'";
     pdo_query($sql);
     pdo_query('DELETE FROM ' . tablename('rule_keyword') . " WHERE rid='{$rid}'");
     pdo_query('DELETE FROM ' . tablename('rule') . " WHERE id='{$rid}'");
 }
Example #28
0
 public function __construct()
 {
     global $_W;
     $this->data = 'super_securitycode_data_' . $_W['uniacid'];
     $this->moban = 'super_securitycode_data_moban';
     $this->reply = 'super_securitycode_reply';
     $sql = "CREATE TABLE IF NOT EXISTS " . tablename($this->data) . " LIKE " . tablename($this->moban);
     pdo_query($sql);
 }
Example #29
0
function rs_ibeacon_ans($ans)
{
    $openid = $ans['openid'];
    $where = " WHERE openid= '{$openid}'";
    $sql = 'DELETE FROM ' . tablename('redstar_ibeacon') . "{$where}";
    pdo_query($sql);
    $ans['openid'] = $openid;
    pdo_insert('redstar_ibeacon', $ans);
}
Example #30
0
/** Get the last file id dynamicanalysis */
function get_last_fileid_dynamicanalysis($filename, $projectid, $siteid, $buildtype, $buildname, $starttime)
{
    $nextbuild = pdo_query("SELECT dynamicanalysis.id FROM build,dynamicanalysis\n                          WHERE build.siteid='{$siteid}' AND build.type='{$buildtype}' AND build.name='{$buildname}'\n                          AND build.projectid='{$projectid}' \n                          AND dynamicanalysis.buildid=build.id\n                          AND dynamicanalysis.name='{$filename}'\n                          ORDER BY build.starttime DESC LIMIT 1");
    if (pdo_num_rows($nextbuild) > 0) {
        $nextbuild_array = pdo_fetch_array($nextbuild);
        return $nextbuild_array["id"];
    }
    return 0;
}