/** * Visualisation de l'aide * * @param string $toReturn * @return string */ public function _createContent(&$toReturn) { $tpl = new CopixTpl(); $displayAide = true; $daoAide = _ioDao('simplehelp'); $sp = _daoSp()->addCondition('page_sh', '=', $this->getParam('page_sh', null, null))->addCondition('key_sh', '=', $this->getParam('key_sh', null, null)); $arAide = $daoAide->findBy($sp); if (count($arAide) > 0) { $aide = $arAide[0]; } else { $displayAide = false; $aide = null; } // cette variable est crée pour différencier si l'aide doit être afficher dans un popup classique ou un popuinformation $popup = false; if ($this->getParam('popup', null, true) === "true") { $popup = true; } $tpl->assign('aide', $aide); $tpl->assign('displayAide', $displayAide); $tpl->assign('popup', $popup); // $tpl->assign ('nofloat', $this->getParam ('nofloat', false)); $toReturn = $tpl->fetch('showaide.tpl'); return true; }
public function processDefault() { $tpl = new CopixTpl(); $tplModule = new CopixTpl(); //if user is not connected : if (1) { // S'il y a un blog prevu a l'accueil $dispBlog = false; $getKernelLimitsIdBlog = Kernel::getKernelLimits('id_blog'); if ($getKernelLimitsIdBlog) { _classInclude('blog|kernelblog'); if ($blog = _ioDao('blog|blog')->getBlogById($getKernelLimitsIdBlog)) { // On v�rifie qu'il y a au moins un article $stats = KernelBlog::getStats($blog->id_blog); if ($stats['nbArticles']['value'] > 0) { $dispBlog = true; } } } if ($dispBlog) { //return CopixActionGroup::process ('blog|frontblog::getListArticle', array ('blog'=>$blog->url_blog)); return new CopixActionReturn(COPIX_AR_REDIRECT, CopixUrl::get('blog||', array('blog' => $blog->url_blog))); } if (!CopixConfig::exists('|can_public_rssfeed') || CopixConfig::get('|can_public_rssfeed')) { CopixHtmlHeader::addOthers('<link rel="alternate" href="' . CopixUrl::get('public||rss', array()) . '" type="application/rss+xml" title="' . htmlentities(CopixI18N::get('public|public.rss.flux.title')) . '" />'); } CopixHTMLHeader::addCSSLink(_resource("styles/module_fichesecoles.css")); $tplModule->assign('user', _currentUser()); $result = $tplModule->fetch('welcome|welcome_' . CopixI18N::getLang() . '.tpl'); $tpl->assign('TITLE_PAGE', '' . CopixI18N::get('public|public.welcome.title')); $tpl->assign('MAIN', $result); return new CopixActionReturn(COPIX_AR_DISPLAY, $tpl); } }
/** * Etablissement d'un challenge, sur la base d'un identifiant SSO * * @author Christophe Beyer <*****@*****.**> * @since 2006/12/08 * @param integer $id_sso Id SSO * @return string résultat du challenge. -ERR xxx si erreur, +OK xxx si c'est bon */ public function challenge() { $id_sso = $this->getRequest('id_sso', null); if (!$id_sso) { echo "-ERR ACC: id_sso manquant"; } elseif (!preg_match('/^[0-9]+$/', $id_sso)) { echo "-ERR ACC: id_sso doit être un nombre"; } else { $token = false; $sql = "SELECT login FROM kernel_sso_users WHERE id_sso = {$id_sso}"; $sso = _doQuery($sql); //print_r($sso); if ($sso) { // On efface l'éventuel challenge courant $daoChallenges = CopixDAOFactory::create('sso|sso_challenges'); $daoChallenges->deleteByIdSso($id_sso); // On insère le nouveau challenge $token = randomkeys(CopixConfig::get('sso|in_encrypt_size')); $res = record('kernel_sso_challenges'); $res->id_sso = $id_sso; $res->challenge = $token; $res->date = mktime(); _ioDao('kernel_sso_challenges')->insert($record); //print_r($res); // if ($res->_idResult != 1) { echo "-ERR BDD: Erreur lors de l'enregistrement dans la base de données"; } //Kernel::deb (md5($token.'FobVVbarwb')); //die(); $token = "+OK " . $token; } else { echo "-ERR ACC: id_sso inexistant"; } echo $token; } return new CopixActionReturn(COPIX_AR_NONE, 0); }
public function testOffsetExistsDAO() { $results = _ioDao('copix:copixconfig')->iFindBy(_daoSp()->addCondition('id_ccfg', '=', 'FOOOOOOOOOOOOVALUE')); $this->assertFalse(isset($results[0])); $results = _ioDAO('copix:copixconfig')->iFindAll(); $this->assertTrue(count($results) > 10); $this->assertTrue(isset($results[0])); }
public function cleanCode(&$content, $title = "") { $content = preg_replace('/<</', '«', $content); $content = preg_replace('/>>/', '»', $content); $content = preg_replace('/\\(c\\)/', '©', $content); $content = preg_replace('/\\(r\\)/', '®', $content); $content = preg_replace('/¿/', '¿', $content); //money $content = preg_replace('/€/', '€', $content); $content = preg_replace('/¥/', '¥', $content); $content = preg_replace('/¢/', '¢', $content); $content = preg_replace('/£/', '£', $content); //arrows $content = preg_replace('/-->/', '→', $content); $content = preg_replace('/<--/', '←', $content); $content = preg_replace('/<->/', '↔', $content); $content = preg_replace('/==>/', '⇒', $content); $content = preg_replace('/<==/', '⇐', $content); $content = preg_replace('/<=>/', '⇔', $content); //math //$content = preg_replace('/`(.*?)`/', '&\\1;', $content); $content = preg_replace('/=</', '≤', $content); $content = preg_replace('/>=/', '≥', $content); $content = preg_replace('/!=/', '≠', $content); $content = preg_replace('/~=/', '≅', $content); //remove tags $content = str_replace('<', '_lower_', $content); $content = str_replace('>', '_greater_', $content); //now replace _lower_ and _greater_ codes... $content = str_replace('_lower_', '<', $content); $content = str_replace('_greater_', '>', $content); //recreate some tags $content = str_replace('_end_strike_', "</del>", $content); $content = str_replace('_strike_', "<del>", $content); //rule $content = preg_replace('/\\n*\\-{4}\\n*/', "<hr />", $content); //code $content = preg_replace('/\'\'(.*?)\'\'/', "<code>\\1</code>", $content); //links $links = array(); preg_match_all('/\\[\\[(.*?)\\]\\]/', $content, $links); $foundlinks = $links[1]; $i = 0; foreach ($foundlinks as $foundlink) { //seek if we have | to set caption $elem = explode("|", $foundlink); $link = $elem[0]; $caption = isset($elem[1]) ? $elem[1] : $elem[0]; $style = "wiki_exists"; //anchors $anchor = explode("#", $link); $link = strlen($anchor[0]) ? $anchor[0] : $title; if (isset($anchor[1])) { $anchor = $anchor[1]; } else { $anchor = ""; } //is it an external link ? if (!preg_match('/http:/', $link)) { //no, so i think this is a wiki link //page exists ? $parts = explode('/', $link); $heading = ''; $lang = ''; if (count($parts) == 3) { $heading = $parts[0]; $link = $parts[1]; } elseif (count($parts) == 2) { $heading = $parts[0]; $link = $parts[1]; } $dao = _ioDao('wikipages'); $res = $dao->findBy(_daoSp()->startGroup()->addCondition('title_wiki', "=", CopixUrl::escapeSpecialChars($link))->addCondition('heading_wiki', '=', $heading)->endGroup()); if (!$res) { $style = "wiki_no_exists"; } else { $anchor = preg_replace("/[^a-zA-Z0-9]/", $this->anchor_separator, $anchor); } $link = _url('wiki||show', array('title' => $link, 'heading' => $heading)); } $link .= isset($anchor) && strlen($anchor) ? "#" . $anchor : ""; //now, replace link $link = "<a href=\"" . $link . "\" title=\"" . $caption . "\" class=\"{$style}\">{$caption}</a>"; //link has "//" but this is used for italic... so we have to //change it for now... see end function to restore links $link = str_replace("//", "_double_slashes_", $link); $content = str_replace($links[0][$i], $link, $content); $i++; } //images $images = array(); preg_match_all('/\\{\\{(.*?)\\}\\}/', $content, $images); $foundimages = $images[1]; $i = 0; foreach ($foundimages as $foundimg) { $elem = explode(":", $foundimg); if ($elem[0] == "file") { //case of file $class = "wiki_dl_file"; $image = "<a href=\"" . _url('wiki|file|getfile', array('title' => $elem[1])) . "\" title=\"" . $elem[1] . "\" class=\"{$class}\">" . $elem[1] . "</a>"; } else { $elem = explode("|", $foundimg); $foundimg = $elem[0]; $width = isset($elem[1]) ? $elem[1] : ""; $align = isset($elem[2]) ? $elem[2] : ""; $disp = ""; //is it an external link ? if (preg_match('/http:/', $foundimg)) { $alt = explode("/", $foundimg); $alt = $alt[count($alt) - 1]; $alt = explode('.', $alt); $alt = $alt[0]; if ($width) { //$disp = '<a href="' . $foundimg . '" target="_blank" title="' . _i18n ("wiki|wiki.show.fullsize") . '">(-)</a>'; $icon = "<img src=\"" . _resource('img/tools/loupe.png') . "\" alt=\"download\"/>"; $disp = '<a href="' . $foundimg . '" target="_blank" title="' . _i18n("wiki|wiki.show.fullsize") . '">' . $icon . '</a>'; $disp = "<span style=\"height:15px;margin-left: -15px;\">{$disp}</span>"; } } else { //no, so i think this is a wiki link $alt = $foundimg; $foundimg = _url('wiki|file|getFile', array('title' => $alt, 'size' => $width)); $_foundimg = _url('wiki|file|getFile', array('title' => $alt)); //$_foundimg="javascript:WikiSeeImage('$_foundimg','$alt')"; $_foundimg = '<a href="' . $_foundimg . '" rel="lightbox[' . $title . ']" title="' . $alt . '">'; if ($width) { $icon = "<img src=\"" . _resource("img/tools/loupe.png") . "\" alt=\"download\" style=\"z-index: 99\" />"; $disp = $_foundimg . $icon . "</a>"; $disp = "<span style=\"height:20px;margin-left: -15px;\">{$disp}</span>"; } if (function_exists("gd_info")) { $width = ""; //because gd resized image } } if (strlen($align) > 0) { $align = ' align="' . $align . '"'; } if (strlen($width) > 0) { $width = ' width="' . $width . '"'; } $image = ""; $image = "<span style=\"display: inline\">"; $image .= '<img name="wiki_image" src="' . $foundimg . '"' . $width . $align . ' alt="' . $alt . '" />'; $image .= $disp . "</span>"; } $content = str_replace($images[0][$i], $image, $content); $i++; } //footnotes preg_match_all('/\\(\\((.*?)\\)\\)/', $content, $fn); $fns = $fn[1]; $i = count($this->footnotes); $j = 0; foreach ($fns as $footnote) { $this->footnotes[] = $footnote; $content = str_replace($fn[0][$j], "<a href=\"#wiki_footnotes\" title=\"{$footnote}\"><sup>" . ($i + 1) . "</sup></a>", $content); $i++; $j++; } //other $content = preg_replace('/\\*{2}(.*?)\\*{2}/', "<strong>\\1</strong>", $content); $content = str_replace("http://", "_URI_STRING_", $content); $content = preg_replace('/\\/{2}(.*?)\\/{2}/', "<em>\\1</em>", $content); $content = str_replace("_URI_STRING_", "http://", $content); $content = preg_replace('/_{2}(.*?)_{2}/', "<u>\\1</u>", $content); //sup $content = preg_replace('/(.+?)\\^\\((.+?)\\)/', '\\1<sup>\\2</sup>', $content); $content = preg_replace('/sqrt\\((.+?)\\)/', ' √<span style="text-decoration: overline">\\1</span>', $content); //last modification: //$content = preg_replace("/(\s)+/", "\\1", $content); $content = str_replace("<br>", "<br />", $content); $content = preg_replace('/<h(\\d)><br \\/>/', "<h\\1>", $content); $content = str_replace("_double_slashes_", "//", $content); }
public function testUnTrainDB() { //DB mode $bayeszero = _Class('bayes|bayes'); $bayeszero->setDataMode("db", "CopixTests"); $bayeszero->train('foo', "foo bar baz"); $bayeszero->train('bar', "foo bar baz"); $bayeszero->train('bar', "foo2 bar2 baz2"); $find = ";foo2;bar2;baz2;"; $bayeszero->untrain('bar', "foo2 bar2 baz2"); $res = _ioDao('bayesian')->findBy(_daoSp()->addCondition('dataset_bayes', '=', 'CopixTests')->addCondition('category_bayes', '=', 'bar')->addCondition('datas_bayes', '=', $find)); $this->assertEquals(count($res), 0); //check if we haven't erased the first data $find = ";foo;bar;baz;"; $res = _ioDao('bayesian')->findBy(_daoSp()->addCondition('dataset_bayes', '=', 'CopixTests')->addCondition('category_bayes', '=', 'bar')->addCondition('datas_bayes', '=', $find)); $this->assertEquals(count($res), 1); }
/** * Untrain remove the data from dataset * @param string $categoryname * @param string $text */ public function untrain($cat, $text) { $texts = $this->prepareText($text); if ($this->mode != "db") { if (isset($this->categories[$cat]) && isset($this->categories[$cat]->texts)) { $i = 0; foreach ($this->categories[$cat]->texts as $t) { if ($texts == $t) { unset($this->categories[$cat]->texts[$i]); break; } $i++; } if (count($this->categories[$cat]->texts) < 1) { unset($this->categories[$cat]); } } } else { $find = ';' . implode(';', $texts) . ';'; $rec = _ioDao($this->dataset, $this->connectionName)->findBy(_daoSp()->addCondition('datas_bayes', '=', $find)->addCondition('category_bayes', '=', $cat)); if (count($rec)) { _ioDao($this->dataset, $this->connectionName)->delete($rec[0]->id_bayes); } } }
public function add($params) { $record = _record('stats|logs'); $record->date = date('Y-m-d H:i:s'); //$record->date = CopixDateTime::timeStampToyyyymmddhhiiss(mktime()); $record->profil = $params['profil']; $record->module_type = $params['module_type']; $record->module_id = $params['module_id']; $record->action = $params['action']; if ($params['parent_type']) { $record->parent_type = $params['parent_type']; } if ($params['parent_id']) { $record->parent_id = $params['parent_id']; } if ($params['objet_a']) { $record->objet_a = $params['objet_a']; } if ($params['objet_b']) { $record->objet_b = $params['objet_b']; } _ioDao('stats|logs')->insert($record); }
public function _createContent(&$toReturn) { CopixHtmlHeader::addCSSLink(_resource('styles/comments.css')); //Si pas d'éléments d'identifiant donné, alors on utilise l'ensemble des paramètres de la requête if (($id = $this->getParam('id')) == "") { $id = array_keys(CopixRequest::asArray()); } if (($mode = $this->getParam('mode')) == "" || $mode == "request") { if (($mode = _request('comments')) == "") { $mode = "summary"; } } if (($newUrl = $this->getParam('moreUrl')) == "") { $newUrl = _url('#', array('comments' => 'list')); } $tpl = new CopixTpl(); $tpl->assign('mode', $mode); $tpl->assign('newUrl', $newUrl); // On teste si nous sommes dans l'actions de prévisualisation if (_request('preview') !== null) { $tpl->assign('preview', 1); $tpl->assign('previewDate', date('YmdHis')); } if (CopixAuth::getCurrentUser()->testCredential('basic:admin')) { $tpl->assign('isAdmin', 1); } else { $tpl->assign('isAdmin', 0); } $idComment = _ioClass('commentsservices')->getId($id); // On vérifie si les commentaires sont ouvert $tpl->assign('locked', _dao('commentslocked')->countBy(_daoSp()->addCondition('locked_page_comment', '=', $idComment))); if ($informations = _ioClass('commentsservices')->getEnabled($idComment)) { $tpl->assign('newComment', $informations['object']); if (_request('errors') !== null) { $tpl->assign('errors', _ioDAO('comments')->check($informations['object'])); } } _ioClass('commentsservices')->addEnabled(array('fromPage' => _url('#'), 'writeCredential' => $this->getParam('credentialWrite'), 'id' => $idComment)); $tpl->assign('idComment', $idComment); switch ($mode) { case "list": if ($this->getParam('credentialRead') != "") { CopixAuth::getCurrentUser()->assertCredential($this->getParam('credentialRead')); } $tpl->assign('arrComments', _dao('comments')->findBy(_daoSp()->addCondition('page_comment', '=', $idComment))); break; case "summary": $tpl->assign('nbComments', _dao('comments')->countBy(_daoSp()->addCondition('page_comment', '=', $idComment))); break; } // Mise en place du captcha si besoin : if (CopixConfig::get('comments|captcha') != 0) { $arrCaptchaMax = _ioDao('commentscaptcha')->findBy(_daoSp()->orderBy(array('captcha_id', 'DESC'))->setLimit(0, 1)); $arrCaptchaMin = _ioDao('commentscaptcha')->findBy(_daoSp()->orderBy('captcha_id')->setLimit(0, 1)); $captcha = false; while (!$captcha || is_null($captcha)) { srand(); $rand = rand($arrCaptchaMin[0]->captcha_id, $arrCaptchaMax[0]->captcha_id); $captcha = _ioDao('commentscaptcha')->get($rand); } $tpl->assign('captcha', $captcha); } $toReturn = $tpl->fetch('zone.comment.tpl'); //_log ('URL: '._url('#')); //_log ('ID: ' . $idComment); return true; }
/** * Permet d'exporter les classes des modukes * * @return CopixActionReturn */ public function processExportClass() { $pModuleName = CopixRequest::get('moduleName'); $pClassFileName = CopixRequest::get('classFileName'); // si on a confirmé l'ajout if (CopixRequest::get('confirm')) { $pServiceName = trim(CopixRequest::get('serviceName')); $pClassName = CopixRequest::get('className'); $pClassFileName = _request('classFileName'); $pModuleName = _request('moduleName'); // nom de service vide if ($pServiceName == '') { return _arRedirect(_url('admin|ExportClass', array('error' => 'serviceEmpty', 'moduleName' => $pModuleName, 'classFileName' => $pClassFileName))); } // verification si on n'a pas déja un service de ce nom $wsservices = _ioDao('wsservices')->findBy(_daoSP()->addCondition('name_wsservices', '=', $pServiceName)); if (count($wsservices) > 0) { return _arRedirect(_url('admin|ExportClass', array('error' => 'serviceExists', 'moduleName' => $pModuleName, 'classFileName' => $pClassFileName))); } CopixDB::getConnection()->doQuery("insert into wsservices (name_wsservices, module_wsservices, file_wsservices, class_wsservices) values ('" . $pServiceName . "','" . $pModuleName . "','" . $pClassFileName . "', '" . $pClassName . "')"); $res = 'Url du Webservice : <a href="' . _url('wsserver||', array('wsname' => $pServiceName)) . '">' . _url('wsserver||', array('wsname' => $pServiceName)) . '</a><br/>' . "\n"; $res .= 'Url du fichier wsdl : <a href="' . _url('wsserver|default|wsdl', array('wsname' => $pServiceName)) . '">' . _url('wsserver|default|wsdl', array('wsname' => $pServiceName)) . '</a><br/>' . "\n"; $res .= '<br />'; $res .= '<input type="button" value="' . _i18n('wsserver.back') . '" onclick="javascript: document.location=\'' . _url('admin|manageWebServices') . '\';" />'; $tpl = new CopixTpl(); $tpl->assign('MAIN', $res); return new CopixActionReturn(CopixActionReturn::DISPLAY, $tpl); // si on doit afficher le formulaire d'ajout } else { $ppo = new CopixPPO(); $ppo->TITLE_PAGE = _i18n('wsserver.title.manageWebServices'); $ppo->classFileName = $pClassFileName; $ppo->arErrors = array(); // erreur "service existant" passée en paramètre if (_request('error') !== null) { $ppo->arErrors[] = _i18n('wsserver.error.' . _request('error')); } $ppo->ModuleName = $pModuleName; $arBefore = get_declared_classes(); include CopixModule::getPath($pModuleName) . COPIX_CLASSES_DIR . $pClassFileName; $arAfter = get_declared_classes(); $arClass = array_diff($arAfter, $arBefore); sort($arClass); if (count($arClass) == 0) { throw new Exception('Pas de classe à exporter'); } $ppo->arClass = $arClass; return _arPPO($ppo, 'wsservices.add.php'); } }
/** * Effacer une aide simple * */ public function processDelete() { if (CopixRequest::get('id_sh', null) === null) { return CopixActionGroup::process('generictools|Messages::getError', array('message' => _i18n('simplehelp.error.missingParameters'), 'back' => _url('simplehelp|admin|listAide'))); } $dao = _ioDao('simplehelp'); if (!($toDelete = $dao->get(CopixRequest::get('id_sh')))) { return CopixActionGroup::process('generictools|Messages::getError', array('message' => _i18n('simplehelp.unableToFind'), 'back' => _url('simplehelp|admin|listAide'))); } //Confirmation screen ? if (CopixRequest::get('confirm', null) === null) { return CopixActionGroup::process('generictools|Messages::getConfirm', array('title' => _i18n('simplehelp.title.confirmdelevent'), 'message' => _i18n('simplehelp.message.confirmdelevent'), 'confirm' => _url('simplehelp|admin|delete', array('id_sh' => $toDelete->id_sh, 'confirm' => '1')), 'cancel' => _url('simplehelp|admin|listAide'))); } //Delete aide $dao->delete($toDelete->id_sh); return _arRedirect(_url('simplehelp|admin|listAide')); }
/** * Récupération en session des paramètres de la leçon en édition * @access: private. */ public function _getSessionLecon() { $tmp = _ioDao('lecon'); $inSession = _sessionGet('modules|agenda|edited_lecon'); return $inSession ? unserialize($inSession) : null; }
/** * R�cup�ration en session des param�tres de l'�v�nement en �dition * @access: private. */ public function _getSessionEvent() { $tmp = _ioDao('event'); $inSession = _sessionGet('modules|agenda|edited_event'); return $inSession ? unserialize($inSession) : null; }
/** * Liste de groupes * * @author Christophe Beyer <*****@*****.**> * @since 2005/11/08 * @param integer $forum Id du forum * @return array Tableau avec les groupes */ public function getListPublic($offset, $count, $kw = null) { $criteres = _daoSp(); $criteres->addCondition('is_open', '=', 1); if (CopixConfig::exists('kernel|groupeAssistance') && ($groupeAssistance = CopixConfig::get('kernel|groupeAssistance'))) { $criteres->addCondition('id', '!=', $groupeAssistance); } // D�coupage du pattern if ($kw) { $testpattern = str_replace(array(" ", "%20"), "%20", $kw); $temp = split("%20", $testpattern); $criteres->startGroup(); foreach ($temp as $word) { if ($word != "") { $criteres->addCondition('titre', 'LIKE', "%{$word}%", 'or'); $criteres->addCondition('description', 'LIKE', "%{$word}%", 'or'); } } $criteres->endGroup(); } if ($offset) { $criteres->setOffset($offset); } if ($count) { $criteres->setCount($count); } $criteres->orderBy(array('date_creation', 'desc')); $list = _ioDao('groupe|groupe')->findBy($criteres); //search tags by Id or Name $listTag = new CopixDAORecordIterator(_doQuery('SELECT g.id AS id, g.titre AS titre, g.description AS description, g.is_open AS is_open, g.createur AS createur, g.date_creation AS date_creation FROM module_groupe_groupe AS g JOIN module_tags_groups AS tg ON tg.id_group = g.id JOIN module_tags AS t ON tg.id_tag = t.id WHERE g.is_open=1 AND t.name LIKE "%' . $kw . '%" OR t.id = ' . (int) $kw), $this->getDAOId()); //merge records $listGroupFinal = array(); foreach ($list as $l) { $listGroupFinal[] = $l; } foreach ($listTag as $l) { $listGroupFinal[] = $l; } $list = $listGroupFinal; $arGroupes = array(); $groupListId = array(); foreach ($list as $groupe) { if (in_array($groupe->id, $groupListId)) { continue; } $groupListId[] = $groupe->id; $parent = Kernel::getNodeParents("CLUB", $groupe->id); $ok = true; if (Kernel::getKernelLimits('ville')) { if ($parent) { $ville = GroupeService::getGroupeVille($groupe->id, $parent); if (!in_array($ville, Kernel::getKernelLimits('ville_as_array'))) { $ok = false; } } else { $ok = false; } } if ($ok) { $groupe->parent = $parent; $arGroupes[] = $groupe; } } $results = $arGroupes; return $results; }