function fma_filter($type, $filename, $Extension) { $autorise = false; $error = ""; if ($type == "f") { $filename = removeHack($filename); } $filename = preg_replace('#[/\\\\:\\*\\?"<>|]#i', '', rawurldecode($filename)); $filename = str_replace("..", "", $filename); // Liste des extensions autorisées $suffix = strtoLower(substr(strrchr($filename, '.'), 1)); if ($suffix != "" or $type == "d") { if (in_array($suffix, $Extension) or $Extension[0] == "*" or $type == "d") { // Fichiers interdits en fonction de qui est connecté if (fma_autorise($type, $filename)) { $autorise = true; } else { $error = fma_translate("Fichier interdit"); } } else { $error = fma_translate("Type de fichier interdit"); } } else { $error = fma_translate("Fichier interdit"); } $tab[] = $autorise; $tab[] = $error; $tab[] = $filename; return $tab; }
/** * Sorts Hours by Day. * * @param $a * @param $b * @return int */ public static function sortByWeekDayFunc($a, $b) { $a = substr(strtolower($a->getDay()), 0, 2); $b = substr(strtoLower($b->getDay()), 0, 2); $days = array("mo", "tu", "we", "th", "fr", "sa", "su"); $indexA = array_search($a, $days); $indexB = array_search($b, $days); if ($indexA === $indexB) { return 0; } return $indexA < $indexB ? -1 : 1; }
/** * Sorts Hours by Day. * * @param $a * @param $b * @return int */ public static function sortByWeekDayFunc(Doghouse_Location_Model_Hour $hourA, Doghouse_Location_Model_Hour $hourB) { // Get the first two letters of the day title $a = substr(strtolower($hourA->getDay()), 0, 2); $b = substr(strtoLower($hourB->getDay()), 0, 2); $days = array("mo", "tu", "we", "th", "fr", "sa", "su"); $indexA = array_search($a, $days); $indexB = array_search($b, $days); if ($indexA === $indexB) { return 0; } return $indexA < $indexB ? -1 : 1; }
public static function search($node, $keyword, $contentType = "") { $aryPages = PageHelper::getDescendants($node, $contentType); $aryResult = array(); $strKeyword = strToLower($keyword); foreach ($aryPages as $objPage) { $aryFields = $objPage->getFields(); foreach ($aryFields as $objField) { if (strstr(strtoLower($objField->getValue()), $strKeyword)) { $aryResult[] = $objPage; break; } } } return $aryResult; }
public function __construct($arr = null) { if (is_null($arr)) { return; } foreach ($arr as $k => $val) { $arrTmp = explode('_', $val); foreach ($arrTmp as $tK => $tV) { if ($tK == 0) { $arrTmp[$tK] = strtoLower($tV); } else { $arrTmp[$tK] = strtoupper(substr($tV, 0, 1)) . strtoLower(substr($tV, 1)); } } $this->{'_' . implode('', $arrTmp)} = null; } }
function LoadList() { while (false !== ($file = readdir($this->Handle))) { if (@is_dir($file) && $file != "." && $file != "..") { $this->DirsList["Name"][] = $file; $this->DirsList["DateM"][] = $this->LastUpdate($file); $this->DirsList["Size"][] = $this->GetDirSz ? $this->GetDirSize($file) : ''; $this->DirsList["Perms"][] = $this->PresPerms($this->GetPerms($file)); } elseif (@is_file($file) && $file != "." && $file != "..") { $suffix = strtoLower(substr(strrchr($file, '.'), 1)); if (in_array($suffix, $this->Extension) or $this->Extension[0] == "*") { $this->FilesList["Name"][] = $file; $this->FilesList["DateM"][] = $this->LastUpdate($file); $this->FilesList["Size"][] = filesize($file); $this->FilesList["Perms"][] = $this->PresPerms($this->GetPerms($file)); $this->FilesList["View"][] = $suffix; } } } }
/** * Returns a new "image" object based on the file extension * * @param object $album the owner album * @param string $filename the filename * @param bool $quiet set true to supress error messages (used by loadimage) * @return object */ function newImage($album, $filename, $quiet = false) { global $_zp_extra_filetypes; if (is_array($filename)) { $xalbum = new Album(new Gallery(), $filename['folder']); $filename = $filename['filename']; } else { $xalbum = $album; } if (!is_object($xalbum) || strtoLower(get_class($xalbum)) != 'album' || !$xalbum->exists) { $msg = sprintf(gettext('Bad album object parameter to newImage(%s)'), $filename); debugLogBacktrace($msg); trigger_error(html_encode($msg), E_USER_NOTICE); return NULL; } if ($ext = is_valid_other_type($filename)) { $object = $_zp_extra_filetypes[$ext]; $image = new $object($xalbum, $filename); } else { if (is_valid_image($filename)) { $image = new _Image($xalbum, $filename); } else { $image = NULL; } } if ($image) { zp_apply_filter('image_instantiate', $image); if ($image->exists) { return $image; } else { return NULL; } } if (!$quiet) { $msg = sprintf(gettext('Bad filename suffix in newImage(%s)'), $filename); debugLogBacktrace($msg); trigger_error(html_encode($msg), E_USER_NOTICE); } return NULL; }
/** * Searches for included .php files in code * and appends their content to $code reference var * * @param $file - path to code file(s) */ public function getIncludes($file) { $matches = array(); $lines = array(); $fp = fopen($file, "r"); if ($fp) { while (!feof($fp)) { $lines[] = fgets($fp, 4096); } fclose($fp); } else { $this->output .= "\nCould not open file: " . $file; return; } $line = ''; foreach ($lines as $line) { $fileName = 'x'; if (strstr($line, 'include') || strstr($line, 'include_once') || strstr($line, 'require') || strstr($line, 'require_once')) { preg_match('#[0-9a-zA-Z_\\-\\s]*\\.class\\.php#', $line, $matches); $fileName = isset($matches[0]) ? $matches[0] : 'x'; } /* check files included with getService() and loadClass() */ if (strstr($line, 'modx->getService')) { $pattern = "/modx\\s*->\\s*getService\\s*\\(\\s*\\'[^,]*,\\s*'([^']*)/"; preg_match($pattern, $line, $matches); if (isset($matches[1])) { $s = strtoLower($matches[1]); if (strstr($s, '.')) { $r = strrev($s); $fileName = strrev(substr($r, 0, strpos($r, '.'))); } else { $fileName = $s; } } } if (strstr($line, 'modx->loadClass')) { $pattern = "/modx\\s*->\\s*loadClass\\s*\\(\\s*\\'([^']*)/"; preg_match($pattern, $line, $matches); if (isset($matches[1])) { $s = strtoLower($matches[1]); if (strstr($s, '.')) { $r = strrev($s); $fileName = strrev(substr($r, 0, strpos($r, '.'))); } else { $fileName = $s; } } } $fileName = strstr($fileName, 'class.php') ? $fileName : $fileName . '.class.php'; if (isset($this->classFiles[$fileName])) { /* skip files we've already included */ if (!in_array($fileName, $this->included)) { $this->scriptCode .= file_get_contents($this->classFiles[$fileName] . '/' . $fileName); $this->included[] = $fileName; $this->getIncludes($this->classFiles[$fileName] . '/' . $fileName); } } } }
/** * Copy one uploaded file to his destination and insert an entry in the database * @access private * @return boolean TRUE if OK */ function uploadFile($IdPost, $IdTopic, $name, $size, $type, $src_file, $inline = DEFAULT_INLINE) { global $MAX_FILE_SIZE; global $mimetypes, $mimetype_default; global $insert_base; settype($size, 'integer'); $this->errno = 0; # Check temporary file # -------------------- if (empty($src_file) || strcasecmp($src_file, 'none') == 0) { $this->errno = NO_FILE; return false; } # Check size # ---------- if ($size == 0) { $this->errno = FILE_EMPTY; return false; } else { $fsize = filesize($src_file); } if ($size != $fsize) { $this->errno = ERR_FILE; return FALSE; } if ($size > $MAX_FILE_SIZE) { $this->errno = FILE_TOO_BIG; return FALSE; } # Check name # ---------- if (empty($name)) { $this->errno = NO_FILE; return false; } $name = preg_replace('#[/\\\\:\\*\\?"<>|]#i', '_', rawurldecode($name)); # Check type and extension # ------------------------ load_mimetypes(); $suffix = strtoLower(substr(strrchr($name, '.'), 1)); if (isset($mimetypes[$suffix])) { $type = $mimetypes[$suffix]; } elseif (empty($type) || $type == 'application/octet-stream') { $type = $mimetype_default; } if (!$this->isAllowedFile($name, $type)) { $this->errno = INVALID_FILE_TYPE; return FALSE; } # Find the path to upload directory # ------------------------------------------- global $DOCUMENTROOT; $rep = $DOCUMENTROOT; settype($log_filename, "string"); if ($insert_base == true) { # insert attachment reference in database # --------------------------------------- $id = insertAttachment($this->apli, $IdPost, $IdTopic, $this->IdForum, $name, $this->upload_dir, $inline, $size, $type); if ($id <= 0) { $this->errno = DB_ERROR; return FALSE; } # copy temporary file to the upload directory # ------------------------------------------- $dest_file = $rep . $this->upload_dir . "{$id}." . $this->apli . ".{$name}"; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $dest_file)) { deleteAttachment($this->apli, $IdPost, $rep . $this->upload_dir, $id, $name); $this->errno = COPY_ERROR; return FALSE; } @chmod($dest_file, 0766); $log_filename = $dest_file; } else { if ($this->apli == "minisite") { # copy temporary file to the upload directory # ------------------------------------------- global $rep_upload_minisite; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $rep . $rep_upload_minisite . $name)) { $this->errno = COPY_ERROR; return FALSE; } @chmod($rep . $rep_upload_minisite . $name, 0766); $log_filename = $rep . $rep_upload_minisite . $name; } elseif ($this->apli == "editeur") { # copy temporary file to the upload directory # ------------------------------------------- global $rep_upload_editeur; $copyfunc = function_exists('move_uploaded_file') ? 'move_uploaded_file' : 'copy'; if (!$copyfunc($src_file, $rep . $rep_upload_editeur . $name)) { $this->errno = COPY_ERROR; return FALSE; } @chmod($rep . $rep_upload_editeur . $name, 0766); $log_filename = $rep . $rep_upload_editeur . $name; } else { return FALSE; } } Ecr_Log("security", "Upload File(s) : " . getip(), $log_filename); return TRUE; }
function att_icon($filename) { global $att_icons, $att_icon_default, $att_icon_multiple; load_mimetypes(); $suffix = strtoLower(substr(strrchr($filename, '.'), 1)); return isset($att_icons[$suffix]) ? $att_icons[$suffix] : $att_icon_default; }
$mime_dspfmt['image/x-png'] = ATT_DSP_IMG; $mime_dspfmt['image/jpeg'] = ATT_DSP_IMG; $mime_dspfmt['image/pjpeg'] = ATT_DSP_IMG; $mime_dspfmt['text/html'] = ATT_DSP_HTML; $mime_dspfmt['text/plain'] = ATT_DSP_PLAINTEXT; $mime_dspfmt['application/x-shockwave-flash'] = ATT_DSP_SWF; // attachement $mime_renderers[ATT_DSP_PLAINTEXT] = "<div class=\"list-group-item\"><div align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</div><pre>\$att_contents</pre></div>"; //$mime_renderers[ATT_DSP_PLAINTEXT] = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"background-color: #000000;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr><td align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</td></tr><tr><td style=\"background-color: #ffffff;\"><pre>\$att_contents</pre></td></tr></table></td></tr></table>"; $mime_renderers[ATT_DSP_HTML] = "<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td style=\"background-color: #000000;\"><table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" width=\"100%\"><tr><td align=\"center\" style=\"background-color: #cccccc;\">\$att_name\$visible_wrn</td></tr><tr><td style=\"background-color: #ffffff;\">\$att_contents</td></tr></table></td></tr></table>"; $mime_renderers[ATT_DSP_LINK] = "\n<a class=\"list-group-item\" href=\"\$att_url\" target=\"_blank\" >\n\$att_icon<span title=\"" . upload_translate("Télécharg.") . " \$att_name (\$att_type - \$att_size)\" data-toggle=\"tooltip\" style=\"font-size: .85rem;\"><strong> \$att_name</strong></span><span class=\"tag tag-default tag-pill pull-right\" style=\"font-size: .75rem;\">\$compteur <i class=\"fa fa-lg fa-download\"></i></span><br /><span align=\"center\">\$visible_wrn</span></a>"; $mime_renderers[ATT_DSP_IMG] = "<a class=\"list-group-item\" href=\"javascript:void(0);\" onclick=\"window.open('\$att_url','fullsizeimg','menubar=no,location=no,directories=no,status=no,copyhistory=no,height=600,width=800,toolbar=no,scrollbars=yes,resizable=yes');\"><img src=\"\$att_url\" alt=\"\$att_name\" border=\"0\" \$img_size />\$visible_wrn </a>"; $mime_renderers[ATT_DSP_SWF] = "<p align=\"center\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4\\,0\\,2\\,0\" \$img_size><param name=\"quality\" value=\"high\"><param name=\"SRC\" value=\"\$att_url\"><embed src=\"\$att_url\" quality=\"high\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" \$img_size></embed></object>\$visible_wrn</p>"; // images $att_icons = ""; $handle = opendir("images/upload/file_types"); while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $prefix = strtoLower(substr($file, 0, strpos($file, '.'))); $att_icons[$prefix] = "<img src=\"images/upload/file_types/" . $file . "\" border=\"0\" align=\"center\" alt=\"\" />"; $att_icons[$prefix] = ' <span class="fa-stack"> <i class="fa fa-file fa-stack-2x"></i> <span class="fa-stack-1x filetype-text">' . $prefix . '</span> </span>'; } } closedir($handle); $att_icon_default = "<img src=\"images/upload/file_types/unknown.gif\" border=\"0\" align=\"center\" alt=\"\" />"; $att_icon_multiple = "<img src=\"images/upload/file_types/multiple.gif\" border=\"0\" align=\"center\" alt=\"\" />"; $att_icon_dir = "<img src=\"images/upload/file_types/dir.gif\" border=\"0\" align=\"center\" alt=\"\" />";
function saveuser($uid, $name, $uname, $email, $femail, $url, $pass, $vpass, $bio, $user_avatar, $user_icq, $user_occ, $user_from, $user_intrest, $user_sig, $user_viewemail, $user_aim, $user_yim, $user_msnm, $attach, $usend_email, $uis_visible, $user_lnl, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $M1, $M2, $T1, $T2, $B1, $MAX_FILE_SIZE, $raz_avatar) { global $NPDS_Prefix; global $user, $userinfo, $system, $minpass; $cookie = cookiedecode($user); $check = $cookie[1]; $result = sql_query("SELECT uid, email FROM " . $NPDS_Prefix . "users WHERE uname='{$check}'"); list($vuid, $vemail) = sql_fetch_row($result); if ($check == $uname and $uid == $vuid) { if (isset($pass) && "{$pass}" != "{$vpass}") { message_error("<i class=\"fa fa-exclamation\"></i> " . translate("Both passwords are different. They need to be identical.") . "<br /><br />", ""); } elseif ($pass != "" && strlen($pass) < $minpass) { message_error("<i class=\"fa fa-exclamation\"></i> " . translate("Sorry, your password must be at least") . " <strong>{$minpass}</strong> " . translate("characters long") . "<br /><br />", ""); } else { $stop = userCheck("edituser", $email); if (!$stop) { if ($bio) { $bio = FixQuotes(strip_tags($bio)); } if ($attach) { $t = 1; } else { $t = 0; } if ($user_viewemail) { $a = 1; } else { $a = 0; } if ($usend_email) { $u = 1; } else { $u = 0; } if ($uis_visible) { $v = 0; } else { $v = 1; } if ($user_lnl) { $w = 1; } else { $w = 0; } if ($url != "") { if (!substr_count($url, "http://")) { $url = "http://" . $url; } if (trim($url) == "http://") { $url = ""; } } include_once "modules/upload/upload.conf.php"; global $avatar_size; if (!$avatar_size) { $avatar_size = "80*100"; } $avatar_limit = explode("*", $avatar_size); if ($DOCUMENTROOT != "") { $rep = $DOCUMENTROOT; } else { global $DOCUMENT_ROOT; if ($DOCUMENT_ROOT) { $rep = $DOCUMENT_ROOT; } else { $rep = $_SERVER['DOCUMENT_ROOT']; } } if ($B1 != "none") { global $language; include_once "modules/upload/lang/upload.lang-{$language}.php"; include_once "modules/upload/clsUpload.php"; $upload = new Upload(); $upload->maxupload_size = $MAX_FILE_SIZE; $field1_filename = trim($upload->getFileName("B1")); $suffix = strtoLower(substr(strrchr($field1_filename, '.'), 1)); if ($suffix == "gif" or $suffix == "jpg" or $suffix == "png") { $field1_filename = removeHack(preg_replace('#[/\\\\:\\*\\?"<>|]#i', '', rawurldecode($field1_filename))); $field1_filename = preg_replace('#\\.{2}|config.php|/etc#i', '', $field1_filename); if ($field1_filename) { if ($autorise_upload_p) { $user_dir = $racine . "/users_private/" . $uname . "/"; if (!is_dir($rep . $user_dir)) { @umask("0000"); if (@mkdir($rep . $user_dir, 0777)) { $fp = fopen($rep . $user_dir . "index.html", 'w'); fclose($fp); } else { $user_dir = $racine . "/users_private/"; } } } else { $user_dir = $racine . "/users_private/"; } if ($upload->saveAs($uname . "." . $suffix, $rep . $user_dir, "B1", true)) { $old_user_avatar = $user_avatar; $user_avatar = $user_dir . $uname . "." . $suffix; $img_size = @getimagesize($rep . $user_avatar); if ($img_size[0] > $avatar_limit[0] or $img_size[1] > $avatar_limit[1]) { $raz_avatar = true; } if ($racine == "") { $user_avatar = substr($user_avatar, 1); } } } } } if ($raz_avatar) { if (strstr($user_avatar, "/users_private")) { @unlink($rep . $user_avatar); @unlink($rep . $old_user_avatar); } $user_avatar = "blank.gif"; } if ($pass != '') { cookiedecode($user); if (!$system) { $pass = crypt($pass, $pass); } sql_query("UPDATE " . $NPDS_Prefix . "users SET name='{$name}', email='{$email}', femail='" . removeHack($femail) . "', url='" . removeHack($url) . "', pass='******', bio='" . removeHack($bio) . "', user_avatar='{$user_avatar}', user_icq='" . removeHack($user_icq) . "', user_occ='" . removeHack($user_occ) . "', user_from='" . removeHack($user_from) . "', user_intrest='" . removeHack($user_intrest) . "', user_sig='" . removeHack($user_sig) . "', user_aim='" . removeHack($user_aim) . "', user_yim='" . removeHack($user_yim) . "', user_msnm='" . removeHack($user_msnm) . "', user_viewemail='{$a}', send_email='{$u}', is_visible='{$v}', user_lnl='{$w}' WHERE uid='{$uid}'"); $result = sql_query("SELECT uid, uname, pass, storynum, umode, uorder, thold, noscore, ublockon, theme FROM " . $NPDS_Prefix . "users WHERE uname='{$uname}' AND pass='******'"); if (sql_num_rows($result) == 1) { $userinfo = sql_fetch_assoc($result); docookie($userinfo['uid'], $userinfo['uname'], $userinfo['pass'], $userinfo['storynum'], $userinfo['umode'], $userinfo['uorder'], $userinfo['thold'], $userinfo['noscore'], $userinfo['ublockon'], $userinfo['theme'], $userinfo['commentmax'], ""); } } else { sql_query("UPDATE " . $NPDS_Prefix . "users SET name='{$name}', email='{$email}', femail='" . removeHack($femail) . "', url='" . removeHack($url) . "', bio='" . removeHack($bio) . "', user_avatar='{$user_avatar}', user_icq='" . removeHack($user_icq) . "', user_occ='" . removeHack($user_occ) . "', user_from='" . removeHack($user_from) . "', user_intrest='" . removeHack($user_intrest) . "', user_sig='" . removeHack($user_sig) . "', user_aim='" . removeHack($user_aim) . "', user_yim='" . removeHack($user_yim) . "', user_msnm='" . removeHack($user_msnm) . "', user_viewemail='{$a}', send_email='{$u}', is_visible='{$v}', user_lnl='{$w}' WHERE uid='{$uid}'"); } sql_query("UPDATE " . $NPDS_Prefix . "users_status SET attachsig='{$t}' WHERE uid='{$uid}'"); $result = sql_query("SELECT uid FROM " . $NPDS_Prefix . "users_extend WHERE uid='{$uid}'"); if (sql_num_rows($result) == 1) { sql_query("UPDATE " . $NPDS_Prefix . "users_extend SET C1='" . removeHack($C1) . "', C2='" . removeHack($C2) . "', C3='" . removeHack($C3) . "', C4='" . removeHack($C4) . "', C5='" . removeHack($C5) . "', C6='" . removeHack($C6) . "', C7='" . removeHack($C7) . "', C8='" . removeHack($C8) . "', M1='" . removeHack($M1) . "', M2='" . removeHack($M2) . "', T1='" . removeHack($T1) . "', T2='" . removeHack($T2) . "', B1='{$B1}' WHERE uid='{$uid}'"); } else { $result = sql_query("INSERT INTO " . $NPDS_Prefix . "users_extend VALUES ('{$uid}','" . removeHack($C1) . "', '" . removeHack($C2) . "', '" . removeHack($C3) . "', '" . removeHack($C4) . "', '" . removeHack($C5) . "', '" . removeHack($C6) . "', '" . removeHack($C7) . "', '" . removeHack($C8) . "', '" . removeHack($M1) . "', '" . removeHack($M2) . "', '" . removeHack($T1) . "', '" . removeHack($T2) . "', '{$B1}')"); } if ($pass != "") { logout(); } else { header("location: user.php?op=edituser"); } } else { message_error($stop, ""); } } } else { Header("Location: index.php"); } }
protected function createResultMap($vo, $row) { $reflection = new \ReflectionObject($vo); $newVo = $reflection->newInstance(); foreach ($row as $colName => $colVal) { $arrTmp = explode('_', $colName); foreach ($arrTmp as $tK => $tV) { if ($tK == 0) { $arrTmp[$tK] = strtoLower($tV); } else { $arrTmp[$tK] = strtoupper(substr($tV, 0, 1)) . strtoLower(substr($tV, 1)); } } $newVo->{'set' . implode('', $arrTmp)}($colVal); //$newVo->{'set'.str_replace('_','',$colName)}($colVal); } return $newVo; }
<?php // Loop through posts foreach ($posts_by_tag as $post) { setup_postdata($post); $category_array = get_the_category(); $category = $category_array[0]; $category_name = $category->cat_name; if ($category_name == 'Opdagelser') { $category_name = 'Opdagelse'; } ?> <li class="h6"> <div class="meta"> <span class="h4 <?php echo 'cat-' . strtoLower($category_name); ?> "> <?php echo $category_name; ?> </span> <span class="h5 text-left date"> <?php echo mysql2date('j. F Y', $post->post_date); ?> </span> </div> <a class="link" href="<?php echo get_post_permalink($post->post_ID);
<?php // get years that have posts $years = $wpdb->get_results("SELECT YEAR(post_date) AS year FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY year DESC"); foreach ($years as $year) { // get posts for each year $posts_this_year = $wpdb->get_results("SELECT ID, post_title FROM wp_posts WHERE post_type = 'post' AND post_status = 'publish' AND YEAR(post_date) = '" . $year->year . "' "); // reverse array of posts krsort($posts_this_year); echo '<h2 class="year-title year-' . $year->year . ' col col-xs-12">' . $year->year . '</h2>'; echo '<span class="year-amount col col-xs-12">' . count($posts_this_year) . ' indlæg' . '</span>'; echo '<div class="year-posts col col-xs-12"><ul>'; foreach ($posts_this_year as $post) { $category_array = get_the_category($post->post_ID); $category = $category_array[0]; $category_name = $category->cat_name; echo '<li><a class="link h6 cat-' . strtoLower($category_name) . '" href="' . get_post_permalink($post->post_ID) . '">' . $post->post_title . '</a></li>'; } echo '</div></ul>'; } ?> </div> </div> <!-- /.container --> </section> </main><!-- #main --> </div><!-- #primary --> <?php
function csvtoservice($url, $options) { $csv = get($url); $lines = preg_split('/\\r?\\n/msi', $csv); $columns = split(',', strtoLower(preg_replace('/\\s/', '', $lines[0]))); $colstring = join(',', $columns); if ($options['preset']) { $pres = $options['preset']; foreach (array_keys($pres) as $p) { $presetstring .= ' and ' . $p . ' like "%' . $pres[$p] . '%"'; } $columns = array_diff($columns, array_keys($pres)); } if ($options['filter']) { $columns = array_diff($columns, $options['filter']); } if ($options['prefill']) { foreach (array_keys($options['prefill']) as $p) { $_GET[$p] = $options['prefill'][$p]; } } if ($options['rename']) { $renames = array_keys($options['rename']); foreach ($columns as $k => $c) { foreach ($renames as $r) { if (!in_array($c, $renames)) { $displaycolumns[$k] = $c; } else { if ($c == $r) { $displaycolumns[$k] = $options['rename'][$r]; } } } } } else { $displaycolumns = $columns; } foreach ($columns as $c) { filter_input(INPUT_GET, $c, FILTER_SANITIZE_SPECIAL_CHARS); $fromget[$c] = $_GET[$c]; } $current = preg_replace('/.*\\/+/', '', $_SERVER['PHP_SELF']); $csvform = '<form action="' . $current . '">'; foreach ($columns as $k => $c) { $csvform .= '<div><label for="' . $c . '">' . ($options['uppercase'] ? ucfirst($displaycolumns[$k]) : $displaycolumns[$k]) . '</label>' . '<input type="text" id="' . $c . '" name="' . $c . '" value="' . $fromget[$c] . '"></div>'; } $csvform .= '<div id="bar"><input type="submit" name="csvsend"' . ' value="search"></div>'; $csvform .= '</form>'; if (isset($_GET['csvsend'])) { $yql = 'select * from csv where url="' . $url . '" ' . 'and columns="' . $colstring . '"'; foreach ($columns as $c) { if (isset($_GET[$c]) && $_GET[$c] != '') { $yql .= ' and ' . $c . ' like "%' . $_GET[$c] . '%"'; } } $yql .= $presetstring; $yqlquery = '<div id="yql">' . $yql . '</div>'; $yqlendpoint = 'http://query.yahooapis.com/v1/public/yql?format=json'; $query = $yqlendpoint . '&q=' . urlencode($yql); $data = get($query); $datadecoded = json_decode($data); $csvtable = '<table><thead><tr>'; foreach ($columns as $k => $c) { $csvtable .= '<th scope="col">' . ($options['uppercase'] ? ucfirst($displaycolumns[$k]) : $displaycolumns[$k]) . '</th>'; } $csvtable .= '</tr></thead><tbody>'; if ($datadecoded->query->results->row) { foreach ($datadecoded->query->results->row as $r) { $csvtable .= '<tr>'; foreach ($columns as $c) { $csvtable .= '<td>' . $r->{$c} . '</td>'; } $csvtable .= '</tr>'; } } else { $csvtable .= '<tr><td class="error" colspan="' . sizeof($columns) . '">No results found. Bummer.</td></tr>'; } $csvtable .= '</tbody></table>'; } return array('table' => $csvtable, 'form' => $csvform, 'query' => $yqlquery, 'json' => $data); }
// Application générique : la présence de getfile.conf.php est nécessaire // Application générique : la présence de getfile.conf.php est nécessaire case "getfile": if (file_exists("{$att_id}/getfile.conf.php") or file_exists("{$att_id}/.getfile.conf.php")) { $fic = "{$att_id}/{$att_name}"; } else { header("location: index.php"); } break; case "f-manager": $fic = "{$att_id}/{$att_name}"; break; } include "modules/upload/lang/upload.lang-{$language}.php"; include "modules/upload/include/mimetypes.php"; $suffix = strtoLower(substr(strrchr($att_name, '.'), 1)); if (isset($type)) { list($type, $garbage) = explode(';', $type); } // strip "; name=.... " (Opera6) if (isset($mimetypes[$suffix])) { $type = $mimetypes[$suffix]; } elseif (empty($type) || $type == 'application/octet-stream') { $type = $mimetype_default; } $att_type = $type; $att_size = @filesize($fic); if (file_exists($fic)) { if ($apli == "forum_npds") { include "auth.php"; $sql = "UPDATE {$upload_table} SET compteur = compteur+1 WHERE att_id = '{$att_id}'";
$Titlesitename = upload_translate("Télécharg."); include "meta/meta.php"; if ($url_upload_css) { $url_upload_cssX = str_replace('style.css', "{$language}-style.css", $url_upload_css); if (is_readable($url_upload . $url_upload_cssX)) { $url_upload_css = $url_upload_cssX; } print "<link href=\"" . $url_upload . $url_upload_css . "\" title=\"default\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" />\n"; } echo "</head>\n"; if (isset($actiontype)) { switch ($actiontype) { case 'upload': $ret = editeur_upload(); if ($ret != '') { $suffix = strtoLower(substr(strrchr($ret, '.'), 1)); if ($suffix == 'gif' or $suffix == 'jpg' or $suffix == 'png') { echo "\n <script type=\"text/javascript\">\n //<![CDATA[\n parent.tinymce.activeEditor.selection.setContent('<img class=\"img-fluid\" src=\"{$ret}\" alt=" . basename($ret) . " />');\n //]]>\n </script>"; } else { echo "<script type=\"text/javascript\">\n //<![CDATA[\n parent.tinymce.activeEditor.selection.setContent('<a href=\"{$ret}\" target=\"_blank\" class=\"noir\">" . basename($ret) . "</a>');\n //]]>\n </script>"; } } echo "<script type=\"text/javascript\">\n //<![CDATA[\n top.tinymce.activeEditor.windowManager.close();\n// top.close();\n //]]>\n </script>"; die; break; } } echo ' <body topmargin="3" leftmargin="3" rightmargin="3"> <div class="card card-block"> <form method="post" action="' . $_SERVER['PHP_SELF'] . '" enctype="multipart/form-data" name="formEdit">
function listarticles($secid) { global $user, $prev; global $NPDS_Prefix; if (file_exists("sections.config.php")) { include "sections.config.php"; } $result = sql_query("SELECT secname, rubid, image, intro, userlevel FROM " . $NPDS_Prefix . "sections WHERE secid='{$secid}'"); list($secname, $rubid, $image, $intro, $userlevel) = sql_fetch_row($result); list($rubname) = sql_fetch_row(sql_query("SELECT rubname FROM " . $NPDS_Prefix . "rubriques WHERE rubid='{$rubid}'")); if ($sections_chemin) { $title = aff_langue($rubname) . " - " . aff_langue($secname); } else { $title = aff_langue($secname); } include 'header.php'; global $SuperCache; if ($SuperCache) { $cache_obj = new cacheManager(); $cache_obj->startCachingPage(); } else { $cache_obj = new SuperCacheEmpty(); } if ($cache_obj->genereting_output == 1 or $cache_obj->genereting_output == -1 or !$SuperCache) { $okprint1 = autorisation_section($userlevel); if ($okprint1) { if ($prev == 1) { echo "<input class=\"btn btn-primary\" type=\"button\" value=\"" . translate("Back to console") . "\" onclick=\"javascript:history.back()\" /><br /><br />"; } if (function_exists("themesection_title")) { themesection_title($title); } else { echo '<h3>' . $title . '</h3>'; } if ($intro != '') { echo aff_langue($intro); } if ($image != '') { if (file_exists("images/sections/{$image}")) { $imgtmp = "images/sections/{$image}"; } else { $imgtmp = $image; } $suffix = strtoLower(substr(strrchr(basename($image), '.'), 1)); echo '<p class="text-xs-center"><img class="img-fluid" src="' . $imgtmp . '" border="0" alt="" /></p>'; } else { } echo "<p>" . translate("Following are the articles published under this section.") . "</p>"; $result = sql_query("SELECT artid, secid, title, content, userlevel, counter, timestamp FROM " . $NPDS_Prefix . "seccont WHERE secid='{$secid}' ORDER BY ordre"); while (list($artid, $secid, $title, $content, $userlevel, $counter, $timestamp) = sql_fetch_row($result)) { $okprint2 = autorisation_section($userlevel); if ($okprint2) { $nouveau = "colspan=\"2\""; if (time() - $timestamp < 86400 * 7) { $nouveau = ""; } echo "\n <p class=\"lead\">\n <a href=\"sections.php?op=viewarticle&artid={$artid}\">" . aff_langue($title) . "</a><small>\n " . translate("read:") . "{$counter} " . translate("times") . "</small> <a href=\"sections.php?op=printpage&artid={$artid}\" title=\"" . translate("Printer Friendly Page") . "\"><i class=\"fa fa-print\"></i></a>"; if ($nouveau == '') { echo ' <i class="fa fa-star"></i>'; } echo '</p>'; } } echo '<a class="btn btn-default" href="sections.php">' . translate("Return to Sections Index") . '</a>'; } else { redirect_url("sections.php"); } sql_free_result($result); } if ($SuperCache) { $cache_obj->endCachingPage(); } include 'footer.php'; }
/** * Initialize class * * @param array $scriptProperties - (optional) $scriptProperties array * @param string $currentProject - (optional) project name (used for unit testing) */ public function init($scriptProperties = array(), $currentProject = '') { clearstatcache(); /* make sure is_dir() is current */ require_once dirname(__FILE__) . '/mcautoload.php'; spl_autoload_register('mc_auto_load'); require_once dirname(__FILE__) . '/lexiconcodefile.class.php'; // Get the project config file if ($currentProject == '') { $currentProjectPath = $this->modx->getOption('mc.root', null, $this->modx->getOption('core_path') . 'components/mycomponent/') . '_build/config/current.project.php'; if (file_exists($currentProjectPath)) { include $currentProjectPath; } else { session_write_close(); die('Could not find current.project.php file at: ' . $currentProjectPath); } } if (empty($currentProject)) { session_write_close(); die('No current Project Set'); } $projectConfigPath = $this->modx->getOption('mc.root', null, $this->modx->getOption('core_path') . 'components/mycomponent/') . '_build/config/' . strtoLower($currentProject) . '.config.php'; if (file_exists($projectConfigPath)) { $properties = (include $projectConfigPath); } else { session_write_close(); die('Could not find Project Config file at: ' . $projectConfigPath); } /* Make sure that we have usable values */ if (!is_array($properties) or empty($properties)) { session_write_close(); die('Config File was not set up correctly: ' . $projectConfigPath); } $this->props = isset($this->props) ? $this->props : array(); $this->props = array_merge($properties, $this->props); unset($currentProjectPath, $projectConfigPath); // include 'helpers.class.php' $this->helpers = new Helpers($this->modx, $this->props); $this->helpers->init(); $this->helpers->sendLog(modX::LOG_LEVEL_INFO, $this->modx->lexicon('mc_project') . ': ' . $this->helpers->getProp('packageName')); $this->helpers->sendLog(modX::LOG_LEVEL_INFO, $this->modx->lexicon('mc_action') . ': ' . $this->modx->lexicon('mc_lexicon_helper') . "\n"); $this->packageNameLower = $this->helpers->getProp('packageNameLower'); $this->targetBase = $this->helpers->getProp('targetRoot'); $this->targetBase = str_replace('\\', '/', $this->targetBase); $this->targetBase = strtolower($this->targetBase); $this->targetData = $this->targetBase . '_build/data/'; $this->targetData = str_replace('\\', '/', $this->targetData); $this->targetCore = $this->targetBase . 'core/components/' . $this->packageNameLower . '/'; $this->targetAssets = $this->targetBase . 'assets/components/' . $this->packageNameLower . '/'; $this->primaryLanguage = $this->modx->getOption('primaryLanguage', $this->props, ''); $this->targetLexDir = $this->targetCore . 'lexicon/'; $this->rewriteLexiconFiles = $this->helpers->getProp('rewriteLexiconFiles', false); $this->rewriteCodeFiles = $this->helpers->getProp('rewriteCodeFiles', false); if (empty($this->primaryLanguage)) { $this->primaryLanguage = 'en'; } $this->targetLexDir = $this->targetCore . 'lexicon/'; clearstatcache(); /* make sure is_dir() is current */ }
/** * @param array $scriptProperties * @param string $currentProject - Usually read from file, but set for unit tests */ public function init($scriptProperties = array(), $currentProject = '') { require dirname(__FILE__) . '/mcautoload.php'; spl_autoload_register('mc_auto_load'); if (empty($currentProject)) { $currentProjectPath = $this->modx->getOption('mc.root', null, $this->modx->getOption('core_path') . 'components/mycomponent/') . '_build/config/current.project.php'; if (file_exists($currentProjectPath)) { include $currentProjectPath; } else { session_write_close(); die('Could not find current.project.php file at: ' . $currentProjectPath); } } if (empty($currentProject)) { session_write_close(); die('No current Project Set'); } $projectConfigPath = $this->modx->getOption('mc.root', null, $this->modx->getOption('core_path') . 'components/mycomponent/') . '_build/config/' . strtoLower($currentProject) . '.config.php'; if (file_exists($projectConfigPath)) { $properties = (include $projectConfigPath); } else { session_write_close(); die('Could not find Project Config file at: ' . $projectConfigPath); } /* Make sure that we get usable values */ if (!is_array($properties) or empty($properties)) { session_write_close(); die('Config File was not set up correctly: ' . $projectConfigPath); } /* Properties sent in method call will override those in Project Config file */ $properties = array_merge($properties, $scriptProperties); $this->packageNameLower = $this->modx->getOption('packageNameLower', $properties, ''); $this->packageName = $this->modx->getOption('packageName', $properties, ''); $this->mcRoot = isset($properties['mycomponentRoot']) ? $properties['mycomponentRoot'] : ''; if (empty($this->mcRoot)) { session_write_close(); die('mcRoot is not set in Project Config: ' . $projectConfigPath); } if (!is_dir($this->mcRoot)) { session_write_close(); die('mcRoot set in project config is not a directory: ' . $projectConfigPath); } $this->mcRoot = $this->modx->getOption('mc.root', null, $this->modx->getOption('core_path') . 'components/mycomponent/'); $this->targetRoot = $this->modx->getOption('targetRoot', $properties, ''); if (empty($this->targetRoot)) { session_write_close(); die('targetRoot is not set in project config file'); } $this->props = $properties; // include 'helpers.class.php'; $helpers = new Helpers($this->modx, $this->props); $this->helpers = $helpers; $this->helpers->init(); $this->initPaths(); $this->dirPermission = $this->helpers->getProp('dirPermission'); $this->updateProjectsFile($projectConfigPath); $this->configPath = $projectConfigPath; $this->helpers->sendLog(modX::LOG_LEVEL_INFO, "\n" . $this->modx->lexicon('mc_project') . ': ' . $this->helpers->getProp('packageName')); ObjectAdapter::$myObjects = array(); }
function smilie($message) { // Tranforme un :-) en IMG global $theme; if ($ibid = theme_image("forum/smilies/smilies.php")) { $imgtmp = "themes/{$theme}/images/forum/smilies/"; } else { $imgtmp = "images/forum/smilies/"; } if (file_exists($imgtmp . "smilies.php")) { include $imgtmp . "smilies.php"; foreach ($smilies as $tab_smilies) { $suffix = strtoLower(substr(strrchr($tab_smilies[1], '.'), 1)); if ($suffix == "gif" or $suffix == "png") { $message = str_replace($tab_smilies[0], "<img class='n-smil' src='" . $imgtmp . $tab_smilies[1] . "' />", $message); } else { $message = str_replace($tab_smilies[0], $tab_smilies[1], $message); } } } if ($ibid = theme_image("forum/smilies/more/smilies.php")) { $imgtmp = "themes/{$theme}/images/forum/smilies/more/"; } else { $imgtmp = "images/forum/smilies/more/"; } if (file_exists($imgtmp . "smilies.php")) { include $imgtmp . "smilies.php"; foreach ($smilies as $tab_smilies) { $message = str_replace($tab_smilies[0], "<img class='n-smil' src='" . $imgtmp . $tab_smilies[1] . "' />", $message); } } return $message; }
public function addParam($param, $value) { if (strtoLower($param) == strtoLower($this->pageParam)) { return $this; } $this->params[$param] = $value; return $this; }