示例#1
0
    function SitepresenterEditSlideForm()
    {
        parent::MailForm();
        $this->parseSettings('inc/app/sitepresenter/forms/edit/slide/settings.php');
        page_add_script('
			function cms_cancel (f) {
				if (arguments.length == 0) {
					window.location.href = "/index/cms-app";
				} else {
					if (f.elements["_return"] && f.elements["_return"].value.length > 0) {
						window.location.href = f.elements["_return"].value;
					} else {
						window.location.href = "/index/sitepresenter-app";
					}
				}
				return false;
			}
		');
        $this->widgets['submit_button']->buttons[1]->extra = 'onclick="return cms_cancel (this.form)"';
        global $cgi;
        page_title(intl_get('Adding Slide to Presentation') . ': ' . db_shift('select title from sitepresenter_presentation where id = ?', $cgi->presentation));
        $res = db_single('select * from sitepresenter_slide where id = ?', $cgi->id);
        foreach (get_object_vars($res) as $k => $v) {
            $this->widgets[$k]->setValue($v);
        }
    }
示例#2
0
 function SiteblogCommentForm()
 {
     parent::MailForm();
     global $cgi;
     $this->parseSettings('inc/app/siteblog/forms/comment/settings.php');
     if (isset($cgi->_key) && !empty($cgi->_key)) {
         //edit a comment
         page_title('Editing Comment');
         $comment = db_single('select * from siteblog_comment where id = ?', $cgi->_key);
         $this->widgets['name']->setValue($comment->author);
         $this->widgets['email']->setValue($comment->email);
         $this->widgets['url']->setValue($comment->url);
         $this->widgets['body']->setValue($comment->body);
     } elseif (!isset($cgi->post)) {
         header('Location: ' . site_prefix() . '/index');
         exit;
     } else {
         if (session_valid()) {
             $this->widgets['name']->setValue(session_username());
             $user = session_get_user();
             $this->widgets['email']->setValue($user->email);
             $this->widgets['url']->setValue($user->website);
         }
         $this->widgets['post']->setValue($cgi->post);
         //page_title ('Post a Comment');
     }
     if (!appconf('comments_security')) {
         unset($this->widgets['security_test']);
     }
 }
示例#3
0
 function SiteblogPropertiesForm()
 {
     parent::MailForm();
     global $cgi;
     if (empty($cgi->blog)) {
         return;
     }
     $this->parseSettings('inc/app/siteblog/forms/properties/settings.php');
     page_title('Editing Category Properties: ' . $cgi->blog);
     $category = db_single('select * from siteblog_category where id = ?', $cgi->blog);
     $set = array();
     if ($category->comments == 'on') {
         $set[] = 'Enable Comments';
     }
     if ($category->poster_visible == 'yes') {
         $set[] = 'Author Visible';
     }
     if ($category->display_rss == 'yes') {
         $set[] = 'Include RSS Links';
     }
     if ($category->status == 'on') {
         $set[] = 'Enabled';
     }
     $this->widgets['blog_properties']->setValue($set);
     $this->widgets['blog']->setValue($cgi->blog);
     $this->widgets['refer']->setValue($_SERVER['HTTP_REFERER']);
 }
示例#4
0
    function SiteglossaryEditForm()
    {
        parent::MailForm();
        $this->parseSettings('inc/app/siteglossary/forms/edit/settings.php');
        global $cgi;
        page_title(intl_get('Editing Glossary Term') . ': ' . $cgi->_key);
        page_add_script('
			function cms_cancel (f) {
				if (arguments.length == 0) {
					window.location.href = "/index/cms-app";
				} else {
					if (f.elements["_return"] && f.elements["_return"].value.length > 0) {
						window.location.href = f.elements["_return"].value;
					} else {
						window.location.href = "/index/siteglossary-app";
					}
				}
				return false;
			}
		');
        // add cancel handler
        $this->widgets['submit_button']->buttons[1]->extra = 'onclick="return cms_cancel (this.form)"';
        $res = db_single('select * from siteglossary_term where word = ?', $cgi->_key);
        foreach (get_object_vars($res) as $k => $v) {
            $this->widgets[$k]->setValue($v);
        }
    }
function flickr_places_get_by_woeid($woeid, $more = array())
{
    if (!isset($more['force'])) {
        if (isset($GLOBALS['flickr_places_cache'][$woeid])) {
            return $GLOBALS['flickr_places_cache'][$woeid];
        }
        # filter by date too?
        $enc_woeid = AddSlashes($woeid);
        $sql = "SELECT * FROM Places WHERE woeid='{$enc_woeid}'";
        if ($row = db_single(db_fetch($sql))) {
            $place = json_decode($row['flickr_data'], "as hash");
            $GLOBALS['flickr_places_cache'][$woeid] = $place;
            return $place;
        }
    }
    $rsp = _flickr_places_getinfo($woeid);
    if (!$rsp['ok']) {
        return null;
    }
    $place = $rsp['rsp']['place'];
    $insert = array('woeid' => AddSlashes($woeid), 'flickr_data' => AddSlashes(json_encode($place)), 'date_created' => time());
    $rsp = db_insert('Places', $insert);
    $GLOBALS['flickr_places_cache'][$woeid] = $place;
    return $place;
}
function flickr_push_subscriptions_get_by_user_and_topic(&$user, $topic_id, $topic_args = null)
{
    if ($topic_args) {
        $topic_args = json_encode($topic_args);
    }
    $cache_key = "flickr_push_subscriptions_user_{$user['id']}_{$topic_id}";
    if ($topic_args) {
        $cache_key .= "#" . md5($topic_args);
    }
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        $row = $cache['data'];
    } else {
        $enc_id = AddSlashes($user['id']);
        $enc_topic = AddSlashes($topic_id);
        $enc_args = $topic_args ? AddSlashes($topic_args) : "";
        $sql = "SELECT * FROM FlickrPushSubscriptions WHERE user_id='{$enc_id}' AND topic_id='{$enc_topic}' AND topic_args='{$enc_args}'";
        $rsp = db_fetch($sql);
        $row = db_single($rsp);
        if ($row) {
            cache_set($cache_key, $row, "cache locally");
        }
    }
    return $row;
}
示例#7
0
 /**
  * Retrieves the info from the most recent indexing.
  */
 function getCurrentIndex()
 {
     $res = db_single('select * from sitesearch_index order by mtime desc limit 1');
     if (!$res) {
         $this->error = db_error();
     }
     return $res;
 }
function flickr_contacts_get_contact($user_id, $contact_id)
{
    $user = users_get_by_id($user_id);
    $cluster_id = $user['cluster_id'];
    $enc_user = AddSlashes($user_id);
    $enc_contact = AddSlashes($contact_id);
    $sql = "SELECT * FROM FlickrContacts WHERE user_id='{$enc_user}' AND contact_id='{$enc_contact}'";
    $rsp = db_fetch_users($cluster_id, $sql);
    return db_single($rsp);
}
function foursquare_users_random_user()
{
    $sql = "SELECT COUNT(user_id) AS count FROM FoursquareUsers";
    $rsp = db_single(db_fetch($sql));
    $count = $rsp['count'];
    $offset = $count == 1 ? 0 : rand(1, $count - 1);
    $sql = "SELECT * FROM FoursquareUsers LIMIT 1 OFFSET {$offset}";
    $rsp = db_single(db_fetch($sql));
    return $rsp;
}
示例#10
0
 function DeadlinesEditForm()
 {
     parent::MailForm();
     $this->parseSettings('inc/app/deadlines/forms/edit/settings.php');
     page_title('Deadlines - Edit Item');
     global $cgi;
     $res = db_single('select * from deadlines where id = ?', $cgi->id);
     foreach ((array) $res as $k => $v) {
         $this->widgets[$k]->setValue($v);
     }
 }
示例#11
0
 function SiteinvoiceEditClientForm()
 {
     parent::MailForm();
     $this->parseSettings('inc/app/siteinvoice/forms/edit/client/settings.php');
     global $cgi;
     page_title('SiteInvoice - Editing Client: ' . $cgi->id);
     $client = db_single('select * from siteinvoice_client where id = ?', $cgi->id);
     foreach (get_object_vars($client) as $k => $v) {
         $this->widgets[$k]->setValue($v);
     }
 }
function flickr_faves_count_for_user(&$user, $more = array())
{
    $defaults = array('viewer_id' => 0);
    $more = array_merge($defaults, $more);
    $cluster_id = $user['cluster_id'];
    $enc_user = AddSlashes($user['id']);
    # TO DO: perms
    $sql = "SELECT COUNT(photo_id) AS cnt FROM FlickrFaves WHERE user_id='{$enc_user}' {$extra}";
    $row = db_single(db_fetch_users($cluster_id, $sql));
    return $row['cnt'];
}
示例#13
0
 function TodoEditForm()
 {
     parent::MailForm();
     $this->parseSettings('inc/app/todo/forms/edit/settings.php');
     global $cgi;
     $f = db_single('select * from todo_list where id = ?', $cgi->id);
     $this->widgets['todo']->setValue($f->todo);
     $this->widgets['priority']->setValue($f->priority);
     $this->widgets['project']->setValue($f->project);
     $this->widgets['person']->setValue($f->person);
 }
示例#14
0
 function SitememberHomepageForm()
 {
     parent::MailForm();
     $this->parseSettings('inc/app/sitemember/forms/homepage/settings.php');
     page_title(intl_get('Editing') . ' ' . session_username() . '\'s ' . intl_get('Homepage'));
     $res = db_single('select * from sitellite_homepage where user = ?', session_username());
     if (is_object($res)) {
         $this->widgets['title']->setValue($res->title);
         $this->widgets['template']->setValue($res->template);
         $this->widgets['body']->setValue($res->body);
     }
 }
示例#15
0
function timetracker_filter_username($user)
{
    $info = db_single('select firstname, lastname from sitellite_user where username = ?', $user);
    if (!empty($info->lastname)) {
        $out = $info->lastname;
        if (!empty($info->firstname)) {
            $out .= ', ' . $info->firstname;
        }
    } else {
        $out = $user;
    }
    return $out;
}
示例#16
0
function login_check_login()
{
    $auth_cookie = $_COOKIE[$GLOBALS['cfg']['auth_cookie_name']];
    if (!$auth_cookie) {
        return;
    }
    $auth_cookie_enc = AddSlashes($auth_cookie);
    $user = db_single(db_fetch("SELECT * FROM glitchmash_players WHERE oauth_token='{$auth_cookie_enc}'"));
    if (!$user['tsid']) {
        return;
    }
    $GLOBALS['cfg']['user'] = $user;
}
function flickr_users_path_aliases_get_by_alias($alias)
{
    $cache_key = "flickr_user_path_aliases_{$alias}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $enc_alias = AddSlashes($alias);
    $sql = "SELECT * FROM FlickrUsersPathAliases WHERE path_alias='{$enc_alias}'";
    $row = db_single(db_fetch($sql));
    cache_set($cache_key, $row, "cache locally");
    return $row;
}
示例#18
0
function get_room_depth($room_id)
{
    if ($room_id == 1) {
        return 1;
    }
    //list($parent_room_id) = mysql_num_rows(mysql_query("SELECT id FROM choose_rooms WHERE room_1=".$room_id." OR room_2=".$room_id));
    $parent_room_id = db_single(mysql_query("SELECT id FROM choose_rooms WHERE room_1=" . $room_id . " OR room_2=" . $room_id));
    //echo "<!-- Parent ID: ".$parent_room_id['id']." --/>";
    if ($parent_room_id['id']) {
        return 1 + get_room_depth($parent_room_id['id']);
    }
    return 1;
}
function dots_lookup_dot($dot_id)
{
    $cache_key = "dots_lookup_{$dot_id}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $enc_id = AddSlashes($dot_id);
    $sql = "SELECT * FROM DotsLookup WHERE dot_id='{$enc_id}'";
    $rsp = db_fetch($sql);
    if ($rsp['ok']) {
        cache_set($cache_key, $rsp, 'cache locally');
    }
    return db_single($rsp);
}
function reverse_geoplanet($lat, $lon, $remote_endpoint = '')
{
    # this takes care of its own caching
    if ($remote_endpoint) {
        return _reverse_geoplanet_remote($lat, $lon, $remote_endpoint);
    }
    $cache_key = _reverse_geoplanet_cache_key($lat, $lon);
    # try to pull it out of memcache
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return okay($cache);
    }
    # try to pull it out of the local db
    list($short_lat, $short_lon, $geohash) = _reverse_geoplanet_shorten($lat, $lon);
    $enc_hash = AddSlashes($geohash);
    $sql = "SELECT * FROM reverse_geoplanet WHERE geohash='{$enc_hash}'";
    $rsp = db_single(db_fetch($sql));
    if ($rsp) {
        cache_set($cache_key, $rsp, "cache locally");
        return okay(array('data' => $rsp));
    }
    # try to pull it out of flickr
    $loc = geo_flickr_reverse_geocode($lat, $lon);
    if (!$loc) {
        return not_okay("failed to reverse geocode");
    }
    $woeid = $loc['woeid'];
    $loc = geo_flickr_get_woeid($loc['woeid']);
    if (!$loc) {
        return not_okay("failed to retrieve data for WOE ID '{$loc['woeid']}");
    }
    if (!$loc['woeid']) {
        return not_okay("failed to parse data for WOE ID '{$loc['woeid']}");
    }
    #
    $hierarchy = array();
    foreach (array('locality', 'region', 'country') as $placetype) {
        $hierarchy[$placetype] = $loc[$placetype]['woeid'];
    }
    $now = time();
    $data = array('latitude' => $short_lat, 'longitude' => $short_lon, 'geohash' => $geohash, 'woeid' => $loc['woeid'], 'locality' => $hierarchy['locality'], 'region' => $hierarchy['region'], 'country' => $hierarchy['country'], 'name' => $loc['name'], 'placetype' => $loc['place_type_id'], 'created' => $now);
    $rsp = reverse_geoplanet_add($data);
    if (!$rsp['ok']) {
        return $rsp;
    }
    return $rsp;
}
示例#21
0
 function getTrail($id, $limit, $incl_self = false)
 {
     if (!$id || $id == '') {
         return array();
     }
     $trail = array();
     if ($incl_self) {
         $trail[] = (object) array('id' => $id, 'title' => $this->getTitle($id));
     }
     $parent = db_shift('select below_page from sitellite_page where id = ?', $id);
     while ($parent) {
         $next = db_single('select id, if(nav_title != "", nav_title, if(title != "", title, id)) as title, below_page from sitellite_page where id = ?', $parent);
         if (is_object($next)) {
             $trail[] = (object) array('id' => $next->id, 'title' => $next->title);
             $parent = $next->below_page;
         } else {
             $parent = false;
         }
     }
     $trail = array_reverse($trail);
     $out = array((object) array('id' => '', 'title' => intl_get('Root')));
     foreach ($trail as $item) {
         //info ($item);
         if (!$incl_self && $item->id == $id) {
             continue;
         }
         $out[] = (object) array('id' => $item->id, 'title' => $item->title);
     }
     //exit;
     return $out;
     /*
     		if (! $id || $id == '') {
     			return array ();
     		}
     		global $menu;
     		$out = array ((object) array ('id' => '', 'title' => intl_get ('Root')));
     		foreach ($menu->trail ($id) as $item) {
     			//info ($item);
     			if (! $incl_self && $item->id == $id) {
     				continue;
     			}
     			$out[] = (object) array ('id' => $item->id, 'title' => $item->title);
     		}
     		//exit;
     		return $out;
     */
 }
示例#22
0
    function SiteforumPostForm()
    {
        parent::MailForm();
        page_title(intl_get('Post a Message'));
        $this->parseSettings('inc/app/siteforum/forms/post/settings.php');
        page_add_script('
			function siteforum_preview (f) {
				t = f.target;
				a = f.action;

				f.target = "_blank";
				f.action = "' . site_prefix() . '/index/siteforum-post-preview-action";
				f.submit ();

				f.target = t;
				f.action = a;
				return false;
			}

			function siteforum_insert_tag (tag) {
				e = document.getElementById ("siteforum-body");
				if (tag == "a") {
					e.value += "<a href=\\"http://\\"></a>";
				} else {
					e.value += "<" + tag + "></" + tag + ">";
				}
				return false;
			}
		');
        global $cgi;
        $this->widgets['submit_button']->buttons[1]->extra = 'onclick="return siteforum_preview (this.form)"';
        $this->widgets['submit_button']->buttons[2]->extra = 'onclick="history.go (-1); return false"';
        if (!empty($cgi->quote)) {
            $obj = db_single('select * from siteforum_post where id = ?', $cgi->quote);
            if (strpos($obj->subject, 'Re: ') !== 0) {
                $obj->subject = 'Re: ' . $obj->subject;
            }
            $this->widgets['subject']->setValue($obj->subject);
            $this->widgets['body']->setValue("<strong>" . $obj->user_id . " said:</strong>\n" . "<blockquote>" . $obj->body . "</blockquote>\n\n");
        }
        if (!session_admin()) {
            $this->widgets['notice'] = new MF_Widget_hidden('notice');
            $this->widgets['notice']->form =& $this;
            $this->widgets['notice']->setValue('no');
        }
    }
function api_oauth2_grant_tokens_get_for_user_and_key(&$user, &$key)
{
    $cache_key = "oauth2_grant_token_uk_{$user['id']}_{$key['id']}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $enc_user = AddSlashes($user['id']);
    $enc_key = AddSlashes($key['id']);
    $sql = "SELECT * FROM OAuth2GrantTokens WHERE user_id='{$enc_user}' AND api_key_id='{$enc_key}'";
    $rsp = db_fetch($sql);
    $row = db_single($rsp);
    if ($rsp['ok']) {
        cache_set($cache_key, $row);
    }
    return $row;
}
示例#24
0
	function delete_room($id){

		$room = db_single(db_fetch("SELECT * FROM choose_rooms WHERE id=$id"));
		$parent	= db_single(db_fetch("SELECT * FROM choose_rooms WHERE room_1=$id OR room_2=$id"));

		if ($room[room_1]) return 0;
		if ($room[room_2]) return 0;

		db_write("DELETE FROM choose_rooms WHERE id=$id");

		if ($parent[id]){
			db_write("UPDATE choose_rooms SET room_1=0 WHERE id=$parent[id] AND room_1=$id");
			db_write("UPDATE choose_rooms SET room_2=0 WHERE id=$parent[id] AND room_2=$id");
		}

		return 1;
	}
示例#25
0
function delete_room($id)
{
    $room = db_single(mysql_query("SELECT * FROM choose_rooms WHERE id=" . $id));
    $parent = db_single(mysql_query("SELECT * FROM choose_rooms WHERE room_1=" . $id . " OR room_2=" . $id));
    if ($room['room_1']) {
        return 0;
    }
    if ($room['room_2']) {
        return 0;
    }
    db_write("DELETE FROM choose_rooms WHERE id=" . $id);
    if ($parent['id']) {
        db_write("UPDATE choose_rooms SET room_1=0 WHERE id=" . $parent['id'] . " AND room_1=" . $id);
        db_write("UPDATE choose_rooms SET room_2=0 WHERE id=" . $parent['id'] . " AND room_2=" . $id);
    }
    return 1;
}
示例#26
0
    function DiggerCommentsEditForm()
    {
        parent::MailForm();
        $this->parseSettings('inc/app/digger/forms/comments/edit/settings.php');
        page_title(intl_get('Editing Comment'));
        global $cgi;
        $comment = db_single('select * from digger_comments where id = ?', $cgi->id);
        $this->widgets['user']->setValue($comment->user);
        $this->widgets['comment_date']->setValue($comment->comment_date);
        $this->widgets['comments']->setValue($comment->comments);
        $this->widgets['story']->setValue($comment->story);
        page_add_script('
function digger_cancel (f) {
window.location.href = "' . site_prefix() . '/index/digger-comments-action/id.' . $cgi->story . '";
return false;
}
');
        $this->widgets['submit_button']->buttons[1]->extra = 'onclick="return digger_cancel (this.form)"';
    }
示例#27
0
function invite_codes_get_by_code($code, $ensure_sent = 1)
{
    $cache_key = "invite_codes_code_{$code}";
    $cache = cache_get($cache_key);
    if ($cache['ok']) {
        return $cache['data'];
    }
    $enc_code = AddSlashes($code);
    $sql = "SELECT * FROM InviteCodes WHERE code='{$code}'";
    $rsp = db_fetch($sql);
    $row = db_single($rsp);
    if ($ensure_sent && !$row['sent']) {
        $row = null;
    }
    if ($row) {
        cache_set($cache_key, $row, "cache locally");
    }
    return $row;
}
示例#28
0
    function getTopics()
    {
        if (session_admin()) {
            $perms = session_allowed_sql();
        } else {
            $perms = session_approved_sql();
        }
        $list = db_fetch_array('select * from siteforum_topic where ' . $perms . ' order by
name asc');
        foreach (array_keys($list) as $k) {
            $list[$k]->threads = db_shift('select count(*) from siteforum_post where topic_id = ? and post_id = ""', $list[$k]->id);
            $list[$k]->posts = db_shift('select count(*) from siteforum_post where topic_id = ?', $list[$k]->id);
            $obj = db_single('select ts, user_id, id from siteforum_post where topic_id = ? order by ts desc limit 1', $list[$k]->id);
            $list[$k]->last_post = $obj->ts;
            $list[$k]->last_post_user = $obj->user_id;
            $list[$k]->last_post_id = $obj->id;
            $list[$k]->last_post_user_public = db_shift('select public from sitellite_user where username = ?', $obj->user_id);
        }
        return $list;
    }
示例#29
0
 function getThread($post, $reverse = false)
 {
     if (session_admin()) {
         $perms = session_allowed_sql();
     } else {
         $perms = session_approved_sql();
     }
     if ($reverse) {
         $append = ' ORDER BY ts DESC';
     } else {
         $append = ' ORDER BY ts ASC';
     }
     $q = db_query('SELECT * FROM siteforum_post WHERE (id = ? OR post_id = ?) AND ' . $perms . $append);
     if ($q->execute($post, $post)) {
         $this->total = $q->rows();
         $res = $q->fetch($this->offset, $this->limit);
         $q->free();
     } else {
         $this->error = $q->error();
         return array();
     }
     foreach (array_keys($res) as $k) {
         $res[$k]->posts = db_shift('select count(*) from siteforum_post where user_id = ?', $res[$k]->user_id);
         $user = db_single('select public, province, country from sitellite_user where username = ?', $res[$k]->user_id);
         $res[$k]->public = $user->public;
         if ($user->public == 'yes') {
             $res[$k]->location = '';
             $concat = '';
             if (!empty($user->province)) {
                 $res[$k]->location .= $concat . $user->province;
                 $concat = ', ';
             }
             if (!empty($user->country)) {
                 $res[$k]->location .= $concat . $user->country;
             }
         }
     }
     return $res;
 }
示例#30
0
	function insertRoutes($id, $data){
		$count = 0;
		$room = db_single(db_fetch("SELECT * FROM choose_rooms WHERE id=$id"));
		if ($room[end_here]){
			print $data."<td bgcolor=\"#ffcccc\"><a href=\"room.php?room=$id\">$id</a></td></tr>";
			$count++;
		}else{
			$data .= "<td bgcolor=\"#eeeeee\"><a href=\"room.php?room=$id\">$id</a></td>";
			if ($room[room_1]){
				$count += insertRoutes($room[room_1],$data);
			}else{
				print $data."<td bgcolor=\"#cccccc\">0a</td></tr>";
				$count++;
			}
			if ($room[room_2]){
				$count += insertRoutes($room[room_2],$data);
			}else{
				print $data."<td bgcolor=\"#cccccc\">0b</td></tr>";
				$count++;
			}
		}
		return $count;
	}