示例#1
0
文件: Export.php 项目: Sywooch/forums
 public function renderXml()
 {
     $nameSuffix = str_replace(' ', '-', utf8_romanize(utf8_deaccent(ucfirst($this->_params['name']))));
     XenForo_Application::autoload('Zend_Debug');
     $this->setDownloadFileName('BBM_BbCode_' . $nameSuffix . '.xml');
     return $this->_params['xml']->saveXml();
 }
示例#2
0
 function add()
 {
     $a = $this->get_macros();
     $macros = $_REQUEST['macro'];
     $words = $_REQUEST['word'];
     foreach ($macros as $key => $value) {
         if (isset($value) && trim($value)) {
             if (isset($words[$key]) && trim($words[$key])) {
                 $value = utf8_deaccent($value);
                 $a[$value] = htmlspecialchars($words[$key], ENT_NOQUOTES, 'UTF-8');
             }
         }
     }
     io_saveFile(MACROS_FILE, serialize($a));
     return $a;
 }
示例#3
0
function cleanID($raw_id)
{
    $sepchar = "_";
    $sepcharpat = '#\\' . $sepchar . '+#';
    $id = trim((string) $raw_id);
    $id = utf8_strtolower($id);
    //alternative namespace seperator
    $id = strtr($id, ';', ':');
    $id = strtr($id, '/', $sepchar);
    $id = utf8_romanize($id);
    $id = utf8_deaccent($id, -1);
    //remove specials
    $id = utf8_stripspecials($id, $sepchar, '\\*');
    $id = utf8_strip($id);
    $id = preg_replace($sepcharpat, $sepchar, $id);
    $id = preg_replace('#:+#', ':', $id);
    $id = preg_replace('#:[:\\._\\-]+#', ':', $id);
    return $id;
}
示例#4
0
/**
 * Encodes an email address header
 *
 * Unicode characters will be deaccented and encoded
 * quoted_printable for headers.
 * Addresses may not contain Non-ASCII data!
 *
 * Example:
 *   mail_encode_address("föö <*****@*****.**>, me@somewhere.com","TBcc");
 *
 * @param string  $string Multiple adresses separated by commas
 * @param string  $header Name of the header (To,Bcc,Cc,...)
 * @param boolean $names  Allow named Recipients?
 */
function mail_encode_address($string, $header = '', $names = true)
{
    $headers = '';
    $parts = split(',', $string);
    foreach ($parts as $part) {
        $part = trim($part);
        // parse address
        if (preg_match('#(.*?)<(.*?)>#', $part, $matches)) {
            $text = trim($matches[1]);
            $addr = $matches[2];
        } else {
            $addr = $part;
        }
        // skip empty ones
        if (empty($addr)) {
            continue;
        }
        // FIXME: is there a way to encode the localpart of a emailaddress?
        if (!utf8_isASCII($addr)) {
            msg(htmlspecialchars("E-Mail address <{$addr}> is not ASCII"), -1);
            continue;
        }
        if (!mail_isvalid($addr)) {
            msg(htmlspecialchars("E-Mail address <{$addr}> is not valid"), -1);
            continue;
        }
        // text was given
        if (!empty($text) && $names) {
            // add address quotes
            $addr = "<{$addr}>";
            if (defined('MAILHEADER_ASCIIONLY')) {
                $text = utf8_deaccent($text);
                $text = utf8_strip($text);
            }
            if (!utf8_isASCII($text)) {
                $text = '=?UTF-8?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
            }
        } else {
            $text = '';
        }
        // add to header comma seperated and in new line to avoid too long headers
        if ($headers != '') {
            $headers .= ',' . MAILHEADER_EOL . ' ';
        }
        $headers .= $text . ' ' . $addr;
    }
    if (empty($headers)) {
        return null;
    }
    //if headername was given add it and close correctly
    if ($header) {
        $headers = $header . ': ' . $headers . MAILHEADER_EOL;
    }
    return $headers;
}
<?php

if (!empty($_GET['anywhere']) && $_GET['searchtype'] == 'metadata') {
    $anywhere_array = array($_GET['anywhere']);
    if ($_GET['anywhere_separator'] == 'AND' || $_GET['anywhere_separator'] == 'OR') {
        $anywhere_array = explode(' ', $_GET['anywhere']);
    }
    while ($anywhere = each($anywhere_array)) {
        $like_query_esc = str_replace("\\", "\\\\", $anywhere[1]);
        $like_query_esc = str_replace("%", "\\%", $like_query_esc);
        $like_query_esc = str_replace("_", "\\_", $like_query_esc);
        $like_query_esc = str_replace("<*>", "%", $like_query_esc);
        $like_query_esc = str_replace("<?>", "_", $like_query_esc);
        $author_like_query = $dbHandle->quote("%L:\"{$like_query_esc}%");
        $like_query = $dbHandle->quote("%{$like_query_esc}%");
        $translation = utf8_deaccent($like_query_esc);
        if ($translation != $like_query_esc) {
            $author_like_query_translated = $dbHandle->quote("%L:\"{$translation}%");
            $like_query_translated = $dbHandle->quote("%{$translation}%");
            $like_sql = "authors LIKE {$author_like_query} ESCAPE '\\' OR" . " editor LIKE {$author_like_query} ESCAPE '\\' OR" . " journal LIKE {$like_query} ESCAPE '\\' OR" . " secondary_title LIKE {$like_query} ESCAPE '\\' OR" . " tertiary_title LIKE {$like_query} ESCAPE '\\' OR" . " affiliation LIKE {$like_query} ESCAPE '\\' OR" . " title LIKE {$like_query} ESCAPE '\\' OR" . " abstract LIKE {$like_query} ESCAPE '\\' OR" . " year LIKE {$like_query} ESCAPE '\\' OR" . " id=" . intval($anywhere[1]) . " OR" . " keywords LIKE {$like_query} ESCAPE '\\' OR" . " authors_ascii LIKE {$author_like_query_translated} ESCAPE '\\' OR" . " title_ascii LIKE {$like_query_translated} ESCAPE '\\' OR" . " abstract_ascii LIKE {$like_query_translated} ESCAPE '\\'";
        } else {
            $like_sql = "authors_ascii LIKE {$author_like_query} ESCAPE '\\' OR" . " editor LIKE {$author_like_query} ESCAPE '\\' OR" . " journal LIKE {$like_query} ESCAPE '\\' OR" . " secondary_title LIKE {$like_query} ESCAPE '\\' OR" . " tertiary_title LIKE {$like_query} ESCAPE '\\' OR" . " affiliation LIKE {$like_query} ESCAPE '\\' OR" . " title_ascii LIKE {$like_query} ESCAPE '\\' OR" . " abstract_ascii LIKE {$like_query} ESCAPE '\\' OR" . " year LIKE {$like_query} ESCAPE '\\' OR" . " id=" . intval($anywhere[1]) . " OR" . " keywords LIKE {$like_query} ESCAPE '\\'";
        }
        $anywhere_regexp[] = '(' . $like_sql . ')';
    }
    if ($_GET['anywhere_separator'] == 'AND') {
        $search_string = join(' AND ', $anywhere_regexp);
    }
    if ($_GET['anywhere_separator'] == 'OR') {
        $search_string = join(' OR ', $anywhere_regexp);
    }
示例#6
0
 /**
  * Verification callback to check that a username is valid
  *
  * @param string Username
  *
  * @return bool
  */
 protected function _verifyUsername(&$username)
 {
     if ($this->isUpdate() && $username === $this->getExisting('username')) {
         return true;
         // unchanged, always pass
     }
     // standardize white space in names
     $username = preg_replace('/\\s+/u', ' ', $username);
     try {
         // if this matches, then \v isn't known (appears to be PCRE < 7.2) so don't strip
         if (!preg_match('/\\v/', 'v')) {
             $newName = preg_replace('/\\v+/u', ' ', $username);
             if (is_string($newName)) {
                 $username = $newName;
             }
         }
     } catch (Exception $e) {
     }
     $username = trim($username);
     $usernameLength = utf8_strlen($username);
     $minLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MIN);
     $maxLength = $this->getOption(self::OPTION_USERNAME_LENGTH_MAX);
     if (!$this->getOption(self::OPTION_ADMIN_EDIT)) {
         if ($minLength > 0 && $usernameLength < $minLength) {
             $this->error(new XenForo_Phrase('please_enter_name_that_is_at_least_x_characters_long', array('count' => $minLength)), 'username');
             return false;
         }
         if ($maxLength > 0 && $usernameLength > $maxLength) {
             $this->error(new XenForo_Phrase('please_enter_name_that_is_at_most_x_characters_long', array('count' => $maxLength)), 'username');
             return false;
         }
         $disallowedNames = $this->getOption(self::OPTION_USERNAME_DISALLOWED_NAMES);
         if ($disallowedNames) {
             foreach ($disallowedNames as $name) {
                 $name = trim($name);
                 if ($name === '') {
                     continue;
                 }
                 if (stripos($username, $name) !== false) {
                     $this->error(new XenForo_Phrase('please_enter_another_name_disallowed_words'), 'username');
                     return false;
                 }
             }
         }
         $matchRegex = $this->getOption(self::OPTION_USERNAME_REGEX);
         if ($matchRegex) {
             $matchRegex = str_replace('#', '\\#', $matchRegex);
             // escape delim only
             if (!preg_match('#' . $matchRegex . '#i', $username)) {
                 $this->error(new XenForo_Phrase('please_enter_another_name_required_format'), 'username');
                 return false;
             }
         }
         $censoredUserName = XenForo_Helper_String::censorString($username);
         if ($censoredUserName !== $username) {
             $this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_any_censored_words'), 'username');
             return false;
         }
     }
     // ignore check if unicode properties aren't compiled
     try {
         if (@preg_match("/\\p{C}/u", $username)) {
             $this->error(new XenForo_Phrase('please_enter_name_without_using_control_characters'), 'username');
             return false;
         }
     } catch (Exception $e) {
     }
     if (strpos($username, ',') !== false) {
         $this->error(new XenForo_Phrase('please_enter_name_that_does_not_contain_comma'), 'username');
         return false;
     }
     if (XenForo_Helper_Email::isEmailValid($username)) {
         $this->error(new XenForo_Phrase('please_enter_name_that_does_not_resemble_an_email_address'), 'username');
         return false;
     }
     $existingUser = $this->_getUserModel()->getUserByName($username);
     if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
         $this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
         return false;
     }
     // compare against romanized name to help reduce confusable issues
     $romanized = utf8_deaccent(utf8_romanize($username));
     if ($romanized != $username) {
         $existingUser = $this->_getUserModel()->getUserByName($romanized);
         if ($existingUser && $existingUser['user_id'] != $this->get('user_id')) {
             $this->error(new XenForo_Phrase('usernames_must_be_unique'), 'username');
             return false;
         }
     }
     return true;
 }
示例#7
0
/**
 * Remove unwanted chars from ID
 *
 * Cleans a given ID to only use allowed characters. Accented characters are
 * converted to unaccented ones
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param  string  $raw_id    The pageid to clean
 * @param  boolean $ascii     Force ASCII
 * @param  boolean $media     Allow leading or trailing _ for media files
 */
function cleanID($raw_id, $ascii = false, $media = false)
{
    global $conf;
    static $sepcharpat = null;
    global $cache_cleanid;
    $cache =& $cache_cleanid;
    // check if it's already in the memory cache
    if (isset($cache[(string) $raw_id])) {
        return $cache[(string) $raw_id];
    }
    $sepchar = $conf['sepchar'];
    if ($sepcharpat == null) {
        // build string only once to save clock cycles
        $sepcharpat = '#\\' . $sepchar . '+#';
    }
    $id = trim((string) $raw_id);
    $id = utf8_strtolower($id);
    //alternative namespace seperator
    $id = strtr($id, ';', ':');
    if ($conf['useslash']) {
        $id = strtr($id, '/', ':');
    } else {
        $id = strtr($id, '/', $sepchar);
    }
    if ($conf['deaccent'] == 2 || $ascii) {
        $id = utf8_romanize($id);
    }
    if ($conf['deaccent'] || $ascii) {
        $id = utf8_deaccent($id, -1);
    }
    //remove specials
    $id = utf8_stripspecials($id, $sepchar, '\\*');
    if ($ascii) {
        $id = utf8_strip($id);
    }
    //clean up
    $id = preg_replace($sepcharpat, $sepchar, $id);
    $id = preg_replace('#:+#', ':', $id);
    $id = $media ? trim($id, ':.-') : trim($id, ':._-');
    $id = preg_replace('#:[:\\._\\-]+#', ':', $id);
    $cache[(string) $raw_id] = $id;
    return $id;
}
示例#8
0
 /**
  * Cleanup and encode the headers array
  */
 protected function cleanHeaders()
 {
     global $conf;
     // clean up addresses
     if (empty($this->headers['From'])) {
         $this->from($conf['mailfrom']);
     }
     $addrs = array('To', 'From', 'Cc', 'Bcc', 'Reply-To', 'Sender');
     foreach ($addrs as $addr) {
         if (isset($this->headers[$addr])) {
             $this->headers[$addr] = $this->cleanAddress($this->headers[$addr]);
         }
     }
     if (isset($this->headers['Subject'])) {
         // add prefix to subject
         if (empty($conf['mailprefix'])) {
             if (utf8_strlen($conf['title']) < 20) {
                 $prefix = '[' . $conf['title'] . ']';
             } else {
                 $prefix = '[' . utf8_substr($conf['title'], 0, 20) . '...]';
             }
         } else {
             $prefix = '[' . $conf['mailprefix'] . ']';
         }
         $len = strlen($prefix);
         if (substr($this->headers['Subject'], 0, $len) != $prefix) {
             $this->headers['Subject'] = $prefix . ' ' . $this->headers['Subject'];
         }
         // encode subject
         if (defined('MAILHEADER_ASCIIONLY')) {
             $this->headers['Subject'] = utf8_deaccent($this->headers['Subject']);
             $this->headers['Subject'] = utf8_strip($this->headers['Subject']);
         }
         if (!utf8_isASCII($this->headers['Subject'])) {
             $this->headers['Subject'] = '=?UTF-8?B?' . base64_encode($this->headers['Subject']) . '?=';
         }
     }
 }
示例#9
0
 protected function _getUrlVersionOfTag($tag)
 {
     $db = $this->_getDb();
     $urlVersion = preg_replace('/[^a-zA-Z0-9_ -]/', '', utf8_romanize(utf8_deaccent($tag)));
     $urlVersion = preg_replace('/[ -]+/', '-', $urlVersion);
     if (!strlen($urlVersion)) {
         $urlVersion = 1 + intval($db->fetchOne("\r\n\t\t\t\tSELECT MAX(tag_id)\r\n\t\t\t\tFROM xf_tag\r\n\t\t\t"));
     } else {
         $existing = $db->fetchRow("\r\n\t\t\t\tSELECT *\r\n\t\t\t\tFROM xf_tag\r\n\t\t\t\tWHERE tag_url = ?\r\n\t\t\t\t\tOR (tag_url LIKE ? AND tag_url REGEXP ?)\r\n\t\t\t\tORDER BY tag_id DESC\r\n\t\t\t\tLIMIT 1\r\n\t\t\t", array($urlVersion, "{$urlVersion}-%", "^{$urlVersion}-[0-9]+\$"));
         if ($existing) {
             $counter = 1;
             if ($existing['tag_url'] != $urlVersion && preg_match('/-(\\d+)$/', $existing['tag_url'], $match)) {
                 $counter = $match[1];
             }
             $testExists = true;
             while ($testExists) {
                 $counter++;
                 $testExists = $db->fetchOne("\r\n\t\t\t\t\t\tSELECT tag_id\r\n\t\t\t\t\t\tFROM xf_tag\r\n\t\t\t\t\t\tWHERE tag_url = ?\r\n\t\t\t\t\t", "{$urlVersion}-{$counter}");
             }
             $urlVersion .= "-{$counter}";
         }
     }
     return $urlVersion;
 }
 $stmt->bindParam(':authors_ascii', $authors_ascii, PDO::PARAM_STR);
 $stmt->bindParam(':title_ascii', $title_ascii, PDO::PARAM_STR);
 $stmt->bindParam(':abstract_ascii', $abstract_ascii, PDO::PARAM_STR);
 $stmt->bindParam(':added_by', $userID, PDO::PARAM_INT);
 $dbHandle->exec("BEGIN IMMEDIATE TRANSACTION");
 $stmt->execute();
 $stmt = null;
 $id = $dbHandle->lastInsertId();
 $new_file = str_pad($id, 5, "0", STR_PAD_LEFT) . '.pdf';
 // Save citation key.
 $stmt6 = $dbHandle->prepare("UPDATE library SET bibtex=:bibtex WHERE id=:id");
 $stmt6->bindParam(':bibtex', $bibtex, PDO::PARAM_STR);
 $stmt6->bindParam(':id', $id, PDO::PARAM_INT);
 $bibtex_author = 'unknown';
 if (!empty($last_name[0])) {
     $bibtex_author = utf8_deaccent($last_name[0]);
 }
 empty($year) ? $bibtex_year = '0000' : ($bibtex_year = substr($year, 0, 4));
 $bibtex = $bibtex_author . '-' . $bibtex_year . '-ID' . $id;
 $insert = $stmt6->execute();
 $insert = null;
 if (isset($_GET['shelf']) && !empty($userID)) {
     $user_query = $dbHandle->quote($userID);
     $file_query = $dbHandle->quote($id);
     $dbHandle->exec("INSERT OR IGNORE INTO shelves (userID,fileID) VALUES ({$user_query},{$file_query})");
 }
 if (isset($_GET['project']) && !empty($_GET['projectID'])) {
     $dbHandle->exec("INSERT OR IGNORE INTO projectsfiles (projectID,fileID) VALUES (" . intval($_GET['projectID']) . "," . intval($id) . ")");
 }
 ####### record new category into categories, if not exists #########
 if (!empty($_GET['category2'])) {
示例#11
0
 print "<br><u>External IDs:</u> " . htmlspecialchars(implode(", ", $uids));
 print '<br><u>DOI:</u> <span id="file-doi">' . htmlspecialchars($paper['doi']) . '</span>';
 if (!empty($paper['bibtex'])) {
     print '<br><u>BibTex:</u> <input type="text" class="bibtex" value="' . htmlspecialchars($paper['bibtex']) . '" style="outline:none;width:200px" readonly>';
 } else {
     $bibtex_author = substr($paper['authors'], 3);
     $bibtex_author = substr($bibtex_author, 0, strpos($bibtex_author, '"'));
     if (empty($bibtex_author)) {
         $bibtex_author = 'unknown';
     }
     $bibtex_year = '0000';
     $bibtex_year_array = explode('-', $paper['year']);
     if (!empty($bibtex_year_array[0])) {
         $bibtex_year = $bibtex_year_array[0];
     }
     $bibtex_key = utf8_deaccent($bibtex_author) . '-' . $bibtex_year . '-ID' . $paper['id'];
     print '<br><u>BibTex:</u> <input type="text" class="bibtex" value="' . $bibtex_key . '" style="outline:none;width:200px" readonly>';
 }
 $editor_string = '';
 if (!empty($paper['editor'])) {
     $array = explode(';', $paper['editor']);
     $array = array_filter($array);
     if (!empty($array)) {
         foreach ($array as $editor) {
             $array2 = explode(',', $editor);
             $last = trim($array2[0]);
             $last = substr($array2[0], 3, -1);
             $first = trim($array2[1]);
             $first = substr($array2[1], 3, -1);
             $new_editor[] = $last . ', ' . $first;
         }
示例#12
0
 /**
  * Gets version of a title that is valid in a URL. Invalid elements are stripped
  * or replaced with '-'. It may not be possible to reverse a URL'd title to the
  * original title.
  *
  * @param string $title
  * @param boolean $romanize If true, non-latin strings are romanized
  *
  * @return string
  */
 public static function getTitleForUrl($title, $romanize = false)
 {
     $title = strval($title);
     $lookup = $title . ($romanize ? '|r' : '');
     if (isset(self::$_titleCache[$lookup])) {
         return self::$_titleCache[$lookup];
     }
     if ($romanize) {
         $title = utf8_romanize(utf8_deaccent($title));
     }
     $aPattern = array("a" => "á|à|ạ|ả|ã|ă|ắ|ằ|ặ|ẳ|ẵ|â|ấ|ầ|ậ|ẩ|ẫ|Á|À|Ạ|Ả|Ã|Ă|Ắ|Ằ|Ặ|Ẳ|Ẵ|Â|Ấ|Ầ|Ậ|Ẩ|Ẫ", "o" => "ó|ò|ọ|ỏ|õ|ô|ố|ồ|ộ|ổ|ỗ|ơ|ớ|ờ|ợ|ở|ỡ|Ó|Ò|Ọ|Ỏ|Õ|Ô|Ố|Ồ|Ộ|Ổ|Ỗ|Ơ|Ớ|Ờ|Ợ|Ở|Ỡ", "e" => "é|è|ẹ|ẻ|ẽ|ê|ế|ề|ệ|ể|ễ|É|È|Ẹ|Ẻ|Ẽ|Ê|Ế|Ề|Ệ|Ể|Ễ", "u" => "ú|ù|ụ|ủ|ũ|ư|ứ|ừ|ự|ử|ữ|Ú|Ù|Ụ|Ủ|Ũ|Ư|Ứ|Ừ|Ự|Ử|Ữ", "i" => "í|ì|ị|ỉ|ĩ|Í|Ì|Ị|Ỉ|Ĩ", "y" => "ý|ỳ|ỵ|ỷ|ỹ|Ý|Ỳ|Ỵ|Ỷ|Ỹ", "d" => "đ|Đ");
     while (list($key, $value) = each($aPattern)) {
         $title = @ereg_replace($value, $key, $title);
     }
     $title = strtr($title, '`!"$%^&*()-+={}[]<>;:@#~,./?|' . "\r\n\t\\", '                             ' . '    ');
     $title = strtr($title, array('"' => '', "'" => ''));
     if ($romanize) {
         $title = preg_replace('/[^a-zA-Z0-9_ -]/', '', $title);
     }
     $title = preg_replace('/[ ]+/', '-', trim($title));
     $title = strtr($title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
     self::$_titleCache[$lookup] = $title;
     return $title;
 }
 function utf8_deaccent($string, $case = 0)
 {
     return utf8_deaccent($string, $case);
 }
示例#14
0
 public function renderXml()
 {
     $title = str_replace(' ', '-', utf8_romanize(utf8_deaccent($this->_params['style']['title'])));
     $this->setDownloadFileName('style-' . $title . '.xml');
     return $this->_params['xml']->saveXml();
 }
示例#15
0
         }
     }
     reset($add_item);
 }
 if (isset($add_item['id'])) {
     $id_author = substr($item['authors'], 3);
     $id_author = substr($id_author, 0, strpos($id_author, '"'));
     if (empty($id_author)) {
         $id_author = 'unknown';
     }
     $id_year_array = explode('-', $item['year']);
     $id_year = '0000';
     if (!empty($id_year_array[0])) {
         $id_year = $id_year_array[0];
     }
     $add_item['id'] = utf8_deaccent($id_author) . '-' . $id_year . '-ID' . $item['id'];
     if ($_GET['format'] == 'BibTex' && !empty($item['bibtex'])) {
         $add_item['id'] = $item['bibtex'];
     }
     $add_item['id'] = str_replace(' ', '', $add_item['id']);
 }
 if ($_GET['format'] == 'list') {
     $new_authors = array();
     $array = explode(';', $item['authors']);
     $array = array_filter($array);
     if (!empty($array)) {
         foreach ($array as $author) {
             $array2 = explode(',', $author);
             $last = trim($array2[0]);
             $last = substr($array2[0], 3, -1);
             $first = trim($array2[1]);
示例#16
0
 /**
  * Gets version of a title that is valid in a URL. Invalid elements are stripped
  * or replaced with '-'. It may not be possible to reverse a URL'd title to the
  * original title.
  *
  * @param string $title
  * @param boolean $romanize If true, non-latin strings are romanized
  *
  * @return string
  */
 public static function getTitleForUrl($title, $romanize = false)
 {
     $title = strval($title);
     $lookup = $title . ($romanize ? '|r' : '');
     if (isset(self::$_titleCache[$lookup])) {
         return self::$_titleCache[$lookup];
     }
     if ($romanize) {
         $title = utf8_romanize(utf8_deaccent($title));
     }
     $title = strtr($title, '`!"$%^&*()-+={}[]<>;:@#~,./?|' . "\r\n\t\\", '                             ' . '    ');
     $title = strtr($title, array('"' => '', "'" => ''));
     if ($romanize) {
         $title = preg_replace('/[^a-zA-Z0-9_ -]/', '', $title);
     }
     $title = preg_replace('/[ ]+/', '-', trim($title));
     $title = strtr($title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
     self::$_titleCache[$lookup] = $title;
     return $title;
 }
示例#17
0
 empty($_POST['bibtex_type']) ? $bibtex_type = '' : ($bibtex_type = trim($_POST['bibtex_type']));
 $added_by = $user_id;
 ##########	get the new filename and record item	##########
 $dbHandle->exec("BEGIN IMMEDIATE TRANSACTION");
 if (!empty($title)) {
     $insert = $stmt->execute();
 }
 $stmt = null;
 $id = $dbHandle->lastInsertId();
 $new_file = str_pad($id, 5, "0", STR_PAD_LEFT) . '.pdf';
 // Save default citation key.
 if (empty($_POST['bibtex'])) {
     $stmt = $dbHandle->prepare("UPDATE library SET bibtex=:bibtex WHERE id=:id");
     $stmt->bindParam(':bibtex', $bibtex, PDO::PARAM_STR);
     $stmt->bindParam(':id', $id, PDO::PARAM_INT);
     empty($_POST['last_name'][0]) ? $bibtex_author = 'unknown' : ($bibtex_author = utf8_deaccent($_POST['last_name'][0]));
     empty($_POST['year']) ? $bibtex_year = '0000' : ($bibtex_year = substr($_POST['year'], 0, 4));
     $bibtex = $bibtex_author . '-' . $bibtex_year . '-ID' . $id;
     $stmt->execute();
 }
 $dbHandle->exec("COMMIT");
 if ($insert == false) {
     $error[] = htmlspecialchars('Error! The item has not been recorded.<br>' . $title);
 }
 if ($insert == true) {
     $message[] = htmlspecialchars('The item has been recorded.<br>' . $title);
 }
 ####### record new category into categories, if not exists #########
 $category_ids = array();
 if (!empty($_POST['category2'])) {
     $_POST['category2'] = preg_replace('/\\s{2,}/', '', $_POST['category2']);
示例#18
0
 /**
  * Gets version of a title that is valid in a URL. Invalid elements are stripped
  * or replaced with '-'. It may not be possible to reverse a URL'd title to the
  * original title.
  *
  * @param string $title
  * @param boolean $romanize If true, non-latin strings are romanized
  *
  * @return string
  */
 public static function getTitleForUrl($title, $romanize = false)
 {
     if ($romanize) {
         $title = utf8_romanize(utf8_deaccent($title));
     }
     $title = strtr($title, '`!"$%^&*()-+={}[]<>;:@#~,./?|' . "\r\n\t\\", '                             ' . '    ');
     $title = strtr($title, array('"' => '', "'" => ''));
     $title = preg_replace('/[ ]+/', '-', trim($title));
     return strtr($title, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
 }
 #if ($_GET['fulltext_separator'] == 'AND') $search_string = join (' ', $fulltext_array);
 while ($fulltext = each($fulltext_array)) {
     $like_query = str_replace("\\", "\\\\", $fulltext[1]);
     $like_query = str_replace("%", "\\%", $like_query);
     $like_query = str_replace("_", "\\_", $like_query);
     $like_query = str_replace("<*>", "%", $like_query);
     $like_query = str_replace("<?>", "_", $like_query);
     $regexp_query = addcslashes($fulltext[1], "\$(..+./<>?[\\^{|");
     $regexp_query = str_replace('\\<\\*\\>', '.*', $regexp_query);
     $regexp_query = str_replace('\\<\\?\\>', '.?', $regexp_query);
     $like_query = $dbHandle->quote("%{$like_query}%");
     $regexp_query = str_replace("'", "''", $regexp_query);
     $translation = utf8_deaccent($like_query);
     if ($translation != $like_query) {
         $like_query_translated = $translation;
         $regexp_query_translated = utf8_deaccent($regexp_query);
         $like_sql = "full_text LIKE {$like_query} ESCAPE '\\' OR full_text LIKE {$like_query_translated} ESCAPE '\\'";
         $regexp_sql = "regexp_match(full_text, '{$regexp_query}', {$case2}) OR regexp_match(full_text, '{$regexp_query_translated}', {$case2})";
     } else {
         $like_sql = "full_text LIKE {$like_query} ESCAPE '\\'";
         $regexp_sql = "regexp_match(full_text, '{$regexp_query}', {$case2})";
     }
     if ($whole_words == 1) {
         $fulltext_regexp[] = '(' . $like_sql . ') AND (' . $regexp_sql . ')';
     } else {
         $fulltext_regexp[] = '(' . $like_sql . ')';
     }
 }
 if ($_GET['fulltext_separator'] == 'AND') {
     $search_string = join(' AND ', $fulltext_regexp);
 }
示例#20
0
     $authors_ascii = utf8_deaccent($authors);
 }
 empty($_POST['affiliation']) ? $affiliation = '' : ($affiliation = $_POST['affiliation']);
 $title = $_POST['title'];
 $title_ascii = utf8_deaccent($title);
 empty($_POST['journal_abbr']) ? $journal = '' : ($journal = $_POST['journal_abbr']);
 empty($_POST['secondary_title']) ? $secondary_title = '' : ($secondary_title = $_POST['secondary_title']);
 empty($_POST['tertiary_title']) ? $tertiary_title = '' : ($tertiary_title = $_POST['tertiary_title']);
 empty($_POST['year']) ? $year = '' : ($year = $_POST['year']);
 $addition_date = date('Y-m-d');
 if (empty($_POST['abstract'])) {
     $abstract = '';
     $abstract_ascii = '';
 } else {
     $abstract = $_POST['abstract'];
     $abstract_ascii = utf8_deaccent($abstract);
 }
 empty($_POST['rating']) ? $rating = '2' : ($rating = $_POST['rating']);
 empty($_POST['uid'][0]) ? $uid = '' : ($uid = join('|', array_filter($_POST['uid'])));
 empty($_POST['volume']) ? $volume = '' : ($volume = $_POST['volume']);
 empty($_POST['issue']) ? $issue = '' : ($issue = $_POST['issue']);
 empty($_POST['pages']) ? $pages = '' : ($pages = $_POST['pages']);
 empty($_POST['editor']) ? $editor = '' : ($editor = $_POST['editor']);
 empty($_POST['url'][0]) ? $url = '' : ($url = join('|', array_filter($_POST['url'])));
 empty($_POST['reference_type']) ? $reference_type = 'article' : ($reference_type = $_POST['reference_type']);
 empty($_POST['publisher']) ? $publisher = '' : ($publisher = $_POST['publisher']);
 empty($_POST['place_published']) ? $place_published = '' : ($place_published = $_POST['place_published']);
 if (empty($_POST['keywords'])) {
     $keywords = '';
 } else {
     $keywords = $_POST['keywords'];
示例#21
0
function show_search_results($result, $select, $display, $shelf_files, $desktop_projects, $tempdbHandle)
{
    $project = '';
    if (!empty($_GET['project'])) {
        $project = $_GET['project'];
    }
    $i = 0;
    if ($display == 'icons') {
        print '<table cellspacing=0 id="icon-container" style="border:0;width:100%">
        <tr><td class="alternating_row" style="width:100%;border-bottom:1px #c5c6c8 solid;border-top:1px #c5c6c8 solid;padding-bottom:11px">';
    }
    while (list($key, $paper) = each($result)) {
        $pmid_url = '';
        $pmcid_url = '';
        $nasaads_url = '';
        $arxiv_url = '';
        $jstor_url = '';
        $other_urls = '';
        $urls = '';
        $other_urls = '';
        $uids = array();
        $pmid = '';
        $pmid_related_url = '';
        $pmid_citedby_pmc = '';
        $nasaid = '';
        $nasa_related_url = '';
        $nasa_citedby_pmc = '';
        $ieeeid = '';
        if (!empty($paper['uid'])) {
            $uids = explode("|", $paper['uid']);
            while (list($key, $uid) = each($uids)) {
                if (preg_match('/PMID:/', $uid)) {
                    $pmid = preg_replace('/PMID:/', '', $uid);
                }
                if (preg_match('/NASAADS:/', $uid)) {
                    $nasaid = preg_replace('/NASAADS:/', '', $uid);
                }
                if (preg_match('/IEEE:/', $uid)) {
                    $ieeeid = preg_replace('/IEEE:/', '', $uid);
                }
            }
        }
        if (!empty($paper['url'])) {
            $urls = explode("|", $paper['url']);
            while (list($key, $url) = each($urls)) {
                if (preg_match('/pubmed\\.org/', $url)) {
                    $pmid_url = $url;
                } elseif (preg_match('/pubmedcentral\\.nih\\.gov/', $url) || preg_match('/\\/pmc\\//', $url)) {
                    $pmcid_url = $url;
                } elseif (preg_match('/adsabs\\.harvard\\.edu/', $url)) {
                    $nasaads_url = $url;
                } elseif (preg_match('/arxiv\\.org/', $url)) {
                    $arxiv_url = $url;
                } elseif (preg_match('/jstor\\.org/', $url)) {
                    $jstor_url = $url;
                } else {
                    $other_urls[] = $url;
                }
            }
        }
        if (!empty($pmid)) {
            $pmid_related_url = 'http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=link&linkname=pubmed_pubmed&uid=' . $pmid;
            $pmid_citedby_pmc = 'http://www.ncbi.nlm.nih.gov/pubmed?db=pubmed&cmd=link&linkname=pubmed_pubmed_citedin&uid=' . $pmid;
        }
        if (!empty($nasaid)) {
            $nasa_related_url = 'http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?return_req=no_params&text=' . urlencode($paper['abstract']) . '&title=' . urlencode($paper['title']);
            $nasa_citedby_pmc = 'http://adsabs.harvard.edu/cgi-bin/nph-data_query?bibcode=' . $nasaid . '&link_type=CITATIONS';
        }
        if (!empty($ieeeid)) {
            $ieee_url = 'http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=' . $ieeeid;
        }
        if (!empty($paper['authors'])) {
            $array = array();
            $new_authors = array();
            $array = explode(';', $paper['authors']);
            $array = array_filter($array);
            if (!empty($array)) {
                foreach ($array as $author) {
                    $array2 = explode(',', $author);
                    $last = trim($array2[0]);
                    $last = substr($array2[0], 3, -1);
                    $first = trim($array2[1]);
                    $first = substr($array2[1], 3, -1);
                    $new_authors[] = '<a href="display.php?select=' . $select . '&browse[' . urlencode($last . ', ' . $first) . ']=authors" class="navigation">' . htmlspecialchars($last . ', ' . $first) . '</a>';
                }
                $paper['authors'] = join('; ', $new_authors);
            }
        }
        $paper['journal'] = htmlspecialchars($paper['journal']);
        $paper['title'] = lib_htmlspecialchars($paper['title']);
        $paper['abstract'] = lib_htmlspecialchars($paper['abstract']);
        $paper['year'] = htmlspecialchars($paper['year']);
        #######new date#########
        $date = '';
        if (!empty($paper['year'])) {
            $date_array = array();
            $date_array = explode('-', $paper['year']);
            if (count($date_array) == 1) {
                $date = $paper['year'];
            } else {
                if (empty($date_array[0])) {
                    $date_array[0] = '1969';
                }
                if (empty($date_array[1])) {
                    $date_array[1] = '01';
                }
                if (empty($date_array[2])) {
                    $date_array[2] = '01';
                }
                $date = date('Y M j', mktime(0, 0, 0, $date_array[1], $date_array[2], $date_array[0]));
            }
        }
        $result2 = $tempdbHandle->query("SELECT notesID,notes FROM temp_notes WHERE fileID=" . intval($paper['id']) . " LIMIT 1");
        $fetched = $result2->fetch(PDO::FETCH_ASSOC);
        $result2 = null;
        $paper['notesID'] = $fetched['notesID'];
        $paper['notes'] = $fetched['notes'];
        $i = $i + 1;
        if ($display == 'icons') {
            if (!extension_loaded('gd')) {
                die('<p>&nbsp;Error! Icon view requires GD extension and Ghostscript.</p>');
            }
            $first_author = '&nbsp;';
            $auth_arr = explode(';', $paper['authors']);
            $auth_arr2 = explode(',', strip_tags($auth_arr[0]));
            if (!empty($auth_arr2[0])) {
                $first_author = $auth_arr2[0];
            }
            $etal = '';
            if (count($auth_arr) > 1) {
                $etal = ', et al.';
            }
            print '<div class="thumb-items" id="display-item-' . $paper['id'] . '" data-file="' . $paper['file'] . '"><div>';
            print '<div class="thumb-titles"><div style="overflow:hidden;white-space:nowrap"><b>' . $paper['title'] . '</b><br>' . $first_author . $etal;
            if (!empty($paper['year'])) {
                print ' (' . substr($paper['year'], 0, 4) . ')';
            }
            print '</div></div>';
            if (date('Y-m-d') == $paper['addition_date']) {
                print '<div class="new-item ui-state-error-text">New!</div>';
            }
            if (is_readable('library/' . $paper['file'])) {
                if (isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'external') {
                    print '<a href="' . htmlspecialchars('downloadpdf.php?file=' . urlencode($paper['file']) . '#pagemode=none&scrollbar=1&navpanes=0&toolbar=1&statusbar=0&page=1&view=FitH,0') . '" target="_blank" style="display:block">';
                }
                if (!isset($_SESSION['pdfviewer']) || isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'internal') {
                    print '<a href="' . htmlspecialchars('viewpdf.php?file=' . urlencode($paper['file']) . '&title=' . urlencode($paper['title'])) . '" target="_blank" style="width:360px;height:240px;display:block">';
                }
                print '<img src="icon.php?file=' . $paper['file'] . '" style="width:360px;height:240px;border:0" alt="Loading PDF..."></a>';
            } else {
                print '<div style="margin-top:90px;margin-left:150px;font-size:18px;color:#b5b6b8">No PDF</div>';
            }
            print '</div>';
            print PHP_EOL . '<table class="item-sticker" style="margin:6px 0;width:100%"><tr><td class="noprint ui-corner-all" style="padding:5px 8px;border:1px solid #c5c6c8">';
            print '<i class="fa fa-plus-circle expander view-icon" style="margin-right:0.5em"></i>';
            print '<span><i class="star ' . ($paper['rating'] >= 1 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>';
            print '&nbsp;<i class="star ' . ($paper['rating'] >= 2 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>';
            print '&nbsp;<i class="star ' . ($paper['rating'] == 3 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i></span>&nbsp;';
            print '<b style="margin:0 0.5em">&middot;</b>';
            if (isset($shelf_files) && in_array($paper['id'], $shelf_files)) {
                print ' <span class="update_shelf clicked"><i class="update_shelf fa fa-check-square ui-state-error-text"></i>&nbsp;Shelf&nbsp;</span>';
            } else {
                print ' <span class="update_shelf"><i class="update_shelf fa fa-square-o"></i>&nbsp;Shelf&nbsp;</span>';
            }
            if (isset($_SESSION['session_clipboard']) && in_array($paper['id'], $_SESSION['session_clipboard'])) {
                print ' &nbsp;<span class="update_clipboard clicked"><i class="update_clipboard fa fa-check-square ui-state-error-text"></i>&nbsp;Clipboard&nbsp;</span>';
            } else {
                print ' &nbsp;<span class="update_clipboard"><i class="update_clipboard fa fa-square-o"></i>&nbsp;Clipboard&nbsp;</span>';
            }
            foreach ($desktop_projects as $desktop_project) {
                $project_rowid = $tempdbHandle->query("SELECT ROWID FROM temp_projects WHERE projectID=" . intval($desktop_project['projectID']) . " AND fileID=" . intval($paper['id']) . " LIMIT 1");
                $project_rowid = $project_rowid->fetchColumn();
                if (!empty($project_rowid)) {
                    print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project clicked" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-check-square ui-state-error-text"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>';
                }
                if (empty($project_rowid)) {
                    print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-square-o"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>';
                }
                $project_rowid = null;
            }
            print PHP_EOL . '</td></tr></table></div>';
        } else {
            print PHP_EOL . '<div id="display-item-' . $paper['id'] . '" class="items" data-file="' . $paper['file'] . '" style="padding:0 0 10px 0">';
            include 'coins.php';
            print '<div class="ui-widget-header" style="overflow:hidden;border-left:0;border-right:0;padding:2px 6px">';
            if (is_file('library/' . $paper['file']) && isset($_SESSION['auth'])) {
                if (isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'external') {
                    print '<div class="noprint titles-pdf" style="float:left;text-shadow:1px 1px 1px white">
                        <a class="ui-state-error-text" href="' . htmlspecialchars('downloadpdf.php?file=' . urlencode($paper['file']) . '#pagemode=none&scrollbar=1&navpanes=0&toolbar=1&statusbar=0&page=1&view=FitH,0') . '" target="_blank" style="display:block">
                                PDF</a></div>';
                }
                if (!isset($_SESSION['pdfviewer']) || isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'internal') {
                    print '<div class="noprint titles-pdf" style="float:left;text-shadow:1px 1px 1px white">
                        <a class="ui-state-error-text" href="' . htmlspecialchars('viewpdf.php?file=' . urlencode($paper['file']) . '&title=' . urlencode($paper['title'])) . '" target="_blank" style="display:block">
                                PDF</a></div>';
                }
            } else {
                print PHP_EOL . '<div class="ui-state-error-text noprint titles-pdf" style="float:left;color:#c5c6c8;cursor:auto">PDF</div>';
            }
            print PHP_EOL . '<div class="titles brief">' . $paper['title'] . '</div>';
            print '</div>';
            print '<div style="clear:both"></div>';
            print '<table class="noprint"><tr><td style="width:24px;padding-top:8px;padding-left:12px">';
            if ($display != 'abstract') {
                print PHP_EOL . '<i class="expander fa fa-plus-circle view-' . $display . '"></i>';
            }
            print '</td><td style="padding-top:8px">';
            if (isset($shelf_files) && in_array($paper['id'], $shelf_files)) {
                print '<span class="update_shelf clicked"><i class="update_shelf fa fa-check-square ui-state-error-text"></i>&nbsp;Shelf&nbsp;</span>';
            } else {
                print '<span class="update_shelf"><i class="update_shelf fa fa-square-o"></i>&nbsp;Shelf&nbsp;</span>';
            }
            if (isset($_SESSION['session_clipboard']) && in_array($paper['id'], $_SESSION['session_clipboard'])) {
                print ' &nbsp;<span class="update_clipboard clicked"><i class="update_clipboard fa fa-check-square ui-state-error-text"></i>&nbsp;Clipboard&nbsp;</span>';
            } else {
                print ' &nbsp;<span class="update_clipboard"><i class="update_clipboard fa fa-square-o"></i>&nbsp;Clipboard&nbsp;</span>';
            }
            foreach ($desktop_projects as $desktop_project) {
                $project_rowid = $tempdbHandle->query("SELECT ROWID FROM temp_projects WHERE projectID=" . intval($desktop_project['projectID']) . " AND fileID=" . intval($paper['id']) . " LIMIT 1");
                $project_rowid = $project_rowid->fetchColumn();
                if (!empty($project_rowid)) {
                    print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project clicked" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-check-square ui-state-error-text"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>';
                }
                if (empty($project_rowid)) {
                    print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-square-o"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>';
                }
                $project_rowid = null;
            }
            print PHP_EOL . '</td></tr></table>';
            print PHP_EOL . '<div class="display-summary" style="margin:0 30px;';
            print $display == 'brief' ? 'display:none">' : '">';
            if (!empty($paper['authors'])) {
                print PHP_EOL . '<div class="authors"><i class="author_expander fa fa-plus-circle"></i> ' . $paper['authors'] . '</div>';
            }
            print !empty($paper['journal']) ? $paper['journal'] : $paper['secondary_title'];
            print !empty($date) ? ' (' . htmlspecialchars($date) . ')' : '';
            if (!empty($paper['volume'])) {
                print ' <b>' . htmlspecialchars($paper['volume']) . '</b>';
            }
            if (!empty($paper['pages'])) {
                print ': ' . htmlspecialchars($paper['pages']);
            }
            if (date('Y-m-d') == $paper['addition_date']) {
                $today = ' <span class="ui-state-error-text"><b>New!</b></span>';
            } else {
                $today = '';
            }
            $result2 = $tempdbHandle->query("SELECT categoryID,category FROM temp_categories WHERE fileID=" . intval($paper['id']) . " ORDER BY category COLLATE NOCASE ASC");
            while ($categories = $result2->fetch(PDO::FETCH_ASSOC)) {
                $category_array[] = '<a href="' . htmlspecialchars('display.php?browse[' . urlencode($categories['categoryID']) . ']=category&select=' . $select . '&project=' . $project) . '" class="navigation">' . htmlspecialchars($categories['category']) . '</a>';
            }
            if (empty($category_array[0])) {
                $category_array[0] = '<a href="' . htmlspecialchars('display.php?browse[0]=category&select=' . $select) . '" class="navigation">!unassigned</a>';
            }
            print '<br><span><i class="star ' . ($paper['rating'] >= 1 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>';
            print '&nbsp;<i class="star ' . ($paper['rating'] >= 2 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>';
            print '&nbsp;<i class="star ' . ($paper['rating'] == 3 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i></span>&nbsp;';
            print '<b style="margin:0 0.5em">&middot;</b>';
            if (!empty($paper['bibtex'])) {
                print htmlspecialchars($paper['bibtex']);
            } else {
                $bibtex_author = strip_tags($paper['authors']);
                $bibtex_author = substr($bibtex_author, 0, strpos($bibtex_author, ','));
                if (empty($bibtex_author)) {
                    $bibtex_author = 'unknown';
                }
                $bibtex_year = '0000';
                $bibtex_year_array = explode('-', $paper['year']);
                if (!empty($bibtex_year_array[0])) {
                    $bibtex_year = $bibtex_year_array[0];
                }
                $bibtex_key = utf8_deaccent($bibtex_author) . '-' . $bibtex_year . '-ID' . $paper['id'];
                print htmlspecialchars($bibtex_key);
            }
            print '<b style="margin:0 0.5em">&middot;</b>';
            print 'Category: ';
            $category_string = join(", ", $category_array);
            $category_array = null;
            print $category_string;
            print '<b style="margin:0 0.5em">&middot;</b> Added:&nbsp;<a href="display.php?select=' . $select . '&browse[' . $paper['addition_date'] . ']=addition_date" class="navigation">' . date('M jS, Y', strtotime($paper['addition_date'])) . '</a>' . $today;
            print '<div class="noprint display-abstract"';
            print $display != 'abstract' ? ' style="display:none"' : '';
            print '>';
            if (!empty($pmid_url)) {
                print '<a href="' . htmlspecialchars($pmid_url) . '" target="_blank">PubMed</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($pmid_related_url)) {
                print '<a href="' . htmlspecialchars($pmid_related_url) . '" target="_blank">Related Articles</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($pmid_citedby_pmc)) {
                print '<a href="' . htmlspecialchars($pmid_citedby_pmc) . '" target="_blank">Cited by</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($pmcid_url)) {
                print '<a href="' . htmlspecialchars($pmcid_url) . '" target="_blank">PubMed Central</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($nasaads_url)) {
                print '<a href="' . htmlspecialchars($nasaads_url) . '" target="_blank">NASA ADS</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($nasa_related_url)) {
                print '<a href="' . htmlspecialchars($nasa_related_url) . '" target="_blank">Related Articles</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($nasa_citedby_pmc)) {
                print '<a href="' . htmlspecialchars($nasa_citedby_pmc) . '" target="_blank">Cited by</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($arxiv_url)) {
                print '<a href="' . htmlspecialchars($arxiv_url) . '" target="_blank">arXiv</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($jstor_url)) {
                print '<a href="' . htmlspecialchars($jstor_url) . '" target="_blank">JSTOR</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($ieee_url)) {
                print '<a href="' . htmlspecialchars($ieee_url) . '" target="_blank">IEEE</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($paper['doi'])) {
                print '<a href="' . htmlspecialchars('http://dx.doi.org/' . urlencode($paper['doi'])) . '" target="_blank">Publisher Website</a> <b style="margin:0 0.5em">&middot;</b> ';
            }
            if (!empty($other_urls)) {
                foreach ($other_urls as $another_url) {
                    print '<a href="' . htmlspecialchars($another_url) . '" target="_blank" class="anotherurl" title="' . htmlspecialchars(parse_url($another_url, PHP_URL_HOST)) . '">Link</a> <b style="margin:0 0.5em">&middot;</b> ';
                }
            }
            print '<a href="stable.php?id=' . $paper['id'] . '" target="_blank">Stable Link</a>';
            print '</div>';
            print '<div class="abstract display-abstract" style="';
            print $display != 'abstract' ? 'display:none' : '';
            print '">' . $paper['abstract'] . '</div>';
            print '<div class="display-abstract" style="';
            print $display != 'abstract' ? 'display:none' : '';
            print '">';
            if (!empty($paper['notes'])) {
                print '<div class="item-sticker ui-widget-content ui-corner-all" style="margin:6px;width:340px;float:left">
                        <div class="ui-widget-header items ui-corner-top" style="border:0"><b class="ui-dialog-titlebar">Notes</b></div><div class="separator" style="margin:0"></div>
                        <div class="alternating_row ui-corner-bottom" style="padding:4px 7px;max-height:200px;overflow:auto">' . $paper['notes'] . '&nbsp;
                        </div></div>';
            }
            if (is_file(graphical_abstract($paper['file']))) {
                print '<div class="item-sticker ui-widget-content ui-corner-all" style="margin:6px;width:340px;float:left">
                        <div class="ui-widget-header items ui-corner-top" style="border:0"><b class="ui-dialog-titlebar">Graphical Abstract</b></div><div class="separator" style="margin:0"></div>
                        <div class="alternating_row ui-corner-bottom" style="padding:4px 7px;max-height:200px;overflow:auto">
                        <img src="' . htmlspecialchars('attachment.php?mode=inline&attachment=' . basename(graphical_abstract($paper['file']))) . '">
                        </div></div>';
            }
            print '</div></div></div>';
        }
    }
    if ($display == 'icons') {
        print '</td></tr></table>';
    }
}
示例#22
0
/**
 * Remove unwanted chars from ID
 *
 * Cleans a given ID to only use allowed characters. Accented characters are
 * converted to unaccented ones
 *
 * @author Andreas Gohr <*****@*****.**>
 * @param  string  $raw_id    The pageid to clean
 * @param  boolean $ascii     Force ASCII
 * @return string cleaned id
 */
function cleanID($raw_id, $ascii = false)
{
    global $conf;
    static $sepcharpat = null;
    global $cache_cleanid;
    $cache =& $cache_cleanid;
    if ($conf['syslog']) {
        syslog(LOG_WARNING, '[pageutils.php] cleanID: raw_id: ' . $raw_id);
    }
    // check if it's already in the memory cache
    if (isset($cache[(string) $raw_id])) {
        return $cache[(string) $raw_id];
    }
    $sepchar = $conf['sepchar'];
    if ($sepcharpat == null) {
        // build string only once to save clock cycles
        $sepcharpat = '#\\' . $sepchar . '+#';
    }
    $id = trim((string) $raw_id);
    if ($conf['mixedcase'] == 0) {
        $id = utf8_strtolower($id);
    }
    //alternative namespace seperator
    if ($conf['useslash']) {
        $id = strtr($id, ';/', '::');
    } else {
        $id = strtr($id, ';/', ':' . $sepchar);
    }
    if ($conf['deaccent'] == 2 || $ascii) {
        $id = utf8_romanize($id);
    }
    if ($conf['deaccent'] || $ascii) {
        $id = utf8_deaccent($id, -1);
    }
    //remove specials if specialcharacters is set to 0
    if ($conf['specialcharacters'] == 0) {
        $id = utf8_stripspecials($id, $sepchar, '\\*');
    }
    if ($ascii) {
        $id = utf8_strip($id);
    }
    //clean up
    $id = preg_replace($sepcharpat, $sepchar, $id);
    $id = preg_replace('#:+#', ':', $id);
    $id = trim($id, ':._-');
    $id = preg_replace('#:[:\\._\\-]+#', ':', $id);
    $id = preg_replace('#[:\\._\\-]+:#', ':', $id);
    $cache[(string) $raw_id] = $id;
    if ($conf['syslog']) {
        syslog(LOG_WARNING, '[pageutils.php] cleanID: id to be returned: ' . $id);
    }
    return $id;
}
示例#23
0
$dbHandle->beginTransaction();
$result = $dbHandle->query("SELECT id, authors, year FROM library WHERE bibtex=''");
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
    extract($row);
    $bibtex_author = 'unknown';
    if (!empty($authors)) {
        $bibtex_author = substr($authors, 3);
        $bibtex_author = substr($bibtex_author, 0, strpos($bibtex_author, ',') - 1);
        $bibtex_author = str_replace(array(' ', '{', '}'), '', $bibtex_author);
    }
    $bibtex_year = '0000';
    $bibtex_year_array = explode('-', $year);
    if (!empty($bibtex_year_array[0]) && is_numeric($bibtex_year_array[0])) {
        $bibtex_year = $bibtex_year_array[0];
    }
    $bibtex = utf8_deaccent($bibtex_author) . '-' . $bibtex_year . '-ID' . $id;
    $stmt->execute();
}
$dbHandle->commit();
$stmt = null;
$dbHandle = null;
// Upgrade settings.
$dbHandle = database_connect(IL_USER_DATABASE_PATH, 'users');
$query = "DELETE FROM settings WHERE setting_value=''";
$stmt = $dbHandle->prepare($query);
$stmt->execute();
$stmt = null;
$query = "UPDATE settings SET setting_name=substr(setting_name,8) WHERE substr(setting_name,1,7)='global_'";
$stmt = $dbHandle->prepare($query);
$stmt->execute();
$stmt = null;
示例#24
0
/**
 * Encodes an email address header
 *
 * Unicode characters will be deaccented and encoded
 * quoted_printable for headers.
 * Addresses may not contain Non-ASCII data!
 *
 * Example:
 *   mail_encode_address("föö <*****@*****.**>, me@somewhere.com","TBcc");
 *
 * @param string  $string Multiple adresses separated by commas
 * @param string  $header Name of the header (To,Bcc,Cc,...)
 * @param boolean $names  Allow named Recipients?
 */
function mail_encode_address($string, $header = '', $names = true)
{
    $headers = '';
    $parts = explode(',', $string);
    foreach ($parts as $part) {
        $part = trim($part);
        // parse address
        if (preg_match('#(.*?)<(.*?)>#', $part, $matches)) {
            $text = trim($matches[1]);
            $addr = $matches[2];
        } else {
            $addr = $part;
        }
        // skip empty ones
        if (empty($addr)) {
            continue;
        }
        // FIXME: is there a way to encode the localpart of a emailaddress?
        if (!utf8_isASCII($addr)) {
            msg(htmlspecialchars("E-Mail address <{$addr}> is not ASCII"), -1);
            continue;
        }
        if (!mail_isvalid($addr)) {
            msg(htmlspecialchars("E-Mail address <{$addr}> is not valid"), -1);
            continue;
        }
        // text was given
        if (!empty($text) && $names) {
            // add address quotes
            $addr = "<{$addr}>";
            if (defined('MAILHEADER_ASCIIONLY')) {
                $text = utf8_deaccent($text);
                $text = utf8_strip($text);
            }
            if (!utf8_isASCII($text)) {
                // put the quotes outside as in =?UTF-8?Q?"Elan Ruusam=C3=A4e"?= vs "=?UTF-8?Q?Elan Ruusam=C3=A4e?="
                if (preg_match('/^"(.+)"$/', $text, $matches)) {
                    $text = '"=?UTF-8?Q?' . mail_quotedprintable_encode($matches[1], 0) . '?="';
                } else {
                    $text = '=?UTF-8?Q?' . mail_quotedprintable_encode($text, 0) . '?=';
                }
                // additionally the space character should be encoded as =20 (or each
                // word QP encoded separately).
                // however this is needed only in mail headers, not globally in mail_quotedprintable_encode().
                $text = str_replace(" ", "=20", $text);
            }
        } else {
            $text = '';
        }
        // add to header comma seperated
        if ($headers != '') {
            $headers .= ',';
            if ($header) {
                $headers .= MAILHEADER_EOL . ' ';
            }
            // avoid overlong mail headers
        }
        $headers .= $text . ' ' . $addr;
    }
    if (empty($headers)) {
        return null;
    }
    //if headername was given add it and close correctly
    if ($header) {
        $headers = $header . ': ' . $headers . MAILHEADER_EOL;
    }
    return $headers;
}
 foreach ($search_array as $search) {
     //SPLIT THE TERM INTO AN OPTIONAL PARETHESES, LAZY TEXT, AND PARETHESES
     if (preg_match('/([\\s\\(]*)([^\\(\\)]*)?([\\s\\)]*)/i', $search, $matches) == 1) {
         //FORMAT THE TEXT FOR SEARCH
         $like_query = str_replace("\\", "\\\\", trim($matches[2]));
         $like_query = str_replace("%", "\\%", $like_query);
         $like_query = str_replace("_", "\\_", $like_query);
         $like_query = str_replace("<*>", "%", $like_query);
         $like_query = str_replace("<?>", "_", $like_query);
         $regexp_query = preg_quote(trim($matches[2]));
         $regexp_query = str_replace('\\<\\*\\>', '.*', $regexp_query);
         $regexp_query = str_replace('\\<\\?\\>', '.?', $regexp_query);
         $like_query = $dbHandle->quote("%{$like_query}%");
         $regexp_query = str_replace("'", "''", $regexp_query);
         //CHECK WHETHER TEXT CONTAINS UTF-8
         $translation = utf8_deaccent($matches[2]);
         if ($translation != $matches[2]) {
             $like_query_translated = $dbHandle->quote("%{$translation}%");
             $regexp_query_translated = str_replace("'", "''", $translation);
             $like_sql = "(full_text LIKE {$like_query} ESCAPE '\\' OR full_text LIKE {$like_query_translated} ESCAPE '\\')";
             $regexp_sql = "(regexp_match(full_text, '{$regexp_query}', {$case2}) OR regexp_match(full_text, '{$regexp_query_translated}', {$case2}))";
         } else {
             $like_sql = "full_text LIKE {$like_query} ESCAPE '\\'";
             $regexp_sql = "regexp_match(full_text, '{$regexp_query}', {$case2})";
         }
         $final = $like_sql;
         if ($whole_words == 1) {
             $final = "(({$final}) AND ({$regexp_sql}))";
         }
         $input = str_replace($matches[0], $matches[1] . " {$final} " . $matches[3], $input);
     } else {
示例#26
0
 public function verifyUsername($username, $userId = null)
 {
     // standardize white space in names
     $username = preg_replace('/\\s+/u', ' ', $username);
     try {
         $newName = preg_replace('/\\v+/u', ' ', $username);
         if (is_string($newName)) {
             $username = $newName;
         }
     } catch (Exception $e) {
     }
     $username = trim($username);
     $usernameLength = utf8_strlen($username);
     $minLength = $this->getOption('usernameLength', 'min');
     $maxLength = $this->getOption('usernameLength', 'max');
     if ($minLength > 0 && $usernameLength < $minLength) {
         return new XenForo_Phrase('please_enter_name_that_is_at_least_x_characters_long', array('count' => $minLength));
     }
     if ($maxLength > 0 && $usernameLength > $maxLength) {
         return new XenForo_Phrase('please_enter_name_that_is_at_most_x_characters_long', array('count' => $maxLength));
     }
     $disallowedNames = preg_split('/\\r?\\n/', $this->getOption('usernameValidation', 'disallowedNames'));
     if ($disallowedNames) {
         foreach ($disallowedNames as $name) {
             $name = trim($name);
             if ($name === '') {
                 continue;
             }
             if (stripos($username, $name) !== false) {
                 return new XenForo_Phrase('please_enter_another_name_disallowed_words');
             }
         }
     }
     $matchRegex = $this->getOption('usernameValidation', 'matchRegex');
     if ($matchRegex) {
         $matchRegex = str_replace('#', '\\#', $matchRegex);
         // escape delim only
         if (!preg_match('#' . $matchRegex . '#i', $username)) {
             return new XenForo_Phrase('please_enter_another_name_required_format');
         }
     }
     $censoredUserName = XenForo_Helper_String::censorString($username);
     if ($censoredUserName !== $username) {
         return new XenForo_Phrase('please_enter_name_that_does_not_contain_any_censored_words');
     }
     // ignore check if unicode properties aren't compiled
     try {
         if (@preg_match("/\\p{C}/u", $username)) {
             return new XenForo_Phrase('please_enter_name_without_using_control_characters');
         }
     } catch (Exception $e) {
     }
     if (strpos($username, ',') !== false) {
         return new XenForo_Phrase('please_enter_name_that_does_not_contain_comma');
     }
     if (Zend_Validate::is($username, 'EmailAddress')) {
         return new XenForo_Phrase('please_enter_name_that_does_not_resemble_an_email_address');
     }
     $existingUser = XenForo_Model::create('XenForo_Model_User')->getUserByName($username);
     if ($existingUser && (!$userId || $userId && $userId != $existingUser['user_id'])) {
         return new XenForo_Phrase('usernames_must_be_unique');
     }
     // compare against romanized name to help reduce confusable issues
     $romanized = utf8_deaccent(utf8_romanize($username));
     if ($romanized != $username) {
         $existingUser = XenForo_Model::create('XenForo_Model_User')->getUserByName($romanized);
         if ($existingUser && (!$userId || $userId && $userId != $existingUser['user_id'])) {
             return new XenForo_Phrase('usernames_must_be_unique');
         }
     }
     return true;
 }
示例#27
0
 /**
  * Create a new Jive group to hold discussions about wiki pages
  * 
  */
 private function createJiveGroup()
 {
     if (($jive = $this->loadHelper('jive')) === NULL) {
         msg('Cannot load helper for jive plugin.', -1);
         return array(FALSE, NULL);
     }
     if (($placeID = $jive->jiveGetDiscussionGroup(NULL)) !== NULL) {
         if (($data = $jive->jiveRequestAPI('GET', '/places/' . $placeID, NULL)) !== FALSE) {
             $info = json_decode($data, TRUE);
             //FIXME stcmp() call seems useless - check for error in JSON
             if (!isset($info['Error'])) {
                 msg("Jive group (placeID=" . $placeID . ") already exists - nothing to do.");
                 return array(FALSE, NULL);
             }
         }
     }
     global $conf;
     if (($displayName = strtr(utf8_deaccent($conf['title']), " ", "-")) === NULL) {
         msg('error converting $conf[\'title\'].', -1);
         return array(FALSE, NULL);
     }
     // Create JSON data for group creation request
     if (($json = json_encode(array("type" => "group", "name" => $conf['title'], "displayName" => $displayName, "description" => sprintf($this->getLang('jiveGroupDescription'), $conf['title']) . " - " . DOKU_URL, "groupType" => "OPEN"))) === FALSE) {
         msg('error encoding group creation post to JSON', -1);
         return array(FALSE, NULL);
     }
     // Call API to create group
     if (($resp = $jive->jiveRequestAPI('POST', '/places', $json)) === FALSE) {
         msg('Failed to create group: ' . $jive->jiveLastErrorMsg(), -1);
         return array(FALSE, NULL);
     }
     // Get the placeID for the group created
     if (($placeID = $jive->jiveGetDiscussionGroup($resp)) === NULL) {
         msg('Failed to get group ID: ' . $jive->jiveLastErrorMsg() . "See JSON data below", -1);
         return array(FALSE, "JSON data returned:<br>" . $resp);
     }
     msg("Jive group (placeID=" . $placeID . ") created on Jive server and stored in Wiki configuration.", 1);
     return array(FALSE, 'You should now delete this Jive plugin statement in this page source.');
 }