本文整理汇总了PHP中sql_fetch_object函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_fetch_object函数的具体用法?PHP sql_fetch_object怎么用?PHP sql_fetch_object使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_fetch_object函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SEARCH
function SEARCH($text)
{
global $blogid;
// $text = preg_replace ("/[<,>,=,?,!,#,^,(,),[,\],:,;,\\\,%]/","",$text);
/* * * for jp * * * * * * * * * * */
$this->encoding = strtolower(preg_replace('|[^a-z0-9-_]|i', '', _CHARSET));
if ($this->encoding != 'utf-8') {
$text = mb_convert_encoding($text, "UTF-8", $this->encoding);
}
$text = str_replace(" ", ' ', $text);
$text = preg_replace("/[<>=?!#^()[\\]:;\\%]/", "", $text);
$this->ascii = '[\\x00-\\x7F]';
$this->two = '[\\xC0-\\xDF][\\x80-\\xBF]';
$this->three = '[\\xE0-\\xEF][\\x80-\\xBF][\\x80-\\xBF]';
$this->jpmarked = $this->boolean_mark_atoms_jp($text);
/* * * * * * * * * * * * * * * * */
$this->querystring = $text;
// $this->marked = $this->boolean_mark_atoms($text);
$this->inclusive = $this->boolean_inclusive_atoms($text);
$this->blogs = array();
// get all public searchable blogs, no matter what, include the current blog allways.
$res = sql_query('SELECT bnumber FROM ' . sql_table('blog') . ' WHERE bincludesearch=1 ');
while ($obj = sql_fetch_object($res)) {
$this->blogs[] = intval($obj->bnumber);
}
}
示例2: do_backup
/**
* This function creates an sql dump of the database and sends it to
* the user as a file (can be gzipped if they want)
*
* @requires
* no output may have preceded (new headers are sent)
* @param gzip
* 1 = compress backup file, 0 = no compression (default)
*/
function do_backup($gzip = 0)
{
global $manager;
// tables of which backup is needed
$tables = array(sql_table('actionlog'), sql_table('ban'), sql_table('blog'), sql_table('comment'), sql_table('config'), sql_table('item'), sql_table('karma'), sql_table('member'), sql_table('skin'), sql_table('skin_desc'), sql_table('team'), sql_table('template'), sql_table('template_desc'), sql_table('plugin'), sql_table('plugin_event'), sql_table('plugin_option'), sql_table('plugin_option_desc'), sql_table('category'), sql_table('activation'), sql_table('tickets'));
// add tables that plugins want to backup to the list
// catch all output generated by plugins
ob_start();
$res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));
while ($plugName = sql_fetch_object($res)) {
$plug =& $manager->getPlugin($plugName->pfile);
if ($plug) {
$tables = array_merge($tables, (array) $plug->getTableList());
}
}
ob_end_clean();
// remove duplicates
$tables = array_unique($tables);
// make sure browsers don't cache the backup
header("Pragma: no-cache");
// don't allow gzip compression when extension is not loaded
if ($gzip != 0 && !extension_loaded("zlib")) {
$gzip = 0;
}
if ($gzip) {
// use an output buffer
@ob_start();
@ob_implicit_flush(0);
// set filename
$filename = 'nucleus_db_backup_' . strftime("%Y-%m-%d-%H-%M-%S", time()) . ".sql.gz";
} else {
$filename = 'nucleus_db_backup_' . strftime("%Y-%m-%d-%H-%M-%S", time()) . ".sql";
}
// send headers that tell the browser a file is coming
header("Content-Type: text/x-delimtext; name=\"{$filename}\"");
header("Content-disposition: attachment; filename={$filename}");
// dump header
echo "#\n";
echo "# " . _BACKUP_BACKUPFILE_TITLE . " \n";
echo "# " . _ADMINPAGEFOOT_OFFICIALURL . "\n";
echo "#\n";
echo "# " . _BACKUP_BACKUPFILE_BACKUPDATE . gmdate("d-m-Y H:i:s", time()) . " GMT\n";
global $nucleus;
echo "# " . _BACKUP_BACKUPFILE_NUCLEUSVERSION . $nucleus['version'] . "\n";
echo "#\n";
echo "# " . _BACKUP_WARNING_NUCLEUSVERSION . "\n";
echo "#\n";
// dump all tables
reset($tables);
array_walk($tables, array(&$this, '_backup_dump_table'));
if ($gzip) {
$Size = ob_get_length();
$Crc = crc32(ob_get_contents());
$contents = gzcompress(ob_get_contents());
ob_end_clean();
echo "‹" . substr($contents, 0, strlen($contents) - 4) . $this->gzip_PrintFourChars($Crc) . $this->gzip_PrintFourChars($Size);
}
exit;
}
示例3: get_payment_link
function get_payment_link($user_name, $amount, $order, $pay_method_type)
{
//ziskani jmena
$names = explode(" ", $user_name);
$surname = $names[count($names) - 1];
$name = trim(str_replace($surname, "", $user_name));
//zaskani mailu
$s = sql_query("select mail from users\n\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $this->me->uid . "')");
$d = sql_fetch_object($s);
//timestamp
$time = time();
//session_id
$session_id = $this->me->uid . "-" . $time;
//popis platby
$desc = $this->l->t("payu_desc");
//ip
$ip = $_SERVER['REMOTE_ADDR'];
//vypocet podpisu
$sig = $this->pos . "" . $pay_method_type . "" . $session_id . "" . $this->auth_key . "" . $amount . "" . $desc;
$sig .= $order . "" . $name . "" . $surname . "" . $d->mail . "" . $this->me->lang_ui;
$sig .= $ip . "" . $time . "" . $this->key1;
$sig = md5($sig);
$url = $this->service_url . "/NewPayment?";
$url .= "&pos_id=" . $this->pos;
$url .= "&pos_auth_key=" . $this->auth_key;
$url .= "&session_id=" . $session_id;
$url .= "&amount=" . $amount;
$url .= "&client_ip=" . $ip;
$url .= "&email=" . $d->mail;
$url .= "&first_name=" . $name;
$url .= "&last_name=" . $surname;
$url .= "&language=" . $this->me->lang_ui;
$url .= "&ts=" . $time;
$url .= "&sig=" . $sig;
$url .= "&order_id=" . $order;
$url .= "&desc=" . $desc;
$url .= "&pay_type=" . $pay_method_type;
/*
echo " <input type=\"hidden\" name=\"email\" value=\"".$d->mail."\">\n";
echo " <input type=\"hidden\" name=\"first_name\" value=\"".$name."\">\n";
echo " <input type=\"hidden\" name=\"last_name\" value=\"".$surname."\">\n";
echo " < input type=\"hidden\" name=\"language\" value=\"".$this->me->lang_ui."\">\n";
echo " <input type=\"hidden\" name=\"ts\" value=\"".$time."\">\n";
echo " <input type=\"hidden\" name=\"sig\" value=\"".$sig."\">\n";
echo " <input type=\"hidden\" name=\"desc\" value=\"".$desc."\">\n";
echo " <input type=\"hidden\" name=\"order_id\" value=\"".$order."\">\n";
*
echo " <input type=\"hidden\" name=\"pos_id\" value=\"".$this->pos."\">\n";
echo " <input type=\"hidden\" name=\"pos_auth_key\" value=\"".$this->auth_key."\">\n";
echo " <input type=\"hidden\" name=\"session_id\" value=\"".$session_id."\">\n";
echo " <input type=\"hidden\" name=\"amount\" value=\"".$amount."\">\n";
echo " <input type=\"hidden\" name=\"client_ip\" value=\"".$ip."\">\n";
*
*
*/
return $url;
}
示例4: load_data
function load_data($id)
{
$sql = sql_query("select id, nick, register_time, mail\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom users\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $id . "')");
$data = sql_fetch_object($sql);
$this->uid = $data->id;
$this->nick = $data->nick;
$this->mail = $data->mail;
$this->register_time = $data->register_time;
}
示例5: set_selfpublishing
private function set_selfpublishing()
{
$s = sql_query("select selfpublishing.id, orders_items.quantity,\n\t\t\t\t\t\t\t\t\t\t\t\tselfpublishing.user,\n\t\t\t\t\t\t\t\t\t\t\t\torders_items.price_per_one\n\t\t\t\t\t\t\t\t\t\t\t\tfrom selfpublishing, orders_items \n\t\t\t\t\t\t\t\t\t\t\t\twhere (selfpublishing.id = orders_items.item\n\t\t\t\t\t\t\t\t\t\t\t\tand orders_items.merchant = 'self'\n\t\t\t\t\t\t\t\t\t\t\t\tand orders_items.order_id = '" . $this->order_id . "')");
while ($d = sql_fetch_object($s)) {
$s_u = sql_query("update selfpublishing\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tset boughts_num = boughts_num + " . $d->quantity . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $d->id . "')");
//za kazdy ulozime vydavajicimu uzivateli platbu
//cenu musime prevest z haleru a odecist poplatek 15%
$price = $d->price_per_one * $d->quantity;
$user_account = new user_account();
$user_account->add_payment("selfpublishing", $price, $d->user);
}
}
示例6: isBanned
/**
* Checks if a given IP is banned from commenting/voting
*
* Returns 0 when not banned, or a BANINFO object containing the
* message and other information of the ban
*/
function isBanned($blogid, $ip)
{
$blogid = intval($blogid);
$query = 'SELECT * FROM ' . sql_table('ban') . ' WHERE blogid=' . $blogid;
$res = sql_query($query);
while ($obj = sql_fetch_object($res)) {
$found = strpos($ip, $obj->iprange);
if (!($found === false)) {
// found a match!
return new BANINFO($obj->iprange, $obj->reason);
}
}
return 0;
}
示例7: get_payment_buttons
function get_payment_buttons($order_id)
{
//nacteme si cenu z objednavky
$s = sql_query("select price from orders\n\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $order_id . "' and user = '" . $this->me->uid . "')");
$d = sql_fetch_object($s);
if (!$d->price) {
return;
}
$payment = new TpPayment($this->config);
$payment->setValue($d->price);
$payment->setDescription($this->l->t("thepay_title"));
$payment->setMerchantData($order_id);
$payment->setReturnUrl("http://www.cbdb.cz/pay_return.php?pay_type=thepay");
$tpHelper = new TpDivMerchantHelper($payment);
return $tpHelper->render();
}
示例8: permanent
function permanent()
{
$me = $_SESSION['me'];
if (!$me->uid) {
$token = $_COOKIE["permanent_login"];
//pokud maji trvale prihlaseni
if ($token) {
$login_data = explode(":", $token);
$sql = sql_query("select user from permanent_login\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (user = '" . mysql_real_escape_string($login_data[0]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand hash_id = '" . mysql_real_escape_string($login_data[1]) . "')");
$num = mysql_num_rows($sql);
if ($num) {
$sql = sql_query("select nick\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom users\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . mysql_real_escape_string($login_data[0]) . "')");
$data = sql_fetch_object($sql);
$uid = $login_data[0];
$me = new me($uid);
$_SESSION['uid'] = $uid;
$_SESSION['me'] = $me;
}
}
}
}
示例9: cleanupActivationTable
/**
* Cleans up entries in the activation table. All entries older than 2 days are removed.
* (static)
*
* @author dekarma
*/
function cleanupActivationTable()
{
$actdays = 2;
if (isset($CONF['ActivationDays']) && intval($CONF['ActivationDays']) > 0) {
$actdays = intval($CONF['ActivationDays']);
} else {
$CONF['ActivationDays'] = 2;
}
$boundary = time() - 60 * 60 * 24 * $actdays;
// 1. walk over all entries, and see if special actions need to be performed
$res = sql_query('SELECT * FROM ' . sql_table('activation') . ' WHERE vtime < \'' . date('Y-m-d H:i:s', $boundary) . '\'');
while ($o = sql_fetch_object($res)) {
switch ($o->vtype) {
case 'register':
// delete all information about this site member. registration is undone because there was
// no timely activation
include_once $DIR_LIBS . 'ADMIN.php';
ADMIN::deleteOneMember(intval($o->vmember));
break;
case 'addresschange':
// revert the e-mail address of the member back to old address
list($oldEmail, $oldCanLogin) = explode('/', $o->vextra);
sql_query('UPDATE ' . sql_table('member') . ' SET mcanlogin=' . intval($oldCanLogin) . ', memail=\'' . sql_real_escape_string($oldEmail) . '\' WHERE mnumber=' . intval($o->vmember));
break;
case 'forgot':
// delete the activation link and ignore. member can request a new password using the
// forgot password link
break;
}
}
// 2. delete activation entries for real
sql_query('DELETE FROM ' . sql_table('activation') . ' WHERE vtime < \'' . date('Y-m-d H:i:s', $boundary) . '\'');
}
示例10: _applyPluginOptions
/**
* @param $aOptions: array ( 'oid' => array( 'contextid' => 'value'))
* (taken from request using requestVar())
* @param $newContextid: integer (accepts a contextid when it is for a new
* contextid there was no id available at the moment of writing the
* formcontrols into the page (by ex: itemOptions for new item)
* @static
*/
function _applyPluginOptions(&$aOptions, $newContextid = 0)
{
global $manager;
if (!is_array($aOptions)) {
return;
}
foreach ($aOptions as $oid => $values) {
// get option type info
$query = 'SELECT opid, oname, ocontext, otype, oextra, odef FROM ' . sql_table('plugin_option_desc') . ' WHERE oid=' . intval($oid);
$res = sql_query($query);
if ($o = sql_fetch_object($res)) {
foreach ($values as $key => $value) {
// avoid overriding the key used by foreach statement
$contextid = $key;
// retreive any metadata
$meta = NucleusPlugin::getOptionMeta($o->oextra);
// if the option is readonly or hidden it may not be saved
if ($meta['access'] != 'readonly' && $meta['access'] != 'hidden') {
$value = undoMagic($value);
// value comes from request
switch ($o->otype) {
case 'yesno':
if ($value != 'yes' && $value != 'no') {
$value = 'no';
}
break;
default:
break;
}
// check the validity of numerical options
if ($meta['datatype'] == 'numerical' && !is_numeric($value)) {
//the option must be numeric, but the it isn't
//use the default for this option
$value = $o->odef;
}
// decide wether we are using the contextid of newContextid
if ($newContextid != 0) {
$contextid = $newContextid;
}
//trigger event PrePluginOptionsUpdate to give the plugin the
//possibility to change/validate the new value for the option
$manager->notify('PrePluginOptionsUpdate', array('context' => $o->ocontext, 'plugid' => $o->opid, 'optionname' => $o->oname, 'contextid' => $contextid, 'value' => &$value));
// delete the old value for the option
sql_query('DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid=' . intval($oid) . ' AND ocontextid=' . intval($contextid));
sql_query('INSERT INTO ' . sql_table('plugin_option') . " (oid, ocontextid, ovalue) VALUES (" . intval($oid) . "," . intval($contextid) . ",'" . sql_real_escape_string($value) . "')");
}
}
}
// clear option value cache if the plugin object is already loaded
if (is_object($o)) {
$plugin =& $manager->pidLoaded($o->opid);
if ($plugin) {
$plugin->clearOptionValueCache();
}
}
}
}
示例11: _getRecentItems
/**
* Returns a list of recent items (Nucleus Version)
* ($amount = max 20);
*/
function _getRecentItems($blogid, $username, $password, $amount)
{
$blogid = intval($blogid);
$amount = intval($amount);
// 1. login
$mem = new MEMBER();
if (!$mem->login($username, $password)) {
return _error(1, "Could not log in");
}
// 2. check if allowed
if (!BLOG::existsID($blogid)) {
return _error(2, "No such blog ({$blogid})");
}
if (!$mem->teamRights($blogid)) {
return _error(3, "Not a team member");
}
$amount = intval($amount);
if ($amount < 1 or $amount > 20) {
return _error(5, "Amount parameter must be in range 1..20");
}
// 3. create and return list of recent items
// Struct returned has dateCreated, userid, blogid and content
$structarray = array();
// the array in which the structs will be stored
$query = "SELECT ibody, iauthor, ibody, imore, ititle, iclosed, idraft, itime" . ' FROM ' . sql_table('item') . " WHERE iblog={$blogid}" . " ORDER BY itime DESC" . " LIMIT {$amount}";
$r = sql_query($query);
while ($obj = sql_fetch_object($r)) {
$newstruct = new xmlrpcval(array("publishDate" => new xmlrpcval(iso8601_encode(strtotime($obj->itime)), "dateTime.iso8601"), "userid" => new xmlrpcval($obj->iauthor, "string"), "blogid" => new xmlrpcval($blogid, "string"), "title" => new xmlrpcval($obj->ititle, "string"), "body" => new xmlrpcval($obj->ibody, "string"), "more" => new xmlrpcval($obj->imore, "string"), "draft" => new xmlrpcval($obj->idraft, "boolean"), "closed" => new xmlrpcval($obj->iclosed, "boolean")), 'struct');
array_push($structarray, $newstruct);
}
return new xmlrpcresp(new xmlrpcval($structarray, "array"));
}
示例12: statuserfilter
function statuserfilter()
{
require_once _base_ . '/lib/lib.table.php';
require_once _base_ . '/lib/lib.form.php';
require_once _lms_ . '/lib/lib.subscribe.php';
$lang =& DoceboLanguage::createInstance('stats', 'lms');
$out =& $GLOBALS['page'];
$form = new Form();
$aclManager =& Docebo::user()->getACLManager();
$out->setWorkingZone('content');
$GLOBALS['module_assigned_name'][$GLOBALS['modname']] = $lang->def('_STATFORUSER');
$out->add(getTitleArea($lang->def('_STATFORUSER'), 'stats'));
$out->add('<div class="std_block">');
$group_filter = Get::req('group_filter', DOTY_INT, STATFILTER_ALL_GROUP);
$status_filter = Get::req('status_filter', DOTY_INT, STATFILTER_ALL_STATUS);
$editions_filter = Get::req('editions_filter', DOTY_INT, STATFILTER_ALL_EDITION);
$date_filter = Get::req('date_filter', DOTY_INT, STATFILTER_ALL_EDITION);
$user_filter = Get::req('user_filter', DOTY_MIXED, '');
$cs = new CourseSubscribe_Manager();
/*
* Print form for group and status selection
*/
$out->add($form->openForm("statuserfilter", "index.php?modname=stats&op=statuser"));
// ------- Filter on group
$arr_idst = $aclManager->getBasePathGroupST('/lms/course/' . (int) $_SESSION['idCourse'] . '/group');
$arr_result_groups = $aclManager->getGroups($arr_idst);
$std_content = $aclManager->getContext();
$aclManager->setContext('/lms/course/' . (int) $_SESSION['idCourse'] . '/group');
$arr_groups = array(STATFILTER_ALL_GROUP => $lang->def('_ALL'));
foreach ($arr_result_groups as $idst_group => $info_group) {
if (!$info_group[ACL_INFO_GROUPHIDDEN]) {
$arr_groups[$idst_group] = $aclManager->relativeId($info_group[ACL_INFO_GROUPID]);
}
}
$aclManager->setContext($std_content);
$out->add(Form::getTextField(Lang::t('_FULLNAME', 'standard'), 'user_filter', 'user_filter', 255, $user_filter));
$out->add($form->getDropdown($lang->def('_GROUPS'), 'group_filter', 'group_filter', $arr_groups, $group_filter));
// ------ Filter on status
$arr_status = array(STATFILTER_ALL_STATUS => $lang->def('_FILTERSTATUSSELECTONEOPTION'));
$arr_status = $arr_status + $cs->getUserStatus();
$out->add($form->getDropdown($lang->def('_ORDER_BY'), 'status_filter', 'status_filter', $arr_status, $status_filter));
//--- filter on edition ------------------------------------------------------
//retrieve edition
$query = "SELECT * FROM %lms_course_editions WHERE id_course = " . (int) $_SESSION['idCourse'];
$res = sql_query($query);
//is there more any edition ?
if (sql_num_rows($res) > 0) {
$arr_editions = array(STATFILTER_ALL_EDITION => $lang->def('_FILTEREDITIONSELECTONEOPTION'));
//list of editions for the dropdown, in the format: "[code] name (date_begin - date_end)"
while ($einfo = sql_fetch_object($res)) {
$_label = '';
if ($einfo->code != '') {
$_label .= '[' . $einfo->code . '] ';
}
if ($einfo->name != '') {
$_label .= $einfo->neme;
}
if (($einfo->date_begin != '' || $einfo->date_begin != '0000-00-00') && ($einfo->date_end != '' || $einfo->date_end != '0000-00-00')) {
$_label .= ' (' . Format::date($einfo->date_begin, 'date') . ' - ' . Format::date($einfo->date_end, 'date') . ')';
}
if ($_label == '') {
//...
}
$arr_editions[$einfo->id_edition] = $_label;
}
//draw editions dropdown
$out->add($form->getDropdown($lang->def('_FILTEREDITIONSELECTTITLE'), 'editions_filter', 'editions_filter', $arr_editions, $editions_filter));
}
//--- filter on class ------------------------------------------------------
//retrieve class (date)
//$query = "SELECT * FROM %lms_course_date WHERE id_course = ".(int)$_SESSION['idCourse'];
$query = "SELECT dt.id_date, dt.code, dt.name, MIN( dy.date_begin ) AS sub_start_date, MAX( dy.date_end ) AS sub_end_date\r\n\t\tFROM %lms_course_date AS dt\r\n\t\tJOIN %lms_course_date_day AS dy ON dy.id_date = dt.id_date\r\n\t\tWHERE dt.id_course = " . (int) $_SESSION['idCourse'] . "\r\n\t\tGROUP BY dt.id_date\r\n\t\tORDER BY dy.date_begin";
$res = sql_query($query);
//is there more any edition ?
if (sql_num_rows($res) > 0) {
$arr_date = array(STATFILTER_ALL_EDITION => $lang->def('_FILTEREDITIONSELECTONEOPTION'));
//list of editions for the dropdown, in the format: "[code] name (date_begin - date_end)"
while ($einfo = sql_fetch_object($res)) {
$_label = '';
if ($einfo->code != '') {
$_label .= '[' . $einfo->code . '] ';
}
if ($einfo->name != '') {
$_label .= $einfo->neme;
}
if (($einfo->sub_start_date != '' || $einfo->sub_start_date != '0000-00-00') && ($einfo->sub_end_date != '' || $einfo->sub_end_date != '0000-00-00')) {
$_label .= ' (' . Format::date($einfo->sub_start_date, 'date') . ' - ' . Format::date($einfo->sub_end_date, 'date') . ')';
}
if ($_label == '') {
//...
}
$arr_date[$einfo->id_date] = $_label;
}
//draw editions dropdown
$out->add($form->getDropdown($lang->def('_FILTEREDITIONSELECTTITLE'), 'date_filter', 'date_filter', $arr_date, $date_filter));
}
//------------------------------------------------------------------------------
if (isset($_POST['start_filter']) && ($_POST['start_filter'] = 1)) {
$out->add($form->getCheckBox($lang->def('_FILTEROBJECTFINISHED'), 'start_filter', 'start_filter', '1', true));
} else {
//.........这里部分代码省略.........
示例13: create_login
function create_login()
{
$user_data = $this->facebook->api('/me');
//pokud nejde ziskat mail, nejde se prihlasit
if (!$user_data["email"]) {
return false;
}
//nejdrive overime, ze nekdo s danym emailem zde jiznema ucet
//pokud ano, propojime je
$s = sql_query("select id, nick from users\n\t\t\t\t\t\t\t\t\t\t\t\twhere (mail = '" . $user_data["email"] . "')");
$data = sql_fetch_object($s);
if ($data->id) {
$s = sql_query("update users\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tset fb_id = '" . $user_data["id"] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $data->id . "')");
if ($s) {
$ret[0] = $data->id;
$ret[1] = $data->nick;
return $ret;
}
} else {
$fb_id = $user_data["id"];
$login = $user_data["name"];
$mail = $user_data["email"];
$pass = sub_str(md5(time() . "sdas"), 0, 8);
//hledame volny login
$i;
while (1) {
$test_login = $login . "" . $i;
$s = sql_query("select id from users\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (nick = '{$test_login}')");
$d = sql_fetch_object($s);
//login jiz existuje, pridame na konec cislici
if ($d->id) {
$i++;
} else {
break;
}
if ($i == 100) {
return false;
}
}
$db_pass = md5(md5(md5(md5(md5($pass)))));
$names = explode(" ", $test_login);
if (count($names) > 1) {
$surname = $names[count($names) - 1];
}
$sql = sql_query("insert into users\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t(nick, mail, pass, register_time, fb_id, virtual_surname,\tregistration_source)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tvalues\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t('{$test_login}', '{$mail}', '{$db_pass}', '" . time() . "', '{$fb_id}', '" . $surname . "', 'web_fb')");
if ($sql) {
$id = mysql_insert_id();
//zkusime ulozit avatar
$img_url = "https://graph.facebook.com/" . $user_data["id"] . "/picture?width=170&height=210&redirect=false";
$img_data = file_get_contents($img_url);
$json_data = json_decode($img_data, true);
$no_file = $json_data["data"]["is_silhouette"];
if (!$no_file) {
$image = file_get_contents($json_data["data"]["url"]);
$x = file_put_contents("users/" . $id . ".jpg", $image);
if ($x) {
if (file_exists("users/" . $id . ".jpg")) {
$s = sql_query("update users set\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tphoto = 'yes'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '{$id}')");
}
}
}
//zaslani s emailem a heslem atd
$text = "Dobrý den,\nDěkujeme za registraci na České bibliografické databází - CBDB.cz\n\n\nPokud byste v budoucnu chtěli využít přihlašování přes login a heslo, vaše přihlašovací údaje jsou:\nNick: " . $test_login . "\nHeslo: " . $pass . "\n\nTým CBDB.cz\nhttp://www.cbdb.cz";
$sent = mail($mail, "Registrace na CBDB.cz", $text, "From: info@cbdb.cz \nContent-Type: text/plain; charset=utf-8");
$ret[0] = $id;
$ret[1] = $test_login;
return $ret;
}
}
return false;
}
示例14: mycertificate
function mycertificate(&$url)
{
checkPerm('view');
require_once _lms_ . '/lib/lib.course.php';
require_once _base_ . '/lib/lib.table.php';
$lang =& DoceboLanguage::createInstance('profile', 'framework');
$lang =& DoceboLanguage::createInstance('course', 'lms');
$lang =& DoceboLanguage::createInstance('certificate', 'lms');
$admin_level = Docebo::user()->getUserLevelId();
$show_preview = true;
//($admin_level == ADMIN_GROUP_ADMIN || $admin_level == ADMIN_GROUP_GODADMIN);
$title = $lang->def('_MY_CERTIFICATE', 'certificate');
$html = getTitleArea($title, 'mycertificate') . '<div class="std_block">';
//--- draw time periods dropdown ---------------------------------------------
$period_start = '';
$period_end = '';
//extract checking period
$p_model = new TimeperiodsAlms();
$year = date("Y");
$p_list = array("0" => $lang->def('_ALL'));
$p_selected = Get::req('selected_period', DOTY_INT, 0);
$p_data = $p_model->getTimePeriods('', true);
if (count($p_data) > 0) {
foreach ($p_data as $obj) {
$p_list[$obj->id_period] = Format::date($obj->start_date, 'date') . ' - ' . Format::date($obj->end_date, 'date');
if ($p_selected == $obj->id_period) {
$period_start = $obj->start_date;
$period_end = $obj->end_date;
}
}
}
if (!array_key_exists($p_selected, $p_list)) {
$p_selected = 0;
$period_start = '';
$period_end = '';
}
//date dropdown
$onchange = ' onchange="javascript:this.form.submit();"';
$html_filter_cert = '' . Form::openForm('selected_period_form_cert', $url->getUrl()) . Form::openElementSpace() . Form::getDropdown(Lang::t('_TIME_PERIODS', 'menu'), 'selected_period_cert', 'selected_period', $p_list, $p_selected, '', '', $onchange) . Form::closeElementSpace() . Form::getHidden('current_tab_cert', 'current_tab', Get::req('current_tab', DOTY_STRING, 'cert')) . Form::getHidden('is_filtering_cert', 'is_filtering_cert', 1) . Form::closeForm();
$html_filter_meta = '' . Form::openForm('selected_period_form_meta', $url->getUrl()) . Form::openElementSpace() . Form::getDropdown(Lang::t('_TIME_PERIODS', 'menu'), 'selected_period_meta', 'selected_period', $p_list, $p_selected, '', '', $onchange) . Form::closeElementSpace() . Form::getHidden('current_tab_meta', 'current_tab', Get::req('current_tab', DOTY_STRING, 'meta')) . Form::getHidden('is_filtering_meta', 'is_filtering_meta', 1) . Form::closeForm();
//----------------------------------------------------------------------------
$cert = new Certificate();
/*
* Print certificates tables, subdivided by year and course type
*/
$html_cert = '';
$tb_cert = new Table(0);
$cont_h = array($lang->def('_YEAR', 'standard'), $lang->def('_COURSE_CODE', 'course'), $lang->def('_COURSE', 'course'), $lang->def('_CERTIFICATE_NAME', 'course'), $lang->def('_DATE_END', 'course'));
//if ($show_preview) $cont_h[] = '<img src="'.getPathImage('lms').'certificate/preview.gif" alt="'.$lang->def('_PREVIEW').'" />';
//$cont_h[] = '<img src="'.getPathImage('lms').'certificate/certificate.gif" alt="'.$lang->def('_ALT_TAKE_A_COPY').'" />';
if ($show_preview) {
$cont_h[] = '<span class="ico-sprite subs_view"><span>' . $lang->def('_PREVIEW') . '"</span></span>';
}
$cont_h[] = '<span class="ico-sprite subs_pdf"><span>' . $lang->def('_ALT_TAKE_A_COPY') . '</span></span>';
$type_h = array('img-cell', '', '', 'align-center', 'align-center', 'img-cell', 'img-cell');
if ($show_preview) {
$type_h[] = 'nowarp';
}
$type_h[] = 'nowarp';
$tb_cert->setColsStyle($type_h);
$tb_cert->addHead($cont_h);
$available_cert = $cert->certificateForCourses(false, false);
$released = $cert->certificateReleased(Docebo::user()->getIdST());
$query_courses = "" . " SELECT c.idCourse, c.code, c.name, u.status AS user_status, c.course_type, c.permCloseLO " . " FROM %lms_course AS c JOIN %lms_courseuser AS u ON (c.idCourse = u.idCourse) " . " WHERE u.idUser = '" . Docebo::user()->getIdST() . "' " . ($period_start != '' ? " AND u.date_complete >= '" . $period_start . "' " : "") . ($period_end != '' ? " AND u.date_complete <= '" . $period_end . "' " : "") . " ORDER BY u.date_complete DESC, u.status DESC ";
$course_list = sql_query($query_courses);
$arr_courses = array();
$arr_courses_ids = array();
while ($obj = sql_fetch_object($course_list)) {
$arr_courses[$obj->course_type][] = array($obj->idCourse, $obj->code, $obj->name, $obj->user_status, $obj->permCloseLO);
$arr_courses_ids[] = $obj->idCourse;
}
$arr_course_types = getCourseTypes();
$table_displayed = false;
//extract certificates details and availability by courses ids
$arr_courses_ids = array_unique($arr_courses_ids);
$arr_certificates_availability = array();
$arr_certificates_details = array();
if (count($arr_courses_ids) > 0) {
$query = "SELECT id_certificate, id_course, available_for_status " . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_course" . " WHERE id_course IN (" . implode(",", $arr_courses_ids) . ")";
//." WHERE id_certificate = '".$id_cert."'"
//." AND id_course IN (".implode(",", $arr_courses_ids).")";
$res = sql_query($query);
while (list($id_certificate, $id_course, $available_for_status) = sql_fetch_row($res)) {
$arr_certificates_availability[$id_course][$id_certificate] = $available_for_status;
}
$cont = array();
$query = "SELECT idCourse, date_inscr, date_first_access, date_complete, status" . " FROM %lms_courseuser WHERE idUser = '" . Docebo::user()->getIdST() . "'" . " AND idCourse IN (" . implode(",", $arr_courses_ids) . ") " . ($period_start != '' ? " AND date_complete >= '" . $period_start . "' " : "") . ($period_end != '' ? " AND date_complete <= '" . $period_end . "' " : "");
$res = sql_query($query);
while (list($id_course, $date_inscr, $date_begin, $date_end, $status) = sql_fetch_row($res)) {
$arr_certificate_details[$id_course] = array($date_inscr, $date_begin, $date_end, $status);
}
}
//order arr_courses by key
ksort($arr_courses);
$years = array();
foreach ($arr_courses as $course_type => $course_data) {
if (in_array($course_type, array_keys($arr_course_types))) {
//$html .= '';
$tb = new Table(0);
$tb->setColsStyle($type_h);
//.........这里部分代码省略.........
示例15: getDesc
function getDesc($id)
{
$query = 'SELECT tddesc FROM ' . sql_table('template_desc') . ' WHERE tdnumber=' . intval($id);
$res = sql_query($query);
$obj = sql_fetch_object($res);
return $obj->tddesc;
}