Пример #1
0
function executeQuery($query)
{
    // call the dbConnect function
    $conn = dbConnect();
    try {
        // execute query and assign results to a PDOStatement object
        $stmt = $conn->query($query);
        do {
            if ($stmt->columnCount() > 0) {
                $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
                //retreive the rows as an associative array
            }
        } while ($stmt->nextRowset());
        // if multiple queries are executed, repeat the process for each set of results
        //Uncomment these 4 lines to display $results
        //    echo '<pre style="font-size:large">';
        //   print_r($results);
        //    echo '</pre>';
        //   die;
        //call dbDisconnect() method to close the connection
        dbDisconnect($conn);
        return $results;
    } catch (PDOException $e) {
        //if execution fails
        dbDisconnect($conn);
        die('Query failed: ' . $e->getMessage());
    }
}
Пример #2
0
function getListOfBuyClicks($dt)
{
    global $mycatid;
    $str = "";
    $lnk = dbConnect('localhost', 'root', 'lyntik');
    $query = "SELECT b.fdate as fdate,b.ip as cip,b.goodid as gid,b.name as sname,b.source as src,b.price as price  FROM buylog b WHERE b.date='{$dt}' AND b.mycat_id={$mycatid} ORDER BY b.ip,b.fdate";
    $res = exec_query($query);
    $ip = "0.0.0.0";
    $i = 0;
    $str .= "<div class=\"all_clicks\">";
    $str .= "<div class=\"click_row_title\">\n             <div class=\"left click_date title\">Дата</div>\n             <div class=\"left click_id title\">ID товара</div>\n             <div class=\"left click_name title\">Наименование</div>\n             <div class=\"left click_id title\">Цена</div>\n             <div class=\"left click_name title\">Источник</div>\n             " . closeFloat() . "\n            </div>";
    if (mysql_num_rows($res) == 0) {
        $str .= "<div>За выбранную дату нажатий не было</div>";
    } else {
        while ($rows = fetch_array($res)) {
            if ($ip != $rows['cip']) {
                $ip = $rows['cip'];
                if ($i != 0) {
                    $str .= "</div>";
                }
                $str .= "<div class=\"ipclicks\">";
                $str .= "<div class=\"client_ip\">Клики с адреса:<b>" . $rows['cip'] . "</b></div>";
            }
            $str .= "<div class=\"click_row\">\n             <div class=\"left click_date\">" . $rows['fdate'] . "</div>\n             <div class=\"left click_id\">" . $rows['gid'] . "</div>\n             <div class=\"left click_name\">" . $rows['sname'] . "</div>\n             <div class=\"left click_id\">" . $rows['price'] . "</div>\n             <div class=\"left click_name\">" . $rows['src'] . "</div>\n             " . closeFloat() . "\n            </div>";
        }
        $str .= "</div>";
    }
    $str .= "</div></div>";
    mysql_free_result($res);
    dbDisconnect($lnk);
    return $str;
}
Пример #3
0
function addContact()
{
    $conn = dbConnect();
    $name = '';
    $email = '';
    $mobile = '';
    $position = '';
    if (isset($_POST['name'])) {
        $name = $conn->real_escape_string($_POST['name']);
    }
    if (isset($_POST['email'])) {
        $email = $conn->real_escape_string($_POST['email']);
    }
    if (isset($_POST['mobile'])) {
        $mobile = $conn->real_escape_string($_POST['mobile']);
    }
    if (isset($_POST['position'])) {
        $position = $conn->real_escape_string($_POST['position']);
    }
    $sql = "INSERT into contactus(name,position,email,mobile) VALUES('{$name}','{$position}','{$email}','{$mobile}')";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../contact.php");
    } else {
        echo "Some error occured..:(";
    }
}
function addTeamMember()
{
    $conn = dbConnect();
    $filePath = '';
    $name = '';
    $category = '';
    $title = '';
    $long_desc = '';
    $short_desc = '';
    $fb_link = '';
    $l_link = '';
    if (isset($_POST['name'])) {
        $name = $conn->real_escape_string($_POST['name']);
    }
    if (isset($_POST['category'])) {
        $category = $conn->real_escape_string($_POST['category']);
    }
    if (isset($_POST['title'])) {
        $title = $conn->real_escape_string($_POST['title']);
    }
    if (isset($_POST['long_desc'])) {
        $long_desc = $conn->real_escape_string($_POST['long_desc']);
    }
    if (isset($_POST['short_desc'])) {
        $short_desc = $conn->real_escape_string($_POST['short_desc']);
    }
    if (isset($_POST['fb_link'])) {
        $fb_link = $_POST['fb_link'];
    }
    if (isset($_POST['l_link'])) {
        $l_link = $_POST['l_link'];
    }
    if (isset($_FILES['file'])) {
        $target_dir = "../uploads/team/";
        $target_file = $target_dir . basename($_FILES["file"]["name"]);
        if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
            $filePath = 'uploads/team/' . $_FILES["file"]["name"];
        }
    }
    $description = array('long_desc' => $long_desc, 'short_desc' => $short_desc);
    $description = json_encode($description);
    $links = array('fb_link' => $fb_link, 'l_link' => $l_link);
    $links = json_encode($links);
    $sql = "INSERT INTO team (name,category,title,description,links,img) VALUES ('" . $name . "','" . $category . "','" . $title . "','" . $description . "','" . $links . "','" . $filePath . "')";
    echo $sql;
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../team.php");
    } else {
        echo "Some error occured..:(";
    }
}
Пример #5
0
function doLogin($username, $password)
{
    $conn = dbConnect();
    $username = $conn->real_escape_string($username);
    $password = $conn->real_escape_string($password);
    $sql = "SELECT id,societyName,username,isSuperAdmin FROM society WHERE username='******' AND password='******' LIMIT 1";
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        $_SESSION['user'] = $result->fetch_assoc();
        $_SESSION['loggedIn'] = true;
        return 1;
    }
    dbDisconnect($conn);
    return 0;
}
Пример #6
0
function errorHandler($errno, $errstr, $errfile = NULL, $errline = NULL, $errcontext = NULL)
{
    global $user;
    if (!ONLINEDEBUG || !checkUserHasPerm('View Debug Information')) {
        cleanSemaphore();
        dbDisconnect();
        printHTMLFooter();
        exit;
    }
    print "Error encountered<br>\n";
    switch ($errno) {
        case E_USER_ERROR:
            echo "<b>FATAL</b> [{$errno}] {$errstr}<br />\n";
            echo "  Fatal error in line {$errline} of file {$errfile}";
            echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
            echo "Aborting...<br />\n";
            cleanSemaphore();
            dbDisconnect();
            exit(1);
            break;
        case E_USER_WARNING:
            echo "<b>ERROR</b> [{$errno}] {$errstr}<br />\n";
            break;
        case E_USER_NOTICE:
            echo "<b>WARNING</b> [{$errno}] {$errstr}<br />\n";
            break;
        default:
            echo "Unkown error type: [{$errno}] {$errstr}<br />\n";
            break;
    }
    if (!empty($errfile) && !empty($errline)) {
        print "Error at {$errline} in {$errfile}<br>\n";
    }
    if (!empty($errcontext)) {
        print "<pre>\n";
        print_r($errcontext);
        print "</pre>\n";
    }
    print "<br><br><br>\n";
    print "<pre>\n";
    print getBacktraceString();
    print "</pre>\n";
    cleanSemaphore();
    dbDisconnect();
    printHTMLFooter();
    exit;
}
Пример #7
0
function errorHandler($errno, $errstr, $errfile = NULL, $errline = NULL, $errcontext = NULL)
{
    global $user;
    if ($user["adminlevel"] != "developer") {
        dbDisconnect();
        printHTMLFooter();
        semUnlock();
        exit;
    }
    print "Error encountered<br>\n";
    switch ($errno) {
        case E_USER_ERROR:
            echo "<b>FATAL</b> [{$errno}] {$errstr}<br />\n";
            echo "  Fatal error in line {$errline} of file {$errfile}";
            echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
            echo "Aborting...<br />\n";
            semUnlock();
            exit(1);
            break;
        case E_USER_WARNING:
            echo "<b>ERROR</b> [{$errno}] {$errstr}<br />\n";
            break;
        case E_USER_NOTICE:
            echo "<b>WARNING</b> [{$errno}] {$errstr}<br />\n";
            break;
        default:
            echo "Unkown error type: [{$errno}] {$errstr}<br />\n";
            break;
    }
    if (!empty($errfile) && !empty($errline)) {
        print "Error at {$errline} in {$errfile}<br>\n";
    }
    if (!empty($errcontext)) {
        print "<pre>\n";
        print_r($errcontext);
        print "</pre>\n";
    }
    print "<br><br><br>\n";
    print "<pre>\n";
    print getBacktraceString();
    print "</pre>\n";
    dbDisconnect();
    printHTMLFooter();
    semUnlock();
    exit;
}
Пример #8
0
function addSociety()
{
    $conn = dbConnect();
    $society_name = '';
    $society_username = '';
    $password = '';
    if (isset($_POST['society_name'])) {
        $society_name = $conn->real_escape_string($_POST['society_name']);
    }
    if (isset($_POST['society_username'])) {
        $society_username = $conn->real_escape_string($_POST['society_username']);
    }
    if (isset($_POST['password'])) {
        $password = $conn->real_escape_string($_POST['password']);
    }
    $sql = "INSERT into society(societyName,username,password) VALUES('{$society_name}','{$society_username}','{$password}')";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../societies.php");
    } else {
        echo "Some error occured..:(";
    }
}
Пример #9
0
function executeProcedure($query)
{
    // call the dbConnect function
    $conn = dbConnect();
    try {
        // execute query and assign results to a PDOStatement object
        $stmt = $conn->query("EXEC" . $query);
        $result = $stmt->execute();
        //Uncomment these 4 lines to display $results
        //  echo '<pre style="font-size:large">';
        // echo 'Result=';
        //   print_r($result);
        // echo '</pre>';
        //   die;
        //call dbDisconnect() method to close the connection
        dbDisconnect($conn);
        return $result;
    } catch (PDOException $e) {
        //if execution fails
        dbDisconnect($conn);
        throw new Exception($e->getMessage(), $e->getCode(), $e);
        //  die ('Query failed: ' . $e->getMessage());
    }
}
function updateWinner()
{
    $conn = dbConnect();
    $event_name = '';
    $winner1 = '';
    $winner2 = '';
    if (isset($_POST['event_name'])) {
        $event_name = $conn->real_escape_string($_POST['event_name']);
    }
    if (isset($_POST['winner1'])) {
        $winner1 = $conn->real_escape_string($_POST['winner1']);
    }
    if (isset($_POST['winner2'])) {
        $winner2 = $conn->real_escape_string($_POST['winner2']);
    }
    $sql = "UPDATE events SET `winner1`='{$winner1}', `winner2`='{$winner2}' WHERE `name`='{$event_name}'";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../winners.php");
    } else {
        echo "Some error occured..:(";
    }
}
Пример #11
0
function submitCreateImage()
{
    global $submitErr, $user, $viewmode, $HTMLheader, $printedHTMLheader, $mode;
    if ($mode == 'submitCreateTestProd') {
        $data = getContinuationVar();
        $data["revisionid"] = processInputVar("revisionid", ARG_MULTINUMERIC);
        # TODO check for valid revisionid
    } else {
        $data = processRequestInput(0);
        $data['length'] = getContinuationVar('length');
    }
    $showrevisions = 0;
    $subimages = 0;
    $images = getImages();
    $revcount = count($images[$data['imageid']]['imagerevision']);
    if ($revcount > 1) {
        $showrevisions = 1;
    }
    if ($images[$data['imageid']]['imagemetaid'] != NULL && count($images[$data['imageid']]['subimages'])) {
        $subimages = 1;
        foreach ($images[$data['imageid']]['subimages'] as $subimage) {
            $revcount = count($images[$subimage]['imagerevision']);
            if ($revcount > 1) {
                $showrevisions = 1;
            }
        }
    }
    if ($data["time"] == "now") {
        $nowArr = getdate();
        if ($nowArr["minutes"] == 0) {
            $subtract = 0;
            $add = 0;
        } elseif ($nowArr["minutes"] < 15) {
            $subtract = $nowArr["minutes"] * 60;
            $add = 900;
        } elseif ($nowArr["minutes"] < 30) {
            $subtract = ($nowArr["minutes"] - 15) * 60;
            $add = 900;
        } elseif ($nowArr["minutes"] < 45) {
            $subtract = ($nowArr["minutes"] - 30) * 60;
            $add = 900;
        } elseif ($nowArr["minutes"] < 60) {
            $subtract = ($nowArr["minutes"] - 45) * 60;
            $add = 900;
        }
        $start = time() - $subtract;
        $start -= $start % 60;
        $nowfuture = "now";
    } else {
        $add = 0;
        $hour = $data["hour"];
        if ($data["hour"] == 12) {
            if ($data["meridian"] == "am") {
                $hour = 0;
            }
        } elseif ($data["meridian"] == "pm") {
            $hour = $data["hour"] + 12;
        }
        $tmp = explode('/', $data["day"]);
        $start = mktime($hour, $data["minute"], "0", $tmp[0], $tmp[1], $tmp[2]);
        if ($start < time()) {
            print $HTMLheader;
            print "<H2>Create / Update an Image</H2>\n";
            print "<font color=\"#ff0000\">The time you requested is in the past.";
            print " Please select \"Now\" or use a time in the future.</font><br>\n";
            $submitErr = 1;
            createSelectImage();
            return;
        }
        $nowfuture = "future";
    }
    // FIXME hard code length to 8 hours
    $data["length"] = 480;
    $end = $start + $data["length"] * 60 + $add;
    // get semaphore lock
    if (!semLock()) {
        abort(3);
    }
    $max = getMaxOverlap($user['id']);
    if (checkOverlap($start, $end, $max)) {
        $printedHTMLheader = 1;
        print $HTMLheader;
        print "<H2>New Reservation</H2>\n";
        if ($max == 0) {
            print "<font color=\"#ff0000\">The time you requested overlaps with ";
            print "another reservation you currently have.  You are only allowed ";
            print "to have a single reservation at any given time. Please select ";
            print "another time to use the application. If you are finished with ";
            print "an active reservation, click \"Current Reservations\", ";
            print "then click the \"End\" button of your active reservation.";
            print "</font><br><br>\n";
        } else {
            print "<font color=\"#ff0000\">The time you requested overlaps with ";
            print "another reservation you currently have.  You are allowed ";
            print "to have {$max} overlapping reservations at any given time. ";
            print "Please select another time to use the application. If you are ";
            print "finished with an active reservation, click \"Current ";
            print "Reservations\", then click the \"End\" button of your active ";
            print "reservation.</font><br><br>\n";
        }
        $submitErr = 1;
        createSelectImage();
        return;
    }
    // if user is owner of the image and there is a test revision of the image
    #   available, ask user if production or test image desired
    if ($mode != "submitCreateTestProd" && $showrevisions && $images[$data["imageid"]]["ownerid"] == $user["id"]) {
        $printedHTMLheader = 1;
        print $HTMLheader;
        print "<H2>New Reservation</H2>\n";
        if ($subimages) {
            print "This is a cluster environment. At least one image in the ";
            print "cluster has more than one revision available. Please select ";
            print "the revision you desire for each image listed below:<br>\n";
        } else {
            print "There are multiple revisions of this environment available.  Please ";
            print "select the revision you would like to check out:<br>\n";
        }
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post><br>\n";
        if (!array_key_exists('subimages', $images[$data['imageid']])) {
            $images[$data['imageid']]['subimages'] = array();
        }
        array_unshift($images[$data['imageid']]['subimages'], $data['imageid']);
        foreach ($images[$data['imageid']]['subimages'] as $subimage) {
            print "{$images[$subimage]['prettyname']}:<br>\n";
            print "<table summary=\"lists revisions of the selected environment, one must be selected to continue\">\n";
            print "  <TR>\n";
            print "    <TD></TD>\n";
            print "    <TH>Revision</TH>\n";
            print "    <TH>Creator</TH>\n";
            print "    <TH>Created</TH>\n";
            print "    <TH>Currently in Production</TH>\n";
            print "  </TR>\n";
            foreach ($images[$subimage]['imagerevision'] as $revision) {
                print "  <TR>\n";
                if (array_key_exists($subimage, $data['revisionid']) && $data['revisionid'][$subimage] == $revision['id']) {
                    print "    <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']} checked></TD>\n";
                } elseif ($revision['production']) {
                    print "    <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']} checked></TD>\n";
                } else {
                    print "    <TD align=center><INPUT type=radio name=revisionid[{$subimage}] value={$revision['id']}></TD>\n";
                }
                print "    <TD align=center>{$revision['revision']}</TD>\n";
                print "    <TD align=center>{$revision['user']}</TD>\n";
                print "    <TD align=center>{$revision['prettydate']}</TD>\n";
                if ($revision['production']) {
                    print "    <TD align=center>Yes</TD>\n";
                } else {
                    print "    <TD align=center>No</TD>\n";
                }
                print "  </TR>\n";
            }
            print "</TABLE>\n";
        }
        addContinuationsEntry('submitCreateImage', array(), SECINDAY, 1, 0);
        // we add this continuation back
        //   so the currently displayed
        //   page can be reloaded
        $cont = addContinuationsEntry('submitCreateTestProd', $data);
        print "<br><INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=Submit>\n";
        print "</FORM>\n";
        return;
    }
    $rc = isAvailable($images, $data["imageid"], $start, $end, $data["os"], 0, 0, 0, 1);
    if ($rc == -1) {
        $printedHTMLheader = 1;
        print $HTMLheader;
        print "<H2>Create / Update an Image</H2>\n";
        print "You have requested an environment that is limited in the number ";
        print "of concurrent reservations that can be made. No further ";
        print "reservations for the environment can be made for the time you ";
        print "have selected. Please select another time to use the ";
        print "environment.<br>";
    } elseif ($rc > 0) {
        $requestid = addRequest(1, $data['revisionid']);
        if ($data["time"] == "now") {
            header("Location: " . BASEURL . SCRIPT . "?mode=viewRequests");
            dbDisconnect();
            exit;
        } else {
            $time = prettyLength($data["length"]);
            if ($data["minute"] == 0) {
                $data["minute"] = "00";
            }
            $printedHTMLheader = 1;
            print $HTMLheader;
            print "<H2>Create / Update an Image</H2>\n";
            print "Your request to use <b>" . $images[$data["imageid"]]["prettyname"];
            print "</b> on " . prettyDatetime($start) . " for {$time} has been ";
            print "accepted.<br><br>\n";
            print "When your reservation time has been reached, the ";
            print "<b>Current Reservations</b> page will give you more ";
            print "information on connecting to the reserved computer. If you ";
            print "would like to modify your reservation, you can do that from ";
            print "the <b>Current Reservations</b> page as well.<br>\n";
        }
    } else {
        $printedHTMLheader = 1;
        print $HTMLheader;
        $cdata = array('imageid' => $data['imageid'], 'length' => $data['length']);
        $cont = addContinuationsEntry('selectTimeTable', $cdata);
        print "<H2>Create / Update an Image</H2>\n";
        print "The reservation you have requested is not available. You may ";
        print "<a href=\"" . BASEURL . SCRIPT . "?continuation={$cont}\">";
        print "view a timetable</a> of free and reserved times to find ";
        print "a time that will work for you.<br>\n";
        #addLogEntry($nowfuture, unixToDatetime($start),
        #            unixToDatetime($end), 0, $data["imageid"]);
    }
}
Пример #12
0
function viewRequests()
{
    global $user, $viewmode, $inContinuation, $mode;
    if ($inContinuation) {
        $lengthchanged = getContinuationVar('lengthchanged', 0);
    } else {
        $lengthchanged = processInputVar('lengthchanged', ARG_NUMERIC, 0);
    }
    $incPaneDetails = processInputVar('incdetails', ARG_NUMERIC, 0);
    $refreqid = processInputVar('reqid', ARG_NUMERIC, 0);
    $requests = getUserRequests("all");
    $images = getImages();
    $computers = getComputers();
    if ($mode != 'AJviewRequests') {
        print "<div id=subcontent>\n";
    }
    $refresh = 0;
    $failed = 0;
    $connect = 0;
    $normal = '';
    $imaging = '';
    $long = '';
    if ($count = count($requests)) {
        $now = time();
        for ($i = 0, $noedit = 0, $text = ''; $i < $count; $i++, $noedit = 0, $text = '') {
            if ($requests[$i]['forcheckout'] == 0 && $requests[$i]['forimaging'] == 0) {
                continue;
            }
            $imageid = $requests[$i]["imageid"];
            $text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
            if (requestIsReady($requests[$i])) {
                $connect = 1;
                # request is ready, print Connect! and End buttons
                $cdata = array('requestid' => $requests[$i]['id']);
                $text .= "    <TD>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cont = addContinuationsEntry('connectRequest', $cdata, SECINDAY);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=\"Connect!\">\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
                if ($requests[$i]['forimaging']) {
                    # this is the imaging case, need to do sanity check here for if the request
                    #   state currstateid or laststateid are "inuse", otherwise disable out the
                    #   create image button
                    $noedit = 1;
                    $text .= "    <TD>\n";
                    if ($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8) {
                        # the user has connected successfully so we will allow create image button
                        #   to be displayed
                        $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                        $cont = addContinuationsEntry('startImage', $cdata);
                        $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                        $text .= "      <INPUT type=submit value=\"Create\nImage\">\n";
                        $text .= "      </FORM>\n";
                    }
                    $text .= "    </TD>\n";
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cdata = array('requestid' => $requests[$i]['id']);
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=Cancel>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                } else {
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=End>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                }
                $startstamp = datetimeToUnix($requests[$i]["start"]);
            } elseif ($requests[$i]["currstateid"] == 5) {
                # request has failed
                $cdata = array('requestid' => $requests[$i]['id']);
                $text .= "    <TD colspan=2 nowrap>\n";
                $text .= "      <span class=scriptonly>\n";
                $text .= "      <span class=compstatelink>";
                $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
                $text .= "return false;\" href=\"#\">Reservation failed</a></span>\n";
                $text .= "      </span>\n";
                $text .= "      <noscript>\n";
                $text .= "      <span class=scriptoff>\n";
                $text .= "      <span class=compstatelink>";
                $text .= "Reservation failed</span>\n";
                $text .= "      </span>\n";
                $text .= "      </noscript>\n";
                $text .= "    </TD>\n";
                $failed = 1;
                $noedit = 1;
            } elseif (datetimeToUnix($requests[$i]["start"]) < $now) {
                # other cases where the reservation start time has been reached
                if ($requests[$i]["currstateid"] == 12 && $requests[$i]['laststateid'] == 11 || $requests[$i]["currstateid"] == 11 || $requests[$i]["currstateid"] == 14 && $requests[$i]["laststateid"] == 11) {
                    # request has timed out
                    if ($requests[$i]['forimaging']) {
                        $text .= "    <TD colspan=3>\n";
                    } else {
                        $text .= "    <TD colspan=2>\n";
                    }
                    $text .= "      <span class=compstatelink>Reservation has ";
                    $text .= "timed out</span>\n";
                    $noedit = 1;
                    $text .= "    </TD>\n";
                } else {
                    # computer is loading, print Pending... and Delete button
                    $remaining = 1;
                    if ($requests[$i]['forimaging']) {
                        $noedit = 1;
                    }
                    if (isComputerLoading($requests[$i], $computers)) {
                        if (datetimeToUnix($requests[$i]["daterequested"]) >= datetimeToUnix($requests[$i]["start"])) {
                            $startload = datetimeToUnix($requests[$i]["daterequested"]);
                        } else {
                            $startload = datetimeToUnix($requests[$i]["start"]);
                        }
                        $imgLoadTime = getImageLoadEstimate($imageid);
                        if ($imgLoadTime == 0) {
                            $imgLoadTime = $images[$imageid]['reloadtime'] * 60;
                        }
                        $tmp = ($imgLoadTime - ($now - $startload)) / 60;
                        $remaining = sprintf("%d", $tmp) + 1;
                        if ($remaining < 1) {
                            $remaining = 1;
                        }
                    }
                    # computer is loading, print Pending... and Delete button
                    if ($requests[$i]['forimaging']) {
                        $text .= "    <TD colspan=2>\n";
                    } else {
                        $text .= "    <TD>\n";
                    }
                    $text .= "      <span class=scriptonly>\n";
                    $text .= "      <span class=compstatelink><i>";
                    $text .= "<a onClick=\"showResStatusPane({$requests[$i]['id']}); ";
                    $text .= "return false;\" href=\"#\">Pending...</a></i></span>";
                    $text .= "      </span>\n";
                    $text .= "      <noscript>\n";
                    $text .= "      <span class=scriptoff>\n";
                    $text .= "      <span class=compstatelink>";
                    $text .= "<i>Pending...</i></span>\n";
                    $text .= "      </span>\n";
                    $text .= "      </noscript>\n";
                    $text .= "<br>Est:&nbsp;{$remaining}&nbsp;min remaining\n";
                    $refresh = 1;
                    $text .= "    </TD>\n";
                    $text .= "    <TD>\n";
                    $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                    $cdata = array('requestid' => $requests[$i]['id']);
                    $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                    $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                    $text .= "      <INPUT type=submit value=Delete>\n";
                    $text .= "      </FORM>\n";
                    $text .= "    </TD>\n";
                }
            } else {
                # reservation is in the future
                $text .= "    <TD></TD>\n";
                $text .= "    <TD>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cdata = array('requestid' => $requests[$i]['id']);
                $cont = addContinuationsEntry('confirmDeleteRequest', $cdata, SECINDAY);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=Delete>\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
            }
            if (!$noedit) {
                # print edit button
                $text .= "    <TD align=right>\n";
                $text .= "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cdata = array('requestid' => $requests[$i]['id']);
                $cont = addContinuationsEntry('editRequest', $cdata);
                $text .= "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                $text .= "      <INPUT type=submit value=Edit>\n";
                $text .= "      </FORM>\n";
                $text .= "    </TD>\n";
            } elseif ($requests[$i]['forimaging'] == 0) {
                $text .= "    <TD></TD>\n";
            }
            # print name of image, add (Testing) if it is the test version of an image
            $text .= "    <TD>" . str_replace("'", "&#39;", $requests[$i]["prettyimage"]);
            if ($requests[$i]["test"]) {
                $text .= " (Testing)";
            }
            $text .= "</TD>\n";
            # print start time
            if (datetimeToUnix($requests[$i]["start"]) < datetimeToUnix($requests[$i]["daterequested"])) {
                $text .= "    <TD>" . prettyDatetime($requests[$i]["daterequested"]) . "</TD>\n";
            } else {
                $text .= "    <TD>" . prettyDatetime($requests[$i]["start"]) . "</TD>\n";
            }
            # print end time
            $text .= "    <TD>" . prettyDatetime($requests[$i]["end"]) . "</TD>\n";
            # print date requested
            $text .= "    <TD>" . prettyDatetime($requests[$i]["daterequested"]) . "</TD>\n";
            if ($viewmode == ADMIN_DEVELOPER) {
                $text .= "    <TD align=center>" . $requests[$i]["id"] . "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["computerid"] . "</TD>\n";
                $text .= "    <TD>" . $requests[$i]["IPaddress"] . "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["currstateid"];
                $text .= "</TD>\n";
                $text .= "    <TD align=center>" . $requests[$i]["laststateid"];
                $text .= "</TD>\n";
                $text .= "    <TD align=center>";
                $text .= $computers[$requests[$i]["computerid"]]["stateid"] . "</TD>\n";
            }
            $text .= "  </TR>\n";
            if ($requests[$i]['forimaging']) {
                $imaging .= $text;
            } elseif ($requests[$i]['longterm']) {
                $long .= $text;
            } else {
                $normal .= $text;
            }
        }
    }
    $text = "<H2>Current Reservations</H2>\n";
    if (!empty($normal)) {
        if (!empty($imaging) || !empty($long)) {
            $text .= "You currently have the following <strong>normal</strong> reservations:<br>\n";
        } else {
            $text .= "You currently have the following normal reservations:<br>\n";
        }
        if ($lengthchanged) {
            $text .= "<font color=red>NOTE: The maximum allowed reservation ";
            $text .= "length for one of these reservations was less than the ";
            $text .= "length you submitted, and the length of that reservation ";
            $text .= "has been adjusted accordingly.</font>\n";
        }
        $text .= "<table id=reslisttable summary=\"lists reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $normal;
        $text .= "</table>\n";
    }
    if (!empty($imaging)) {
        if (!empty($normal)) {
            $text .= "<hr>\n";
        }
        $text .= "You currently have the following <strong>imaging</strong> reservations:<br>\n";
        $text .= "<table id=imgreslisttable summary=\"lists imaging reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        $computers = getComputers();
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $imaging;
        $text .= "</table>\n";
    }
    if (!empty($long)) {
        if (!empty($normal) || !empty($imaging)) {
            $text .= "<hr>\n";
        }
        $text .= "You currently have the following <strong>long term</strong> reservations:<br>\n";
        $text .= "<table id=\"longreslisttable\" summary=\"lists long term reservations you currently have\" cellpadding=5>\n";
        $text .= "  <TR>\n";
        $text .= "    <TD colspan=3></TD>\n";
        $text .= "    <TH>Environment</TH>\n";
        $text .= "    <TH>Starting</TH>\n";
        $text .= "    <TH>Ending</TH>\n";
        $text .= "    <TH>Initially requested</TH>\n";
        $computers = getComputers();
        if ($viewmode == ADMIN_DEVELOPER) {
            $text .= "    <TH>Req ID</TH>\n";
            $text .= "    <TH>Comp ID</TH>\n";
            $text .= "    <TH>IP address</TH>\n";
            $text .= "    <TH>Current State</TH>\n";
            $text .= "    <TH>Last State</TH>\n";
            $text .= "    <TH>Computer State</TH>\n";
        }
        $text .= "  </TR>\n";
        $text .= $long;
        $text .= "</table>\n";
    }
    # connect div
    if ($connect) {
        $text .= "<br><br>Click the <strong>";
        $text .= "Connect!</strong> button to get further ";
        $text .= "information about connecting to the reserved system. You must ";
        $text .= "click the button from a web browser running on the same computer ";
        $text .= "from which you will be connecting to the remote computer; ";
        $text .= "otherwise, you may be denied access to the machine.\n";
    }
    if ($refresh) {
        $text .= "<br><br>This page will automatically update ";
        $text .= "every 20 seconds until the <font color=red><i>Pending...</i>";
        #$text .= "</font> reservation is ready.<br></div>\n";
        $text .= "</font> reservation is ready.\n";
        $cont = addContinuationsEntry('AJviewRequests', $cdata, SECINDAY);
        $text .= "<INPUT type=hidden id=resRefreshCont value=\"{$cont}\">\n";
    }
    if ($failed) {
        $text .= "<br><br>An error has occurred that has kept one of your reservations ";
        $text .= "from being processed. We apologize for any inconvenience ";
        $text .= "this may have caused.\n";
        if (!$refresh) {
            $cont = addContinuationsEntry('AJviewRequests', $cdata, SECINDAY);
            $text .= "<INPUT type=hidden id=resRefreshCont value=\"{$cont}\">\n";
        }
    }
    if (empty($normal) && empty($imaging) && empty($long)) {
        $text .= "You have no current reservations.<br>\n";
    }
    $text .= "</div>\n";
    if ($mode != 'AJviewRequests') {
        if ($refresh || $failed) {
            $text .= "<div dojoType=FloatingPane\n";
            $text .= "      id=resStatusPane\n";
            $text .= "      constrainToContainer=false\n";
            $text .= "      hasShadow=true\n";
            $text .= "      resizable=true\n";
            $text .= "      windowState=minimized\n";
            $text .= "      displayMinimizeAction=true\n";
            $text .= "      style=\"width: 350px; height: 280px; position: absolute; left: 130; top: 0px;\"\n";
            $text .= ">\n";
            $text .= "<div id=resStatusText></div>\n";
            $text .= "<input type=hidden id=detailreqid value=0>\n";
            $text .= "</div>\n";
            $text .= "<script type=\"text/javascript\">\n";
            $text .= "dojo.addOnLoad(showScriptOnly);\n";
            $text .= "dojo.byId('resStatusPane').title = \"Detailed Reservation Status\";\n";
            $text .= "</script>\n";
        }
        print $text;
    } else {
        $text = str_replace("\n", ' ', $text);
        if ($refresh) {
            print "refresh_timer = setTimeout(resRefresh, 20000);\n";
        }
        print setAttribute('subcontent', 'innerHTML', $text);
        print "AJdojoCreate('subcontent');";
        if ($incPaneDetails) {
            $text = detailStatusHTML($refreqid);
            print setAttribute('resStatusText', 'innerHTML', $text);
        }
        dbDisconnect();
        exit;
    }
}
Пример #13
0
function sendHeaders()
{
    global $mode, $user, $authed, $oldmode, $viewmode, $actionFunction, $skin;
    global $shibauthed;
    $setwrapreferer = processInputVar('am', ARG_NUMERIC, 0);
    if (!$authed && $mode == "auth") {
        header("Location: " . BASEURL . SCRIPT . "?mode=selectauth");
        dbDisconnect();
        exit;
    }
    switch ($mode) {
        case 'logout':
            if ($shibauthed) {
                $shibdata = getShibauthData($shibauthed);
                if (array_key_exists('Shib-logouturl', $shibdata) && !empty($shibdata['Shib-logouturl'])) {
                    dbDisconnect();
                    header("Location: {$shibdata['Shib-logouturl']}");
                    exit;
                }
            }
        case 'shiblogout':
            setcookie("ITECSAUTH", "", time() - 10, "/", COOKIEDOMAIN);
            setcookie("VCLAUTH", "", time() - 10, "/", COOKIEDOMAIN);
            if ($shibauthed) {
                $msg = '';
                $shibdata = getShibauthData($shibauthed);
                # find and clear shib cookies
                /*foreach(array_keys($_COOKIE) as $key) {
                			if(preg_match('/^_shibsession[_0-9a-fA-F]+$/', $key))
                				setcookie($key, "", time() - 10, "/", $_SERVER['SERVER_NAME']);
                			elseif(preg_match('/^_shibstate_/', $key))
                				setcookie($key, "", time() - 10, "/", $_SERVER['SERVER_NAME']);
                		}*/
                doQuery("DELETE FROM shibauth WHERE id = {$shibauthed}", 101);
                stopSession();
                dbDisconnect();
                if (array_key_exists('Shib-logouturl', $shibdata) && !empty($shibdata['Shib-logouturl'])) {
                    print "<html>\n";
                    print "   <head>\n";
                    print "      <style type=\"text/css\">\n";
                    print "         .red {\n";
                    print "            color: red;\n";
                    print "         }\n";
                    print "         body{\n";
                    print "            margin:0px; color: red;\n";
                    print "         }\n";
                    print "      </style>\n";
                    print "   </head>\n";
                    print "   <body>\n";
                    print "      <span class=red>Done.</span>&nbsp;&nbsp;&nbsp;<a target=\"_top\" href=\"" . BASEURL . "/\">Return to VCL</a>\n";
                    print "   </body>\n";
                    print "</html>\n";
                } else {
                    print "<html>\n";
                    print "<head>\n";
                    print "<META HTTP-EQUIV=REFRESH CONTENT=\"5;url=" . BASEURL . "\">\n";
                    print "<style type=\"text/css\">\n";
                    print "  .hidden {\n";
                    print "    display: none;\n";
                    print "  }\n";
                    print "</style>\n";
                    print "</head>\n";
                    print "<body>\n";
                    print "Logging out of VCL...";
                    print "<iframe src=\"http://{$_SERVER['SERVER_NAME']}/Shibboleth.sso/Logout\" class=hidden>\n";
                    print "</iframe>\n";
                    if (array_key_exists('Shib-Identity-Provider', $shibdata) && !empty($shibdata['Shib-Identity-Provider'])) {
                        $tmp = explode('/', $shibdata['Shib-Identity-Provider']);
                        $idp = "{$tmp[0]}//{$tmp[2]}";
                        print "<iframe src=\"{$idp}/idp/logout.jsp\" class=hidden>\n";
                        print "</iframe>\n";
                    }
                    print "</body>\n";
                    print "</html>\n";
                }
                exit;
            }
            header("Location: " . HOMEURL);
            stopSession();
            dbDisconnect();
            exit;
    }
    if ($mode == "submitviewmode") {
        $expire = time() + 31536000;
        //expire in 1 year
        $newviewmode = processInputVar("viewmode", ARG_NUMERIC);
        if (!empty($newviewmode) && $newviewmode <= $user['adminlevelid']) {
            setcookie("VCLVIEWMODE", $newviewmode, $expire, "/", COOKIEDOMAIN);
        }
        stopSession();
        header("Location: " . BASEURL . SCRIPT);
        dbDisconnect();
        exit;
    }
    if ($mode == "statgraphday" || $mode == "statgraphdayconcuruser" || $mode == "statgraphdayconcurblade" || $mode == "statgraphhour") {
        $actionFunction();
        dbDisconnect();
        exit;
    }
    if ($mode == "viewNodes") {
        $openNodes = processInputVar("openNodes", ARG_STRING);
        $activeNode = processInputVar("activeNode", ARG_NUMERIC);
        if (!empty($openNodes)) {
            $expire = time() + 31536000;
            //expire in 1 year
            setcookie("VCLNODES", $openNodes, $expire, "/", COOKIEDOMAIN);
        }
        if (!empty($activeNode)) {
            $expire = time() + 31536000;
            //expire in 1 year
            setcookie("VCLACTIVENODE", $activeNode, $expire, "/", COOKIEDOMAIN);
        }
        return;
    }
    if ($mode == "submitDeleteNode") {
        $activeNode = processInputVar("activeNode", ARG_NUMERIC);
        $nodeinfo = getNodeInfo($activeNode);
        $expire = time() + 31536000;
        //expire in 1 year
        setcookie("VCLACTIVENODE", $nodeinfo["parent"], $expire, "/", COOKIEDOMAIN);
    }
    if ($mode == "sendRDPfile") {
        header("Cache-Control: max-age=5, must-revalidate");
        header('Pragma: cache');
    } else {
        header("Cache-Control: no-cache, must-revalidate");
    }
    header("Expires: Sat, 1 Jan 2000 00:00:00 GMT");
}
Пример #14
0
                                            <td><?php 
    echo $row['username'];
    ?>
</td>
                                            <td><?php 
    echo $row['password'];
    ?>
</td>
<td><a class='deleteSociety' href="scripts/delete.php?id=<?php 
    echo $row['id'];
    ?>
&type=society">Delete</a></td>
                                        </tr>
                                      <?php 
}
dbDisconnect($conn);
?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                            
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
                                Add Society
                            </button>
                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
Пример #15
0
 public function create()
 {
     if (isset($_SESSION['TournamentId'])) {
         if (isset($_POST) && sizeof($_POST) == 9) {
             foreach ($_POST as $key => $value) {
                 echo $key, " => ", $value, "<br />";
                 switch ($key) {
                     case "name":
                         $this->name = htmlentities($_POST['name'], ENT_QUOTES);
                         break;
                     case "round":
                         $this->round = htmlentities($_POST['round'], ENT_QUOTES);
                         break;
                     case "teamcount":
                         $this->teamcount = htmlentities($_POST['teamcount'], ENT_QUOTES);
                         break;
                     case "link":
                         $this->link = htmlentities($_POST['link'], ENT_QUOTES);
                         break;
                     case "logopath":
                         $this->logopath = htmlentities($_POST['logopath'], ENT_QUOTES);
                         break;
                     case "begin":
                         if (!empty($_POST['begin'])) {
                             $this->begin = htmlentities($_POST['begin'], ENT_QUOTES);
                         } else {
                             $this->begin = date('Y-m-d H:i:s', time());
                         }
                         break;
                     case "end":
                         if (isset($_POST['end']) && !empty($_POST['end'])) {
                             $this->end = htmlentities($_POST['end'], ENT_QUOTES);
                         } else {
                             $this->withoutend = true;
                         }
                         break;
                     case "bestOfOption":
                         $this->bestOfOption = htmlentities($_POST['bestOfOption'], ENT_QUOTES);
                         break;
                     case "newGroup":
                         break;
                     default:
                         $this->start = false;
                 }
             }
         } else {
             $this->start = false;
         }
         if ($this->start) {
             $this->dbConnect();
             $table = "ftm_group";
             if ($this->withoutend) {
                 $values = array($this->name, $this->teamcount, $this->link, $this->logopath, $this->begin, $this->bestOfOption);
                 $rows = "name,teamCount,link,logoPath,begin,bestOfOption";
             } else {
                 $values = array($this->name, $this->teamcount, $this->link, $this->logopath, $this->begin, $this->end, $this->bestOfOption);
                 $rows = "name,teamCount,link,logoPath,begin,end,bestOfOption";
             }
             if ($this->db->insert($table, $values, $rows)) {
                 // Turnierdaten des neuen Turniers ermitteln (ID)
                 $rows = "*";
                 $table = "ftm.ftm_group";
                 $where = "ftm_group.begin='" . $this->begin . "'";
                 $order = "_ID DESC LIMIT 0,1";
                 $group = "";
                 $joins = "";
                 if ($this->db->select($table, $rows, $where, $order)) {
                     $this_result = $this->db->getResult();
                     $this->db->clear_results();
                     $this->id = $this_result['_Id'];
                     // Turnierdaten des neuen Turniers ermitteln (ID)
                     $table = "ftm_tournamentgroups";
                     $values = array($_SESSION['TournamentId'], $this->id, $this->round);
                     $rows = "tournamentId,groupId,round";
                     if ($this->db->insert($table, $values, $rows)) {
                         return true;
                     } else {
                         echo "Insert ftm_tournamentgroups Error";
                         return false;
                     }
                 } else {
                     echo "Select Group Error";
                     return false;
                 }
             } else {
                 echo "Insert Group Error";
                 return false;
             }
             dbDisconnect();
         } else {
             echo "No Post";
             return false;
         }
     }
 }
Пример #16
0
function get_prods_urls()
{
    global $sitemapstr, $numlinks, $mycatid, $isFinish;
    $lnk = dbConnect('', '', '');
    $query = "SELECT id as pid,translit as tr FROM ln_product_my WHERE mycat_id={$mycatid}";
    $res = exec_query($query);
    $def = "http://ychebniki.ru/products/getdetails/item/";
    while ($rows = fetch_array($res)) {
        $isFinish = false;
        $url = $def . $rows['tr'];
        $sitemapstr .= get_sitemap_url($url, 0.9);
        $numlinks++;
        if ($numlinks > 39999) {
            finish_file();
        }
    }
    dbDisconnect($lnk);
}
Пример #17
0
function AJsubmitAddResourcePriv()
{
    global $user;
    $node = processInputVar("activeNode", ARG_NUMERIC);
    if (!checkUserHasPriv("resourceGrant", $user["id"], $node)) {
        $text = "You do not have rights to add new resource groups at this node.";
        print "addUserGroupPaneHide(); ";
        print "alert('{$text}');";
        dbDisconnect();
        exit;
    }
    $newgroupid = processInputVar("newgroupid", ARG_NUMERIC);
    # FIXME validate newgroupid
    $perms = explode(':', processInputVar('perms', ARG_STRING));
    $privtypes = array("block", "cascade", "available", "administer", "manageGroup");
    $newgroupprivs = array();
    foreach ($privtypes as $type) {
        if (in_array($type, $perms)) {
            array_push($newgroupprivs, $type);
        }
    }
    if (empty($newgroupprivs) || count($newgroupprivs) == 1 && in_array("cascade", $newgroupprivs)) {
        $text = "<font color=red>No resource group privileges were specified</font>";
        print setAttribute('addResourceGroupPrivStatus', 'innerHTML', $text);
        dbDisconnect();
        exit;
    }
    updateResourcePrivs($newgroupid, $node, $newgroupprivs, array());
    clearPrivCache();
    print "addResourceGroupPaneHide(); ";
    print "refreshPerms(); ";
    dbDisconnect();
    exit;
}
Пример #18
0
function editEvent()
{
    $conn = dbConnect();
    $societyId = -1;
    $id = -1;
    $display = 0;
    $eventTime = '';
    $filePath = '';
    $event_name = '';
    $category = '';
    $about = '';
    $desc = '';
    $prize1 = '';
    $prize2 = '';
    $contact1 = '';
    $contact2 = '';
    $link = '';
    $rules = array();
    if (isset($_POST['event_name'])) {
        $event_name = $conn->real_escape_string($_POST['event_name']);
    }
    if (isset($_POST['category'])) {
        $category = $conn->real_escape_string($_POST['category']);
    }
    if (isset($_POST['about'])) {
        $about = $_POST['about'];
    }
    if (isset($_POST['description'])) {
        $desc = $_POST['description'];
    }
    if (isset($_POST['prize1'])) {
        $prize1 = $_POST['prize1'];
    }
    if (isset($_POST['prize2'])) {
        $prize2 = $_POST['prize2'];
    }
    if (isset($_POST['eventTime'])) {
        $eventTime = $_POST['eventTime'];
    }
    if (isset($_POST['contact1'])) {
        $contact1 = $_POST['contact1'];
    }
    if (isset($_POST['contact2'])) {
        $contact2 = $_POST['contact2'];
    }
    if (isset($_POST['link'])) {
        $link = $_POST['link'];
    }
    if (isset($_POST['rules'])) {
        $rules = $_POST['rules'];
    }
    if (isset($_POST['id'])) {
        $id = $_POST['id'];
    }
    if (isset($_POST['societyId'])) {
        $societyId = $_POST['societyId'];
    }
    if (isset($_POST['filePath']) && $_POST['filePath'] != '') {
        $filePath = $_POST['filePath'];
    }
    if (isset($_POST['display'])) {
        $display = $_POST['display'];
    }
    if (isset($_FILES['file']) && $_FILES['file']['error'] != 4) {
        $fileNameArray = explode('.', $_FILES["file"]['name']);
        $_FILES['file']['name'] = $fileNameArray[0] . '' . trim(str_replace(' ', '', $event_name)) . '.' . $fileNameArray[1];
        $target_dir = "../uploads/events/";
        $target_file = $target_dir . basename($_FILES["file"]["name"]);
        if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
            $filePath = 'uploads/events/' . $_FILES["file"]["name"];
        }
    }
    $eventData = array('about' => $about, 'prize1' => $prize1, 'prize2' => $prize2, 'contact1' => $contact1, 'contact2' => $contact2, 'link' => $link, 'rules' => $rules, 'filePath' => $filePath, 'description' => $desc);
    $eventData = json_encode($eventData);
    $sql = "UPDATE events SET societyId=" . $societyId . ",eventData='" . $eventData . "',category='" . $category . "',name='" . $event_name . "',display=" . $display . ",eventTime='" . $eventTime . "' WHERE id=" . $id . "";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../events.php");
    } else {
        echo "Some error occured..:(";
    }
}
Пример #19
0
function writeToLog($name, $id, $ip)
{
    $date = date("d-m-Y", time() + 32400);
    $datet = date("d-m-Y H:i:s", time() + 32400);
    $filename = $date . ".txt";
    $f = fopen($filename, "a+");
    fwrite($f, $ip . "   " . $datet . "   " . $id . "   " . $name . "\n");
    fclose($f);
    $lnk = dbConnect('localhost', 'root', 'lyntik');
    $query = "SELECT mycat_id as mycat FROM ln_product_my WHERE id={$id}";
    $res = exec_query($query);
    $mycat = 0;
    $rows = null;
    if (mysql_num_rows($res) != 0) {
        $rows = fetch_array($res);
        $mycat = $rows['mycat'];
    }
    $query = "INSERT INTO buylog (date,fdate,ip,goodid,name,mycat_id) VALUES ('{$date}','{$datet}','{$ip}',{$id},'{$name}',{$mycat})";
    $res = exec_query($query);
    dbDisconnect($lnk);
    return true;
}
Пример #20
0
function get_prods_urls()
{
    global $sitemapstr, $mycatid, $limit_cnt;
    echo "Выгружаем товары<br/>";
    $sitemapstr .= "<offers>";
    $lnk = dbConnect('', '', '');
    $query = "SELECT id as pid,price as price,categoryId as cat,picture as pict,producer as vendor,name as pname,description as description,translit as trans FROM ln_product_my WHERE mycat_id={$mycatid}";
    $res = exec_query($query);
    $schet = 0;
    while ($rows = fetch_array($res)) {
        $sitemapstr .= get_sitemap_offer_url($rows['pid'], $rows['price'], $rows['cat'], $rows['pict'], $rows['vendor'], $rows['pname'], substr($rows['description'], 0, 255), $rows['trans']);
        $schet++;
        if ($limit_cnt != 0 && $schet == $limit_cnt) {
            break;
        }
    }
    $sitemapstr .= "</offers>";
    dbDisconnect($lnk);
}
Пример #21
0
/**
 * Enter description here...
 *
 * @param unknown_type $dir
 * @param unknown_type $module
 */
function deleteSql($dir, $module)
{
    $settings = getMagentoDatabaseSettings($dir);
    $connection = dbConnect($settings);
    $module = preg_replace('/\\/$/', '', $module);
    $module = strtolower(substr(strrchr($module, '/'), 1));
    $tblPrefix = getTablePrefix($dir);
    $sql = "DELETE FROM " . $tblPrefix . "core_resource WHERE code = '" . $module . "_setup'";
    $delete = mysql_query($sql);
    $sql = "DROP TABLE " . $tblPrefix . $module;
    $drop = mysql_query($sql);
    dbDisconnect($connection);
    if ($delete and $drop) {
        return true;
    }
    return false;
}
Пример #22
0
{
    $title_seo = translit_fromRussian($title_seo);
    $title_seo = preg_replace("/[^0-9a-zA-Z_]/", '-', $title_seo);
    $title_seo = preg_replace("/-[-]*-/", '-', $title_seo);
    return $title_seo;
}
function translit_fromRussian($s)
{
    $TRAN = array('а' => 'a', 'б' => 'b', 'в' => 'v', 'г' => 'g', 'д' => 'd', 'е' => 'e', 'ё' => 'jo', 'ж' => 'zh', 'з' => 'z', 'и' => 'i', 'й' => 'jj', 'к' => 'k', 'л' => 'l', 'м' => 'm', 'н' => 'n', 'о' => 'o', 'п' => 'p', 'р' => 'r', 'с' => 's', 'т' => 't', 'у' => 'u', 'ф' => 'f', 'х' => 'kh', 'ц' => 'c', 'ч' => 'ch', 'ш' => 'sh', 'щ' => 'shh', 'ъ' => '', 'ы' => 'y', 'ь' => "", 'э' => 'eh', 'ю' => 'yu', 'я' => 'ya', 'А' => 'A', 'Б' => 'B', 'В' => 'V', 'Г' => 'G', 'Д' => 'D', 'Е' => 'E', 'Ё' => 'Jo', 'Ж' => 'Zh', 'З' => 'Z', 'И' => 'I', 'Й' => 'Jj', 'К' => 'K', 'Л' => 'L', 'М' => 'M', 'Н' => 'N', 'О' => 'O', 'П' => 'P', 'Р' => 'R', 'С' => 'S', 'Т' => 'T', 'У' => 'U', 'Ф' => 'F', 'Х' => 'Kh', 'Ц' => 'C', 'Ч' => 'Ch', 'Ш' => 'Sh', 'Щ' => 'Shh', 'Ъ' => '', 'Ы' => 'Y', 'Ь' => "", 'Э' => 'Eh', 'Ю' => 'Yu', 'Я' => 'Ya');
    foreach ($TRAN as $ru => $en) {
        $s = str_replace($ru, $en, $s);
    }
    return $s;
}
function translit_checkExistInProd($str, $num)
{
    $find = $str;
    $query = "SELECT * FROM ln_product_my WHERE translit='" . $find . "'";
    $res = exec_query($query);
    if (mysql_num_rows($res) > 0) {
        $num++;
        $find .= $num;
        $find = translit_checkExistInProd($find, $num);
    }
    return $find;
}
set_time_limit(0);
$lnk = dbConnect('', '', '');
translit_translitProds();
dbDisconnect($lnk);
Пример #23
0
require_once ".ht-inc/states.php";
require_once '.ht-inc/errors.php';
require_once '.ht-inc/utils.php';
dbConnect();
initGlobals();
$modes = array_keys($actions['mode']);
$args = array_keys($actions['args']);
$hasArg = 0;
if (in_array($mode, $modes)) {
    $actionFunction = $actions['mode'][$mode];
    if (in_array($mode, $args)) {
        $hasArg = 1;
        $arg = $actions['args'][$mode];
    }
} else {
    $actionFunction = "main";
}
checkAccess();
sendHeaders();
printHTMLHeader();
if ($viewmode == ADMIN_DEVELOPER) {
    set_error_handler("errorHandler");
}
if ($hasArg) {
    $actionFunction($arg);
} else {
    $actionFunction();
}
printHTMLFooter();
dbDisconnect();
semUnlock();
Пример #24
0
function changeLocale()
{
    global $locale;
    $newlocale = getContinuationVar('locale');
    $oldmode = getContinuationVar('oldmode');
    $authtype = getContinuationVar('authtype', '');
    $locale = $newlocale;
    setcookie("VCLLOCALE", $locale, time() + 86400 * 31, "/", COOKIEDOMAIN);
    $extra = '';
    if ($oldmode == 'selectauth' && !empty($authtype)) {
        $extra = "&authtype={$authtype}";
    }
    header("Location: " . BASEURL . SCRIPT . "?mode={$oldmode}{$extra}");
    dbDisconnect();
    exit;
}
Пример #25
0
function checkExpiredDemoUser($userid, $groups = 0)
{
    global $mode, $skin, $noHTMLwrappers;
    if ($groups == 0) {
        $groups = getUsersGroups($userid, 1);
    }
    if (count($groups) != 1) {
        return;
    }
    $tmp = array_values($groups);
    if ($tmp[0] != 'demo') {
        return;
    }
    $query = "SELECT start " . "FROM log " . "WHERE userid = {$userid} " . "AND finalend < NOW() " . "ORDER BY start " . "LIMIT 3";
    $qh = doQuery($query, 101);
    $expire = time() - SECINDAY * 3;
    $rows = mysql_num_rows($qh);
    if ($row = mysql_fetch_assoc($qh)) {
        if ($rows >= 3 || datetimeToUnix($row['start']) < $expire) {
            if (in_array($mode, $noHTMLwrappers)) {
                # do a redirect and handle removal on next page load so user can
                #   be notified - doesn't always work, but handles a few extra
                #   cases
                header("Location: " . BASEURL . SCRIPT);
            } else {
                $nodemoid = getUserGroupID('nodemo', getAffiliationID('ITECS'));
                $query = "DELETE FROM usergroupmembers " . "WHERE userid = {$userid}";
                # because updateGroups doesn't
                # delete from custom groups
                doQuery($query, 101);
                updateGroups(array($nodemoid), $userid);
                checkUpdateServerRequestGroups($groupid);
                if (empty($skin)) {
                    $skin = 'default';
                    require_once "themes/{$skin}/page.php";
                }
                $mode = 'expiredemouser';
                printHTMLHeader();
                print "<h2>Account Expired</h2>\n";
                print "The account you are using is a demo account that has now expired. ";
                print "You cannot make any more reservations. Please contact <a href=\"";
                print "mailto:" . HELPEMAIL . "\">" . HELPEMAIL . "</a> if you need ";
                print "further access to VCL.<br>\n";
            }
            cleanSemaphore();
            # probably not needed but ensures we do not leave stale entries
            printHTMLFooter();
            dbDisconnect();
            exit;
        }
    }
}
Пример #26
0
function sendEmail($mail, $id)
{
    $lnk = dbConnect('', '', '');
    $query = "SELECT COUNT(orr.id) as cnt\n             FROM order_res orr WHERE orr.order_id={$id}";
    $res = exec_query($query);
    $rows = fetch_array($res);
    $cnt = $rows['cnt'];
    $query = "SELECT number as num,description as descr FROM orders WHERE id={$id}";
    $res = exec_query($query);
    $rows = fetch_array($res);
    $desc = $rows['descr'];
    $num = $rows['num'];
    $msg = $cnt == 0 ? "К сожалению, товаров, соответствующих вашему запросу не найдено, либо их нет в наличии. Попробуйте сделать заявку попозже. Приносим извинения за неудобства. Вы можете вступить в группу Вконтакте по поиску учебников <a href=\"http://vk.com/y4ebniki\">http://vk.com/y4ebniki</a><br>" : "Чтобы просмотреть результаты поиска, перейдите по ссылке <a href=\"http://ychebniki.ru/zakaznik?stext={$num}\">http://ychebniki.ru/zakaznik?stext={$num}</a> или введите номер Вашей заявки в разделе 'Узнать результат' на странице <a href=\"http://ychebniki.ru/zakaznik.php\">заказника</a>. Приглашаем Вас так же вступить в группу Вконтакте по поиску учебников <a href=\"http://vk.com/y4ebniki\">http://vk.com/y4ebniki</a><br>";
    $mesg = "Здравствуйте. Вы оставляли заявку на поиск товара в интернет-магазине ychebniki.ru <br>";
    $mesg .= "Если вы этого не делали просто проигнорируйте это письмо и удалите его.<br>";
    $mesg .= "Номер Вашей заявки: {$num}<br>";
    $mesg .= "Описание заявки: " . $desc . "<br>";
    $mesg .= $msg;
    $mesg .= "Данное письмо сформировано автоматически. По всем вопросам обращаться : info@ychebniki.ru<br>";
    $subj = "Поиск товара в интернет-магазине ychebniki.ru<br>";
    $mesg .= "С уважением, администрация www.ychebniki.ru<br>";
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=win-1251\r\n";
    $headers .= "From: ychebniki.ru support <*****@*****.**>";
    mail($mail, $subj, $mesg, $headers);
    mail("*****@*****.**", $subj, $mesg, $headers);
    mysql_free_result($res);
    dbDisconnect($lnk);
    return 1;
}