当前位置: 首页>>代码示例>>PHP>>正文


PHP pdo_select_db函数代码示例

本文整理汇总了PHP中pdo_select_db函数的典型用法代码示例。如果您正苦于以下问题:PHP pdo_select_db函数的具体用法?PHP pdo_select_db怎么用?PHP pdo_select_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pdo_select_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_related_dates

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;
}
开发者ID:rpshaw,项目名称:CDash,代码行数:60,代码来源:viewChanges.php

示例2: generate_subprojects_dashboard_XML

/** Generate the subprojects dashboard */
function generate_subprojects_dashboard_XML($project_instance, $date)
{
    $start = microtime_float();
    $noforcelogin = 1;
    include_once "cdash/config.php";
    require_once "cdash/pdo.php";
    include 'login.php';
    include_once "models/banner.php";
    include_once "models/subproject.php";
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        echo "Error connecting to CDash database server<br>\n";
        return;
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        echo "Error selecting CDash database<br>\n";
        return;
    }
    $Project = $project_instance;
    $projectid = $project_instance->Id;
    $homeurl = make_cdash_url(htmlentities($Project->HomeUrl));
    checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid);
    $xml = begin_XML_for_XSLT();
    $xml .= "<title>CDash - " . $Project->Name . "</title>";
    $Banner = new Banner();
    $Banner->SetProjectId(0);
    $text = $Banner->GetText();
    if ($text !== false) {
        $xml .= "<banner>";
        $xml .= add_XML_value("text", $text);
        $xml .= "</banner>";
    }
    $Banner->SetProjectId($projectid);
    $text = $Banner->GetText();
    if ($text !== false) {
        $xml .= "<banner>";
        $xml .= add_XML_value("text", $text);
        $xml .= "</banner>";
    }
    global $CDASH_SHOW_LAST_SUBMISSION;
    if ($CDASH_SHOW_LAST_SUBMISSION) {
        $xml .= "<showlastsubmission>1</showlastsubmission>";
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $Project->NightlyTime);
    $svnurl = make_cdash_url(htmlentities($Project->CvsUrl));
    $homeurl = make_cdash_url(htmlentities($Project->HomeUrl));
    $bugurl = make_cdash_url(htmlentities($Project->BugTrackerUrl));
    $googletracker = htmlentities($Project->GoogleTracker);
    $docurl = make_cdash_url(htmlentities($Project->DocumentationUrl));
    // Main dashboard section
    $xml .= "<dashboard>\n  <datetime>" . date("l, F d Y H:i:s T", time()) . "</datetime>\n  <date>" . $date . "</date>\n  <unixtimestamp>" . $currentstarttime . "</unixtimestamp>\n  <svn>" . $svnurl . "</svn>\n  <bugtracker>" . $bugurl . "</bugtracker>\n  <googletracker>" . $googletracker . "</googletracker>\n  <documentation>" . $docurl . "</documentation>\n  <logoid>" . $Project->getLogoID() . "</logoid>\n  <projectid>" . $projectid . "</projectid>\n  <projectname>" . $Project->Name . "</projectname>\n  <projectname_encoded>" . urlencode($Project->Name) . "</projectname_encoded>\n  <previousdate>" . $previousdate . "</previousdate>\n  <projectpublic>" . $Project->Public . "</projectpublic>\n  <nextdate>" . $nextdate . "</nextdate>";
    if (empty($Project->HomeUrl)) {
        $xml .= "<home>index.php?project=" . urlencode($Project->Name) . "</home>";
    } else {
        $xml .= "<home>" . $homeurl . "</home>";
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/models/proProject.php")) {
        include_once "local/models/proProject.php";
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $xml .= "<proedition>" . $pro->GetEdition(1) . "</proedition>";
    }
    if ($currentstarttime > time()) {
        $xml .= "<future>1</future>";
    } else {
        $xml .= "<future>0</future>";
    }
    $xml .= "</dashboard>";
    // Menu definition
    $xml .= "<menu>";
    if (!has_next_date($date, $currentstarttime)) {
        $xml .= add_XML_value("nonext", "1");
    }
    $xml .= "</menu>";
    $beginning_timestamp = $currentstarttime;
    $end_timestamp = $currentstarttime + 3600 * 24;
    $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp);
    $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp);
    // User
    if (isset($_SESSION['cdash'])) {
        $xml .= "<user>";
        $userid = $_SESSION['cdash']['loginid'];
        $user2project = pdo_query("SELECT role FROM user2project WHERE userid='{$userid}' and projectid='{$projectid}'");
        $user2project_array = pdo_fetch_array($user2project);
        $user = pdo_query("SELECT admin FROM " . qid("user") . "  WHERE id='{$userid}'");
        $user_array = pdo_fetch_array($user);
        $xml .= add_XML_value("id", $userid);
        $isadmin = 0;
        if ($user2project_array["role"] > 1 || $user_array["admin"]) {
            $isadmin = 1;
        }
        $xml .= add_XML_value("admin", $isadmin);
        $xml .= add_XML_value("projectrole", $user2project_array['role']);
        $xml .= "</user>";
    }
    // Get some information about the project
    $xml .= "<project>";
    $xml .= add_XML_value("nbuilderror", $Project->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate, true));
    $xml .= add_XML_value("nbuildwarning", $Project->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate, true));
//.........这里部分代码省略.........
开发者ID:josephsnyder,项目名称:CDash,代码行数:101,代码来源:index.php

示例3: addDailyChanges

/** Add daily changes if necessary */
function addDailyChanges($projectid)
{
    include "cdash/config.php";
    include_once "cdash/common.php";
    include_once "cdash/sendemail.php";
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    pdo_select_db("{$CDASH_DB_NAME}", $db);
    $project_array = pdo_fetch_array(pdo_query("SELECT nightlytime,name,autoremovetimeframe,autoremovemaxbuilds,emailadministrator\n                                              FROM project WHERE id='{$projectid}'"));
    $date = "";
    // now
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array["nightlytime"]);
    $date = gmdate(FMT_DATE, $currentstarttime);
    // Check if we already have it somwhere
    $query = pdo_query("SELECT id FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'");
    if (pdo_num_rows($query) == 0) {
        $cvsauthors = array();
        pdo_query("INSERT INTO dailyupdate (projectid,date,command,type,status)\n               VALUES ({$projectid},'{$date}','NA','NA','0')");
        $updateid = pdo_insert_id("dailyupdate");
        $dates = get_related_dates($project_array["nightlytime"], $date);
        $commits = get_repository_commits($projectid, $dates);
        // Insert the commits
        foreach ($commits as $commit) {
            $filename = $commit['directory'] . "/" . $commit['filename'];
            $checkindate = $commit['time'];
            $author = addslashes($commit['author']);
            $email = '';
            if (isset($commit['email'])) {
                $email = addslashes($commit['email']);
            }
            $log = addslashes($commit['comment']);
            $revision = $commit['revision'];
            $priorrevision = $commit['priorrevision'];
            // Check if we have a robot file for this build
            $robot = pdo_query("SELECT authorregex FROM projectrobot\n                  WHERE projectid=" . qnum($projectid) . " AND robotname='" . $author . "'");
            if (pdo_num_rows($robot) > 0) {
                $robot_array = pdo_fetch_array($robot);
                $regex = $robot_array['authorregex'];
                preg_match($regex, $commit['comment'], $matches);
                if (isset($matches[1])) {
                    $author = addslashes($matches[1]);
                }
            }
            if (!in_array(stripslashes($author), $cvsauthors)) {
                $cvsauthors[] = stripslashes($author);
            }
            pdo_query("INSERT INTO dailyupdatefile (dailyupdateid,filename,checkindate,author,email,log,revision,priorrevision)\n                   VALUES ({$updateid},'{$filename}','{$checkindate}','{$author}','{$email}','{$log}','{$revision}','{$priorrevision}')");
            add_last_sql_error("addDailyChanges", $projectid);
        }
        // end foreach commit
        // If the project has the option to send an email to the author
        if ($project_array['emailadministrator']) {
            sendEmailUnregisteredUsers($projectid, $cvsauthors);
        }
        // Send an email if some expected builds have not been submitting
        sendEmailExpectedBuilds($projectid, $currentstarttime);
        // cleanBuildEmail
        cleanBuildEmail();
        cleanUserTemp();
        // If the status of daily update is set to 2 that means we should send an email
        $query = pdo_query("SELECT status FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'");
        $dailyupdate_array = pdo_fetch_array($query);
        $dailyupdate_status = $dailyupdate_array["status"];
        if ($dailyupdate_status == 2) {
            // Find the groupid
            $group_query = pdo_query("SELECT buildid,groupid FROM summaryemail WHERE date='{$date}'");
            while ($group_array = pdo_fetch_array($group_query)) {
                $groupid = $group_array["groupid"];
                $buildid = $group_array["buildid"];
                // Find if the build has any errors
                $builderror = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='0'");
                $builderror_array = pdo_fetch_array($builderror);
                $nbuilderrors = $builderror_array[0];
                // Find if the build has any warnings
                $buildwarning = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='1'");
                $buildwarning_array = pdo_fetch_array($buildwarning);
                $nbuildwarnings = $buildwarning_array[0];
                // Find if the build has any test failings
                if ($project_emailtesttimingchanged) {
                    $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND (status='failed' OR timestatus>" . qnum($project_testtimemaxstatus) . ")";
                } else {
                    $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND status='failed'";
                }
                $nfail_array = pdo_fetch_array(pdo_query($sql));
                $nfailingtests = $nfail_array[0];
                sendsummaryemail($projectid, $groupid, $nbuildwarnings, $nbuilderrors, $nfailingtests);
            }
        }
        pdo_query("UPDATE dailyupdate SET status='1' WHERE projectid='{$projectid}' AND date='{$date}'");
        // Remove the old logs
        include_once "models/errorlog.php";
        $ErrorLog = new ErrorLog();
        $ErrorLog->Clean(10);
        // 10 days
        // Clean the backup directory
        clean_backup_directory();
        // Remove the first builds of the project
        include_once "cdash/autoremove.php";
        removeFirstBuilds($projectid, $project_array["autoremovetimeframe"], $project_array["autoremovemaxbuilds"]);
        removeBuildsGroupwise($projectid, $project_array["autoremovemaxbuilds"]);
//.........这里部分代码省略.........
开发者ID:rpshaw,项目名称:CDash,代码行数:101,代码来源:dailyupdates.php

示例4: session_start

<?php

session_start();
include_once "pdo_mysql.php";
if (isset($_POST['submit_signup'])) {
    $username = 'pnguyen';
    $password = '00000949559';
    $host = 'dbserver.engr.scu.edu';
    $database = 'sdb_pnguyen';
    if (!($server = pdo_connect("{$host}", $username, $password))) {
        die('Error connecting to ' . $host . '.' . pdo_error());
    }
    if (!($conn = pdo_select_db($database, $server))) {
        die('Error selecting ' . $database . '.' . pdo_error());
    }
    $user = $_POST['name'];
    if ($_POST['password'] == $_POST['password2']) {
        $password = $_POST['password'];
        $email = $_POST['email'];
        $NewRequestQuery = "INSERT INTO `enqueue_login` (`user`, `email`, `password`, `isInstructor`) VALUES ('{$user}', '{$email}', '{$password}', '0')";
        pdo_query($NewRequestQuery);
        echo "Success! Redirecting to home...";
        header("refresh:3; url= landing_page.php");
    } else {
        echo "Your passwords did not match! Redirecting to signup...";
        header("refresh:3; url=signup.php");
    }
}
开发者ID:psnguyen,项目名称:enqueue,代码行数:28,代码来源:signupcheck.php

示例5: googleAuthenticate


//.........这里部分代码省略.........
      }

    // check that the anti-forgery token is valid
    if ($state != $_SESSION['cdash']['state'])
      {
      add_log("state anti-forgery token mismatch: " . $state .
        " vs " . $_SESSION['cdash']['state'], LOG_ERR);
      return;
      }

    // Request the access token
    $headers = array(
      'Content-Type: application/x-www-form-urlencoded;charset=UTF-8',
      'Connection: Keep-Alive'
    );

    $redirectURI = strtok(get_server_URI(false), '?');

    $postData = join('&', array(
      'grant_type=authorization_code',
      'code='.$_GET["code"],
      'client_id='.$GOOGLE_CLIENT_ID,
      'client_secret='.$GOOGLE_CLIENT_SECRET,
      'redirect_uri='.$redirectURI
    ));

    $url = 'https://accounts.google.com/o/oauth2/token';
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_PORT, 443);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    $resp = curl_exec($curl);

    $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($httpStatus != 200)
      {
      add_log("Google access token request failed: $resp", LOG_ERR);
      return;
      }

    $resp = json_decode($resp);
    $accessToken = $resp->access_token;
    $tokenType = $resp->token_type;

    // Use the access token to get the user's email address
    $headers = array(
      'Authorization: '.$tokenType.' '.$accessToken
    );
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://www.googleapis.com/plus/v1/people/me');
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_PORT, 443);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    $resp = curl_exec($curl);

    $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if ($httpStatus != 200)
      {
      add_log("Get Google user email address request failed: $resp", LOG_ERR);
      return;
      }

    // Extract the user's email address from the response.
    $resp = json_decode($resp);
    $email = strtolower($resp->emails[0]->value);

    // Check if this email address appears in our user database
    $db = pdo_connect("$CDASH_DB_HOST", "$CDASH_DB_LOGIN","$CDASH_DB_PASS");
    pdo_select_db("$CDASH_DB_NAME",$db);
    $sql="SELECT id,password FROM ".qid("user")." WHERE email='".pdo_real_escape_string($email)."'";
    $result = pdo_query("$sql");

    if(pdo_num_rows($result)==0)
      {
      // if no match is found, redirect to pre-filled out registration page
      pdo_free_result($result);
      $firstname = $resp->name->givenName;
      $lastname = $resp->name->familyName;
      header("Location: register.php?firstname=$firstname&lastname=$lastname&email=$email");
      return false;
      }

    $user_array = pdo_fetch_array($result);
    $pass = $user_array["password"];

    $sessionArray = array(
      "login" => $email,
      "passwd" => $user_array['password'],
      "ID" => session_id(),
      "valid" => 1,
      "loginid" => $user_array["id"]);
    $_SESSION['cdash'] = $sessionArray;
    session_write_close();
    pdo_free_result($result);
    header("Location: $requestedURI");
    return true;                               // authentication succeeded
  }
开发者ID:rpshaw,项目名称:CDash,代码行数:101,代码来源:googleauth_callback.php

示例6: pdo_query

            /*if($CDASH_DB_TYPE == "mysql") // necessary for looping through rows
              {
              $link_identifier->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
              }*/
            pdo_query("SET client_encoding to 'UTF8'");
            return true;
        } catch (PDOException $e) {
            //print_r($e); // Add debug information
            return false;
        }
    } else {
        $ln = get_link_identifier($link_identifier);
        $db = mysql_select_db($database_name, $ln);
        if (PHP_VERSION >= 5.3) {
            mysql_set_charset('utf8', $ln);
        } else {
            mysql_query("SET NAMES 'utf8'");
        }
        return $db;
    }
}
global $cdash_pdo_connect_result;
global $CDASH_DB_HOST;
global $CDASH_DB_LOGIN;
global $CDASH_DB_PASS;
global $CDASH_DB_NAME;
global $CDASH_DB_PORT;
if (!isset($cdash_pdo_connect_result)) {
    $cdash_pdo_connect_result = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    pdo_select_db("{$CDASH_DB_NAME}", $cdash_pdo_connect_result);
}
开发者ID:BetsyMcPhail,项目名称:CDash,代码行数:31,代码来源:pdocore.php

示例7: get_dashboard_JSON

function get_dashboard_JSON($projectname, $date, &$response)
{
    include "cdash/config.php";
    require_once "cdash/pdo.php";
    $projectid = get_project_id($projectname);
    if ($projectid == -1) {
        return;
    }
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        echo "Error connecting to CDash database server<br>\n";
        exit(0);
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        echo "Error selecting CDash database<br>\n";
        exit(0);
    }
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
    } else {
        $project_array = array();
        $project_array["cvsurl"] = "unknown";
        $project_array["bugtrackerurl"] = "unknown";
        $project_array["documentationurl"] = "unknown";
        $project_array["homeurl"] = "unknown";
        $project_array["googletracker"] = "unknown";
        $project_array["name"] = $projectname;
        $project_array["nightlytime"] = "00:00:00";
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array["nightlytime"]);
    $response['datetime'] = date("l, F d Y H:i:s", time());
    $response['date'] = $date;
    $response['unixtimestamp'] = $currentstarttime;
    $response['startdate'] = date("l, F d Y H:i:s", $currentstarttime);
    $response['svn'] = make_cdash_url(htmlentities($project_array["cvsurl"]));
    $response['bugtracker'] = make_cdash_url(htmlentities($project_array["bugtrackerurl"]));
    $response['googletracker'] = htmlentities($project_array["googletracker"]);
    $response['documentation'] = make_cdash_url(htmlentities($project_array["documentationurl"]));
    $response['projectid'] = $projectid;
    $response['projectname'] = $project_array["name"];
    $response['projectname_encoded'] = urlencode($project_array["name"]);
    $response['projectpublic'] = $project_array["public"];
    $response['previousdate'] = $previousdate;
    $response['nextdate'] = $nextdate;
    $response['logoid'] = getLogoID($projectid);
    if (empty($project_array["homeurl"])) {
        $response['home'] = "index.php?project=" . urlencode($project_array["name"]);
    } else {
        $response['home'] = make_cdash_url(htmlentities($project_array["homeurl"]));
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/models/proProject.php")) {
        include_once "local/models/proProject.php";
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $response['proedition'] = $pro->GetEdition(1);
    }
    $userid = 0;
    if (isset($_SESSION['cdash'])) {
        $userid = $_SESSION['cdash']['loginid'];
        // Is the user super administrator
        $userquery = pdo_query("SELECT admin FROM " . qid('user') . " WHERE id='{$userid}'");
        $user_array = pdo_fetch_array($userquery);
        $response['admin'] = $user_array[0];
        // Is the user administrator of the project
        $userquery = pdo_query("SELECT role FROM user2project WHERE userid=" . qnum($userid) . " AND projectid=" . qnum($projectid));
        $user_array = pdo_fetch_array($userquery);
        $response['projectrole'] = $user_array[0];
    }
    $response['userid'] = $userid;
}
开发者ID:rpshaw,项目名称:CDash,代码行数:71,代码来源:common.php

示例8: echo_main_dashboard_JSON

function echo_main_dashboard_JSON($project_instance, $date)
{
    $start = microtime_float();
    $noforcelogin = 1;
    include_once dirname(dirname(dirname(__DIR__))) . '/config/config.php';
    require_once 'include/pdo.php';
    include 'public/login.php';
    include_once 'models/banner.php';
    include_once 'models/build.php';
    include_once 'models/subproject.php';
    $response = array();
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        $response['error'] = 'Error connecting to CDash database server';
        echo json_encode($response);
        return;
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        $response['error'] = 'Error selecting CDash database';
        echo json_encode($response);
        return;
    }
    $projectid = $project_instance->Id;
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
        $projectname = $project_array['name'];
        if (isset($project_array['testingdataurl']) && $project_array['testingdataurl'] != '') {
            $testingdataurl = make_cdash_url(htmlentities($project_array['testingdataurl']));
        }
    } else {
        $response['error'] = "This project doesn't exist. Maybe the URL you are trying to access is wrong.";
        echo json_encode($response);
        return;
    }
    if (!checkUserPolicy(@$_SESSION['cdash']['loginid'], $project_array['id'], 1)) {
        $response['requirelogin'] = 1;
        echo json_encode($response);
        return;
    }
    $response = begin_JSON_response();
    $response['title'] = "CDash - {$projectname}";
    $response['feed'] = $CDASH_ENABLE_FEED;
    $response['showcalendar'] = 1;
    $Banner = new Banner();
    $Banner->SetProjectId(0);
    $text = $Banner->GetText();
    $banners = array();
    if ($text !== false) {
        $banners[] = $text;
    }
    $Banner->SetProjectId($projectid);
    $text = $Banner->GetText();
    if ($text !== false) {
        $banners[] = $text;
    }
    $response['banners'] = $banners;
    $site_response = array();
    // If parentid is set we need to lookup the date for this build
    // because it is not specified as a query string parameter.
    if (isset($_GET['parentid'])) {
        $parentid = pdo_real_escape_numeric($_GET['parentid']);
        $parent_build = new Build();
        $parent_build->Id = $parentid;
        $date = $parent_build->GetDate();
        $response['parentid'] = $parentid;
    } else {
        $response['parentid'] = -1;
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']);
    // Main dashboard section
    get_dashboard_JSON($projectname, $date, $response);
    $response['displaylabels'] = $project_array['displaylabels'];
    $page_id = 'index.php';
    $response['childview'] = 0;
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/models/proProject.php')) {
        include_once 'local/models/proProject.php';
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $response['proedition'] = $pro->GetEdition(1);
    }
    if ($currentstarttime > time() && !isset($_GET['parentid'])) {
        $response['error'] = 'CDash cannot predict the future (yet)';
        echo json_encode($response);
        return;
    }
    // Menu definition
    $response['menu'] = array();
    $beginning_timestamp = $currentstarttime;
    $end_timestamp = $currentstarttime + 3600 * 24;
    $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp);
    $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp);
    if ($project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) {
        $response['menu']['subprojects'] = 1;
    }
    if (isset($_GET['parentid'])) {
        $page_id = 'indexchildren.php';
        $response['childview'] = 1;
        // When a parentid is specified, we should link to the next build,
        // not the next day.
//.........这里部分代码省略.........
开发者ID:kitware,项目名称:cdash,代码行数:101,代码来源:index.php

示例9: die

	</thead>

	<tbody>
		<?php 
if (isset($_POST['instructorJoinBtn'])) {
    $_SESSION['classID'] = $_POST['joinClass'];
}
$classID = $_SESSION['classID'];
$host = 'dbserver.engr.scu.edu';
$username = 'pnguyen';
$password = '00000949559';
$database = 'sdb_pnguyen';
if (!($conn = pdo_connect("{$host}", $username, $password))) {
    die('Error connecting to ' . host . '.' . pdo_error());
}
if (!pdo_select_db($database, $conn)) {
    die('Error selecting ' . $database . '. ' . pdo_error());
}
$classID = $_SESSION['classID'];
$execItems = pdo_query("SELECT classID, reqCount, studentName, reqDescrip, category, timeIn FROM `enqueue` WHERE classID = {$classID} and studentName != 'blank' and isSolved = 'FALSE' ORDER BY `order`");
$countID = 0;
while ($row = pdo_fetch_array($execItems, MYSQL_ASSOC)) {
    echo "\n\t\t\t\t\t<tr id = " . $row['reqCount'] . ">\n\t\t\t\t\t\t\t<td> <input type=\"checkbox\" name=\"chk\"/></td>\n\t\t\t\t\t\t\t<td>" . $row['studentName'] . "</td>\n\t\t\t\t\t\t\t<td>" . $row['reqDescrip'] . "</td>\n\t\t\t\t\t\t\t<td>" . $row['category'] . "</td>\n\t\t\t\t\t\t\t<td>" . $row['timeIn'] . "</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t";
    $countID++;
}
?>
	
	</tbody>
</table>
<br>
	<input type="button" value = "Remove Request" onclick = "delRow()"/>
开发者ID:psnguyen,项目名称:enqueue,代码行数:31,代码来源:instructor_session_page.php

示例10: connect

 public function connect($dbname = null)
 {
     $dbname = $this->db;
     $host = $this->host;
     $user = $this->user;
     $password = $this->password;
     $conn = "host='{$host}' dbname='{$dbname}' user='{$user}' password='{$password}'";
     if (!empty($this->port)) {
         $conn .= " port='{$this->port}'";
     }
     pdo_connect($host, $user, $password);
     return pdo_select_db($dbname, $this->dbconnect);
 }
开发者ID:kitware,项目名称:cdash,代码行数:13,代码来源:kw_db.php

示例11: pdo_select_db

<?php

require_once 'mysql.inc.php';
pdo_select_db($DBsta);
echo 'Scanning SND...';
$res = $DB->query("SELECT *\n                   FROM ressnd\n                   WHERE resfolder NOT LIKE '5QDemo/%'\n                   AND resfolder NOT LIKE '%Mb84'\n                   AND resfolder NOT LIKE '%Mb85'\n                   AND resfolder NOT LIKE '%Mh23'\n                   AND resfolder NOT LIKE '%Md42'\n                   AND resfolder NOT LIKE '%Md70'\n                   AND resfolder NOT LIKE '%Md71'\n                   AND resfolder NOT LIKE '%Md72'\n                   AND resfolder NOT LIKE '%Me13'\n                   AND resfolder NOT LIKE '%Me21'\n                   AND resfolder NOT LIKE '%Me22'\n                   AND resfolder NOT LIKE '%Me23'\n                   AND resfolder NOT LIKE '%Mg40'");
while ($rs = $res->fetch()) {
    $list = scandir('../res-full/' . $rs['resfolder']);
    if (sizeof($list)) {
        $IDlist = array();
        foreach ($list as $file) {
            if (strpos($file, '.ogg') !== FALSE) {
                $ID = str_replace('.ogg', '', $file);
                if ($ID < 1000) {
                    $IDlist[$ID] = 1;
                }
            }
        }
        ksort($IDlist);
        if (sizeof($IDlist) > 0) {
            $IDlist = implode(',', array_keys($IDlist));
            $DB->query("UPDATE ressnd\n                        SET val = '" . addslashes($IDlist) . "'\n                        WHERE grp = '" . addslashes($rs['grp']) . "'\n                        AND name = '" . addslashes($rs['name']) . "'\n                        AND variantType = '" . addslashes($rs['variantType']) . "'\n                        AND variantValue = '" . addslashes($rs['variantValue']) . "'");
        }
    } else {
        echo $rs['resfolder'] . " doesn't exists;";
    }
}
echo 'OK<br/>';
开发者ID:Mwyann,项目名称:ydkjs,代码行数:28,代码来源:scan-snd.php

示例12: register

/** Authentication function */
function register()
{
    global $reg;
    include "cdash/config.php";
    require_once "cdash/pdo.php";
    if (isset($_GET["key"])) {
        $key = pdo_real_escape_string($_GET["key"]);
        $sql = "SELECT * FROM " . qid("usertemp") . " WHERE registrationkey='{$key}'";
        $query = pdo_query($sql);
        if (pdo_num_rows($query) == 0) {
            $reg = "The key is invalid.";
            return 0;
        }
        $query_array = pdo_fetch_array($query);
        $email = $query_array['email'];
        $passwd = $query_array['password'];
        $fname = $query_array['firstname'];
        $lname = $query_array['lastname'];
        $institution = $query_array['institution'];
        // We copy the data from usertemp to user
        $sql = "INSERT INTO " . qid("user") . " (email,password,firstname,lastname,institution)\n          VALUES ('{$email}','{$passwd}','{$fname}','{$lname}','{$institution}')";
        if (pdo_query($sql)) {
            pdo_query("DELETE FROM usertemp WHERE email='" . $email . "'");
            return 1;
        } else {
            $reg = pdo_error();
            return 0;
        }
    } else {
        if (isset($_POST["sent"])) {
            $url = $_POST["url"];
            if ($url != "catchbot") {
                $reg = "Bots are not allowed to obtain CDash accounts!";
                return 0;
            }
            $email = $_POST["email"];
            $passwd = $_POST["passwd"];
            $passwd2 = $_POST["passwd2"];
            if (!($passwd == $passwd2)) {
                $reg = "Passwords do not match!";
                return 0;
            }
            $fname = $_POST["fname"];
            $lname = $_POST["lname"];
            $institution = $_POST["institution"];
            if ($email && $passwd && $passwd2 && $fname && $lname && $institution) {
                $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
                pdo_select_db("{$CDASH_DB_NAME}", $db);
                $passwd = md5($passwd);
                $email = pdo_real_escape_string($email);
                $sql = "SELECT email FROM " . qid("user") . " WHERE email='{$email}'";
                if (pdo_num_rows(pdo_query($sql)) > 0) {
                    $reg = "{$email} is already registered.";
                    return 0;
                }
                $sql = "SELECT email  FROM " . qid("usertemp") . " WHERE email='{$email}'";
                if (pdo_num_rows(pdo_query($sql)) > 0) {
                    $reg = "{$email} is already registered. Check your email if you haven't received the link to activate yet.";
                    return 0;
                }
                $passwd = pdo_real_escape_string($passwd);
                $fname = pdo_real_escape_string($fname);
                $lname = pdo_real_escape_string($lname);
                $institution = pdo_real_escape_string($institution);
                if ($CDASH_REGISTRATION_EMAIL_VERIFY) {
                    // Create a key
                    srand(microtime_float());
                    $keychars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                    $length = 40;
                    $key = "";
                    $max = strlen($keychars) - 1;
                    for ($i = 0; $i < $length; $i++) {
                        $key .= substr($keychars, rand(0, $max), 1);
                    }
                    $date = date(FMT_DATETIME);
                    $sql = "INSERT INTO " . qid("usertemp") . " (email,password,firstname,lastname,institution,registrationkey,registrationdate)\n              VALUES ('{$email}','{$passwd}','{$fname}','{$lname}','{$institution}','{$key}','{$date}')";
                } else {
                    $sql = "INSERT INTO " . qid("user") . " (email,password,firstname,lastname,institution)\n              VALUES ('{$email}','{$passwd}','{$fname}','{$lname}','{$institution}')";
                }
                if (pdo_query($sql)) {
                    if ($CDASH_REGISTRATION_EMAIL_VERIFY) {
                        $currentURI = get_server_URI();
                        // Send the email
                        $emailtitle = "Welcome to CDash!";
                        $emailbody = "Hello " . $fname . ",\n\n";
                        $emailbody .= "Welcome to CDash! In order to validate your registration please follow this link: \n";
                        $emailbody .= $currentURI . "/register.php?key=" . $key . "\n";
                        $serverName = $CDASH_SERVER_NAME;
                        if (strlen($serverName) == 0) {
                            $serverName = $_SERVER['SERVER_NAME'];
                        }
                        $emailbody .= "\n-CDash on " . $serverName . "\n";
                        if (cdashmail("{$email}", $emailtitle, $emailbody, "From: CDash <" . $CDASH_EMAIL_FROM . ">\nReply-To: " . $CDASH_EMAIL_REPLY . "\nContent-type: text/plain; charset=utf-8\nX-Mailer: PHP/" . phpversion() . "\nMIME-Version: 1.0")) {
                            add_log("email sent to: " . $email, "Registration");
                        } else {
                            add_log("cannot send email to: " . $email, "Registration", LOG_ERR);
                        }
                        $reg = "A confirmation email has been sent. Check your email (including your spam folder) to confirm your registration!\n";
                        $reg .= "You need to activate your account within 24 hours.";
//.........这里部分代码省略.........
开发者ID:rpshaw,项目名称:CDash,代码行数:101,代码来源:register.php

示例13: get_dashboard_JSON

function get_dashboard_JSON($projectname, $date, &$response)
{
    include 'config/config.php';
    require_once 'include/pdo.php';
    $projectid = get_project_id($projectname);
    if ($projectid == -1) {
        return;
    }
    $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
    if (!$db) {
        echo "Error connecting to CDash database server<br>\n";
        exit(0);
    }
    if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
        echo "Error selecting CDash database<br>\n";
        exit(0);
    }
    $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
    if (pdo_num_rows($project) > 0) {
        $project_array = pdo_fetch_array($project);
    } else {
        $project_array = array();
        $project_array['cvsurl'] = 'unknown';
        $project_array['bugtrackerurl'] = 'unknown';
        $project_array['documentationurl'] = 'unknown';
        $project_array['homeurl'] = 'unknown';
        $project_array['googletracker'] = 'unknown';
        $project_array['name'] = $projectname;
        $project_array['nightlytime'] = '00:00:00';
    }
    if (is_null($date)) {
        $date = date(FMT_DATE);
    }
    list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']);
    $response['datetime'] = date('l, F d Y H:i:s', time());
    $response['date'] = $date;
    $response['unixtimestamp'] = $currentstarttime;
    $response['startdate'] = date('l, F d Y H:i:s', $currentstarttime);
    $response['vcs'] = make_cdash_url(htmlentities($project_array['cvsurl']));
    $response['bugtracker'] = make_cdash_url(htmlentities($project_array['bugtrackerurl']));
    $response['googletracker'] = htmlentities($project_array['googletracker']);
    $response['documentation'] = make_cdash_url(htmlentities($project_array['documentationurl']));
    $response['projectid'] = $projectid;
    $response['projectname'] = $project_array['name'];
    $response['projectname_encoded'] = urlencode($project_array['name']);
    $response['public'] = $project_array['public'];
    $response['previousdate'] = $previousdate;
    $response['nextdate'] = $nextdate;
    $response['logoid'] = getLogoID($projectid);
    if (empty($project_array['homeurl'])) {
        $response['home'] = 'index.php?project=' . urlencode($project_array['name']);
    } else {
        $response['home'] = make_cdash_url(htmlentities($project_array['homeurl']));
    }
    if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/models/proProject.php')) {
        include_once 'local/models/proProject.php';
        $pro = new proProject();
        $pro->ProjectId = $projectid;
        $response['proedition'] = $pro->GetEdition(1);
    }
    $userid = 0;
    if (isset($_SESSION['cdash']) && isset($_SESSION['cdash']['loginid'])) {
        $userid = $_SESSION['cdash']['loginid'];
        // Is the user an administrator of this project?
        $row = pdo_single_row_query('SELECT role FROM user2project
            WHERE userid=' . qnum($userid) . ' AND
            projectid=' . qnum($projectid));
        $response['projectrole'] = $row[0];
        if ($response['projectrole'] > 1) {
            $response['user']['admin'] = 1;
        }
    }
    $response['userid'] = $userid;
}
开发者ID:kitware,项目名称:cdash,代码行数:74,代码来源:common.php

示例14: set_time_limit

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notices for more information.

=========================================================================*/
include "cdash/config.php";
require_once "cdash/pdo.php";
include 'login.php';
include "cdash/version.php";
require_once "cdash/common.php";
set_time_limit(0);
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
if (!$db) {
    echo pdo_error();
}
if (pdo_select_db("{$CDASH_DB_NAME}", $db) === FALSE) {
    echo pdo_error();
    return;
}
checkUserPolicy(@$_SESSION['cdash']['loginid'], 0);
// only admin
@($projectid = $_GET["projectid"]);
if ($projectid != NULL) {
    $projectid = pdo_real_escape_numeric($projectid);
}
$xml = begin_XML_for_XSLT();
//get date info here
@($dayTo = pdo_real_escape_numeric($_POST["dayFrom"]));
if (empty($dayTo)) {
    $time = strtotime("2000-01-01 00:00:00");
    if (isset($projectid)) {
开发者ID:rpshaw,项目名称:CDash,代码行数:31,代码来源:removeBuilds.php

示例15: mysql_select_db

 function mysql_select_db($database_name = NULL, $link_identifier = NULL)
 {
     return pdo_select_db(func_get_args());
 }
开发者ID:jalota16,项目名称:nightcaviar,代码行数:4,代码来源:pdo_mysql.php


注:本文中的pdo_select_db函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。