当前位置: 首页>>代码示例>>PHP>>正文


PHP get_guid函数代码示例

本文整理汇总了PHP中get_guid函数的典型用法代码示例。如果您正苦于以下问题:PHP get_guid函数的具体用法?PHP get_guid怎么用?PHP get_guid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_guid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: privacy_image_cache_init

function privacy_image_cache_init()
{
    $urlhash = 'pic:' . sha1($_REQUEST['url']);
    $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' LIMIT 1", $urlhash);
    if (count($r)) {
        $img_str = $r[0]['data'];
        $mime = $r[0]["desc"];
        if ($mime == "") {
            $mime = "image/jpeg";
        }
    } else {
        require_once "Photo.php";
        $img_str = fetch_url($_REQUEST['url'], true);
        if (substr($img_str, 0, 6) == "GIF89a") {
            $mime = "image/gif";
            $image = @imagecreatefromstring($img_str);
            if ($image === FALSE) {
                die;
            }
            q("INSERT INTO `photo`\n\t\t\t( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `desc`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )\n\t\t\tVALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' )", 0, 0, get_guid(), dbesc($urlhash), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(basename(dbesc($_REQUEST["url"]))), dbesc(''), intval(imagesy($image)), intval(imagesx($image)), 'image/gif', dbesc($img_str), 100, intval(0), dbesc(''), dbesc(''), dbesc(''), dbesc(''));
        } else {
            $img = new Photo($img_str);
            if ($img->is_valid()) {
                $img->store(0, 0, $urlhash, $_REQUEST['url'], '', 100);
                $img_str = $img->imageString();
            }
            $mime = "image/jpeg";
        }
    }
    header("Content-type: {$mime}");
    header("Expires: " . gmdate("D, d M Y H:i:s", time() + 3600 * 24) . " GMT");
    header("Cache-Control: max-age=" . 3600 * 24);
    echo $img_str;
    killme();
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:35,代码来源:privacy_image_cache.php

示例2: gen_vs

	public function gen_vs($name) {
		$this->name = strtolower($name);
		$this->projects = array();

		foreach(array("lib", "dll", "util") as $type) {
			$name = "{$this->name}_{$type}";
			$this->projects[$type] = array("name"=>$name, "guid"=>get_guid($name));
		}

		$this->include_dirs = array("./", "../app/include", "../app/extensions", "../framework/include", "../framework/driver", "../framework/driver/x86");
	}
开发者ID:vstakhov,项目名称:blake2b-opt,代码行数:11,代码来源:genvs.php

示例3: terminate_friendship

function terminate_friendship($user, $self, $contact)
{
    $a = get_app();
    require_once 'include/datetime.php';
    if ($contact['network'] === NETWORK_OSTATUS) {
        $slap = replace_macros(get_markup_template('follow_slap.tpl'), array('$name' => $user['username'], '$profile_page' => $a->get_baseurl() . '/profile/' . $user['nickname'], '$photo' => $self['photo'], '$thumb' => $self['thumb'], '$published' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME), '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . get_guid(32), '$title' => '', '$type' => 'text', '$content' => t('stopped following'), '$nick' => $user['nickname'], '$verb' => 'http://ostatus.org/schema/1.0/unfollow', '$ostat_follow' => ''));
        if (x($contact, 'notify') && strlen($contact['notify'])) {
            require_once 'include/salmon.php';
            slapper($user, $contact['notify'], $slap);
        }
    } elseif ($contact['network'] === NETWORK_DIASPORA) {
        require_once 'include/diaspora.php';
        diaspora_unshare($user, $contact);
    } elseif ($contact['network'] === NETWORK_DFRN) {
        require_once 'include/items.php';
        dfrn_deliver($user, $contact, 'placeholder', 1);
    }
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:18,代码来源:Contact.php

示例4: save_business_unit

 /**
  * Save Business Unit
  *
  * @return void
  * @author
  **/
 function save_business_unit()
 {
     $out = array();
     if (!$_POST) {
         $out['error'] = 'No data';
     } elseif (isset($_POST['unitid'])) {
         $business_unit = new Business_unit();
         // Translate groups to single entries
         $translate = array('keys' => 'key', 'machine_groups' => 'machine_group', 'users' => 'user', 'managers' => 'manager');
         $unitid = $_POST['unitid'];
         // Check if new unit
         if ($unitid == 'new') {
             $unitid = $business_unit->get_max_unitid() + 1;
         }
         $out['unitid'] = $unitid;
         // Check if there are changed items
         if (isset($_POST['iteminfo'])) {
             $groups = array();
             // If sent a '#', no items are in the iteminfo array
             // proceed with empty groups array
             if (!in_array('#', $_POST['iteminfo'])) {
                 // Loop through iteminfo
                 foreach ($_POST['iteminfo'] as $entry) {
                     // No key, create new
                     if ($entry['key'] === '') {
                         $mg = new Machine_group();
                         $newgroup = $mg->get_max_groupid() + 1;
                         // Store name
                         $mg->merge(array('id' => '', 'groupid' => $newgroup, 'property' => 'name', 'value' => $entry['name']));
                         $mg->save();
                         // Store GUID key
                         $mg->merge(array('id' => '', 'groupid' => $newgroup, 'property' => 'key', 'value' => get_guid()));
                         $mg->save();
                         $groups[] = $newgroup;
                     } else {
                         // Add key to list
                         $groups[] = intval($entry['key']);
                     }
                 }
             }
             // Set new machine_groups to list
             $_POST['machine_groups'] = $groups;
             unset($_POST['iteminfo']);
         }
         foreach ($_POST as $property => $val) {
             // Skip unitid
             if ($property == 'unitid') {
                 continue;
             }
             if (is_scalar($val)) {
                 $business_unit->id = '';
                 $business_unit->retrieve_one('unitid=? AND property=?', array($unitid, $property));
                 $business_unit->unitid = $unitid;
                 $business_unit->property = $property;
                 $business_unit->value = $val;
                 $business_unit->save();
                 $out[$property] = $val;
             } else {
                 // Check if this is a valid property
                 if (!isset($translate[$property])) {
                     $out['error'][] = 'Illegal property: ' . $property;
                     continue;
                 }
                 // Translate property to db entry
                 $name = $translate[$property];
                 $business_unit->delete_where('unitid=? AND property=?', array($unitid, $name));
                 foreach ($val as $entry) {
                     // Empty array placeholder
                     if ($entry === '#') {
                         $out[$property] = array();
                         continue;
                     }
                     $business_unit->id = '';
                     $business_unit->unitid = $unitid;
                     $business_unit->property = $name;
                     $business_unit->value = is_numeric($entry) ? 0 + $entry : $entry;
                     $business_unit->save();
                     $out[$property][] = is_numeric($entry) ? 0 + $entry : $entry;
                 }
             }
         }
     } else {
         $out['error'] = 'Unitid missing';
     }
     $obj = new View();
     $obj->view('json', array('msg' => $out));
 }
开发者ID:pexner,项目名称:munkireport-php,代码行数:93,代码来源:admin.php

示例5: getSplashOnlyUser

 /**
  * Get's the splash-only user.
  *
  * This is the user that people logged-in at a splash-only hotspot will
  * show up as.  This user always has multiple-login capabilities.
  *
  * @param string $username The username of the user
  * @param string $account_origin The account origin
  *
  * @return object A User object
  *
  * @access public
  */
 public function getSplashOnlyUser()
 {
     $username = 'SPLASH_ONLY_USER';
     if (!empty($this->splashOnlyUser)) {
         $user = $this->splashOnlyUser;
     } else {
         $user = User::getUserByUsernameAndOrigin($username, $this);
         if (!$user) {
             $user = User::createUser(get_guid(), $username, $this, '', '');
             $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED);
         }
         $this->splashOnlyUser = $user;
     }
     return $user;
 }
开发者ID:cnlangzi,项目名称:wifidog-auth,代码行数:28,代码来源:Network.php

示例6: new_contact


//.........这里部分代码省略.........
            $result['message'] .= t('An author or name was not found.') . EOL;
        }
        if (!x($ret, 'url')) {
            $result['message'] .= t('No browser URL could be matched to this address.') . EOL;
        }
        if (strpos($url, '@') !== false) {
            $result['message'] .= t('Unable to match @-style Identity Address with a known protocol or email contact.') . EOL;
            $result['message'] .= t('Use mailto: in front of address to force email check.') . EOL;
        }
        return $result;
    }
    if ($ret['network'] === NETWORK_OSTATUS && get_config('system', 'ostatus_disabled')) {
        $result['message'] .= t('The profile address specified belongs to a network which has been disabled on this site.') . EOL;
        $ret['notify'] = '';
    }
    if (!$ret['notify']) {
        $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
    }
    $writeable = $ret['network'] === NETWORK_OSTATUS && $ret['notify'] ? 1 : 0;
    $subhub = $ret['network'] === NETWORK_OSTATUS ? true : false;
    $hidden = $ret['network'] === NETWORK_MAIL ? 1 : 0;
    if ($ret['network'] === NETWORK_MAIL) {
        $writeable = 1;
    }
    if ($ret['network'] === NETWORK_DIASPORA) {
        $writeable = 1;
    }
    // check if we already have a contact
    // the poll url is more reliable than the profile url, as we may have
    // indirect links or webfinger links
    $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `poll` IN ('%s', '%s') AND `network` = '%s' LIMIT 1", intval($uid), dbesc($ret['poll']), dbesc(normalise_link($ret['poll'])), dbesc($ret['network']));
    if (!count($r)) {
        $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` = '%s' LIMIT 1", intval($uid), dbesc(normalise_link($url)), dbesc($ret['network']));
    }
    if (count($r)) {
        // update contact
        if ($r[0]['rel'] == CONTACT_IS_FOLLOWER || $network === NETWORK_DIASPORA && $r[0]['rel'] == CONTACT_IS_SHARING) {
            q("UPDATE `contact` SET `rel` = %d , `subhub` = %d, `readonly` = 0 WHERE `id` = %d AND `uid` = %d", intval(CONTACT_IS_FRIEND), intval($subhub), intval($r[0]['id']), intval($uid));
        }
    } else {
        // check service class limits
        $r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0", intval($uid));
        if (count($r)) {
            $total_contacts = $r[0]['total'];
        }
        if (!service_class_allows($uid, 'total_contacts', $total_contacts)) {
            $result['message'] .= upgrade_message();
            return $result;
        }
        $r = q("select count(network) as total from contact where uid = %d and network = '%s' and pending = 0 and self = 0", intval($uid), dbesc($network));
        if (count($r)) {
            $total_network = $r[0]['total'];
        }
        if (!service_class_allows($uid, 'total_contacts_' . $network, $total_network)) {
            $result['message'] .= upgrade_message();
            return $result;
        }
        $new_relation = $ret['network'] === NETWORK_MAIL ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING;
        if ($ret['network'] === NETWORK_DIASPORA) {
            $new_relation = CONTACT_IS_FOLLOWER;
        }
        // create contact record
        $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `addr`, `alias`, `batch`, `notify`, `poll`, `poco`, `name`, `nick`, `network`, `pubkey`, `rel`, `priority`,\n\t\t\t`writable`, `hidden`, `blocked`, `readonly`, `pending`, `subhub` )\n\t\t\tVALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, 0, 0, 0, %d ) ", intval($uid), dbesc(datetime_convert()), dbesc($ret['url']), dbesc(normalise_link($ret['url'])), dbesc($ret['addr']), dbesc($ret['alias']), dbesc($ret['batch']), dbesc($ret['notify']), dbesc($ret['poll']), dbesc($ret['poco']), dbesc($ret['name']), dbesc($ret['nick']), dbesc($ret['network']), dbesc($ret['pubkey']), intval($new_relation), intval($ret['priority']), intval($writeable), intval($hidden), intval($subhub));
    }
    $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `network` = '%s' AND `uid` = %d LIMIT 1", dbesc($ret['url']), dbesc($ret['network']), intval($uid));
    if (!count($r)) {
        $result['message'] .= t('Unable to retrieve contact information.') . EOL;
        return $result;
    }
    $contact = $r[0];
    $contact_id = $r[0]['id'];
    $result['cid'] = $contact_id;
    $g = q("select def_gid from user where uid = %d limit 1", intval($uid));
    if ($g && intval($g[0]['def_gid'])) {
        require_once 'include/group.php';
        group_add_member($uid, '', $contact_id, $g[0]['def_gid']);
    }
    require_once "include/Photo.php";
    $photos = import_profile_photo($ret['photo'], $uid, $contact_id);
    $r = q("UPDATE `contact` SET `photo` = '%s',\n\t\t\t`thumb` = '%s',\n\t\t\t`micro` = '%s',\n\t\t\t`name-date` = '%s',\n\t\t\t`uri-date` = '%s',\n\t\t\t`avatar-date` = '%s'\n\t\t\tWHERE `id` = %d", dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(datetime_convert()), intval($contact_id));
    // pull feed and consume it, which should subscribe to the hub.
    proc_run('php', "include/onepoll.php", "{$contact_id}", "force");
    // create a follow slap
    $tpl = get_markup_template('follow_slap.tpl');
    $slap = replace_macros($tpl, array('$name' => $a->user['username'], '$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'], '$photo' => $a->contact['photo'], '$thumb' => $a->contact['thumb'], '$published' => datetime_convert('UTC', 'UTC', 'now', ATOM_TIME), '$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . get_guid(32), '$title' => '', '$type' => 'text', '$content' => t('following'), '$nick' => $a->user['nickname'], '$verb' => ACTIVITY_FOLLOW, '$ostat_follow' => ''));
    $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\tWHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid));
    if (count($r)) {
        if ($contact['network'] == NETWORK_OSTATUS && strlen($contact['notify'])) {
            require_once 'include/salmon.php';
            slapper($r[0], $contact['notify'], $slap);
        }
        if ($contact['network'] == NETWORK_DIASPORA) {
            require_once 'include/diaspora.php';
            $ret = diaspora_share($a->user, $contact);
            logger('mod_follow: diaspora_share returns: ' . $ret);
        }
    }
    $result['success'] = true;
    return $result;
}
开发者ID:ZerGabriel,项目名称:friendica,代码行数:101,代码来源:follow.php

示例7: item_is_remote_self

function item_is_remote_self($contact, &$datarray)
{
    $a = get_app();
    if (!$contact['remote_self']) {
        return false;
    }
    // Prevent the forwarding of posts that are forwarded
    if ($datarray["extid"] == NETWORK_DFRN) {
        return false;
    }
    // Prevent to forward already forwarded posts
    if ($datarray["app"] == $a->get_hostname()) {
        return false;
    }
    // Only forward posts
    if ($datarray["verb"] != ACTIVITY_POST) {
        return false;
    }
    if ($contact['network'] != NETWORK_FEED and $datarray['private']) {
        return false;
    }
    $datarray2 = $datarray;
    logger('remote-self start - Contact ' . $contact['url'] . ' - ' . $contact['remote_self'] . ' Item ' . print_r($datarray, true), LOGGER_DEBUG);
    if ($contact['remote_self'] == 2) {
        $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`", intval($contact['uid']));
        if (count($r)) {
            $datarray['contact-id'] = $r[0]["id"];
            $datarray['owner-name'] = $r[0]["name"];
            $datarray['owner-link'] = $r[0]["url"];
            $datarray['owner-avatar'] = $r[0]["thumb"];
            $datarray['author-name'] = $datarray['owner-name'];
            $datarray['author-link'] = $datarray['owner-link'];
            $datarray['author-avatar'] = $datarray['owner-avatar'];
        }
        if ($contact['network'] != NETWORK_FEED) {
            $datarray["guid"] = get_guid(32);
            unset($datarray["plink"]);
            $datarray["uri"] = item_new_uri($a->get_hostname(), $contact['uid'], $datarray["guid"]);
            $datarray["parent-uri"] = $datarray["uri"];
            $datarray["extid"] = $contact['network'];
            $urlpart = parse_url($datarray2['author-link']);
            $datarray["app"] = $urlpart["host"];
        } else {
            $datarray['private'] = 0;
        }
    }
    if ($contact['network'] != NETWORK_FEED) {
        // Store the original post
        $r = item_store($datarray2, false, false);
        logger('remote-self post original item - Contact ' . $contact['url'] . ' return ' . $r . ' Item ' . print_r($datarray2, true), LOGGER_DEBUG);
    } else {
        $datarray["app"] = "Feed";
    }
    return true;
}
开发者ID:EmilienB,项目名称:friendica,代码行数:55,代码来源:items.php

示例8: item_post


//.........这里部分代码省略.........
        $emailcc = $orig_post['emailcc'];
        $app = $orig_post['app'];
        $categories = $orig_post['file'];
        $title = notags(trim($_REQUEST['title']));
        $body = escape_tags(trim($_REQUEST['body']));
        $private = $orig_post['private'];
        $pubmail_enable = $orig_post['pubmail'];
        $network = $orig_post['network'];
        $guid = $orig_post['guid'];
        $extid = $orig_post['extid'];
    } else {
        // if coming from the API and no privacy settings are set,
        // use the user default permissions - as they won't have
        // been supplied via a form.
        if ($api_source && !array_key_exists('contact_allow', $_REQUEST) && !array_key_exists('group_allow', $_REQUEST) && !array_key_exists('contact_deny', $_REQUEST) && !array_key_exists('group_deny', $_REQUEST)) {
            $str_group_allow = $user['allow_gid'];
            $str_contact_allow = $user['allow_cid'];
            $str_group_deny = $user['deny_gid'];
            $str_contact_deny = $user['deny_cid'];
        } else {
            // use the posted permissions
            $str_group_allow = perms2str($_REQUEST['group_allow']);
            $str_contact_allow = perms2str($_REQUEST['contact_allow']);
            $str_group_deny = perms2str($_REQUEST['group_deny']);
            $str_contact_deny = perms2str($_REQUEST['contact_deny']);
        }
        $title = notags(trim($_REQUEST['title']));
        $location = notags(trim($_REQUEST['location']));
        $coord = notags(trim($_REQUEST['coord']));
        $verb = notags(trim($_REQUEST['verb']));
        $emailcc = notags(trim($_REQUEST['emailcc']));
        $body = escape_tags(trim($_REQUEST['body']));
        $network = notags(trim($_REQUEST['network']));
        $guid = get_guid(32);
        $naked_body = preg_replace('/\\[(.+?)\\]/', '', $body);
        if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
            $l = new Text_LanguageDetect();
            //$lng = $l->detectConfidence($naked_body);
            //$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
            $lng = $l->detect($naked_body, 3);
            if (sizeof($lng) > 0) {
                $postopts = "";
                foreach ($lng as $language => $score) {
                    if ($postopts == "") {
                        $postopts = "lang=";
                    } else {
                        $postopts .= ":";
                    }
                    $postopts .= $language . ";" . $score;
                }
            }
            logger('mod_item: detect language' . print_r($lng, true) . $naked_body, LOGGER_DATA);
        } else {
            $postopts = '';
        }
        $private = strlen($str_group_allow) || strlen($str_contact_allow) || strlen($str_group_deny) || strlen($str_contact_deny) ? 1 : 0;
        if ($user['hidewall']) {
            $private = 2;
        }
        // If this is a comment, set the permissions from the parent.
        if ($parent_item) {
            $private = 0;
            // for non native networks use the network of the original post as network of the item
            if ($parent_item['network'] != NETWORK_DIASPORA and $parent_item['network'] != NETWORK_OSTATUS and $network == "") {
                $network = $parent_item['network'];
            }
开发者ID:strk,项目名称:friendica,代码行数:67,代码来源:item.php

示例9: createNewObject

 /**
  * Create a new GraphElement object in the database
  *
  * @param string $element_id The element id of the new element.  Must be specified
  * @param string $element_type The element type of this element.  Must be specified
  *
  * @return mixed The newly created object, or null if there was an error
  *
  * @see GenericObject
  * @static
  * @access public
  */
 public static function createNewObject($element_id, $element_type, $parent_element = null)
 {
     $db = AbstractDb::getObject();
     $graph_element_id = get_guid();
     if (!(class_exists($element_type) && get_parent_class($element_type) == 'HotspotGraphElement')) {
         throw new Exception(_('Cannot add element to hotspot graph. Wrong type specified: ') . $element_type);
     }
     $sql = "INSERT INTO hotspot_graph_elements (hotspot_graph_element_id, element_id, element_type) VALUES ('{$graph_element_id}', '{$element_id}', '{$element_type}')";
     if (!$db->execSqlUpdate($sql, false)) {
         throw new Exception(_('Unable to insert the new element in the database!'));
     }
     $object = self::getObject($element_id, $element_type);
     if (!is_null($parent_element)) {
         if (method_exists($parent_element, 'getHgeId')) {
             $parentid = $parent_element->getHgeId();
             $childid = $object->getHgeId();
             HotspotGraph::addRelation($parentid, $childid);
         }
     }
     return $object;
 }
开发者ID:cnlangzi,项目名称:wifidog-auth,代码行数:33,代码来源:HotspotGraphElement.php

示例10: store

 public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
 {
     $r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1", dbesc($rid));
     if (count($r)) {
         $guid = $r[0]['guid'];
     } else {
         $guid = get_guid();
     }
     $r = q("INSERT INTO `photo`\n\t\t\t( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )\n\t\t\tVALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )", intval($uid), intval($cid), dbesc($guid), dbesc($rid), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc(basename($filename)), dbesc($album), intval($this->height), intval($this->width), dbesc($this->imageString()), intval($scale), intval($profile), dbesc($allow_cid), dbesc($allow_gid), dbesc($deny_cid), dbesc($deny_gid));
     return $r;
 }
开发者ID:nextgensh,项目名称:friendica,代码行数:11,代码来源:Photo.php

示例11: item_post


//.........这里部分代码省略.........
    $datarray['received'] = datetime_convert();
    $datarray['changed'] = datetime_convert();
    $datarray['uri'] = $uri;
    $datarray['title'] = $title;
    $datarray['body'] = $body;
    $datarray['app'] = $app;
    $datarray['location'] = $location;
    $datarray['coord'] = $coord;
    $datarray['tag'] = $str_tags;
    $datarray['inform'] = $inform;
    $datarray['verb'] = $verb;
    $datarray['allow_cid'] = $str_contact_allow;
    $datarray['allow_gid'] = $str_group_allow;
    $datarray['deny_cid'] = $str_contact_deny;
    $datarray['deny_gid'] = $str_group_deny;
    $datarray['private'] = $private;
    $datarray['pubmail'] = $pubmail_enable;
    $datarray['attach'] = $attachments;
    $datarray['bookmark'] = intval($bookmark);
    $datarray['thr-parent'] = $thr_parent;
    $datarray['postopts'] = '';
    $datarray['origin'] = $origin;
    /**
     * These fields are for the convenience of plugins...
     * 'self' if true indicates the owner is posting on their own wall
     * If parent is 0 it is a top-level post.
     */
    $datarray['parent'] = $parent;
    $datarray['self'] = $self;
    //	$datarray['prvnets']       = $user['prvnets'];
    if ($orig_post) {
        $datarray['edit'] = true;
    } else {
        $datarray['guid'] = get_guid();
    }
    // preview mode - prepare the body for display and send it via json
    if ($preview) {
        require_once 'include/conversation.php';
        $o = conversation(&$a, array(array_merge($contact_record, $datarray)), 'search', false, true);
        echo json_encode(array('preview' => $o));
        killme();
    }
    call_hooks('post_local', $datarray);
    if ($orig_post) {
        $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", dbesc($body), dbesc(datetime_convert()), intval($post_id), intval($profile_uid));
        proc_run('php', "include/notifier.php", 'edit_post', "{$post_id}");
        if (x($_POST, 'return') && strlen($return_path)) {
            logger('return: ' . $return_path);
            goaway($a->get_baseurl() . "/" . $return_path);
        }
        killme();
    } else {
        $post_id = 0;
    }
    $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, \n\t\t`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, \n\t\t`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin` )\n\t\tVALUES( '%s', %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d )", dbesc($datarray['guid']), intval($datarray['uid']), dbesc($datarray['type']), intval($datarray['wall']), intval($datarray['gravity']), intval($datarray['contact-id']), dbesc($datarray['owner-name']), dbesc($datarray['owner-link']), dbesc($datarray['owner-avatar']), dbesc($datarray['author-name']), dbesc($datarray['author-link']), dbesc($datarray['author-avatar']), dbesc($datarray['created']), dbesc($datarray['edited']), dbesc($datarray['commented']), dbesc($datarray['received']), dbesc($datarray['changed']), dbesc($datarray['uri']), dbesc($datarray['thr-parent']), dbesc($datarray['title']), dbesc($datarray['body']), dbesc($datarray['app']), dbesc($datarray['location']), dbesc($datarray['coord']), dbesc($datarray['tag']), dbesc($datarray['inform']), dbesc($datarray['verb']), dbesc($datarray['postopts']), dbesc($datarray['allow_cid']), dbesc($datarray['allow_gid']), dbesc($datarray['deny_cid']), dbesc($datarray['deny_gid']), intval($datarray['private']), intval($datarray['pubmail']), dbesc($datarray['attach']), intval($datarray['bookmark']), intval($datarray['origin']));
    $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($datarray['uri']));
    if (count($r)) {
        $post_id = $r[0]['id'];
        logger('mod_item: saved item ' . $post_id);
        if ($parent) {
            // This item is the last leaf and gets the comment box, clear any ancestors
            $r = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent` = %d ", dbesc(datetime_convert()), intval($parent));
            // Inherit ACL's from the parent item.
            $r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d\n\t\t\t\tWHERE `id` = %d LIMIT 1", dbesc($parent_item['allow_cid']), dbesc($parent_item['allow_gid']), dbesc($parent_item['deny_cid']), dbesc($parent_item['deny_gid']), intval($parent_item['private']), intval($post_id));
            if ($contact_record != $author) {
                notification(array('type' => NOTIFY_COMMENT, 'notify_flags' => $user['notify-flags'], 'language' => $user['language'], 'to_name' => $user['username'], 'to_email' => $user['email'], 'item' => $datarray, 'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id, 'source_name' => $datarray['author-name'], 'source_link' => $datarray['author-link'], 'source_photo' => $datarray['author-avatar'], 'verb' => ACTIVITY_POST, 'otype' => 'item'));
开发者ID:nphyx,项目名称:friendica,代码行数:67,代码来源:item.php

示例12: createNewObject

 /**
  * Create a new Content object in the database
  *
  * @param string $server_id The server id of the new server. If absent,
  *                           will be assigned a guid.
  *
  * @return mixed The newly created object, or null if there was an error
  *
  * @see GenericObject
  *
  * @static
  * @access public
  */
 public static function createNewObject($server_id = null)
 {
     $db = AbstractDb::getObject();
     if (empty($server_id)) {
         $server_id = get_guid();
     }
     $server_id = $db->escapeString($server_id);
     $sql = "INSERT INTO servers (server_id) VALUES ('{$server_id}')";
     if (!$db->execSqlUpdate($sql, false)) {
         throw new Exception(_('Unable to insert the new server in the database!'));
     }
     $_object = self::getObject($server_id);
     return $_object;
 }
开发者ID:cnlangzi,项目名称:wifidog-auth,代码行数:27,代码来源:Server.php

示例13: login

 /**
  * Attempts to login a user against the authentication source
  *
  * If successfull, returns a User object
  *
  * @param string $username A valid identifying token for the source. Not
  *                         necessarily unique.
  * @param string $password Clear text password.
  * @param string $errmsg   Reference of error message
  *
  * @return object The actual User object if login was successfull, false
  *                otherwise.
  */
 public function login($username, $password, &$errmsg = null)
 {
     $db = AbstractDb::getObject();
     // Init values
     $retval = false;
     $username = $db->EscapeString($username);
     $password = $db->EscapeString($password);
     // Check if php-ldap extension is loaded
     if (Dependency::check("ldap", $errmsg)) {
         if ($this->checkLdapUser($username, $password, $this->mldap_hostname, $this->mldap_o, $this->mldap_filter, $errmsg)) {
             //LDAP Authentication Successful
             $sql = "SELECT user_id, pass FROM users WHERE (username='{$username}') AND account_origin='" . $this->getNetwork()->getId() . "'";
             $db->ExecSqlUniqueRes($sql, $user_info, false);
             if ($user_info != null) {
                 $user = User::getObject($user_info['user_id']);
                 if ($user->isUserValid($errmsg)) {
                     $retval = $user;
                     User::setCurrentUser($user);
                     $errmsg = _("Login successfull");
                 } else {
                     $retval = false;
                     //Error already been set
                 }
             } else {
                 $user = User::createUser(get_guid(), $username, $this->getNetwork(), "", "");
                 $retval =& $user;
                 $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED);
                 $errmsg = _("Login successfull");
             }
         } else {
             $retval = false;
             //Error already been set
         }
     }
     User::setCurrentUser($retval);
     return $retval;
 }
开发者ID:soitun,项目名称:wifidog-auth,代码行数:50,代码来源:AuthenticatorLDAP.php

示例14: send_message

function send_message($recipient = 0, $body = '', $subject = '', $replyto = '')
{
    $a = get_app();
    if (!$recipient) {
        return -1;
    }
    if (!strlen($subject)) {
        $subject = t('[no subject]');
    }
    $me = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval(local_user()));
    $contact = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($recipient), intval(local_user()));
    if (!(count($me) && count($contact))) {
        return -2;
    }
    $hash = random_string();
    $uri = 'urn:X-dfrn:' . $a->get_baseurl() . ':' . local_user() . ':' . $hash;
    $convid = 0;
    $reply = false;
    // look for any existing conversation structure
    if (strlen($replyto)) {
        $reply = true;
        $r = q("select convid from mail where uid = %d and ( uri = '%s' or `parent-uri` = '%s' ) limit 1", intval(local_user()), dbesc($replyto), dbesc($replyto));
        if (count($r)) {
            $convid = $r[0]['convid'];
        }
    }
    if (!$convid) {
        // create a new conversation
        $conv_guid = get_guid();
        $recip_host = substr($contact[0]['url'], strpos($contact[0]['url'], '://') + 3);
        $recip_host = substr($recip_host, 0, strpos($recip_host, '/'));
        $recip_handle = $contact[0]['addr'] ? $contact[0]['addr'] : $contact[0]['nick'] . '@' . $recip_host;
        $sender_handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(), '://') + 3);
        $handles = $recip_handle . ';' . $sender_handle;
        $r = q("insert into conv (uid,guid,creator,created,updated,subject,recips) values(%d, '%s', '%s', '%s', '%s', '%s', '%s') ", intval(local_user()), dbesc($conv_guid), dbesc($sender_handle), dbesc(datetime_convert()), dbesc(datetime_convert()), dbesc($subject), dbesc($handles));
        $r = q("select * from conv where guid = '%s' and uid = %d limit 1", dbesc($conv_guid), intval(local_user()));
        if (count($r)) {
            $convid = $r[0]['id'];
        }
    }
    if (!$convid) {
        logger('send message: conversation not found.');
        return -4;
    }
    if (!strlen($replyto)) {
        $replyto = $uri;
    }
    $r = q("INSERT INTO `mail` ( `uid`, `guid`, `convid`, `from-name`, `from-photo`, `from-url`, \n\t\t`contact-id`, `title`, `body`, `seen`, `reply`, `replied`, `uri`, `parent-uri`, `created`)\n\t\tVALUES ( %d, '%s', %d, '%s', '%s', '%s', %d, '%s', '%s', %d, %d, %d, '%s', '%s', '%s' )", intval(local_user()), dbesc(get_guid()), intval($convid), dbesc($me[0]['name']), dbesc($me[0]['thumb']), dbesc($me[0]['url']), intval($recipient), dbesc($subject), dbesc($body), 1, intval($reply), 0, dbesc($uri), dbesc($replyto), datetime_convert());
    $r = q("SELECT * FROM `mail` WHERE `uri` = '%s' and `uid` = %d LIMIT 1", dbesc($uri), intval(local_user()));
    if (count($r)) {
        $post_id = $r[0]['id'];
    }
    /**
     *
     * When a photo was uploaded into the message using the (profile wall) ajax 
     * uploader, The permissions are initially set to disallow anybody but the
     * owner from seeing it. This is because the permissions may not yet have been
     * set for the post. If it's private, the photo permissions should be set
     * appropriately. But we didn't know the final permissions on the post until
     * now. So now we'll look for links of uploaded messages that are in the
     * post and set them to the same permissions as the post itself.
     *
     */
    $match = null;
    if (preg_match_all("/\\[img\\](.*?)\\[\\/img\\]/", $body, $match)) {
        $images = $match[1];
        if (count($images)) {
            foreach ($images as $image) {
                if (!stristr($image, $a->get_baseurl() . '/photo/')) {
                    continue;
                }
                $image_uri = substr($image, strrpos($image, '/') + 1);
                $image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
                $r = q("UPDATE `photo` SET `allow_cid` = '%s'\n\t\t\t\t\tWHERE `resource-id` = '%s' AND `album` = '%s' AND `uid` = %d ", dbesc('<' . $recipient . '>'), dbesc($image_uri), dbesc(t('Wall Photos')), intval(local_user()));
            }
        }
    }
    if ($post_id) {
        proc_run('php', "include/notifier.php", "mail", "{$post_id}");
        return intval($post_id);
    } else {
        return -3;
    }
}
开发者ID:nextgensh,项目名称:friendica,代码行数:84,代码来源:message.php

示例15: item_store

function item_store($arr, $force_parent = false)
{
    // If a Diaspora signature structure was passed in, pull it out of the
    // item array and set it aside for later storage.
    $dsprsig = null;
    if (x($arr, 'dsprsig')) {
        $dsprsig = json_decode(base64_decode($arr['dsprsig']));
        unset($arr['dsprsig']);
    }
    // if an OStatus conversation url was passed in, it is stored and then
    // removed from the array.
    $ostatus_conversation = null;
    if (isset($arr["ostatus_conversation"])) {
        $ostatus_conversation = $arr["ostatus_conversation"];
        unset($arr["ostatus_conversation"]);
    }
    if (x($arr, 'gravity')) {
        $arr['gravity'] = intval($arr['gravity']);
    } elseif ($arr['parent-uri'] === $arr['uri']) {
        $arr['gravity'] = 0;
    } elseif (activity_match($arr['verb'], ACTIVITY_POST)) {
        $arr['gravity'] = 6;
    } else {
        $arr['gravity'] = 6;
    }
    // extensible catchall
    if (!x($arr, 'type')) {
        $arr['type'] = 'remote';
    }
    // Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin.
    if (strpos($arr['body'], '<') !== false || strpos($arr['body'], '>') !== false) {
        $arr['body'] = strip_tags($arr['body']);
    }
    if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
        require_once 'library/langdet/Text/LanguageDetect.php';
        $naked_body = preg_replace('/\\[(.+?)\\]/', '', $arr['body']);
        $l = new Text_LanguageDetect();
        //$lng = $l->detectConfidence($naked_body);
        //$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
        $lng = $l->detect($naked_body, 3);
        if (sizeof($lng) > 0) {
            $postopts = "";
            foreach ($lng as $language => $score) {
                if ($postopts == "") {
                    $postopts = "lang=";
                } else {
                    $postopts .= ":";
                }
                $postopts .= $language . ";" . $score;
            }
            $arr['postopts'] = $postopts;
        }
    }
    $arr['wall'] = x($arr, 'wall') ? intval($arr['wall']) : 0;
    $arr['uri'] = x($arr, 'uri') ? notags(trim($arr['uri'])) : random_string();
    $arr['extid'] = x($arr, 'extid') ? notags(trim($arr['extid'])) : '';
    $arr['author-name'] = x($arr, 'author-name') ? notags(trim($arr['author-name'])) : '';
    $arr['author-link'] = x($arr, 'author-link') ? notags(trim($arr['author-link'])) : '';
    $arr['author-avatar'] = x($arr, 'author-avatar') ? notags(trim($arr['author-avatar'])) : '';
    $arr['owner-name'] = x($arr, 'owner-name') ? notags(trim($arr['owner-name'])) : '';
    $arr['owner-link'] = x($arr, 'owner-link') ? notags(trim($arr['owner-link'])) : '';
    $arr['owner-avatar'] = x($arr, 'owner-avatar') ? notags(trim($arr['owner-avatar'])) : '';
    $arr['created'] = x($arr, 'created') !== false ? datetime_convert('UTC', 'UTC', $arr['created']) : datetime_convert();
    $arr['edited'] = x($arr, 'edited') !== false ? datetime_convert('UTC', 'UTC', $arr['edited']) : datetime_convert();
    $arr['commented'] = datetime_convert();
    $arr['received'] = datetime_convert();
    $arr['changed'] = datetime_convert();
    $arr['title'] = x($arr, 'title') ? notags(trim($arr['title'])) : '';
    $arr['location'] = x($arr, 'location') ? notags(trim($arr['location'])) : '';
    $arr['coord'] = x($arr, 'coord') ? notags(trim($arr['coord'])) : '';
    $arr['last-child'] = x($arr, 'last-child') ? intval($arr['last-child']) : 0;
    $arr['visible'] = x($arr, 'visible') !== false ? intval($arr['visible']) : 1;
    $arr['deleted'] = 0;
    $arr['parent-uri'] = x($arr, 'parent-uri') ? notags(trim($arr['parent-uri'])) : '';
    $arr['verb'] = x($arr, 'verb') ? notags(trim($arr['verb'])) : '';
    $arr['object-type'] = x($arr, 'object-type') ? notags(trim($arr['object-type'])) : '';
    $arr['object'] = x($arr, 'object') ? trim($arr['object']) : '';
    $arr['target-type'] = x($arr, 'target-type') ? notags(trim($arr['target-type'])) : '';
    $arr['target'] = x($arr, 'target') ? trim($arr['target']) : '';
    $arr['plink'] = x($arr, 'plink') ? notags(trim($arr['plink'])) : '';
    $arr['allow_cid'] = x($arr, 'allow_cid') ? trim($arr['allow_cid']) : '';
    $arr['allow_gid'] = x($arr, 'allow_gid') ? trim($arr['allow_gid']) : '';
    $arr['deny_cid'] = x($arr, 'deny_cid') ? trim($arr['deny_cid']) : '';
    $arr['deny_gid'] = x($arr, 'deny_gid') ? trim($arr['deny_gid']) : '';
    $arr['private'] = x($arr, 'private') ? intval($arr['private']) : 0;
    $arr['bookmark'] = x($arr, 'bookmark') ? intval($arr['bookmark']) : 0;
    $arr['body'] = x($arr, 'body') ? trim($arr['body']) : '';
    $arr['tag'] = x($arr, 'tag') ? notags(trim($arr['tag'])) : '';
    $arr['attach'] = x($arr, 'attach') ? notags(trim($arr['attach'])) : '';
    $arr['app'] = x($arr, 'app') ? notags(trim($arr['app'])) : '';
    $arr['origin'] = x($arr, 'origin') ? intval($arr['origin']) : 0;
    $arr['guid'] = x($arr, 'guid') ? notags(trim($arr['guid'])) : get_guid();
    $arr['thr-parent'] = $arr['parent-uri'];
    if ($arr['parent-uri'] === $arr['uri']) {
        $parent_id = 0;
        $parent_deleted = 0;
        $allow_cid = $arr['allow_cid'];
        $allow_gid = $arr['allow_gid'];
        $deny_cid = $arr['deny_cid'];
        $deny_gid = $arr['deny_gid'];
//.........这里部分代码省略.........
开发者ID:ridcully,项目名称:friendica,代码行数:101,代码来源:items.php


注:本文中的get_guid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。