Ejemplo n.º 1
0
{
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {
            $q_id = $row["question_id"];
            $sql_answer = "SELECT count(answer_id) as count FROM `answer` WHERE question_id=" . $q_id;
            $count_answer = mysqli_fetch_assoc(mysqli_query($conn, $sql_answer));
            echo "<hr size='2' NOSHADE>";
            echo "<div class=\"question\">";
            echo "\n\t    \t\t<span class=\"vote\">" . $row["vote"] . "<br>votes</span>\n\t    \t\t<span class=\"answer\">" . $count_answer["count"] . "<br>answer</span>\n\t    \t\t<span id=\"question\">";
            if (isset($row["topic"])) {
                echo "<p id=\"question-title\"><a href='question.php?q_id={$q_id}'>" . $row["topic"] . "</a></p>";
            }
            $content = $row["content"];
            if (strlen($content) > 330) {
                $content = substr($content, 0, 327) . "...";
            }
            echo "\n\t    \t\t\t<p id=\"question-content\">{$content}</p>\n\t    \t\t</span>\n\t    \t\t<div class=\"identity\">\n\t    \t\t<br>asked by: <span id=\"name\">" . $row["name"] . "</span> | <a id=\"edit\" href='form.php?q_id={$q_id}&idx=2'>Edit</a> | <a id=\"delete\" onclick='return validate_delete()' href='function/database.php?q_id={$q_id}&delete=true'>Delete</a><br>";
            echo "</div></div>";
        }
    } else {
        echo "0 Results";
    }
    echo "<script src='js/script.js'></script>";
}
if (isset($_GET["delete"])) {
    if ($_GET["delete"]) {
        $conn = connect_database();
        $data["question_id"] = $_GET["q_id"];
        update_database(3, $conn, $data);
    }
}
Ejemplo n.º 2
0
<?php

include "function/database.php";
$conn = connect_database();
$data = $_POST;
if (isset($_GET["q_id"])) {
    $data["question_id"] = $_GET["q_id"];
}
update_database($_GET["idx"], $conn, $data);
Ejemplo n.º 3
0
        update_database($info);
    } elseif (copy($old_rrd_path, $new_rrd_path)) {
        $done_count++;
        echo "NOTE: Copy Complete for File '" . $info["rrd_path"] . "'\n";
        if ($config["cacti_server_os"] != "win32") {
            if (chown($new_rrd_path, $owner_id) && chgrp($new_rrd_path, $group_id)) {
                echo "NOTE: Permissions set for '{$new_rrd_path}'\n";
            } else {
                /* turn on the poller */
                enable_poller();
                echo "FATAL: Could not Set Permissions for File '{$new_rrd_path}'\n";
                exit - 6;
            }
        }
        /* alter database */
        update_database($info);
        if (unlink($old_rrd_path)) {
            echo "NOTE: Old File '{$old_rrd_path}' Removed\n";
        } else {
            /* turn on the poller */
            enable_poller();
            echo "FATAL: Old File '{$old_rrd_path}' Could not be removed\n";
            exit - 2;
        }
    } else {
        /* turn on the poller */
        enable_poller();
        echo "FATAL: Could not Copy RRD File '{$old_rrd_path}' to '{$new_rrd_path}'\n";
        exit - 3;
    }
}
Ejemplo n.º 4
0
 function _link_unique_update($group_id, $target_group_id, $link_type_id, $link_id = NULL)
 {
     // update link, but check the change would not create a duplicate
     // (same target project and link type)
     global $Language;
     $targetProject = ProjectManager::instance()->getProject($target_group_id);
     $feedback = "";
     $pfcheck = db_query("SELECT link_type_id FROM\n            plugin_projectlinks_relationship\n            WHERE (\n                (target_group_id=" . db_ei($target_group_id) . ")\n                AND (master_group_id=" . db_ei($group_id) . ")\n                AND (link_type_id=" . db_ei($link_type_id) . ")\n                " . (is_null($link_id) ? "" : " AND (link_id<>" . db_ei($link_id) . ")") . "\n            )");
     if (db_numrows($pfcheck) > 0) {
         $feedback = $Language->getText('plugin_plinks', 'project_link_change_makes_duplicate', $targetProject->getPublicName());
     } else {
         $updates = array("link_type_id" => $link_type_id, "target_group_id" => $target_group_id, "master_group_id" => $group_id);
         if (is_null($link_id)) {
             // new item - set date, otherwise leave it alone
             $updates["creation_date"] = time();
         }
         if (update_database("plugin_projectlinks_relationship", $updates, is_null($link_id) ? "" : "link_id={$link_id}")) {
             $this->addWidgetOnSummaryPage($target_group_id);
             $feedback = $Language->getText('plugin_plinks', 'update_ok_named', $targetProject->getPublicName()) . ' ';
         } else {
             $feedback = $Language->getText('plugin_plinks', 'update_failed_named', array(db_error(), $targetProject->getPublicName()));
         }
     }
     return $feedback;
 }
Ejemplo n.º 5
0
		echo "NOTE: Copy Complete for File '" . $info["rrd_path"] . "'\n";
		if ($config["cacti_server_os"] != "win32") {
			if (chown($new_rrd_path, $owner_id) && chgrp($new_rrd_path, $group_id)) {
				echo "NOTE: Permissions set for '$new_rrd_path'\n";
			}else{
				/* turn on the poller */
				enable_poller();

				echo "FATAL: Could not Set Permissions for File '$new_rrd_path'\n";
				exit -6;
			}
		}

		/* alter database */
		update_database();

		if (unlink($old_rrd_path)) {
			echo "NOTE: Old File '$old_rrd_path' Removed\n";
		} else {
			/* turn on the poller */
			enable_poller();

			echo "FATAL: Old File '$old_rrd_path' Could not be removed\n";
			exit -2;
		}
	} else {
		/* turn on the poller */
		enable_poller();

		echo "FATAL: Could not Copy RRD File '$old_rrd_path' to '$new_rrd_path'\n";
Ejemplo n.º 6
0
        }
        // When no update was applied, stop trying. We are probably up to date
        // or stuck with an unupgradable version.
        break;
    }
}
$updates = array();
$updates[] = new Update(null, 1.1, array("CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "cast` (\n    `movie_id` int(7) NOT NULL,\n    `name_id` int(7) NOT NULL,\n    `order` int(3) NOT NULL,\n    PRIMARY KEY  (`movie_id`,`name_id`),\n    KEY `name_id` (`name_id`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8", "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "crew` (\n    `movie_id` int(7) NOT NULL,\n    `name_id` int(7) NOT NULL,\n    `order` int(3) NOT NULL,\n    PRIMARY KEY  (`movie_id`,`name_id`),\n    KEY `name_id` (`name_id`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8", "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "imdbtop250` (\n    `id` int(7) NOT NULL,\n    `order` int(3) NOT NULL,\n    PRIMARY KEY  (`id`),\n    UNIQUE KEY `id` (`id`),\n    UNIQUE KEY `order` (`order`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8", "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "movies` (\n    `id` int(7) NOT NULL,\n    `title` varchar(255) NOT NULL,\n    `title_english` varchar(255) NOT NULL,\n    `language` varchar(2) NOT NULL,\n    `genre` set('Action','Adventure','Animation','Biography','Comedy','Crime',\n\t\t\t'Documentary','Drama','Family','History','Horror','Music','Musical',\n\t\t\t'Mystery','Sci-Fi','Short','Sport','Talk Show','Thriller','War',\n\t\t\t'Western') NOT NULL,\n    `year` int(4) NOT NULL,\n    `runtime` int(3) NOT NULL,\n    `rating` tinyint(2) NOT NULL,\n    `date_added` datetime NOT NULL,\n    PRIMARY KEY  (`id`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8", "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "names` (\n    `id` int(7) NOT NULL,\n    `name` varchar(255) NOT NULL,\n    PRIMARY KEY  (`id`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8", "CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "options` (\n    `name` varchar(255) NOT NULL,\n    `value` varchar(255) NOT NULL,\n    PRIMARY KEY  (`name`)\n  ) ENGINE=MyISAM DEFAULT CHARSET=utf8"));
$updates[] = new Update(1.1, 1.2, array("ALTER TABLE `" . DB_PREFIX . "movies` CHANGE `genre` `genre`\n    SET('Action','Adventure','Animation','Biography','Comedy','Crime',\n    'Documentary','Drama','Family','Fantasy','Film-Noir','Game-Show','History',\n    'Horror','Music','Musical','Mystery','News','Reality-TV','Romance','Sci-Fi',\n    'Sport','Talk-Show','Thriller','War','Western') NOT NULL DEFAULT ''"));
$ignored_prefix_sql_updates = array("DROP TRIGGER IF EXISTS `" . DB_PREFIX . "_sort_title`", "CREATE TRIGGER `" . DB_PREFIX . "_sort_title` BEFORE INSERT ON `" . DB_PREFIX . "movies`\n\t\tFOR EACH ROW\n\t\tBEGIN\n\t\t\tCASE\n\t\t\t" . generate_prefix_remove_sql("\n\t\t\t\tWHEN LEFT(NEW.title, %d) = '%s' THEN\n\t\t\t\t\tSET NEW.sort_title = SUBSTRING(NEW.title FROM %d);\n\t\t\t", $ignoredPrefixes) . "\n\t\t\t\tELSE\n\t\t\t\t\tSET NEW.sort_title = NEW.title;\n\t\t\tEND CASE;\n\t\tEND", "UPDATE `" . DB_PREFIX . "movies`\n\t\tSET sort_title = CASE\n\t\t\t" . generate_prefix_remove_sql("\n\t\t\tWHEN LEFT(title, %d) = '%s' THEN\n\t\t\t\tSUBSTRING(title FROM %d)\n\t\t\t", $ignoredPrefixes) . "\n\t\t\tELSE\n\t\t\t\ttitle\n\t\tEND");
$updates[] = new Update(1.2, 1.3, array_merge(array("ALTER TABLE `" . DB_PREFIX . "movies`\n\t\tADD `sort_title` VARCHAR(255) NULL DEFAULT NULL AFTER `title`,\n\t\tADD INDEX `sort_index` (`sort_title`)"), $ignored_prefix_sql_updates));
function generate_prefix_remove_sql($format, $prefixes)
{
    $sql = '';
    foreach ($prefixes as $prefix) {
        // WHEN LEFT(NEW.title, 4) = 'The ' THEN
        //   SET NEW.sort_title = SUBSTRING(NEW.title FROM 5);
        $sql .= sprintf($format, strlen($prefix) + 1, $prefix . ' ', strlen($prefix) + 2);
    }
    return $sql;
}
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die('Could not connect: ' . mysql_error());
mysql_select_db(DB_NAME, $conn) or die('Could not select database');
$db = new MDB($conn);
if (!isset($_GET['skip-backups'])) {
    backup_database($db, $conn);
}
update_database($db, $conn, $updates);
if (!error_get_last()) {
    header('Location: ./?message=update-success');
}
Ejemplo n.º 7
0
        $new_sysid = $row_get_sysid['sysid'];
        switch ($row_get_sysid['property_type']) {
            case 'Multifamily':
                $property_type = 7;
                break;
            case 'Residential Detached':
                $property_type = 1;
                break;
            case 'Residential Attached':
                $property_type = 2;
                break;
        }
        if (!empty($property_type)) {
            $listing_array = get_data_array($property_type, $new_sysid);
            if (!empty($listing_array)) {
                update_database($property_type, $listing_array, $new_sysid);
                patch($new_sysid);
            }
        }
    }
} else {
    echo '<br/>All listings are patched<br/>';
}
$selectSQL = "SELECT SQL_CALC_FOUND_ROWS DISTINCT listings.sysid, postal_code, house_number, street_name, street_type, city, province FROM listings\nLEFT JOIN listing_geoaddress ON listings.sysid=listing_geoaddress.sysid WHERE (ISNULL(lat) OR listing_geoaddress.updated='N')  AND status='A' AND property_type!='Land Only' ORDER BY RAND() LIMIT 0, 10";
$get_sysid = mysql_query_or_die($selectSQL, $useradmin);
$row = mysql_fetch_row(mysql_query("SELECT FOUND_ROWS()", $useradmin));
if ($row[0] > 0) {
    echo "<br/>There are " . $row[0] . " listings that don't have geo code address (or don't have accurate geo code).<br/><br/>";
    //login and receive server response.
    //$response=$rets->Login();
    //var_dump($response);