Esempio n. 1
0
 public function migrateLegacyFiles($dry_run = TRUE)
 {
     $this->dry_run = $dry_run;
     require_once PA::$path . "/db/Dal/DbUpdate.php";
     echo "Migrating legacy files to new storage system\n";
     $this->all_files = array();
     if (!($h = opendir(PA::$path . '/web/files'))) {
         throw new PAException(GENERAL_SOME_ERROR, "Unable to open web/files directory");
     }
     while (false !== ($f = readdir($h))) {
         if ($f[0] == '.') {
             continue;
         }
         $this->all_files[$f] = TRUE;
     }
     closedir($h);
     $this->unmatched = count($this->all_files);
     $this->unmatchable = 0;
     $this->matched = 0;
     $this->dupes = 0;
     echo "{$this->unmatched} files found\n";
     echo "Matching with user images ...\n";
     $sql = Dal::validate_sql("SELECT user_id,picture FROM {users}", $network);
     $sth = Dal::query($sql);
     while ($r = Dal::row($sth)) {
         list($uid, $pic) = $r;
         // user avatar
         $this->_matchLegacyFile($pic, array("role" => "avatar", "user" => $uid));
         //TODO: user header image
     }
     $this->_dumpMatchResults();
     $networks = DbUpdate::get_valid_networks();
     echo "Processing " . count($networks) . " networks\n";
     foreach ($networks as $network) {
         echo " Network: {$network}\n";
         // network level stuff
         list($network_id, $act, $logo, $extra) = Dal::query_one("SELECT network_id, is_active, inner_logo_image, extra FROM networks WHERE address=?", array($network));
         assert($act);
         // sanity check
         $extra = unserialize($extra);
         // network avatar
         $this->_matchLegacyFile($logo, array("role" => "avatar", "network" => $network_id));
         // network header image
         $header_image = @$extra["basic"]["header_image"]["name"];
         if (!empty($header_image)) {
             $this->_matchLegacyFile($header_image, array("role" => "header", "network" => $network_id));
         }
         // emblems
         foreach (unserialize(Dal::query_first(Dal::validate_sql("SELECT data FROM {moduledata} WHERE modulename='LogoModule'"))) as $emblem) {
             $this->_matchLegacyFile($emblem["file_name"], array("role" => "emblem", "network" => $network_id));
         }
         // group pictures
         $sth = Dal::query(Dal::validate_sql("SELECT collection_id, picture FROM {contentcollections} WHERE type=1 AND is_active=1", $network));
         while ($r = Dal::row($sth)) {
             list($cid, $pic) = $r;
             $this->_matchLegacyFile($pic, array("role" => "avatar", "network" => $network_id, "group" => $cid));
             $header = Dal::query_first(Dal::validate_sql("SELECT header_image FROM groups WHERE group_id=?", $network), array($cid));
             $this->_matchLegacyFile($header, array("role" => "header", "network" => $network_id, "group" => $cid));
         }
         /* disabled until we update peopleaggregator.net
         	    $sth = Dal::query(Dal::validate_sql("SELECT group_id, header_image FROM {groups}", $network));
         	    while ($r = Dal::row($sth)) {
         		list ($gid, $pic) = $r;
         		$this->_matchLegacyFile($network, "group", $gid, $pic);
         	    }
         	    */
         //TODO: advertisements
         // images, audio, video
         foreach (array("image", "audio", "video") as $table) {
             $sth = Dal::query(Dal::validate_sql('SELECT mc.content_id, mc.' . $table . '_file, c.author_id, c.collection_id, c.is_active FROM {' . $table . 's} mc LEFT JOIN {contents} c ON mc.content_id=c.content_id HAVING c.is_active=1', $network));
             while ($r = Dal::row($sth)) {
                 list($cid, $fn, $uid, $ccid, $act) = $r;
                 $this->_matchLegacyFile($fn, array("role" => "media", "network" => $network_id, "content" => $cid));
             }
         }
     }
     $this->_dumpMatchResults();
     foreach ($this->all_files as $fn => $v) {
         if ($v === TRUE) {
             echo " * unmatchable: {$fn}\n";
         }
     }
     echo "Overall results from web/files: ";
     $this->_dumpMatchResults();
 }
<?php

require_once dirname(__FILE__) . '/../config.inc';
require_once "{$path_prefix}/db/Dal/Dal.php";
require_once "{$path_prefix}/db/Dal/DbUpdate.php";
require_once "{$path_prefix}/api/Network/Network.php";
// Re-include constants.php to make sure we have the most up to date
// constants.  If we are in the middle of an update and this script is
// being included by web/update/run_scripts.php, we might not have all
// the constants.
include "{$path_prefix}/web/includes/constants.php";
// $settings_new contains the mapping of page names to modules they contain.
global $settings_new;
$db = Dal::get_connection();
foreach (DbUpdate::get_valid_networks() as $net_address) {
    set_time_limit(30);
    $net = Network::get_network_by_address($net_address);
    $table_name = 'page_default_settings';
    if ($net->type != MOTHER_NETWORK_TYPE) {
        // 1 for home network
        $table_name = $net->address . '_' . $table_name;
    }
    $sql = ' TRUNCATE TABLE ' . $table_name;
    $res = Dal::query($sql);
    foreach ($settings_new as $page_id => $v1) {
        $page_name = $v1['page_name'];
        $data = $v1['data'];
        $settings_data = serialize($data);
        $is_configurable = isset($v1['is_configurable']) ? $v1['is_configurable'] : FALSE;
        //default value will be false is not specified
        $sql = "INSERT INTO {$table_name} (page_id, page_name, default_settings, is_configurable) VALUES (?, ?, ?, ?)";
Esempio n. 3
0
  function update_single_network($network) {
    // make sure the network exists
    if (!DbUpdate::is_network_valid($network)) {
      throw new PAException(NETWORK_NOT_FOUND, "Cannot update $network as it does not exist in the database");
    }

    // we shouldn't need to care about this, but just in case, keep copies of updated vars
    $stored_full_update = $this->full_update;
    $this->full_update = FALSE;
    $stored_quiet = $this->quiet;
    $this->quiet = TRUE;

    // update just the specified network
    $this->networks = array($network);
    $this->do_updates();

    // pop old values
    $this->full_update = $stored_full_update;
    $this->quiet = $stored_quiet;
  }
Esempio n. 4
0
                echo json_encode($result);
            }
        } else {
            $response["error"] = TRUE;
            $response["error_msg"] = "List is false";
            echo json_encode($response);
        }
    } else {
        $response["error"] = TRUE;
        $response["error_msg"] = "Unknown tag. Use a proper tag";
        echo json_encode($response);
    }
} else {
    if (isset($_GET['tag']) && $_GET['tag'] != '') {
        $tag = $_GET['tag'];
        $db = new DbUpdate();
        $res = array("tag" => $tag, "error" => FALSE);
        if ($tag == "getUpdates") {
            $result = $db->getUpdates();
            if ($result != false) {
                $list = array();
                $res["error"] = FALSE;
                $res['result'] = $result;
                echo json_encode($res);
            } else {
                $res["error"] = TRUE;
                $res["error_msg"] = "No update found";
                echo json_encode($res);
            }
        } else {
            if ($tag == "getCourses") {
Esempio n. 5
0
// xsrf
//session cookie
// perla -> localhost, zal, przeg cookie sesyjne ADMIN
//$salt = 'hewuoghwdpfweighweipghrgweighwerigri';
// dhsafgad sghdafgdhif/
//	$token = md5( $_COOKIE['PHPSESSID'] . $salt); // rozne
// E&A
// bartek -> alamakota  localhost/zapytania.php facebook.com, formularz $_POST method post name ? input ? x.php zapytanie.php POST name = user id privileges = 128 USER token = $token
//   zapytanie.php if ($_SESSION['uzy_prawa'] == xyz) {  }   if (post [tok] === md5($_COOKIE['PHPSESSID'] . $salt))
//echo '55';
if (isset($_POST['zatwierdz'])) {
    require_once 'D:\\self\\trainings\\Dropbox\\szkolenie\\v 2.0\\code\\Eagles\\includePathSetter.php';
    require_once 'TrainingFive/Database/DbHandle.php';
    require_once 'TrainingFive/Database/DbUpdate.php';
    $dbUpdate = new DbUpdate();
    $dbHandle = new DbHandle();
    $dbHandle->Connect();
    $update = $dbUpdate->RenderQuery('applicationtests', array('codesnipet' => $_POST['yourcode'], 'rightanswers' => pg_escape_string($dbHandle->connectionHandle, $_POST['youranswer'])));
    $dbHandle->SetData($update);
}
?>

<form method="post" action="/">
	
	<input type="text" name="yourcode" placeholder="type your code" />
	
	<input type="text" name="youranswer" placeholder="type your answer" />

	<input type="submit" name="zatwierdz" />
</form>