Esempio n. 1
0
File: page.php Progetto: Mauru/red
function page_content(&$a)
{
    $observer = $a->get_observer();
    $ob_hash = $observer ? $observer['xchan_hash'] : '';
    $perms = get_all_perms($a->profile['profile_uid'], $ob_hash);
    if (!$perms['view_pages']) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = argv(2);
    $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
    if (!$u) {
        notice(t('Channel not found.') . EOL);
        return;
    }
    if ($_REQUEST['rev']) {
        $revision = " and revision = " . intval($_REQUEST['rev']) . " ";
    } else {
        $revision = " order by revision desc ";
    }
    require_once 'include/security.php';
    $sql_options = item_permissions_sql($u[0]['channel_id']);
    $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
    if (!$r) {
        // Check again with no permissions clause to see if it is a permissions issue
        $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\titem_restrict = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
        if ($x) {
            // Yes, it's there. You just aren't allowed to see it.
            notice(t('Permission denied.') . EOL);
        } else {
            notice(t('Page not found.') . EOL);
        }
        return;
    }
    if ($r[0]['layout_mid']) {
        $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']));
        if ($l) {
            require_once 'include/comanche.php';
            comanche_parser(get_app(), $l[0]['body']);
        }
    }
    // logger('layout: ' . print_r($a->layout,true));
    // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
    if ($perms['write_pages']) {
        $chan = $a->channel['channel_id'];
        $who = $channel_address;
        $which = $r[0]['id'];
        $o .= writepages_widget($who, $which);
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
Esempio n. 2
0
File: home.php Progetto: Mauru/red
function home_content(&$a)
{
    $o = '';
    if (x($_SESSION, 'theme')) {
        unset($_SESSION['theme']);
    }
    if (x($_SESSION, 'mobile_theme')) {
        unset($_SESSION['mobile_theme']);
    }
    $channel_address = get_config("system", "site_channel");
    if ($channel_address) {
        // We can do better, but until we figure out auto-linkification, let's keep things simple
        $page_id = 'home';
        $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
        if (!$u) {
            notice(t('Channel not found.') . EOL);
            return;
        }
        $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\t\titem_restrict = %d limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
        if (!$r) {
            notice(t('Item not found.') . EOL);
            return;
        }
        xchan_query($r);
        $r = fetch_post_tags($r, true);
        $a->profile = array('profile_uid' => $u[0]['channel_id']);
        $o .= prepare_page($r[0]);
        return $o;
    }
    if (get_config('system', 'projecthome')) {
        $o .= file_get_contents('assets/home.html');
        $a->page['template'] = 'full';
        $a->page['title'] = t('Red Matrix - &quot;The Network&quot;');
        return $o;
    }
    if (file_exists('home.html')) {
        $o .= file_get_contents('home.html');
    } else {
        // If there's no site channel or home contents configured, fallback to the old behaviour
        $sitename = get_config('system', 'sitename');
        if ($sitename) {
            $o .= '<h1>' . sprintf(t("Welcome to %s"), $sitename) . '</h1>';
        }
        if (!$a->config['system']['no_login_on_homepage']) {
            $o .= login($a->config['system']['register_policy'] == REGISTER_CLOSED ? 0 : 1);
        }
    }
    call_hooks('home_content', $o);
    return $o;
}
Esempio n. 3
0
function page_content(&$a)
{
    $r = $a->data['webpage'];
    if (!$r) {
        return;
    }
    if ($r[0]['item_type'] == ITEM_TYPE_PDL) {
        $r[0]['body'] = t('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.');
        $r[0]['mimetype'] = 'text/plain';
        $r[0]['title'] = '';
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
Esempio n. 4
0
function page_content(&$a)
{
    $r = $a->data['webpage'];
    if (!$r) {
        return;
    }
    if ($r[0]['item_restrict'] == ITEM_PDL) {
        $r[0]['body'] = t('Lorem Ipsum');
        $r[0]['mimetype'] = 'text/plain';
        $r[0]['title'] = '';
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
Esempio n. 5
0
function page_content(&$a)
{
    $r = $a->data['webpage'];
    if (!$r) {
        return;
    }
    // logger('layout: ' . print_r($a->layout,true));
    // Use of widgets should be determined by Comanche, but we don't have it on system pages yet, so...
    // I recommend we now get rid of this bit - it's quite a hack to work around... - mike
    if ($perms['write_pages']) {
        $chan = $a->channel['channel_id'];
        $who = $channel_address;
        $which = $r[0]['id'];
        $o .= writepages_widget($who, $which);
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
Esempio n. 6
0
function block_content(&$a)
{
    if (!perm_is_allowed($a->profile['profile_uid'], get_observer_hash(), 'view_pages')) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if (argc() < 3) {
        notice(t('Invalid item.') . EOL);
        return;
    }
    $channel_address = argv(1);
    $page_id = argv(2);
    $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
    if (!$u) {
        notice(t('Channel not found.') . EOL);
        return;
    }
    if ($_REQUEST['rev']) {
        $revision = " and revision = " . intval($_REQUEST['rev']) . " ";
    } else {
        $revision = " order by revision desc ";
    }
    require_once 'include/security.php';
    $sql_options = item_permissions_sql($u[0]['channel_id']);
    $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and \n\t\titem_type = %d {$sql_options} {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_BLOCK));
    if (!$r) {
        // Check again with no permissions clause to see if it is a permissions issue
        $x = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\twhere item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and \n\t\titem_type = %d {$revision} limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_TYPE_BLOCK));
        if ($x) {
            // Yes, it's there. You just aren't allowed to see it.
            notice(t('Permission denied.') . EOL);
        } else {
            notice(t('Page not found.') . EOL);
        }
        return;
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
Esempio n. 7
0
function widget_item($arr)
{
    $uid = $a->profile['profile_uid'];
    if (!$uid || !$arr['mid']) {
        return '';
    }
    if (!perm_is_allowed($uid, get_observer_hash(), 'view_pages')) {
        return '';
    }
    require_once 'include/security.php';
    $sql_extra = item_permissions_sql($uid);
    $r = q("select * from item where mid = '%s' and uid = %d and item_restrict = " . intval(ITEM_WEBPAGE) . " {$sql_extra} limit 1", dbesc($arr['mid']), intval($uid));
    if (!$r) {
        return '';
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o .= prepare_page($r[0]);
    return $o;
}
<html><title>PracSys: Ateneo DISCS Practicum Management System</title>
	<link rel="stylesheet" href="style.css">

		<?php 
include 'page_setup.php';
$user = prepare_page();
?>
		<div id='body2'>
			<center>
				<h1> UPDATE ACCOUNT INFORMATION </h1><br>
				<?php 
$conn = sql_setup();
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$quer = "SELECT * FROM account WHERE Username = '******'";
$temp = mysqli_query($conn, $quer);
$results = mysqli_fetch_array($temp);
echo "Username: "******"<br>";
echo "E-mail Address: " . $results['Email'] . "<br>";
echo "Name: " . $results['Name'] . "<br>";
echo "Contact Number: " . $results['ContactNumber'] . "<br>";
?>
				<br>
				*Re-type fields even if only one of them needs updating
				<form action = "edit_info.php">
					New E-mail Address: <input type = "text" name = "email" value = ""> <br> 
					New Contact Number: <input type = "text" name = "contactNum" value = ""> <br><br>
				<input type = "submit" value = "Update Info" onclick="this.disabled=true;this.value='Sending, please wait...';this.form.submit();"> <br>
			</center>
		</div>
<html><title>PracSys: Ateneo DISCS Practicum Management System</title>
<link rel="stylesheet" href="style.css">
<?php 
include 'page_setup.php';
prepare_page();
?>
<div id = "body2">
	<center>
		<?php 
$success = true;
$string = $_GET['mentorName'];
$tok = explode(" : ", $string);
$mentorUsername = $tok[1];
$student = $_GET['student'];
$conn = sql_setup();
if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$quer = "UPDATE account_student\n\t\t\tSET Mentor = '{$mentorUsername}'\n\t\t\tWHERE Username = '******'";
if (!($arr = mysqli_query($conn, $quer))) {
    $success = false;
    $error = mysqli_error($conn);
    echo "ERROR LINKING ACCOUNTS<br>";
    die('Error: ' . $error);
}
if ($success) {
    echo "<h1> SUCCESSFULLY LINKED STUDENT AND MENTOR! <h1>";
}
?>
		<br>
		<a href = 'home.php'><button> Return Home </button></a>
<html><title>PracSys: Ateneo DISCS Practicum Management System</title>
<link rel="stylesheet" href="style.css">
<head>
<?php 
include 'page_setup.php';
$temp = prepare_page();
$con = sql_setup();
if (mysqli_connect_errno()) {
    die("Failed to connect to MySQL: " . mysqli_connect_error());
}
?>
</head>
<body>
<div id='body2'>
<center>
<?php 
$result = mysqli_query($con, "SELECT * FROM Form WHERE Active=TRUE;");
echo "<h1>Form List</h1><br>";
echo "<table class=\"custom\">";
echo "<tr><th>Form Name</th><th>Status</th></tr>";
$count = 0;
while ($row = mysqli_fetch_array($result)) {
    if (strpos($row['AccountPath'], 'S') === FALSE) {
        continue;
    }
    echo "<tr" . ($count++ % 2 == 0 ? "" : " class=\"alt\"") . ">";
    $tmp = $row['ID'];
    $tmp2 = $row['Name'];
    echo "<td><a href=\"DisplayForm.php?id={$tmp}&username={$temp}\">{$tmp2}</a></td>";
    $resultb = mysqli_query($con, "SELECT * FROM FormInstance WHERE Username='******' AND FormID={$tmp};");
    echo "<td>";
Esempio n. 11
0
function widget_item($arr)
{
    $channel_id = 0;
    if (array_key_exists('channel_id', $arr) && intval($arr['channel_id'])) {
        $channel_id = intval($arr['channel_id']);
    }
    if (!$channel_id) {
        $channel_id = get_app()->profile_uid;
    }
    if (!$channel_id) {
        return '';
    }
    if (!$arr['mid'] && !$arr['title']) {
        return '';
    }
    if (!perm_is_allowed($channel_id, get_observer_hash(), 'view_pages')) {
        return '';
    }
    require_once 'include/security.php';
    $sql_extra = item_permissions_sql($channel_id);
    if ($arr['title']) {
        $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and item_type = %d {$sql_options} {$revision} limit 1", intval($channel_id), dbesc($arr['title']), intval(ITEM_TYPE_WEBPAGE));
    } else {
        $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " {$sql_extra} limit 1", dbesc($arr['mid']), intval($channel_id));
    }
    if (!$r) {
        return '';
    }
    xchan_query($r);
    $r = fetch_post_tags($r, true);
    $o = prepare_page($r[0]);
    return $o;
}
Esempio n. 12
0
function home_content(&$a, $update = 0, $load = false)
{
    $o = '';
    if ($load) {
        $_SESSION['loadtime'] = datetime_convert();
    }
    if (x($_SESSION, 'theme')) {
        unset($_SESSION['theme']);
    }
    if (x($_SESSION, 'mobile_theme')) {
        unset($_SESSION['mobile_theme']);
    }
    $splash = argc() > 1 && argv(1) === 'splash' ? true : false;
    if (get_config('system', 'projecthome')) {
        $o .= file_get_contents('assets/home.html');
        $a->page['template'] = 'full';
        $a->page['title'] = t('Red Matrix - &quot;The Network&quot;');
        return $o;
    }
    // Deprecated
    $channel_address = get_config("system", "site_channel");
    // See if the sys channel set a homepage
    if (!$channel_address) {
        require_once 'include/identity.php';
        $u = get_sys_channel();
        if ($u) {
            $u = array($u);
            // change to channel_id when below deprecated and skip the $u=...
            $channel_address = $u[0]['channel_address'];
        }
    }
    if ($channel_address) {
        $page_id = 'home';
        $u = q("select channel_id from channel where channel_address = '%s' limit 1", dbesc($channel_address));
        $r = q("select item.* from item left join item_id on item.id = item_id.iid\n\t\t\twhere item.uid = %d and sid = '%s' and service = 'WEBPAGE' and \n\t\t\titem_restrict = %d limit 1", intval($u[0]['channel_id']), dbesc($page_id), intval(ITEM_WEBPAGE));
        if ($r) {
            xchan_query($r);
            $r = fetch_post_tags($r, true);
            if ($r[0]['layout_mid']) {
                $l = q("select body from item where mid = '%s' and uid = %d limit 1", dbesc($r[0]['layout_mid']), intval($u[0]['channel_id']));
                if ($l) {
                    require_once 'include/comanche.php';
                    comanche_parser($a, $l[0]['body']);
                    $a->pdl = $l[0]['body'];
                }
            }
            $a->profile = array('profile_uid' => $u[0]['channel_id']);
            $a->profile_uid = $u[0]['channel_id'];
            $o .= prepare_page($r[0]);
            return $o;
        }
    }
    // Nope, we didn't find an item.  Let's see if there's any html
    if (file_exists('home.html')) {
        $o .= file_get_contents('home.html');
    } else {
        $sitename = get_config('system', 'sitename');
        if ($sitename) {
            $o .= '<h1>' . sprintf(t("Welcome to %s"), $sitename) . '</h1>';
        }
        if (intval(get_config('system', 'block_public')) && !local_channel() && !remote_channel()) {
            // If there's nothing special happening, just spit out a login box
            if (!$a->config['system']['no_login_on_homepage']) {
                $o .= login($a->config['system']['register_policy'] == REGISTER_CLOSED ? 0 : 1);
            }
            return $o;
        } else {
            if (get_config('system', 'disable_discover_tab')) {
                call_hooks('home_content', $o);
                return $o;
            }
            if (!$update) {
                $maxheight = get_config('system', 'home_divmore_height');
                if (!$maxheight) {
                    $maxheight = 75;
                }
                $o .= '<div id="live-home"></div>' . "\r\n";
                $o .= "<script> var profile_uid = " . (intval(local_channel()) ? local_channel() : -1) . "; var profile_page = " . $a->pager['page'] . "; divmore_height = " . intval($maxheight) . "; </script>\r\n";
                $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"), array('$baseurl' => z_root(), '$pgtype' => 'home', '$uid' => local_channel() ? local_channel() : '0', '$gid' => '0', '$cid' => '0', '$cmin' => '0', '$cmax' => '99', '$star' => '0', '$liked' => '0', '$conv' => '0', '$spam' => '0', '$fh' => '1', '$nouveau' => '0', '$wall' => '0', '$list' => '0', '$page' => $a->pager['page'] != 1 ? $a->pager['page'] : 1, '$search' => '', '$order' => 'comment', '$file' => '', '$cats' => '', '$tags' => '', '$dend' => '', '$mid' => '', '$verb' => '', '$dbegin' => ''));
            }
            if ($update && !$load) {
                // only setup pagination on initial page view
                $pager_sql = '';
            } else {
                $a->set_pager_itemspage(20);
                $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start']));
            }
            require_once 'include/identity.php';
            if (get_config('system', 'site_firehose')) {
                require_once 'include/security.php';
                $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0  and (item_flags & " . intval(ITEM_WALL) . " ) > 0 ";
            } else {
                $sys = get_sys_channel();
                $uids = " and item.uid  = " . intval($sys['channel_id']) . " ";
                $a->data['firehose'] = intval($sys['channel_id']);
            }
            $page_mode = 'list';
            $simple_update = $update ? " and item.item_unseen = 1 " : '';
            if ($update && $_SESSION['loadtime']) {
                $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' )  OR item.changed > '" . datetime_convert('UTC', 'UTC', $_SESSION['loadtime']) . "' ) ";
            }
            if ($load) {
                $simple_update = '';
            }
            //logger('update: ' . $update . ' load: ' . $load);
            if ($update) {
                $ordering = "commented";
                if ($load) {
                    // Fetch a page full of parent items for this page
                    $r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent = item.id\n\t\t\t\t\t\tand ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}\n\t\t\t\t\t\tORDER BY {$ordering} DESC {$pager_sql} ", intval(ABOOK_FLAG_BLOCKED));
                } elseif ($update) {
                    $r = q("SELECT distinct item.id AS item_id, {$ordering} FROM item\n\t\t\t\t\t\tleft join abook on item.author_xchan = abook.abook_xchan\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent = item.id {$simple_update}\n\t\t\t\t\t\tand ((abook.abook_flags & %d) = 0 or abook.abook_flags is null)\n\t\t\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets}", intval(ABOOK_FLAG_BLOCKED));
                    $_SESSION['loadtime'] = datetime_convert();
                }
                // Then fetch all the children of the parents that are on this page
                $parents_str = '';
                $update_unseen = '';
                if ($r) {
                    $parents_str = ids_to_querystr($r, 'item_id');
                    $items = q("SELECT item.*, item.id AS item_id FROM item\n\t\t\t\t\t\tWHERE true {$uids} AND item.item_restrict = 0\n\t\t\t\t\t\tAND item.parent IN ( %s )\n\t\t\t\t\t\t{$sql_extra} ", dbesc($parents_str));
                    xchan_query($items, true, -1);
                    $items = fetch_post_tags($items, true);
                    $items = conv_sort($items, $ordering);
                } else {
                    $items = array();
                }
            }
            // fake it
            $mode = 'network';
            $o .= conversation($a, $items, $mode, $update, $page_mode);
            if ($items && !$update) {
                $o .= alt_pager($a, count($items));
            }
            return $o;
        }
        call_hooks('home_content', $o);
        return $o;
    }
    return $o;
}