コード例 #1
0
ファイル: add_pub_submit.php プロジェクト: papersdb/papersdb
 public function __construct()
 {
     parent::__construct(null, 'Publication Submitted', 'Admin/add_pub_submit.php', pdNavMenuItem::MENU_NEVER);
     if ($this->loginError) {
         return;
     }
     if (!isset($_SESSION['state']) || $_SESSION['state'] != 'pub_add') {
         $this->pageError = true;
         return;
     }
     $pub =& $_SESSION['pub'];
     $user =& $_SESSION['user'];
     if ($pub->pub_id != null) {
         echo 'The following PapersDB entry has been modified:<p/>';
     } else {
         echo 'The following PapersDB entry has been added to the database:<p/>';
     }
     $pub->submit = $user->name;
     $pub->dbSave($this->db);
     // deal with paper
     if (isset($_SESSION['paper'])) {
         if ($_SESSION['paper'] != 'none') {
             $pub->paperSave($this->db, $_SESSION['paper']);
         } else {
             $pub->deletePaper($this->db);
         }
     }
     if (isset($_SESSION['attachments']) && count($_SESSION['attachments']) > 0) {
         for ($i = 0, $n = count($_SESSION['attachments']); $i < $n; $i++) {
             assert('isset($_SESSION["att_types"][$i])');
             $pub->attSave($this->db, $_SESSION['attachments'][$i], $_SESSION['att_types'][$i]);
         }
     }
     if (isset($_SESSION['removed_atts']) && count($_SESSION['removed_atts']) > 0) {
         foreach ($_SESSION['removed_atts'] as $filename) {
             $pub->deleteAttByFilename($this->db, $filename);
         }
     }
     if ($this->debug) {
         debugVar('$pub', $pub);
     }
     // does pub entry require validation?
     if ($pub->validationRequired($this->db) && $user->isAdministrator()) {
         $pub->markValid($this->db);
     } else {
         $pub->markPending($this->db);
     }
     echo $pub->getCitationHtml(), getPubIcons($this->db, $pub, 0xf, '../');
     pubSessionInit();
 }
コード例 #2
0
ファイル: author_confirm.php プロジェクト: papersdb/papersdb
 public function __construct()
 {
     parent::__construct('author_confirm', 'Author Confirm', 'Admin/author_confirm.php');
     if ($this->loginError) {
         return;
     }
     if (!isset($_SESSION['new_author'])) {
         $this->pageError = true;
         return;
     }
     $new_author = $_SESSION['new_author'];
     if (isset($new_author->author_id)) {
         $this->pageError = true;
         debugVar('new_author', $new_author);
         return;
     }
     $this->form =& $this->confirmForm('author_confirm', null, 'Add');
     if ($this->form->validate()) {
         $values = $this->form->exportValues();
         $new_author->dbSave($this->db);
         if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') {
             assert('isset($_SESSION["pub"])');
             $pub =& $_SESSION['pub'];
             $pub->addAuthor($this->db, $new_author->author_id);
             header('Location: add_pub2.php');
             return;
         }
         echo 'Author <span class="emph">', $new_author->name, '</span> ', 'succesfully added to the database.', '<p/>', '<a href="add_author.php">', 'Add another new author</a>';
     } else {
         $like_authors = pdAuthorList::create($this->db, $new_author->firstname, $new_author->lastname);
         assert('count($like_authors) > 0');
         echo 'Attempting to add new author: ', '<span class="emph">', $new_author->name, "</span><p/>\n", 'The following authors, already in the database, have similar names:<ul>';
         foreach ($like_authors as $auth) {
             echo '<li>', $auth, '</li>';
         }
         echo '</ul>Do you really want to add this author?';
         $renderer =& $this->form->defaultRenderer();
         $this->form->accept($renderer);
         $this->renderer =& $renderer;
     }
 }
コード例 #3
0
ファイル: add_pub3.php プロジェクト: papersdb/papersdb
 public function processForm()
 {
     $form =& $this->form;
     $values = $form->exportValues();
     debugVar('values', $values);
     if (isset($this->pub->category) && $this->pub->category->info != null) {
         foreach ($this->formInfoElementsGet() as $element => $name) {
             if (isset($values[$element])) {
                 $this->pub->info[$name] = $values[$element];
             }
         }
     }
     if (!empty($values['venue_id']) && $values['venue_id'] > 0) {
         $this->pub->addVenue($this->db, $values['venue_id']);
     } else {
         if (is_object($this->pub->venue)) {
             unset($this->pub->venue);
             unset($this->pub->venue_id);
         }
     }
     if ($values['cat_id'] > 0) {
         if (!isset($this->pub->venue) || is_object($this->pub->venue) && isset($this->pub->category) && is_object($this->pub->category) && $this->pub->category->cat_id != $values['cat_id']) {
             // either no venue set for this pub entry, OR user has
             // overriden the category since user selected one that does not
             // match the venue
             $this->pub->addCategory($this->db, $values['cat_id']);
         }
     }
     if (isset($values['paper_rank'])) {
         $this->pub->rank_id = $values['paper_rank'];
     }
     if (isset($values['paper_rank']) && $values['paper_rank'] == -1 && strlen($values['paper_rank_other']) > 0) {
         $this->pub->rank_id = -1;
         $this->pub->ranking = $values['paper_rank_other'];
     }
     $this->pub->published = $values['pub_date']['Y'] . '-' . $values['pub_date']['M'] . '-1';
     $extra_info_arr = array();
     if ($values['extra_info'] != '') {
         $extra_info_arr = array_merge($extra_info_arr, array($values['extra_info']));
     }
     $this->pub->extraInfoSet($extra_info_arr);
     if ($this->debug) {
         debugVar('values', $values);
         debugVar('pub', $this->pub);
         return;
     }
     if (isset($values['add_venue'])) {
         header('Location: add_venue.php');
     } else {
         if (isset($values['prev_step'])) {
             header('Location: add_pub2.php');
         } else {
             if (isset($values['finish'])) {
                 header('Location: add_pub_submit.php');
             } else {
                 header('Location: add_pub4.php');
             }
         }
     }
 }
コード例 #4
0
ファイル: add_pub1.php プロジェクト: papersdb/papersdb
 /**
  * Called to process the input typed into the form by the user.
  */
 public function processForm()
 {
     assert('isset($_SESSION["pub"])');
     $form =& $this->form;
     $values = $form->exportValues();
     $this->pub->load($values);
     $_SESSION['state'] = 'pub_add';
     $result = $this->pub->duplicateTitleCheck($this->db);
     if (count($result) > 0) {
         $_SESSION['similar_pubs'] = $result;
     }
     if ($this->debug) {
         debugVar('values', $values);
         debugVar('pub', $this->pub);
         return;
     }
     if (isset($values['finish'])) {
         header('Location: add_pub_submit.php');
     } else {
         if (isset($values['step2'])) {
             header('Location: add_pub2.php');
         } else {
             if (isset($values['step3'])) {
                 header('Location: add_pub3.php');
             } else {
                 if (isset($values['step4'])) {
                     header('Location: add_pub4.php');
                 }
             }
         }
     }
 }
コード例 #5
0
    function getContent($url, $enableProxy = true, $logCrawl = true)
    {
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_URL, $url);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_FAILONERROR, $this->_CURLOPT_FAILONERROR);
        @curl_setopt($this->_CURL_RESOURCE, CURLOPT_FOLLOWLOCATION, $this->_CURLOPT_FOLLOWLOCATION);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_RETURNTRANSFER, $this->_CURLOPT_RETURNTRANSFER);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_TIMEOUT, $this->_CURLOPT_TIMEOUT);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_COOKIEJAR, $this->_CURLOPT_COOKIEJAR);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_COOKIEFILE, $this->_CURLOPT_COOKIEFILE);
        curl_setopt($this->_CURL_RESOURCE, CURLOPT_HEADER, $this->_CURLOPT_HEADER);
        if (!empty($this->_CURLOPT_COOKIE)) {
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_COOKIE, $this->_CURLOPT_COOKIE);
        }
        if (!empty($this->_CURLOPT_REFERER)) {
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_REFERER, $this->_CURLOPT_REFERER);
        }
        if (strlen($this->_CURLOPT_POSTFIELDS) > 1) {
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_POST, $this->_CURLOPT_POST);
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_POSTFIELDS, $this->_CURLOPT_POSTFIELDS);
        }
        // user agent assignment
        $this->_CURLOPT_USERAGENT = defined('SP_USER_AGENT') ? SP_USER_AGENT : $this->_CURLOPT_USERAGENT;
        if (strlen($this->_CURLOPT_USERAGENT) > 0) {
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_USERAGENT, $this->_CURLOPT_USERAGENT);
        }
        if (strlen($this->_CURLOPT_USERPWD) > 2) {
            curl_setopt($this->_CURL_RESOURCE, CURLOPT_USERPWD, $this->_CURLOPT_USERPWD);
        }
        // to use proxy if proxy enabled
        if (SP_ENABLE_PROXY && $enableProxy) {
            $proxyCtrler = new ProxyController();
            if ($proxyInfo = $proxyCtrler->getRandomProxy()) {
                curl_setopt($this->_CURL_RESOURCE, CURLOPT_PROXY, $proxyInfo['proxy'] . ":" . $proxyInfo['port']);
                curl_setopt($this->_CURL_RESOURCE, CURLOPT_HTTPPROXYTUNNEL, CURLOPT_HTTPPROXYTUNNEL_VAL);
                if (!empty($proxyInfo['proxy_auth'])) {
                    curl_setopt($this->_CURL_RESOURCE, CURLOPT_PROXYUSERPWD, $proxyInfo['proxy_username'] . ":" . $proxyInfo['proxy_password']);
                }
            } else {
                showErrorMsg("No active proxies found!! Please check your proxy settings from Admin Panel.");
            }
        }
        $ret['page'] = curl_exec($this->_CURL_RESOURCE);
        $ret['error'] = curl_errno($this->_CURL_RESOURCE);
        $ret['errmsg'] = curl_error($this->_CURL_RESOURCE);
        // update crawl log in database for future reference
        if ($logCrawl) {
            $crawlLogCtrl = new CrawlLogController();
            $crawlInfo['crawl_status'] = $ret['error'] ? 0 : 1;
            $crawlInfo['ref_id'] = $crawlInfo['crawl_link'] = addslashes($url);
            $crawlInfo['crawl_referer'] = addslashes($this->_CURLOPT_REFERER);
            $crawlInfo['crawl_cookie'] = addslashes($this->_CURLOPT_COOKIE);
            $crawlInfo['crawl_post_fields'] = addslashes($this->_CURLOPT_POSTFIELDS);
            $crawlInfo['crawl_useragent'] = addslashes($this->_CURLOPT_USERAGENT);
            $crawlInfo['proxy_id'] = $proxyInfo['id'];
            $crawlInfo['log_message'] = addslashes($ret['errmsg']);
            $ret['log_id'] = $crawlLogCtrl->createCrawlLog($crawlInfo);
        }
        // disable proxy if not working
        if (SP_ENABLE_PROXY && $enableProxy && !empty($ret['error']) && !empty($proxyInfo['id'])) {
            // deactivate proxy
            if (PROXY_DEACTIVATE_CRAWL) {
                $proxyCtrler->__changeStatus($proxyInfo['id'], 0);
            }
            // chekc with another proxy
            if (CHECK_WITH_ANOTHER_PROXY_IF_FAILED) {
                $ret = $this->getContent($url, $enableProxy);
            }
        }
        // check debug request is enabled
        if (!empty($_GET['debug']) || !empty($_POST['debug'])) {
            ?>
			<div style="width: 760px; margin-top: 30px; padding: 14px; height: 900px; overflow: auto; border: 1px solid #B0C2CC;">
				<?php 
            if ($_GET['debug_format'] == 'html' || $_POST['debug_format'] == 'html') {
                highlight_string($ret['page']);
            } else {
                debugVar($ret, false);
            }
            ?>
			</div>
			<?php 
        }
        return $ret;
    }
コード例 #6
0
ファイル: fix_interests.php プロジェクト: papersdb/papersdb
if (count($numeric_interests) == 0) {
    exit(0);
}
//pdDb::debugOn();
//debugVar('n', $numeric_interests);
$q = $db->select(array('author', 'author_interest', 'interest'), array('author.author_id', 'interest.interest_id', 'interest.interest'), array('interest.interest_id' => array_keys($numeric_interests), 'interest.interest_id=author_interest.interest_id', 'author.author_id=author_interest.author_id'));
$authors = array();
$author_info_list = array();
foreach ($q as $r) {
    if (!isset($authors[$r->author_id])) {
        $authors[$r->author_id] = pdAuthor::newFromDb($db, $r->author_id, pdAuthor::DB_LOAD_BASIC | pdAuthor::DB_LOAD_INTERESTS);
    }
    $author_info_list[] = array('interest_id' => $r->interest_id, 'new_interest' => array($all_interests[$r->interest_id] => $all_interests[$all_interests[$r->interest_id]]), 'author' => &$authors[$r->author_id]);
}
//debugVar('$author_info_list', $author_info_list);
foreach ($author_info_list as $info) {
    $info['author']->interests = $info['author']->interests + $info['new_interest'];
    unset($info['author']->interests[$info['interest_id']]);
}
//debugVar('$authors', $authors);
foreach ($authors as $author) {
    $author->dbSave($db);
}
debugVar('$numeric_interests', $numeric_interests);
foreach ($numeric_interests as $k => $i) {
    $q = $db->select('author_interest', '*', array('interest_id' => $k));
    if (count($q) == 0) {
        $result = $db->delete('interest', array('interest_id' => $k));
        echo "{$result}\n";
    }
}
コード例 #7
0
ファイル: delete.php プロジェクト: araynaud/FoodPortrait
<?php

require_once "../include/includes.php";
setContentType("text", "plain");
session_start();
//receive file and other form fields
//move file to temp location:  $BASE_IMAGE_DIR/$username/$filename
//load, resize, crop image.
//do not keep original file
//insert into upload table.
//What if user/filename already exists? can user reuse existing image, select from uploads?
//response: image metadata from EXIF and url.
//echo jsValue($fpConfig, true, true);
$username = fpCurrentUsername();
$upload_id = reqParam("upload_id");
debugVar("username", true);
debug("Request", $_REQUEST);
debug("GET request", $_GET);
debug("POST request", $_POST);
debug("POST files", $_FILES, true);
if (!$username) {
    return errorMessage("Not logged in.");
}
if (!$upload_id) {
    return errorMessage("No File deleted.");
}
$db = new SqlManager($fpConfig);
if ($db->offline) {
    return errorMessage("DB offline. No File deleted.");
}
//if profile filters( Q_ ) : demographic
コード例 #8
0
ファイル: add_pub2.php プロジェクト: papersdb/papersdb
 public function processForm()
 {
     assert('isset($_SESSION["pub"])');
     $form =& $this->form;
     $values = $form->exportValues();
     if (empty($values['authors'])) {
         $this->pub->clearAuthors();
     } else {
         // need to retrieve author_ids for the selected authors
         $selAuthors = explode(', ', preg_replace('/\\s\\s+/', ' ', $values['authors']));
         $author_ids = array();
         foreach ($selAuthors as $author) {
             if (empty($author)) {
                 continue;
             }
             $result = array_search($author, $this->authors);
             if ($result !== false) {
                 $author_ids[] = $result;
             }
         }
         if (count($author_ids) > 0) {
             $this->pub->addAuthor($this->db, $author_ids);
         }
     }
     if (isset($values['paper_col']) && count($values['paper_col']) > 0) {
         $this->pub->collaborations = array_keys($values['paper_col']);
     }
     if ($this->debug) {
         debugVar('values', $values);
         debugVar('pub', $this->pub);
         return;
     }
     if (isset($values['add_new_author'])) {
         header('Location: add_author.php');
     } else {
         if (isset($values['prev_step'])) {
             header('Location: add_pub1.php');
         } else {
             if (isset($values['finish'])) {
                 header('Location: add_pub_submit.php');
             } else {
                 header('Location: add_pub3.php');
             }
         }
     }
 }
コード例 #9
0
ファイル: add_venue.php プロジェクト: papersdb/papersdb
 private function processForm()
 {
     $form =& $this->form;
     $values = $form->exportValues();
     $this->venue->load($values);
     //add http:// to webpage address if needed
     if ($this->venue->url != '' && strpos($this->venue->url, 'http') === false) {
         $this->venue->url = "http://" . $this->venue->url;
     }
     $this->venue->title = str_replace('"', "'", $this->venue->title);
     if (isset($values['venue_rank'])) {
         $this->venue->rank_id = $values['venue_rank'];
     }
     if (isset($values['venue_rank']) && $values['venue_rank'] == -1 && strlen($values['venue_rank_other']) > 0) {
         $this->venue->rank_id = -1;
         $this->venue->ranking = $values['venue_rank_other'];
     }
     if (isset($values['venue_date']) && is_object($this->venue->category) && $this->venue->category->category == 'In Workshop') {
         $this->venue->date = $values['venue_date']['Y'] . '-' . $values['venue_date']['M'] . '-1';
     }
     $this->venue->deleteOccurrences();
     if (isset($values['numNewOccurrences']) && count($values['numNewOccurrences']) > 0) {
         for ($i = 0; $i < $values['numNewOccurrences']; $i++) {
             $this->venue->addOccurrence($values['newOccurrenceLocation'][$i], $values['newOccurrenceDate'][$i]['Y'] . '-' . $values['newOccurrenceDate'][$i]['M'] . '-1', $values['newOccurrenceUrl'][$i]);
         }
     }
     $vopt_names = $this->venue->voptsGet();
     if (!empty($vopt_names)) {
         foreach ($vopt_names as $vopt_id => $name) {
             $name = strtolower(preg_replace('/\\s+/', '_', $name));
             $this->venue->options[$vopt_id] = $values[$name];
         }
     }
     $this->venue->dbSave($this->db);
     if (isset($_SESSION['state']) && $_SESSION['state'] == 'pub_add') {
         assert('isset($_SESSION["pub"])');
         $pub =& $_SESSION['pub'];
         $pub->addVenue($this->db, $this->venue);
         if ($this->debug) {
             debugVar('values', $values);
             debugVar('venue', $this->venue);
             return;
         }
         if (isset($values['finish'])) {
             header('Location: add_pub_submit.php');
         } else {
             header('Location: add_pub4.php');
         }
     } else {
         if (empty($this->venue_id)) {
             echo 'You have successfully added the venue "';
             if (!empty($this->venue->title)) {
                 echo $this->venue->title, '".';
             } else {
                 echo $this->venue->name, '".';
             }
             echo '<br><a href="./add_venue.php">Add another venue</a>';
         } else {
             echo 'You have successfully edited the venue "';
             if (!empty($this->venue->title)) {
                 echo $this->venue->title, '".';
             } else {
                 echo $this->venue->name, '".';
             }
         }
         if (!empty($this->referer)) {
             echo '<p/><a href="', $this->referer, '">Return to venue list</a>';
         }
     }
     if ($this->debug) {
         debugVar('values', $values);
         debugVar('venue', $this->venue);
         return;
     }
 }
コード例 #10
0
ファイル: login.php プロジェクト: araynaud/FoodPortrait
//compare MD5 password in db with MD5 password submitted
function validatePassword($dbUser, $postData)
{
    if (!$dbUser || !isset($postData["password"])) {
        return false;
    }
    return $dbUser["password"] == $postData["password"];
}
switch ($action) {
    case "login":
        //find user by username or by email
        $dbUser = getUser($db, $postData["username"]);
        if (!$dbUser) {
            $dbUser = getUser($db, $postData["username"], "email");
        }
        debugVar("dbUser");
        $response["success"] = validatePassword($dbUser, $postData);
        if ($response["success"]) {
            $response["message"] = "User logged in.";
            unset($dbUser["password"]);
            $dbUser["hasProfile"] = hasProfile($db, $dbUser["username"]);
            $response["user"] = fpSetUser($dbUser);
        } else {
            $response["message"] = "Login failed.";
            fpUserLogout();
        }
        break;
    case "signup":
        $params = $postData;
        $params["table"] = "user";
        unset($params["action"]);
コード例 #11
0
        } else {
            if ($p['position'] == 'PDF') {
                $pos_id = $positions['Post Doctoral Fellow'];
            } else {
                if ($p['position'] == 'PhD') {
                    $pos_id = $positions['PhD Student'];
                } else {
                    if ($p['position'] == 'MSc') {
                        $pos_id = $positions['MSc Student'];
                    }
                }
            }
        }
    } else {
        $pos_id = $positions[$p['position']];
    }
    $staff_member = array('author_id' => $author_id, 'pos_id' => $pos_id, 'start_date' => $p['start_date']);
    if (isset($p['end_date'])) {
        $staff_member['end_date'] = $p['end_date'];
    }
    $staff[] = $staff_member;
}
// $staff contains staff members that are already in the papersDb database
foreach ($staff as $member) {
    $result = $db->insert('aicml_staff', $member);
    if (!$result) {
        echo 'could not insert staff information for ', $member['author_id'], "\n";
    }
}
debugVar('$staff', $staff);
コード例 #12
0
 /**
  * Performs and advanced search.
  */
 private function advancedSearch()
 {
     // VENUE SEARCH ------------------------------------------
     if ($this->sp->venue != '') {
         $parser = new SearchTermParser($this->sp->venue);
         $the_search_array = $parser->getWordList();
         foreach ($the_search_array as $and_terms) {
             $union_array = array();
             foreach ($and_terms as $or_term) {
                 $this->venuesSearch('title', $or_term, $union_array);
                 $this->venuesSearch('name', $or_term, $union_array);
             }
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // CATEGORY SEARCH ----------------------------------------------------
     //
     // if category search found, pass on only the ids found with that match
     // with category
     if ($this->sp->cat_id != '') {
         $temporary_array = NULL;
         $cat_id = $this->sp->cat_id;
         $search_query = "SELECT DISTINCT pub_id FROM pub_cat WHERE cat_id=" . $this->db->quote_smart($cat_id);
         //we then add these matching id's to a temp array
         $this->add_to_array($search_query, $temporary_array);
         //then we only keep the common ids between both arrays
         $this->result_pubs = array_intersect($this->result_pubs, $temporary_array);
     }
     // PUBLICATION FIELDS SEARCH ------------------------------------------
     $fields = array("title", "paper", "abstract", "keywords", "extra_info");
     //same thing happening as category, just with each of these fields
     foreach ($fields as $field) {
         if (isset($this->sp->{$field}) && $this->sp->{$field} != '') {
             $parser = new SearchTermParser($this->sp->{$field});
             $the_search_array = $parser->getWordList();
             foreach ($the_search_array as $and_terms) {
                 $union_array = null;
                 foreach ($and_terms as $or_term) {
                     $this->add_to_array('SELECT DISTINCT pub_id from publication WHERE ' . $field . ' LIKE ' . $this->db->quote_smart('%' . $or_term . '%'), $union_array);
                 }
                 $this->result_pubs = array_intersect($this->result_pubs, $union_array);
             }
         }
     }
     // MYSELF or AUTHOR SELECTED SEARCH -----------------------------------
     $authors = array();
     if (!empty($this->sp->authors)) {
         // need to retrieve author_ids for the selected authors
         $sel_author_names = explode(', ', preg_replace('/\\s\\s+/', ' ', $this->sp->authors));
         $author_ids = array();
         foreach ($sel_author_names as $author_name) {
             if (empty($author_name)) {
                 continue;
             }
             $author_id = array_search($author_name, $this->db_authors);
             if ($author_id !== false) {
                 $author_ids[] = $author_id;
             }
         }
         if (count($author_ids) > 0) {
             $authors = array_merge($authors, $author_ids);
         }
     }
     if (!empty($_SESSION['user'])) {
         if ($this->sp->author_myself != '' && $_SESSION['user']->author_id != '') {
             array_push($authors, $_SESSION['user']->author_id);
         }
     }
     if (count($authors) > 0) {
         foreach ($authors as $auth_id) {
             $author_pubs = array();
             $search_query = "SELECT DISTINCT pub_id from pub_author " . "WHERE author_id=" . $this->db->quote_smart($auth_id);
             $this->add_to_array($search_query, $author_pubs);
             $this->result_pubs = array_intersect($this->result_pubs, $author_pubs);
         }
     }
     // ranking
     if (isset($this->sp->paper_rank)) {
         $union_array = array();
         foreach ($this->sp->paper_rank as $rank_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $search_result = $this->db->query('SELECT venue_id from venue_rankings ' . 'WHERE rank_id=' . $this->db->quote_smart($rank_id));
             foreach ($search_result as $row) {
                 if (!empty($row->venue_id)) {
                     $this->add_to_array('SELECT DISTINCT pub_id from publication ' . 'WHERE venue_id=' . $this->db->quote_smart($row->venue_id), $union_array);
                 }
             }
         }
         foreach ($this->sp->paper_rank as $rank_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $this->add_to_array('SELECT DISTINCT pub_id from publication ' . 'WHERE rank_id=' . $this->db->quote_smart($rank_id), $union_array);
         }
     }
     if (!empty($this->sp->paper_rank_other)) {
         $this->add_to_array('SELECT DISTINCT pub_id from pub_rankings ' . 'WHERE description LIKE ' . $this->db->quote_smart("%" . $this->sp->paper_rank_other . "%"), $union_array);
     }
     if (isset($union_array) && is_array($union_array) && count($union_array) > 0) {
         $this->result_pubs = array_intersect($this->result_pubs, $union_array);
     }
     // collaboration
     if (isset($this->sp->paper_col)) {
         $union_array = array();
         foreach ($this->sp->paper_col as $col_id => $value) {
             if ($value != 'yes') {
                 continue;
             }
             $this->add_to_array('SELECT DISTINCT pub_id from pub_col ' . 'WHERE col_id=' . $this->db->quote_smart($col_id), $union_array);
         }
         if (count($union_array) > 0) {
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // user info
     if (!empty($this->sp->user_info)) {
         pdDb::debugOn();
         $union_array = array();
         $user_infos = preg_split('/\\s*[;,]\\s*/', $this->sp->user_info);
         foreach ($user_infos as $user_info) {
             $user_info = trim($user_info);
             $this->add_to_array('SELECT DISTINCT pub_id from publication ' . "WHERE user like '%{$user_info}%'", $union_array);
         }
         if (count($union_array) > 0) {
             $this->result_pubs = array_intersect($this->result_pubs, $union_array);
         }
     }
     // DATES SEARCH --------------------------------------
     // adjust date information if user did not enter all the fields
     if (isset($this->sp->startdate['Y']) && !isset($this->sp->startdate['M'])) {
         $this->sp->startdate['M'] = '1';
     }
     if (isset($this->sp->enddate['Y']) && !isset($this->sp->enddate['M'])) {
         $this->sp->enddate['M'] = '12';
     }
     if (isset($this->sp->startdate)) {
         $startdate =& $this->sp->startdate;
         $stime = strtotime(implode('-', $startdate) . '-1');
     }
     if (isset($this->sp->enddate)) {
         $enddate =& $this->sp->enddate;
         $etime = strtotime(implode('-', $enddate) . '-1');
     }
     if (isset($stime) && isset($etime)) {
         if ($stime > $etime) {
             // the user did not enter an end date, default it to now
             $enddate['Y'] = date('Y');
             $enddate['M'] = date('m');
             $etime = strtotime(implode('-', $enddate) . '-1');
         }
         if ($etime > $stime) {
             $startdate_str = date('Y-m-d', mktime(0, 0, 0, $startdate['M'], 1, $startdate['Y']));
             $enddate_str = date('Y-m-d', mktime(0, 0, 0, $enddate['M'] + 1, 0, $enddate['Y']));
             $temporary_array = NULL;
             $search_query = "SELECT DISTINCT pub_id from publication " . "WHERE published BETWEEN " . $this->db->quote_smart($startdate_str) . " AND " . $this->db->quote_smart($enddate_str);
             $this->add_to_array($search_query, $temporary_array);
             $this->result_pubs = array_intersect($this->result_pubs, $temporary_array);
         }
     }
     if ($this->debug) {
         debugVar('result', $this->result_pubs);
     }
     return $this->result_pubs;
 }
コード例 #13
0
                    $index = $count > 0 ? $count - 1 : 0;
                    $log_words[$index][] = $word;
                    $or_condition = false;
                } else {
                    $log_words[] = array($word);
                }
            }
        }
        // now remove common words
        foreach ($log_words as $and_term) {
            foreach ($and_term as $key => $or_term) {
                if (in_array($or_term, self::$common_words)) {
                    unset($and_term[$key]);
                }
            }
        }
        return $log_words;
    }
}
// the following code runs only in CLI mode.
//
// should be replaced by unit test (in it's own file).
if (PHP_SAPI == "cli") {
    require_once '../../php_common/functions.php';
    if (!isset($argv[1])) {
        die("parameter expected\n");
    }
    $parser = new SearchTermParser($argv[1]);
    $wordList = $parser->getWordList();
    debugVar('$wordList', $wordList);
}
コード例 #14
0
ファイル: query.php プロジェクト: araynaud/FoodPortrait
    foreach ($groups as $groupValue) {
        if ($groupValue === "NULL") {
            continue;
        }
        $params[$groupBy] = $groupValue;
        $data = demographicPortrait($db, $params, $portraitType);
        if (!count($data)) {
            continue;
        }
        setExists($data);
        $groupKey = $groupValue;
        $groupKey = "group_{$groupValue}";
        $groupKey = str_replace(":", "_", $groupKey);
        if (@$form_answers[$groupValue]) {
            $groupTitles[$groupKey] = $form_answers[$groupValue]["label"];
        } else {
            if ($interval > 1) {
                $groupTitles[$groupKey] = str_replace(":", " to ", $groupValue);
            }
        }
        debugVar("groupTitles", "print_r");
        $results[$groupKey] = $data;
    }
}
$queries = $db->getLog();
$db->disconnect();
$response = array();
$response["time"] = getTimer(true);
addVarsToArray($response, "params age years users groups groupTitles queries results");
echo jsValue($response, true);
getTimer();