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); } }
/** * 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; }
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; }
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; }
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); } }
/** * 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; }
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 = '******')"); $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(); }
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 = '******'\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; } } } }
/** * 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='******', 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) . '\''); }
/** * @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(); } } } }
/** * 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")); }
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 { $out->add($form->getCheckBox($lang->def('_FILTEROBJECTFINISHED'), 'start_filter', 'start_filter', '1')); } $out->add('<br/>'); $out->add($form->getButton('gofilter', 'gofilter', $lang->def('_SEARCH'))); /* * Get all students of course that is contained in selected group * For any student compute progress */ $tabStat = new Table(Get::sett('visuItem'), $lang->def('_STATS_USERS'), $lang->def('_STATS_USERS')); $tabStat->initNavBar('ini', 'button'); $limit = $tabStat->getSelectedElement(); // step 2) load all students of course in selected group $lev = false; $group_all_members = false; if ($group_filter != STATFILTER_ALL_GROUP) { $group_all_members = $aclManager->getGroupAllUser($group_filter); } //$students = getSubscribedInfo((int)$_SESSION['idCourse'], FALSE, $lev, TRUE, ( $status_filter != -1 ? $status_filter : false ), false, true); $students = getSubscribedInfo((int) $_SESSION['idCourse'], false, $lev, true, $status_filter != STATFILTER_ALL_STATUS ? $status_filter : false, $editions_filter != STATFILTER_ALL_EDITION ? $editions_filter : false, true, $user_filter, $group_all_members, $limit, $date_filter != STATFILTER_ALL_EDITION ? $date_filter : false); $query = "SELECT COUNT(*)" . " FROM %lms_courseuser AS cu" . ($user_filter !== '' ? " JOIN " . $GLOBALS['prefix_fw'] . "_user AS u ON u.idst = cu.idUser" : '') . " WHERE cu.idCourse = " . (int) $_SESSION['idCourse'] . ($status_filter != STATFILTER_ALL_STATUS ? " AND cu.status = '" . $status_filter . "'" : '') . ($user_filter !== '' ? " AND (u.firstname LIKE '%" . $user_filter . "%' OR u.lastname LIKE '%" . $user_filter . "%' OR u.userid LIKE '%" . $user_filter . "%')" : '') . ($group_all_members !== false ? " AND c.idUser IN (" . implode(',', $group_all_members) . ")" : ''); list($total_user) = sql_fetch_row(sql_query($query)); $content_h = array($lang->def('_USERNAME'), $lang->def('_STATS_FULLNAME'), $lang->def('_STATUS'), $lang->def('_LEARNING_OBJECTS'), $lang->def('_PROGRESS')); $type_h = array('', '', 'image', 'image', 'image'); $tabStat->setColsStyle($type_h); $tabStat->addHead($content_h); $aclManager =& Docebo::user()->getACLManager(); $acl =& Docebo::user()->getACL(); // search memebers of the selected group foreach ($students as $idst => $user_course_info) { if ($group_filter == STATFILTER_ALL_GROUP || in_array($idst, $group_all_members)) { $user_info = $aclManager->getUser($idst, FALSE); if ($user_info != false) { $totItems = getNumCourseItems((int) $_SESSION['idCourse'], FALSE, $idst, FALSE); $totComplete = getStatStatusCount($idst, (int) $_SESSION['idCourse'], array('completed', 'passed')); $totFailed = getStatStatusCount($idst, (int) $_SESSION['idCourse'], array('failed')); $stat_status = $cs->getUserStatusTr($user_course_info['status']); if (isset($_POST['start_filter']) && ($_POST['start_filter'] = 1)) { if ($totComplete) { // now print entry $content = array('<a href="index.php?modname=stats&op=statoneuser&idUser='******'" >' . $aclManager->relativeId($user_info[ACL_INFO_USERID]) . '</a>', $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME], '<a href="index.php?modname=stats&op=modstatus&idUser='******'">' . $stat_status . '</a>'); $content[] = $totComplete . '/' . $totFailed . '/' . $totItems; $content[] = renderProgress($totComplete, $totFailed, $totItems); $tabStat->addBody($content); } } else { // now print entry $content = array('<a href="index.php?modname=stats&op=statoneuser&idUser='******'" >' . $aclManager->relativeId($user_info[ACL_INFO_USERID]) . '</a>', $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME], '<a href="index.php?modname=stats&op=modstatus&idUser='******'">' . $stat_status . '</a>'); $content[] = $totComplete . '/' . $totFailed . '/' . $totItems; $content[] = renderProgress($totComplete, $totFailed, $totItems); $tabStat->addBody($content); } } } } $out->add($tabStat->getTable()); $out->add($tabStat->getNavBar($limit, $total_user)); $out->add($form->closeForm()); $out->add('</div>'); }
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 j*z 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; }
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 = '******' " . ($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 = '******'" . " 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); $tb->addHead($cont_h); //filter and organize data to display $display_data = array(); foreach ($course_data as $k => $value) { list($id_course, $code, $name, $user_status, $perm_close_lo) = $value; if (isset($available_cert[$id_course])) { $can_rel_exceptional = false; while (list($id_cert, $certificate) = each($available_cert[$id_course])) { if ($cert->certificateAvailableForUser($id_cert, $id_course, getLogUserId())) { if ($certificate[CERT_AV_POINT_REQUIRED] > 0) { $course_score_final = false; if ($perm_close_lo == 0) { require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_man = new OrganizationManagement(false); $score_final = $org_man->getFinalObjectScore(array(getLogUserId()), array($id_course)); if (isset($score_final[$id_course][getLogUserId()]) && $score_final[$id_course][getLogUserId()]['max_score']) { $course_score_final = $score_final[$id_course][getLogUserId()]['score']; $course_score_final_max = $score_final[$id_course][getLogUserId()]['max_score']; } } else { require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php'; $rep_man = new CourseReportManager(); $score_course = $rep_man->getUserFinalScore(array(getLogUserId()), array($id_course)); if (!empty($score_course)) { $course_score_final = isset($score_course[getLogUserId()][$id_course]) ? $score_course[getLogUserId()][$id_course]['score'] : false; $course_score_final_max = isset($score_course[getLogUserId()][$id_course]) ? $score_course[getLogUserId()][$id_course]['max_score'] : false; } } if ($course_score_final >= $certificate[CERT_AV_POINT_REQUIRED]) { $can_rel_exceptional = true; } } } } reset($available_cert[$id_course]); //count years for rowspans while (list($id_cert, $certificate) = each($available_cert[$id_course])) { //(aggiunto if prima dell'or) if ($cert->certificateAvailableForUser($id_cert, $id_course, getLogUserId())) { //$value[4] = $id_cert; list($available_for_status) = $arr_certificates_availability[$id_course][$id_cert]; list($date_inscr, $date_begin, $date_end, $status) = $arr_certificate_details[$id_course]; if ($available_for_status == 3 && $status == 2 || $available_for_status == 2 && $status == 1 || $available_for_status == 1) { //$year = substr($date_end, 0, 4); switch ($available_for_status) { case 3: $cur_year = substr($date_end, 0, 4); break; case 2: $cur_year = substr($date_begin, 0, 4); break; case 1: $cur_year = substr($date_inscr, 0, 4); break; default: $cur_year = '-'; } // (mi ricreo l'array value perchè manca di date_* BUG FIX) $value = array($id_course, $code, $name, $date_begin, $date_end, $user_status, $perm_close_lo); $value[6] = $id_cert; $query = "SELECT name " . " FROM " . $GLOBALS['prefix_lms'] . "_certificate" . " WHERE id_certificate = " . $id_cert; $res = sql_query($query); list($cname) = sql_fetch_row($res); $value[7] = $cname; if ($can_rel_exceptional && $certificate[CERT_AV_POINT_REQUIRED] > 0) { if (isset($years[$course_type][$cur_year])) { $years[$course_type][$cur_year]++; } else { $years[$course_type][$cur_year] = 1; } $display_data[$cur_year][] = $value; } elseif (!$can_rel_exceptional && $certificate[CERT_AV_POINT_REQUIRED] == 0) { if (isset($years[$course_type][$cur_year])) { $years[$course_type][$cur_year]++; } else { $years[$course_type][$cur_year] = 1; } $display_data[$cur_year][] = $value; } } } } } } if (count($display_data) > 0) { krsort($display_data); } $av_cert = 0; $prev_year = false; $rowspan_counter = 0; require_once $GLOBALS['where_lms'] . '/lib/lib.orgchart.php'; $org_man = new OrganizationManagement(false); foreach ($display_data as $year => $rows) { $first = true; foreach ($rows as $row) { // list($id_course, $code, $name, $user_status, $id_cert) = $row; list($id_course, $code, $name, $date_begin, $date_end, $user_status, $id_cert, $cname) = $row; $cont = array(); if ($first) { $cont[] = array('rowspan' => isset($years[$course_type][$year]) ? $years[$course_type][$year] : 1, 'value' => $year, 'style' => $type_h[0] . ' mycertificate_rowspan' . ($rowspan_counter % 2 > 0 ? '_odd' : '')); $rowspan_counter++; $first = false; } // 2 - the code of the course $cont[] = array('value' => $code, 'style' => $type_h[1]); // 3 - the name of the course $cont[] = array('value' => $name, 'style' => $type_h[2]); // sostituito date_begin con certificate name // 4 - starting date // $cont[] = array( // 'value' => Format::date($date_begin, 'datetime'), // 'style' => $type_h[3] // ); $cont[] = array('value' => $cname, 'style' => $type_h[3]); // 5 - complete date $cont[] = array('value' => Format::date($date_end, 'datetime'), 'style' => $type_h[4]); //-- scores -- $score_start = $org_man->getStartObjectScore(array(Docebo::user()->getIdST()), array($id_course)); $score_final = $org_man->getFinalObjectScore(array(Docebo::user()->getIdST()), array($id_course)); $_value1 = isset($score_start[$id_course][Docebo::user()->getIdST()]) && $score_start[$id_course][Docebo::user()->getIdST()]['max_score'] ? $score_start[$id_course][Docebo::user()->getIdST()]['score'] . ' / ' . $score_start[$id_course][Docebo::user()->getIdST()]['max_score'] : ''; $_value2 = isset($score_final[$id_course][Docebo::user()->getIdST()]) && $score_final[$id_course][Docebo::user()->getIdST()]['max_score'] ? $score_final[$id_course][Docebo::user()->getIdST()]['score'] . ' / ' . $score_final[$id_course][Docebo::user()->getIdST()]['max_score'] : ''; /* hide course scores - remove comment to show // 6 - init score $cont[] = array( 'value' => $_value1, 'style' => $type_h[5] ); // 7 - end score $cont[] = array( 'value' => $_value2, 'style' => $type_h[6] ); */ if (isset($released[$id_course][$id_cert])) { $av_cert++; if ($show_preview) { $cont[] = array('value' => '', 'style' => $type_h[7]); } $_value = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_TAKE_A_COPY') . '"><span>' . $lang->def('_TAKE_A_COPY') . '</span></a>'; $cont[] = array('value' => $_value, 'style' => $type_h[$show_preview ? 8 : 7]); } else { $av_cert++; if ($show_preview) { $_value = '<a class="ico-wt-sprite subs_view" href="' . $url->getUrl('op=preview_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_PREVIEW') . '"><span>' . $lang->def('_PREVIEW') . '</span></a>'; $cont[] = array('value' => $_value, 'style' => $type_h[7]); } $_value = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_cert . '&id_course=' . $id_course) . '" ' . ' title="' . $lang->def('_NEW_CERTIFICATE') . '"><span>' . $lang->def('_NEW_CERTIFICATE') . '</span></a>'; $cont[] = array('value' => $_value, 'style' => $type_h[$show_preview ? 8 : 7]); } $tb->addBody($cont); } } if ($av_cert > 0) { $table_displayed = true; $html_cert .= '<h2 class="mycertificate_title">' . $arr_course_types[$course_type] . '</h2>'; $html_cert .= $tb->getTable(); } } } //end course_type foreach if (!$table_displayed) { $is_filtering = Get::req('is_filtering_cert', DOTY_INT, 0); $html_cert .= '<p>' . ($is_filtering ? $html_filter_cert : '') . $lang->def('_NO_CONTENT') . '</p>'; } else { $html_cert = $html_filter_cert . $html_cert; } //------------------------------------------------------------------------------------------- /* * Print meta-certificates table */ $html_meta = ''; $tb_meta_cert = new Table(0); $cont_h = array(); $cont_h[] = $lang->def('_CODE'); $cont_h[] = $lang->def('_NAME'); $cont_h[] = $lang->def('_COURSE_LIST'); //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(); $type_h[] = ''; $type_h[] = ''; $type_h[] = ''; if ($show_preview) { $type_h[] = 'img-cell'; } //'nowrap'; $type_h[] = 'img-cell'; //'nowrap'; $tb_meta_cert->setColsStyle($type_h); $tb_meta_cert->addHead($cont_h); $query = "SELECT c.idMetaCertificate, m.title, m.description, m.idCertificate" . " FROM %lms_certificate_meta_course as c" . " JOIN %lms_certificate_meta as m ON c.idMetaCertificate = m.idMetaCertificate" . " WHERE c.idUser = '******'" . " GROUP BY c.idMetaCertificate" . " ORDER BY m.title, m.description"; $result = sql_query($query); $av_meta_cert = sql_num_rows($result); $cert_meta_html = ''; while (list($id_meta, $name, $description, $id_certificate) = sql_fetch_row($result)) { $cont = array(); $query = "SELECT code, name" . " FROM %lms_certificate" . " WHERE id_certificate = " . " (" . " SELECT idCertificate" . " FROM %lms_certificate_meta" . " WHERE idMetaCertificate = '" . $id_meta . "'" . " )"; list($code, $name) = sql_fetch_row(sql_query($query)); $cont[] = $code; $cont[] = $name; $query_released = "SELECT on_date" . " FROM %lms_certificate_meta_assign" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'"; $result_released = sql_query($query_released); $query = "SELECT user_release" . " FROM %lms_certificate" . " WHERE id_certificate = '" . $id_certificate . "'"; list($user_release) = sql_fetch_row(sql_query($query)); if (sql_num_rows($result_released)) { $course_list = ''; $first = true; $query_course = "SELECT code, name" . " FROM %lms_course" . " WHERE idCourse IN " . "(" . "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'" . ")"; $result_course = sql_query($query_course); while (list($code, $name) = sql_fetch_row($result_course)) { if ($first) { $first = false; } else { $course_list .= '<br/>'; } $course_list .= '(' . $code . ') - ' . $name; } $cont[] = $course_list; if ($show_preview) { $cont[] = ''; } list($date) = sql_fetch_row($result_released); $cont[] = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_TAKE_A_COPY') . '"><span>' . $lang->def('_TAKE_A_COPY') . '</span></a>'; $tb_meta_cert->addBody($cont); } elseif ($user_release == 0) { $av_meta_cert--; } else { $query = "SELECT idCourse" . " FROM %lms_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'"; $result_int = sql_query($query); $control = true; while (list($id_course) = sql_fetch_row($result_int)) { $query = "SELECT COUNT(*)" . " FROM %lms_courseuser" . " WHERE idCourse = '" . $id_course . "'" . " AND idUser = '******'" . " AND status = '" . _CUS_END . "'"; list($number) = sql_fetch_row(sql_query($query)); if (!$number) { $control = false; } } if ($control) { $course_list = ''; $first = true; $query_course = "SELECT code, name" . " FROM %lms_course" . " WHERE idCourse IN " . "(" . "SELECT idCourse" . " FROM " . $GLOBALS['prefix_lms'] . "_certificate_meta_course" . " WHERE idUser = '******'" . " AND idMetaCertificate = '" . $id_meta . "'" . ")"; $result_course = sql_query($query_course); while (list($code, $name) = sql_fetch_row($result_course)) { if ($first) { $first = false; } else { $course_list .= '<br/>'; } $course_list .= '(' . $code . ') - ' . $name; } $cont[] = $course_list; if ($show_preview) { $cont[] = '<a class="ico-wt-sprite subs_view" href="' . $url->getUrl('op=preview_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_PREVIEW') . '"><span>' . $lang->def('_PREVIEW') . '</span></a>'; } $cont[] = '<a class="ico-wt-sprite subs_pdf" href="' . $url->getUrl('op=release_cert&id_certificate=' . $id_certificate . '&idmeta=' . $id_meta) . '" ' . ' title="' . $lang->def('_NEW_CERTIFICATE') . '"><span>' . $lang->def('_NEW_CERTIFICATE') . '</span></a>'; $tb_meta_cert->addBody($cont); } else { $av_meta_cert--; } } } if ($av_meta_cert) { $html_meta .= $tb_meta_cert->getTable() . '<br/><br/>'; } else { //$is_filtering = Get::req('is_filtering_meta', DOTY_INT, 0); //$html_meta .= '<p>'.($is_filtering>0 ? $html_filter_meta : '').$lang->def('_NO_CONTENT').'</p>'; $html_meta .= '<p>' . $lang->def('_NO_CONTENT') . '</p>'; } //----------------------------------------------------------------------------- $selected_tab = Get::req('current_tab', DOTY_STRING, 'cert'); $html .= '<div id="mycertificate_tabs" class="yui-navset"> <ul class="yui-nav"> <li' . ($selected_tab == 'cert' ? ' class="selected"' : '') . '><a href="#cert"><em>' . Lang::t('_CERTIFICATE', 'menu') . '</em></a></li> <li' . ($selected_tab == 'meta' ? ' class="selected"' : '') . '><a href="#meta"><em>' . Lang::t('_TITLE_META_CERTIFICATE', 'certificate') . '</em></a></li> </ul> <div class="yui-content"> <div>' . $html_cert . '</div> <div>' . $html_meta . '</div> </div> </div>'; $html .= '</div>'; //close std_block div cout($html, 'content'); YuiLib::load('tabs'); cout('<script type="text/javascript">var myTabs = new YAHOO.widget.TabView("mycertificate_tabs");</script>', 'scripts'); }
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; }
public function getUserFinishedCoursepath($id_user, $conditions = '') { $query = "SELECT cp.id_path, cp.path_code, cp.path_name, cp.path_descr, cpu.course_completed" . " FROM %lms_coursepath AS cp" . " JOIN %lms_coursepath_user AS cpu ON cpu.id_path = cp.id_path" . " WHERE idUser = "******" " . $conditions . " ORDER BY cp.path_name"; $result = sql_query($query); $res = array(); while ($row = sql_fetch_assoc($result)) { $res[$row['id_path']] = $row; } require_once _lms_ . '/lib/lib.course.php'; $query = "SELECT cp.id_path, COUNT(*) " . " FROM %lms_coursepath AS cp JOIN %lms_coursepath_courses AS cpc " . " JOIN %lms_coursepath_user AS cpu JOIN %lms_courseuser AS cu " . " ON (cp.id_path = cpc.id_path AND cpc.id_item = cu.idCourse " . " AND cpu.id_path = cp.id_path AND cpu.idUser = cu.idUser " . $conditions . ") " . " WHERE cu.status = '" . _CUS_END . "' AND cu.idUser = "******" " . " GROUP BY cp.id_path"; $qres = sql_query($query); while (list($id_path, $count) = sql_fetch_row($qres)) { if (isset($res[$id_path])) { $res[$id_path]['course_completed'] = $count; } } $query_num_coursepath = "SELECT id_path, COUNT(*) as courses" . " FROM %lms_coursepath_courses" . " WHERE id_path IN (" . implode(',', array_keys($res)) . ")" . " GROUP BY id_path"; $result = sql_query($query_num_coursepath); while ($o = sql_fetch_object($result)) { $res[$o->id_path]['coursepath_courses'] = $o->courses; $res[$o->id_path]['percentage'] = $res[$o->id_path]['course_completed'] == 0 ? 0 : round($res[$o->id_path]['course_completed'] / $o->courses * 100, 0); if ($res[$o->id_path]['percentage'] < 100) { unset($res[$o->id_path]); } } return $res; }
/** * Returns a skin ID given its shortname * @param string $name Skin shortname * @return int Skin ID * @static */ function getIdFromName($name) { $query = 'SELECT sdnumber' . ' FROM ' . sql_table('skin_desc') . ' WHERE sdname="' . sql_real_escape_string($name) . '"'; $res = sql_query($query); $obj = sql_fetch_object($res); return $obj->sdnumber; }
function writePollReport($id_poll, $id_param, $back_url, $mvc = false) { require_once _lms_ . '/lib/lib.param.php'; require_once _lms_ . '/lib/lib.poll.php'; $poll_man = new PollManagement($id_poll); $report_man = new ReportPollManagement(); $poll_info = $poll_man->getPollAllInfo(); $valid_track = $report_man->getAllTrackId($id_poll, 'valid'); $tot_tracks = $report_man->getHowMuchStat($id_poll, 'valid'); // save page track info $quest_sequence_number = $poll_man->getInitQuestSequenceNumberForPage(1); $query_question = $report_man->getQuestions($id_poll); $treeview_value = str_replace('treeview_selected_' . $_SESSION['idCourse'], '', array_search($poll_info['title'], $_POST)); $editions_filter = Get::req('poll_editions_filter', DOTY_INT, -1); if (Get::req('del_filter', DOTY_STRING, '') != '') { $editions_filter = -1; } $output = ""; $str = (!$mvc ? '<div class="std_block">' : '') . '<div class="test_answer_space">'; if ($mvc) { $output .= $str; } else { cout($str, 'content'); } //--- filter on edition ------------------------------------------------------ //retrieve editions $query = "SELECT * FROM %lms_course_editions WHERE id_course = " . (int) $_SESSION['idCourse']; $res = sql_query($query); //is there any edition ? if (sql_num_rows($res) > 0) { $arr_editions = array(-1 => Lang::t('_FILTEREDITIONSELECTONEOPTION', 'stats', 'lms')); //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 and filter $str = Form::openForm('tree_filter_form', 'index.php?modname=stats&op=statcourse') . Form::getHidden('seq_0.' . $treeview_value, 'treeview_selected_' . $_SESSION['idCourse'] . $treeview_value, $poll_info['title']) . Form::getHidden('treeview_selected_' . $_SESSION['idCourse'], 'treeview_selected_' . $_SESSION['idCourse'], $treeview_value) . Form::getHidden('treeview_state_' . $_SESSION['idCourse'], 'treeview_state_' . $_SESSION['idCourse'], $_POST['treeview_state_' . $_SESSION['idCourse']]) . Form::openElementSpace() . Form::getDropdown(Lang::t('_FILTEREDITIONSELECTTITLE', 'stats', 'lms'), 'poll_editions_filter', 'poll_editions_filter', $arr_editions, $editions_filter) . Form::openButtonSpace() . Form::getButton('filter', 'filter', Lang::t('_SEARCH', 'stats', 'lms')) . Form::getButton('del_filter', 'del_filter', Lang::t('_DEL_FILTER', 'stats', 'lms')) . Form::closeButtonSpace() . Form::closeElementSpace() . Form::closeForm(); if ($mvc) { $output .= $str; } else { cout($str, 'content'); } } //------------------------------------------------------------------------------ $user = array(); $tracks = array(); if ($editions_filter > 0) { $query = "SELECT idUser FROM %lms_courseuser " . " WHERE idCourse = '" . (int) $_SESSION['idCourse'] . "' AND edition_id = '" . $editions_filter . "'"; $res = sql_query($query); while (list($idUser) = sql_fetch_row($res)) { $users[] = $idUser; } if (count($users) > 0) { $query_traks = "SELECT id_track " . " FROM %lms_polltrack " . " WHERE id_user IN (" . implode(', ', $users) . ") "; $result_traks = sql_query($query_traks); while (list($id_traks) = sql_fetch_row($result_traks)) { $tracks[$id_traks] = $id_traks; } } } if (!empty($tracks)) { $valid_track = array_intersect($valid_track, $tracks); } elseif ($editions_filter != -1) { $valid_track = array(); $valid_track[] = 0; } if (empty($valid_track)) { $valid_track[] = 0; } $tot_tracks = count($valid_track); //---------------------------------------------------------------------------- // Get question from database $re_question = sql_query($query_question); if (isset($_POST['export'])) { $export = true; $filename = 'stats_' . str_replace(' ', '_', $poll_info['title']) . '_' . date("Y\\_m\\_d") . '.csv'; $filetext = ''; } else { $export = false; } while (list($idQuest, $type_quest, $type_file, $type_class) = sql_fetch_row($re_question)) { require_once _lms_ . '/modules/question_poll/' . $type_file; $quest_obj = eval("return new {$type_class}( {$idQuest} );"); if ($export) { $filetext .= $quest_obj->export_CSV($quest_sequence_number, $tot_tracks, $valid_track); $filetext .= "\r\n"; } else { $GLOBALS['page']->add($quest_obj->playReport($quest_sequence_number, $tot_tracks, $valid_track), 'content'); } if ($type_quest != 'break_page' && $type_quest != 'title') { ++$quest_sequence_number; } } if ($export) { require_once _base_ . '/lib/lib.download.php'; sendStrAsFile($filetext, $filename); } $treeview_value = str_replace('treeview_selected_' . $_SESSION['idCourse'], '', array_search($poll_info['title'], $_POST)); $str = Form::openForm('tree_export_form', 'index.php?modname=stats&op=statcourse') . Form::getHidden('seq_0.' . $treeview_value, 'treeview_selected_' . $_SESSION['idCourse'] . $treeview_value, $poll_info['title']) . Form::getHidden('treeview_selected_' . $_SESSION['idCourse'], 'treeview_selected_' . $_SESSION['idCourse'], $treeview_value) . Form::getHidden('treeview_state_' . $_SESSION['idCourse'], 'treeview_state_' . $_SESSION['idCourse'], $_POST['treeview_state_' . $_SESSION['idCourse']]) . Form::openButtonSpace() . Form::getButton('export', 'export', Lang::t('_EXPORT_CSV', 'standard')) . Form::closeButtonSpace() . Form::closeForm(); if ($mvc) { $output .= $str; } else { cout($str, 'content'); } $str = '</div>' . (!$mvc ? '</div>' : ''); if ($mvc) { $output .= $str; } else { cout($str, 'content'); } }
public function getUserEditionsInfo($id_user, $courses) { if ((int) $id_user <= 0) { return FALSE; } if (is_numeric($courses)) { $courses = array($courses); } if (!is_array($courses)) { return FALSE; } if (empty($courses)) { return array(); } $enrolled_arr = array(); $qtxt = "SELECT d.id_course, d.id_date, COUNT(*) AS enrolled FROM\n\t\t\t%lms_course_date_user as du\n\t\t\tJOIN %lms_course_date d ON (du.id_date = d.id_date AND d.id_course IN (" . implode(",", $courses) . "))\n\t\t\tGROUP BY du.id_date"; $q = sql_query($qtxt); while ($obj = sql_fetch_object($q)) { $enrolled_arr[$obj->id_course][$obj->id_date] = $obj->enrolled; $date_arr[$obj->id_date] = $obj->enrolled; //$date_arr[$obj->id_course][$obj->id_date] = $obj->enrolled; $id_date_arr[] = $obj->id_date; } array_unique($id_date_arr); if (empty($id_date_arr)) { $id_date_arr = array(0); } $date_arr = array(); $qtxt = "SELECT dd.id_date, MIN(dd.date_begin) AS date_begin, MAX(dd.date_end) AS date_end,\n\t\t\tdd.pause_begin, dd.pause_end, c.idClassroom, c.name AS class_name,\n\t\t\tGROUP_CONCAT(DISTINCT l.location SEPARATOR ', ') AS location, d.id_course\n\t\t\tFROM %lms_course_date_day AS dd\n\t\t\tJOIN %lms_course_date AS d ON d.id_date = dd.id_date\n\t\t\tLEFT JOIN %lms_classroom AS c ON dd.classroom = c.idClassroom\n\t\t\tLEFT JOIN %lms_class_location AS l ON l.location_id = c.location_id\n\t\t\tWHERE dd.id_date IN (" . implode(',', $id_date_arr) . ")\n\t\t\tGROUP BY dd.id_date"; $q = sql_query($qtxt); while ($row = sql_fetch_assoc($q)) { $date_arr[$row['id_date']] = $row; //$date_arr[$row['id_course']][$row['id_date']] = $row; } $dates_minmax = array(); $query_minmax = "SELECT id_date, MIN(date_begin) AS date_min, MAX(date_end) AS date_max " . " FROM %lms_course_date_day WHERE id_date IN (" . implode(',', $id_date_arr) . ") GROUP BY id_date"; $res_minmax = sql_query($query_minmax); while (list($id_date, $date_min, $date_max) = sql_fetch_row($res_minmax)) { $dates_minmax[$id_date] = array($date_min, $date_max); } $output = array(); $query = "SELECT d.id_date, d.id_course, d.code, d.name, d.status\n\t\t\tFROM %lms_course_date AS d\n\t\t\tJOIN %lms_course_date_user AS du ON (du.id_date = d.id_date)\n\t\t\tWHERE du.id_user = "******" AND d.id_course IN (" . implode(",", $courses) . ")"; $id_date_arr = array(); $res = sql_query($query); while ($obj = sql_fetch_object($res)) { if (isset($date_arr[$obj->id_date])) { $output[$obj->id_course][$obj->id_date] = $obj; if (isset($enrolled_arr[$obj->id_course][$obj->id_date])) { $output[$obj->id_course][$obj->id_date]->enrolled = $enrolled_arr[$obj->id_course][$obj->id_date]; } if (isset($dates_minmax[$obj->id_date])) { $output[$obj->id_course][$obj->id_date]->date_min = $dates_minmax[$obj->id_date][0]; $output[$obj->id_course][$obj->id_date]->date_max = $dates_minmax[$obj->id_date][1]; } else { $output[$obj->id_course][$obj->id_date]->date_min = ''; $output[$obj->id_course][$obj->id_date]->date_max = ''; } $output[$obj->id_course][$obj->id_date]->date_info = $date_arr[$obj->id_date]; } } return $output; }
/** * Check if the days and classroom selection is available: return the intersecation * and if availability is ok the result will be an empty array * * @param <type> $info * @return array */ public function checkDateAvailability($info) { $output = array(); if (!empty($info)) { //get class occupation $classrooms = array(); foreach ($info as $day) { if ($day['classroom'] > 0 && !in_array($day['classroom'], $classrooms)) { $classrooms[] = $day['classroom']; } } if (!empty($classrooms)) { $query = "SELECT * FROM %lms_course_date_day WHERE classroom IN (" . implode(",", $classrooms) . ")"; $res = sql_query($query); while ($obj = sql_fetch_object($res)) { } } } return $output; }
static function create_selfpublishing_cover($id, $path = '') { $bg_color = "b3a396"; //nacteni dat ---------------------------------------------- $sql = sql_query("select selfpublishing.name,\n\t\t\t\t\t\t\t\t\t\t\t\t\tusers.nick\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom selfpublishing, users\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere (selfpublishing.id = '" . $id . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\tand selfpublishing.user = users.id)"); $data = sql_fetch_object($sql); $filename = "selfpublishing/" . $id . ".jpg"; //zpracovani nazvu ----------------------------------------------- //pokud presahne pocet moznych znaku, orezeme $name = $data->name; if (strlen(no_dia($name)) > 30) { $name = sub_str($name, 0, 30); } $lines = split(" ", $name); //radky rozdelene podle mezer $lines_breaked = array(); //to stejne + rozdelena dlouha slova for ($i = 0; $i < count($lines); $i++) { //pokud je slovo na radku dalsi nez 90 znaku, rozdelime (až na 3 nove radky) if (strlen(no_dia($lines[$i])) > 10) { $line1 = sub_str($lines[$i], 0, 10); $line2 = sub_str($lines[$i], 10, 10); $line3 = sub_str($lines[$i], 20, 10); $lines_breaked[] = trim($line1 . "-"); if ($line3) { $line2 .= "-"; } $lines_breaked[] = trim($line2); if ($line3) { $lines_breaked[] = trim($line3); } } else { $lines_breaked[] = trim($lines[$i]); } } //projdeme pole a slova, jejich spojena delka je mensi nez 9 spojime k sobe na jeden radek $lines_final = array(); for ($i = 0; $i <= count($lines_breaked); $i++) { if ($lines_breaked[$i] == "") { continue; } if (strlen(no_dia($lines_breaked[$i])) + strlen(no_dia($lines_breaked[$i + 1])) < 10) { $lines_breaked[$i] .= " " . $lines_breaked[$i + 1]; $lines_breaked[$i + 1] = ""; } $lines_final[] = trim($lines_breaked[$i]); } //spojime pole pomoci znaku \n $lines_final = array_slice($lines_final, 0, 3); $final_name = implode("\n", $lines_final); //vytvoreni obrazku --------------------------------------- $create_img = imagecreatetruecolor(156, 210); //potrebne barvy $r_bg = "0x" . substr($bg_color, 0, 2); $g_bg = "0x" . substr($bg_color, 2, 2); $b_bg = "0x" . substr($bg_color, 4, 2); $bg_color = imagecolorallocate($create_img, $r_bg, $g_bg, $b_bg); $r_bg = "0x" . substr($line_color, 0, 2); $g_bg = "0x" . substr($line_color, 2, 2); $b_bg = "0x" . substr($line_color, 4, 2); $line_color = imagecolorallocate($create_img, $r_bg, $g_bg, $b_bg); $text_color = imagecolorallocate($create_img, 255, 255, 255); $border_color = imagecolorallocate($create_img, 216, 212, 210); //vykresleni ramecku a obsahu imagefilledrectangle($create_img, 0, 0, 156, 210, $border_color); imagefilledrectangle($create_img, 1, 1, 154, 208, $bg_color); imagefilledrectangle($create_img, 1, 119, 155, 150, $border_color); //vykresleni nazvu a autoru $font_address = "grafika/SourceSansProSemibold.ttf"; imagettftext($create_img, 16, 0, 14, 40, $text_color, $font_address, mb_strtoupper($final_name, "UTF-8")); imagettftext($create_img, 9, 0, 14, 174, $text_color, $font_address, mb_strtoupper($data->nick, "UTF-8")); //ulozeni a uvolneni pameti imagejpeg($create_img, $filename, 98); imagedestroy($create_img); }
static function sent_payment_mail($id, $lang, $invoice_id) { //nacteme objednavku $sql = sql_query("select users.mail,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.id, orders.pay_method, orders.is_paid, orders.i_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.i_street, orders.i_city, orders.i_zip, orders.i_country,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.time, orders.payment_time, orders.company_name,\n\t\t\t\t\t\t\t\t\t\t\t\t\torders.company_ic, orders.company_dic\n\t\t\t\t\t\t\t\t\t\t\t\t\tfrom orders, users\n\t\t\t\t\t\t\t\t\t\t\t\t\twhere (orders.user = users.id\n\t\t\t\t\t\t\t\t\t\t\t\t\tand orders.id = '" . $id . "')"); $data = sql_fetch_object($sql); if (!$data->mail) { return; } //vytvorime url pro fakturu $invoice = new invoice($invoice_id); $hash = $invoice->access_hash(); // $invoice_url = "http://www.cbdb.cz/".$l->l("faktura")."-".$invoice_id."-".$hash; //hlavicka --------------------- $text = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; $text .= "<style type=\"text/css\">"; $text .= "* {"; $text .= "font-family: Verdana;"; $text .= "font-size: 13px;"; $text .= "}"; $text .= ".h td {"; $text .= "background-color: #9e0000;"; $text .= "color: #ffffff;"; $text .= "font-weight: bold;"; $text .= "padding-top: 2px;"; $text .= "padding-bottom: 2px;"; $text .= "border: solid 1px #9e0000;"; $text .= "}"; $text .= "table {"; $text .= "border-collapse: collapse;"; $text .= "min-width: 80%;"; $text .= "}"; $text .= "td {"; $text .= "padding-left: 6px;"; $text .= "padding-right: 6px;"; $text .= "padding-top: 4px;"; $text .= "padding-bottom: 4px;"; $text .= "border: solid 1px #aaaaaa;"; $text .= "vertical-align: top;"; $text .= "}"; $text .= "</style>"; $text .= "</head>"; $text .= "<body>"; // $text .= $l->t("header")."<br /><br />"; $text .= "<table>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td colspan=\"2\">".$l->t("info_h")."</td>\n"; $text .= "</tr>\n"; $text .= "<tr>\n"; $text .= "<td>\n"; // $text .= "<b>".$l->t("id")."</b>: ".$data->id."<br />"; // $text .= "<b>".$l->t("time")."</b>: ".date("j.n.Y", $data->time)."<br />"; // $text .= "<b>".$l->t("pay_type")."</b>: ".self::pay_type_str($data->pay_method)."<br />"; $text .= "</td>\n"; $text .= "<td>\n"; // $text .= "<b>".$l->t("mail")."</b>: ".$data->mail."<br />"; // $text .= "<b>".$l->t("state")."</b>: ".self::is_paid_str($data->is_paid)."<br />"; $text .= "</td>\n"; $text .= "</tr>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td colspan=\"2\">".$l->t("invoice_h")."</td>\n"; $text .= "</tr>\n"; $text .= "<tr>\n"; $text .= "<td colspan=\"2\">\n"; $text .= "<b>" . $data->i_name . "<br />"; $text .= "<b>" . $data->i_street . "<br />"; $text .= "<b>" . $data->i_city . "<br />"; // $text .= "<b>".$l->t("country_".$data->i_country)."<br />"; if ($data->company_name) { $text .= "<b>" . $data->company_name . "<br />"; // $text .= "<b>".$l->t("ic")." ".$data->company_ic."<br />"; // $text .= "<b>".$l->t("dic")." ".$data->company_dic."<br />"; } $text .= "</td>\n"; $text .= "</td>\n"; $text .= "</tr>\n"; $text .= "</table>\n"; //produkty --------------------- $text .= "<table>\n"; $text .= "<tr class=\"h\">\n"; // $text .= "<td>".$l->t("products_h")."</td>\n"; // $text .= "<td>".$l->t("price_h")."</td>\n"; // $text .= "<td>".$l->t("num_h")."</td>\n"; // $text .= "<td>".$l->t("sum_h")."</td>\n"; $text .= "</tr>\n"; $s = sql_query("select merchant, item, quantity, price_per_one\n\t\t\t\t\t\t\t\t\t\t\t\tfrom orders_items\n\t\t\t\t\t\t\t\t\t\t\t\twhere (order_id = '" . $id . "')"); $sum = 0; while ($d = sql_fetch_object($s)) { if ($d->merchant == 'audiolx') { $s_p = sql_query("select name, authors\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom merchant_audiolibrix\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (id = '" . $d->item . "')"); $d_p = sql_fetch_object($s_p); $authors = $d_p->authors; // $type = $l->t("type_audio"); } if ($d->merchant == 'self') { $s_p = sql_query("select selfpublishing.name,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tusers.nick\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tfrom users, selfpublishing\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twhere (users.id = selfpublishing.user\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tand selfpublishing.id = '" . $d->item . "')"); $d_p = sql_fetch_object($s_p); $authors = $d_p->nick; // $type = $l->t("type_self"); } $name = $d_p->name; $price = $d->price_per_one * $d->quantity; $sum += $price; $text .= "<tr>"; $text .= "<td>"; $text .= "<b>" . $name . "</b><br />"; // $text .= "<span style=\"font-size: 85%;\">- ".$l->t("author").": ".$authors.", ".$l->t("type").": ".$type."</span>"; $text .= "</td>\n"; // $text .= "<td>".$d->price_per_one." ".$l->cur()."</td>"; $text .= "<td>" . $d->quantity . "</td>"; // $text .= "<td>".$price." ".$l->cur()."</td>"; $text .= "</tr>"; } $text .= "<tr>"; $text .= "<td colspan=\"3\" style=\"text-align: right\">"; // $text .= "<b>".$l->t("sum_h")."</b>:</b>"; // $text .= "<td><b>".$sum." ".$l->cur()."</b></td>"; $text .= "</tr>"; $text .= "</table><br /><br />\n"; //stazeni ---------------------- // $text .= "<b>".$l->t("download")."</b><br /><br />"; // $text .= $l->t("download_text")."<br /><br />"; //faktura ---------------------- // $text .= "<b>".$l->t("invoice")."</b><br /><br />"; // $text .= $l->t("invoice_text", $invoice_url)."<br /><br /><br />"; //paticka ---------------------- // $text .= $l->t("footer")."<br /><br />"; $text .= "</body></html>"; //odesleme email -------------- $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-Type: text/html; charset=UTF-8' . "\r\n"; $headers .= 'From: CBDB.cz <*****@*****.**>' . "\r\n"; // $subject = $l->t("subject", $id); $sent = mail($data->mail, no_dia($subject), $text, $headers); if ($sent) { return 1; } return; }
function getCategoryIdFromName($name) { $res = sql_query('SELECT catid FROM ' . sql_table('category') . ' WHERE cblog=' . $this->getID() . ' and cname="' . sql_real_escape_string($name) . '"'); if (sql_num_rows($res) > 0) { $o = sql_fetch_object($res); return $o->catid; } else { return $this->getDefaultCategory(); } }
function _get_competences_query($type = 'html', $report_data = NULL, $other = '') { $cmodel = new CompetencesAdm(); if ($report_data == NULL) { $ref =& $_SESSION['report_tempdata']; } else { $ref =& $report_data; } $rc_filters =& $ref['columns_filter']['filters_list']; $rc_exclusive = $ref['columns_filter']['exclusive']; //die('<pre>'.print_r($rc_filters, true).'</pre>'); $final_arr = array(); $all_users = $ref['rows_filter']['all_users']; $users_selection = $ref['rows_filter']['users']; //check admin permissions if (Docebo::user()->getUserLevelId() != ADMIN_GROUP_GODADMIN && !Docebo::user()->isAnonymous()) { require_once _base_ . '/lib/lib.preference.php'; $adminManager = new AdminPreference(); $admin_tree = $adminManager->getAdminTree(Docebo::user()->getIdST()); $admin_users = Docebo::aclm()->getAllUsersFromIdst($admin_tree); $all_users = false; $users_selection = array_intersect($users_selection, $admin_users); unset($admin_users); //free some memory } if (!$all_users && empty($users_selection)) { cout(Lang::t('_EMPTY_SELECTION', 'report'), 'content'); return; } if (!$all_users) { $user_query_select = " AND t4.idst IN (" . implode(',', $users_selection) . ")"; } else { $user_query_select = ""; } //process filter and build query $table1 = "%lms_competence"; $table2 = "%lms_competence_lang"; $table3 = "%lms_competence_user"; $table4 = "%adm_user"; //extract all competneces for all selected users and store the data $arr_data = array(); $arr_userids = array(); $arr_competences = array(); $language = getLanguage(); $acl_man = Docebo::user()->getACLManager(); $query = "SELECT t1.id_competence, t2.name, t3.id_user, t4.userid, t3.score_got " . " FROM (" . $table1 . " as t1 LEFT JOIN " . $table2 . " as t2 ON (t1.id_competence = t2.id_competence " . " AND t2.lang_code='" . $language . "')) JOIN " . $table3 . " as t3 ON (t1.id_competence = t3.id_competence) " . " JOIN " . $table4 . " as t4 ON (t3.id_user = t4.idst AND t4.valid=1 " . $user_query_select . " ) " . " ORDER BY t4.userid"; $res = sql_query($query); while ($obj = sql_fetch_object($res)) { $arr_data[$obj->id_user][$obj->id_competence] = $obj->score_got; if (!in_array($obj->id_competence, $arr_competences)) { $arr_competences[] = $obj->id_competence; } $arr_userids[$obj->id_user] = $acl_man->relativeId($obj->userid); } if (count($arr_competences) <= 0) { cout(Lang::t('_NO_CONTENT', 'report'), 'content'); return; } $cinfo = $cmodel->getCompetencesInfo($arr_competences); $ucount = 0; $signs = array('0' => '<', '1' => '<=', '2' => '=', '3' => '>=', '4' => '>'); $conds = array(); $icon_actv = '<span class="ico-sprite subs_actv"><span>' . Lang::t('_COMPETENCE_OBTAINED', 'competences') . '</span></span>'; $icon_email = $this->_loadEmailIcon(); //prepare buffer object require_once _lms_ . '/admin/modules/report/report_tableprinter.php'; $buffer = new ReportTablePrinter($type, true); $buffer->openTable(Lang::t('_RC_CAPTION', 'report'), Lang::t('RC_CAPTION', 'report')); $buffer->openHeader(); //set header $_head = array(Lang::t('_USER', 'standard')); foreach ($arr_competences as $cid) { $_head[] = array('style' => 'img-cell', 'value' => $cinfo[$cid]->langs[$language]['name']); } if ($this->use_mail) { $_head[] = array('style' => 'img-cell', 'value' => $icon_email); } //render header $buffer->addHeader($_head); $buffer->closeHeader(); $buffer->openBody(); //die('<pre>'.print_r($rc_filters, true).'</pre>'); //check all data row and print them while (list($id_user, $ucomps) = each($arr_data)) { $is_valid = true; $satisfied = 0; $num_conditions = 0; foreach ($rc_filters as $id_competence => $filter) { if (isset($filter['flag'])) { //we are checking a competence of type 'flag' --> just check if the score exists and is > 0 $num_conditions++; if ($filter['flag'] == 'yes') { //check conditions if (array_key_exists($id_competence, $ucomps) && $ucomps[$id_competence] > 0) { $satisfied++; } } else { if (!array_key_exists($id_competence, $ucomps) || $ucomps[$id_competence] <= 0) { $satisfied++; } } } else { foreach ($filter as $fvalue) { $num_conditions++; $_sign = $fvalue['sign']; $_value = $fvalue['value']; if (array_key_exists($id_competence, $ucomps) && $ucomps[$id_competence] > 0) { //condition ok $condition = false; switch ($_sign) { case 0: $condition = $ucomps[$id_competence] < $_value; break; case 1: $condition = $ucomps[$id_competence] <= $_value; break; case 2: $condition = $ucomps[$id_competence] == $_value; break; case 3: $condition = $ucomps[$id_competence] >= $_value; break; case 4: $condition = $ucomps[$id_competence] > $_value; break; } if ($condition) { $satisfied++; } } } } } $is_valid = true; if ($num_conditions > 0) { $is_valid = false; if ($rc_exclusive && $satisfied >= $num_conditions) { $is_valid = true; } if (!$rc_exclusive && $satisfied > 0) { $is_valid = true; } } if ($is_valid) { //update lines counter $ucount++; //set line values $line = array($arr_userids[$id_user]); foreach ($arr_competences as $id_competence) { $line[] = array('style' => 'img-cell', 'value' => array_key_exists($id_competence, $ucomps) && $ucomps[$id_competence] > 0 ? $cinfo[$id_competence]->type == 'score' ? '<b>' . $ucomps[$id_competence] . '</b>' : $icon_actv : ''); } if ($this->use_mail) { $line[] = array('style' => 'img-cell', 'value' => '<div class="align_center">' . Form::getInputCheckbox('mail_' . $id_user, 'mail_recipients[]', $id_user, isset($_POST['select_all']), '') . '</div>'); } //render line $buffer->addLine($line); } } //check if we have rendered any row if ($ucount <= 0) { cout(Lang::t('_NO_CONTENT', 'report'), 'content'); return; } //close table $buffer->closeBody(); $buffer->closeTable(); //***************** cout($buffer->get()); if ($this->use_mail) { $this->_loadEmailActions(); } }
/** * Outputs the XML contents of the export file * * @param $setHeaders * set to 0 if you don't want to send out headers * (optional, default 1) */ function export($setHeaders = 1) { if ($setHeaders) { // make sure the mimetype is correct, and that the data does not show up // in the browser, but gets saved into and XML file (popup download window) header('Content-Type: text/xml'); header('Content-Disposition: attachment; filename="skinbackup.xml"'); header('Expires: 0'); header('Pragma: no-cache'); } echo "<nucleusskin>\n"; // meta echo "\t<meta>\n"; // skins foreach ($this->skins as $skinId => $skinName) { $skinName = htmlspecialchars($skinName, ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $skinName = mb_convert_encoding($skinName, 'UTF-8', _CHARSET); } echo "\t\t" . '<skin name="' . htmlspecialchars($skinName, ENT_QUOTES) . '" />' . "\n"; } // templates foreach ($this->templates as $templateId => $templateName) { $templateName = htmlspecialchars($templateName, ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $templateName = mb_convert_encoding($templateName, 'UTF-8', _CHARSET); } echo "\t\t" . '<template name="' . htmlspecialchars($templateName, ENT_QUOTES) . '" />' . "\n"; } // extra info if ($this->info) { if (strtoupper(_CHARSET) != 'UTF-8') { $skin_info = mb_convert_encoding($this->info, 'UTF-8', _CHARSET); } else { $skin_info = $this->info; } echo "\t\t<info><![CDATA[" . $skin_info . "]]></info>\n"; } echo "\t</meta>\n\n\n"; // contents skins foreach ($this->skins as $skinId => $skinName) { $skinId = intval($skinId); $skinObj = new SKIN($skinId); $skinName = htmlspecialchars($skinName, ENT_QUOTES); $contentT = htmlspecialchars($skinObj->getContentType(), ENT_QUOTES); $incMode = htmlspecialchars($skinObj->getIncludeMode(), ENT_QUOTES); $incPrefx = htmlspecialchars($skinObj->getIncludePrefix(), ENT_QUOTES); $skinDesc = htmlspecialchars($skinObj->getDescription(), ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $skinName = mb_convert_encoding($skinName, 'UTF-8', _CHARSET); $contentT = mb_convert_encoding($contentT, 'UTF-8', _CHARSET); $incMode = mb_convert_encoding($incMode, 'UTF-8', _CHARSET); $incPrefx = mb_convert_encoding($incPrefx, 'UTF-8', _CHARSET); $skinDesc = mb_convert_encoding($skinDesc, 'UTF-8', _CHARSET); } echo "\t" . '<skin name="' . $skinName . '" type="' . $contentT . '" includeMode="' . $incMode . '" includePrefix="' . $incPrefx . '">' . "\n"; echo "\t\t" . '<description>' . $skinDesc . '</description>' . "\n"; $que = 'SELECT' . ' stype,' . ' scontent ' . 'FROM ' . sql_table('skin') . ' WHERE' . ' sdesc = ' . $skinId; $res = sql_query($que); while ($partObj = sql_fetch_object($res)) { $type = htmlspecialchars($partObj->stype, ENT_QUOTES); $cdata = $this->escapeCDATA($partObj->scontent); if (strtoupper(_CHARSET) != 'UTF-8') { $type = mb_convert_encoding($type, 'UTF-8', _CHARSET); $cdata = mb_convert_encoding($cdata, 'UTF-8', _CHARSET); } echo "\t\t" . '<part name="' . $type . '">'; echo '<![CDATA[' . $cdata . ']]>'; echo "</part>\n\n"; } echo "\t</skin>\n\n\n"; } // contents templates foreach ($this->templates as $templateId => $templateName) { $templateId = intval($templateId); $templateName = htmlspecialchars($templateName, ENT_QUOTES); $templateDesc = htmlspecialchars(TEMPLATE::getDesc($templateId), ENT_QUOTES); if (strtoupper(_CHARSET) != 'UTF-8') { $templateName = mb_convert_encoding($templateName, 'UTF-8', _CHARSET); $templateDesc = mb_convert_encoding($templateDesc, 'UTF-8', _CHARSET); } echo "\t" . '<template name="' . $templateName . '">' . "\n"; echo "\t\t" . '<description>' . $templateDesc . "</description>\n"; $que = 'SELECT' . ' tpartname,' . ' tcontent' . ' FROM ' . sql_table('template') . ' WHERE' . ' tdesc = ' . $templateId; $res = sql_query($que); while ($partObj = sql_fetch_object($res)) { $type = htmlspecialchars($partObj->tpartname, ENT_QUOTES); $cdata = $this->escapeCDATA($partObj->tcontent); if (strtoupper(_CHARSET) != 'UTF-8') { $type = mb_convert_encoding($type, 'UTF-8', _CHARSET); $cdata = mb_convert_encoding($cdata, 'UTF-8', _CHARSET); } echo "\t\t" . '<part name="' . $type . '">'; echo '<![CDATA[' . $cdata . ']]>'; echo '</part>' . "\n\n"; } echo "\t</template>\n\n\n"; } echo '</nucleusskin>'; }
function RegistPath($objID, $path, $bid, $oParam, $name, $new = FALSE) { global $CONF; switch ($oParam) { case 'item': case 'member': if (preg_match('/.html$/', $path)) { $path = substr($path, 0, -5); } break; case 'blog': case 'category': case 'subcategory': break; default: return; break; } $bid = intval($bid); $objID = intval($objID); $name = rawurlencode($name); if ($new && $oParam == 'item') { $tque = 'SELECT itime as result FROM %s WHERE inumber = %d'; $itime = quickQuery(sprintf($tque, sql_table('item'), $objID)); list($y, $m, $d, $trush) = sscanf($itime, '%d-%d-%d %s'); $param['year'] = sprintf('%04d', $y); $param['month'] = sprintf('%02d', $m); $param['day'] = sprintf('%02d', $d); $dfItem = $this->getOption('customurl_dfitem'); $ikey = TEMPLATE::fill($dfItem, $param); if ($path == $ikey) { $path = $ikey . '_' . $objID; } } elseif (!$new && strlen($path) == 0) { $del_que = 'DELETE FROM %s WHERE obj_id = %d AND obj_param = "%s"'; sql_query(sprintf($del_que, _CUSTOMURL_TABLE, $objID, $oParam)); $msg = array(0, _DELETE_PATH, $name, _DELETE_MSG); return $msg; exit; } $dotslash = array('.', '/'); $path = str_replace($dotslash, '_', $path); if (!preg_match('/^[-_a-zA-Z0-9]+$/', $path)) { $msg = array(1, _INVALID_ERROR, $name, _INVALID_MSG); return $msg; exit; } $tempPath = $path; if ($oParam == 'item' || $oParam == 'member') { $tempPath .= '.html'; } $conf_que = 'SELECT obj_id FROM %s' . ' WHERE obj_name = "%s"' . ' AND obj_bid = %d' . ' AND obj_param = "%s"' . ' AND obj_id != %d'; $res = sql_query(sprintf($conf_que, _CUSTOMURL_TABLE, $tempPath, $bid, $oParam, $objID)); if ($res && sql_num_rows($res)) { $msg = array(0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); $path .= '_' . $objID; } if ($oParam == 'category' && !$msg) { $conf_cat = 'SELECT obj_id FROM %s WHERE obj_name = "%s"' . ' AND obj_param = "blog"'; $res = sql_query(sprintf($conf_cat, _CUSTOMURL_TABLE, $tempPath)); if ($res && sql_num_rows($res)) { $msg = array(0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); $path .= '_' . $objID; } } if ($oParam == 'blog' && !$msg) { $conf_blg = 'SELECT obj_id FROM %s WHERE obj_name = "%s"' . ' AND obj_param = "category"'; $res = sql_query(sprintf($conf_blg, _CUSTOMURL_TABLE, $tempPath)); if ($res && sql_num_rows($res)) { $msg = array(0, _CONFLICT_ERROR, $name, _CONFLICT_MSG); $path .= '_' . $objID; } } $newPath = $path; if ($oParam == 'item' || $oParam == 'member') { $newPath .= '.html'; } $query = 'SELECT * FROM %s WHERE obj_id = %d AND obj_param = "%s"'; $res = sql_query(sprintf($query, _CUSTOMURL_TABLE, $objID, $oParam)); $row = sql_fetch_object($res); $pathID = $row->id; if ($pathID) { $query = 'UPDATE %s SET obj_name = "%s" WHERE id = %d'; sql_query(sprintf($query, _CUSTOMURL_TABLE, $newPath, $pathID)); } else { $query = 'INSERT INTO %s (obj_param, obj_name, obj_id, obj_bid)' . ' VALUES ("%s", "%s", %d, %d)'; sql_query(sprintf($query, _CUSTOMURL_TABLE, $oParam, $newPath, $objID, $bid)); } switch ($oParam) { case 'blog': $this->setBlogOption($objID, 'customurl_bname', $path); break; case 'category': $this->setCategoryOption($objID, 'customurl_cname', $path); break; case 'member': $this->setMemberOption($objID, 'customurl_mname', $path); break; default: break; } return $msg; }
if ($db->sql_numrows($result8) > 0) { echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n" . "<font class=\"option\"><b>{$top} " . _VOTEDPOLLS . "</b></font><br><br><font class=\"content\">\n"; $lugar = 1; $result9 = sql_query("SELECT pollID, pollTitle, timeStamp, voters FROM " . $prefix . "_poll_desc {$querylang} order by voters DESC limit 0,{$top}", $dbi); $counter = 0; while ($object = sql_fetch_object($result9, $dbi)) { $resultArray[$counter] = array($object->pollID, $object->pollTitle, $object->timeStamp, $object->voters); $counter++; } for ($count = 0; $count < count($resultArray); $count++) { $id = $resultArray[$count][0]; $pollTitle = $resultArray[$count][1]; $voters = $resultArray[$count][3]; for ($i = 0; $i < 12; $i++) { $result10 = sql_query("SELECT optionCount FROM " . $prefix . "_poll_data WHERE (pollID='{$id}') AND (voteID='{$i}')", $dbi); $object = sql_fetch_object($result10, $dbi); $optionCount = $object->optionCount; $sum = (int) $sum + $optionCount; } echo "<strong><big>·</big></strong> {$lugar}: <a href=\"modules.php?name=Surveys&pollID={$id}\">{$pollTitle}</a> - ({$sum} " . _LVOTES . ")<br>\n"; $lugar++; $sum = 0; } echo "</font></td></tr></table><br>\n"; } /* Top 10 authors */ $result11 = $db->sql_query("SELECT aid, counter FROM " . $prefix . "_authors ORDER BY counter DESC LIMIT 0,{$top}"); if ($db->sql_numrows($result11) > 0) { echo "<table border=\"0\" cellpadding=\"10\" width=\"100%\"><tr><td align=\"left\">\n" . "<font class=\"option\"><b>{$top} " . _MOSTACTIVEAUTHORS . "</b></font><br><br><font class=\"content\">\n"; $lugar = 1; while ($row11 = $db->sql_fetchrow($result11)) {
/** * @static * @todo document this */ function _insertPluginOptions($context, $contextid = 0) { // get all current values for this contextid // (note: this might contain doubles for overlapping contextids) $aIdToValue = array(); $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid)); while ($o = sql_fetch_object($res)) { $aIdToValue[$o->oid] = $o->ovalue; } // get list of oids per pid $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin') . ' WHERE opid=pid and ocontext=\'' . sql_real_escape_string($context) . '\' ORDER BY porder, oid ASC'; $res = sql_query($query); $aOptions = array(); while ($o = sql_fetch_object($res)) { if (in_array($o->oid, array_keys($aIdToValue))) { $value = $aIdToValue[$o->oid]; } else { $value = $o->odef; } array_push($aOptions, array('pid' => $o->pid, 'pfile' => $o->pfile, 'oid' => $o->oid, 'value' => $value, 'name' => $o->oname, 'description' => $o->odesc, 'type' => $o->otype, 'typeinfo' => $o->oextra, 'contextid' => $contextid, 'extra' => '')); } global $manager; $manager->notify('PrePluginOptionsEdit', array('context' => $context, 'contextid' => $contextid, 'options' => &$aOptions)); $iPrevPid = -1; foreach ($aOptions as $aOption) { // new plugin? if ($iPrevPid != $aOption['pid']) { $iPrevPid = $aOption['pid']; if (!defined('_PLUGIN_OPTIONS_TITLE')) { define('_PLUGIN_OPTIONS_TITLE', 'Options for %s'); } echo '<tr><th colspan="2">' . sprintf(_PLUGIN_OPTIONS_TITLE, htmlspecialchars($aOption['pfile'], ENT_QUOTES)) . '</th></tr>'; } $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']); if (@$meta['access'] != 'hidden') { echo '<tr>'; listplug_plugOptionRow($aOption); echo '</tr>'; } } }
function doSkinVar($skinType, $numberOfWritebacks = 5, $filter = '', $TBorCm = 'all', $numberOfCharacters = 60, $numberOfTitleCharacters = 40, $toadd = "...") { global $manager, $CONF, $blog; if (!is_numeric($numberOfWritebacks)) { $filter = $numberOfWritebacks; $numberOfWritebacks = 5; // defaults to 5 } $b =& $manager->getBlog($CONF['DefaultBlog']); $this->defaultblogurl = $b->getURL(); if (!$this->defaultblogurl) { $this->defaultblogurl = $CONF['IndexURL']; } if ($blog) { $b =& $blog; } $blogid = $b->getID(); //for select $filter = trim($filter); if ($filter == 'current') { $filter = 'cblog = ' . $blogid; } elseif (strstr($filter, '=')) { $filter = str_replace('=', '', $filter); $filter = ' cblog IN(' . str_replace('/', ',', $filter) . ')'; } elseif (strstr($filter, '<>')) { $filter = str_replace('<>', '', $filter); $filter = ' cblog <> ' . str_replace('/', ' AND cblog <> ', $filter); } setlocale(LC_TIME, $this->getOption('timelocale')); $arr_res = array(); if ($TBorCm != 't') { $join = ''; $query = 'SELECT' . ' c.cnumber as commentid,' . ' c.cuser as commentator,' . ' c.cbody as commentbody,' . ' c.citem as itemid,' . ' c.cmember as memberid,' . ' SUBSTRING(c.ctime, 6, 5) as commentday,' . ' UNIX_TIMESTAMP(c.ctime) as ctimest'; if ($EzComment2 = $this->pluginCheck('EzComment2')) { if (method_exists($EzComment2, 'getTemplateParts')) { $query .= ', s.comid as cid, ' . 's.secflg as secret, ' . 's.module as modname, ' . 's.userID as identity '; $join = ' LEFT OUTER JOIN ' . sql_table('plug_ezcomment2') . ' as s ' . ' ON c.cnumber = s.comid '; } } // select $query .= ' FROM ' . sql_table('comment') . ' as c ' . $join; if ($filter) { $query .= ' WHERE ' . $filter; } $query .= ' ORDER by c.ctime DESC LIMIT 0, ' . $numberOfWritebacks; $comments = sql_query($query); if (sql_num_rows($comments)) { while ($row = sql_fetch_object($comments)) { $content = (array) $row; $tempBody = strip_tags($content['commentbody']); $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET); $tempBody = shorten($tempBody, $numberOfCharacters, $toadd); $tempBody = htmlspecialchars($tempBody, ENT_QUOTES, _CHARSET); $tempBody = str_replace("\r\n", ' ', $tempBody); $tempBody = str_replace("&", '&', $tempBody); $tempBody = str_replace(">", '>', $tempBody); $tempBody = str_replace("<", '<', $tempBody); $content['commentdate'] = strftime($this->getOption('cmdateformat'), $content['ctimest']); $content['commentbody'] = str_replace("&amp;", '&', $tempBody); if (!empty($row->memberid)) { $mem = new MEMBER(); $mem->readFromID(intval($row->memberid)); $content['commentator'] = $mem->getRealName(); } if ($EzComment2) { $bid = intval(getBlogIDFromItemID(intval($comment['itemid']))); if ($EzComment2->getBlogOption($bid, 'secret') == 'yes') { $b = $manager->getBlog($bid); global $member; $judge = $EzComment2->setSecretJudge($bid, $member, $b); } } if ($judge && $content['secret']) { $content = $EzComment2->JudgementCommentSecrets($content, $judge); } /* $cid = $row->cnumber; $ct = $row->ctimest; $ctst = date("y-m-d H:i",$ct); $text = strip_tags($row->cbody); $text = htmlspecialchars($text, ENT_QUOTES,_CHARSET); $ctext = shorten($text,$numberOfCharacters,$toadd); if (!$row->cmember) $myname = $row->cuser; else { $mem = new MEMBER; $mem->readFromID(intval($row->cmember)); $myname = $mem->getRealName(); }*/ // $itemlink = $this->_createItemLink($row->citem, ''); // $arr_res[$ct] = "<li>♣<a href=\"".$itemlink."#c".$cid."\">$ctst|".$myname.">".$ctext."</a></li>" ; $itemlink = $this->_createItemLink($content['itemid']); $content['itemlink'] = $itemlink; $arr_res[$content['ctimest']] = TEMPLATE::fill($this->getOption('cmttemplate'), $content); } } } //========================= if ($manager->pluginInstalled('NP_TrackBack') && $TBorCm != 'c') { $query = 'SELECT' . ' t.id as tbid,' . ' t.title as entrytitle,' . ' t.excerpt as expect,' . ' t.url as tburl,' . ' t.tb_id as trackbackid,' . ' t.blog_name as blogname,' . ' t.timestamp as tbdate,' . ' SUBSTRING(t.timestamp, 6, 5) as tbday,' . ' UNIX_TIMESTAMP(t.timestamp) as ttimest' . ' FROM ' . sql_table('plugin_tb') . ' t,' . sql_table('item') . ' i' . ' WHERE t.tb_id = i.inumber'; if ($this->checkTBVersion()) { $query .= ' and t.block = 0'; } if ($filter) { $tfilter = str_replace('c.cblog', 'i.iblog', $filter); $query .= ' and ' . $tfilter; } $query .= ' ORDER by t.timestamp DESC LIMIT 0, ' . $numberOfWritebacks; $comments = sql_query($query); if (sql_num_rows($comments)) { while ($row = sql_fetch_object($comments)) { $content = (array) $row; $entrytitle = strip_tags($content['entrytitle']); $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET); $entrytitle = shorten($entrytitle, $numberOfCharacters, $toadd); $entrytitle = htmlspecialchars($entrytitle, ENT_QUOTES, _CHARSET); $content['entrytitle'] = $entrytitle; $content['expect'] = str_replace("\r\n", ' ', $content['expect']); $blogname = htmlspecialchars($content['blogname'], ENT_QUOTES, _CHARSET); $content['blogname'] = $blogname; $content['tbdate'] = strftime($this->getOption('tbdateformat'), $content['ttimest']); /* $title = strip_tags($row->title); $title = htmlspecialchars($title, ENT_QUOTES,_CHARSET); $ctitle = shorten($title,$numberOfCharacters,$toadd); $blogname = htmlspecialchars($row->blog_name, ENT_QUOTES,_CHARSET); $tbtime = $row->ttimest; $ttst = date("y-m-d H:i",$tbtime);*/ // $itemlink = $this->_createItemLink($row->tb_id, ''); // $arr_res[$tbtime] = '<li>…<a href="'.$itemlink.'#trackback">'.$ttst.'|'.$blogname.' ping: "'.$ctitle.'"</a></li>'; $itemlink = $this->_createItemLink($content['trackbackid']); $content['itemlink'] = $itemlink; $arr_res[$content['ttimest']] = TEMPLATE::fill($this->getOption('tbktemplate'), $content); } } } //========================= krsort($arr_res); $ress = array_values($arr_res); $show_rescnt = min(intval($numberOfWritebacks), count($arr_res)); switch ($TBorCm) { case 'c': $head = $this->getOption('cmlisthead'); $foot = $this->getOption('cmlistfoot'); break; case 't': $head = $this->getOption('tblisthead'); $foot = $this->getOption('tblistfoot'); break; default: $head = ' <ul class="nobullets"> '; $foot = ' </ul> '; break; } // echo ' <ul class="nobullets"> '; echo $head; for ($j = 0; $j < $show_rescnt; $j++) { echo $ress[$j] . "\n"; } echo $foot; // echo " </ul> "; }
/** * Install custom plugins */ function installCustomPlugs(&$manager) { global $aConfPlugsToInstall, $DIR_LIBS; $aErrors = array(); if (count($aConfPlugsToInstall) == 0) { return $aErrors; } $res = sql_query('SELECT * FROM ' . sql_table('plugin')); $numCurrent = sql_num_rows($res); foreach ($aConfPlugsToInstall as $plugName) { // do this before calling getPlugin (in case the plugin id is used there) $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . ++$numCurrent . ', "' . addslashes($plugName) . '")'; sql_query($query); // get and install the plugin $manager->clearCachedInfo('installedPlugins'); $plugin =& $manager->getPlugin($plugName); $plugin->plugid = $numCurrent; if (!$plugin) { sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pfile=\'' . addslashes($plugName) . '\''); $numCurrent--; array_push($aErrors, _ERROR22 . $plugName); continue; } $plugin->install(); } // SYNC PLUGIN EVENT LIST sql_query('DELETE FROM ' . sql_table('plugin_event')); // loop over all installed plugins $res = sql_query('SELECT pid, pfile FROM ' . sql_table('plugin')); while ($o = sql_fetch_object($res)) { $pid = $o->pid; $plug =& $manager->getPlugin($o->pfile); if ($plug) { $eventList = $plug->getEventList(); foreach ($eventList as $eventName) { sql_query('INSERT INTO ' . sql_table('plugin_event') . ' (pid, event) VALUES (' . $pid . ', \'' . $eventName . '\')'); } } } return $aErrors; }