コード例 #1
1
ファイル: locum-client.php プロジェクト: aadl/locum
 public function count_download($bnum, $type, $tracknum = NULL)
 {
     $couch = new couchClient($this->couchserver, $this->couchdatabase);
     try {
         $doc = $couch->getDoc($bnum);
     } catch (Exception $e) {
         return FALSE;
     }
     if ($tracknum) {
         if ($type == "play") {
             $count = $doc->tracks->{$tracknum}->plays ? $doc->tracks->{$tracknum}->plays : 0;
             $count++;
             $doc->tracks->{$tracknum}->plays = $count;
         } else {
             if ($type == "track") {
                 $count = $doc->tracks->{$tracknum}->downloads ? $doc->tracks->{$tracknum}->downloads : 0;
                 $count++;
                 $doc->tracks->{$tracknum}->downloads = $count;
             }
         }
     } else {
         $key = "download_" . $type;
         $count = $doc->{$key} ? $doc->{$key} : 0;
         $count++;
         $doc->{$key} = $count;
     }
     $couch->storeDoc($doc);
 }
コード例 #2
0
ファイル: cabinet.php プロジェクト: klawd-prime/stack
 /**
  * Read a file
  *
  * @param string $path
  *
  * @return File
  */
 public function fetchFile($path)
 {
     $document = $this->client->getDoc('stack:/' . $path);
     // create module via factory
     $module = $this->moduleFactory->createModule($document->module, $document->data);
     return new File($document, $module);
 }
コード例 #3
0
ファイル: talk2db.php プロジェクト: T-TEL/TelBel
function recordActionViewed($resourceID, $dbgroup)
{
    global $couchUrl;
    $resources = new couchClient($couchUrl, $dbgroup);
    $doc = $resources->getDoc($_GET['resid']);
    $doc->views = intval($doc->views) + 1;
    $resources->storeDoc($doc);
}
コード例 #4
0
    $doc = new stdClass();
    $docType = end(explode(".", $_FILES['uploadedfile']['name']));
    $doc->legacy = array("id" => "", "type" => strtolower($docType));
    $doc->type = $_POST['resType'];
    $doc->kind = 'Resource';
    $doc->language = $_POST['Language'];
    $doc->description = $_POST['discription'];
    $doc->title = $_POST['title'];
    $doc->author = $_POST['author'];
    $doc->created = date('Y-m-d');
    $responce = $ttel_resources->storeDoc($doc);
    print_r($responce);
    try {
        // add attached to document with specified id from response
        $fileName = $responce->id . '.' . end(explode(".", $_FILES['uploadedfile']['name']));
        $ttel_resources->storeAttachment($ttel_resources->getDoc($responce->id), $_FILES['uploadedfile']['tmp_name'], custom_mime_content_type($_FILES['uploadedfile']['tmp_name']), $fileName);
        ///$resources->storeAttachment($resources->getDoc($responce->id),$_FILES['uploadedfile']['tmp_name'], mime_content_type($_FILES['uploadedfile']['tmp_name']));
    } catch (Exception $e) {
        print "No Resource to uploaded<br>";
    }
    $resDoc = $ttel_resources->getDoc($responce->id);
    $resDoc->legacy->id = $responce->id;
    $ttel_resources->storeDoc($resDoc);
    ///   recordAction($_SESSION['name'],"Uploaded resources... res title : ".$_POST['RTitle']);
    echo '<script type="text/javascript">alert("Successfully Uploaded ' . $_POST['title'] . '");</script>';
    die("<br><br><br><br>Successfully saved - " . $_POST['title'] . "");
}
?>

<script src="../includes/ice/ice.js" type="text/javascript"></script>
<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
コード例 #5
0
ファイル: index.php プロジェクト: jpweber/system_status_api
function set_monitor_status($server, $status)
{
    $client = new couchClient('http://<hostname>:5984', 'watchcat_hosts');
    $opts = array("key" => $server);
    $pre_doc = $client->setQueryParameters($opts)->getView('wc_hosts', 'by_hostname');
    $doc = $client->getDoc($pre_doc->rows[0]->id);
    $doc->monitor_active = $status;
    try {
        $response = $client->storeDoc($doc);
    } catch (Exception $e) {
        echo "something weird happened: " . $e->getMessage() . "<BR>\n";
    }
    var_dump($response);
}
コード例 #6
0
try {
    $result = $client->storeDoc($doc);
} catch (Exception $e) {
    echo "The document update failed: " . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n";
}
/**
* To retrieve a document, just use getDoc($doc_id)
*
*
*
*
*/
echo "#### Getting document: some_doc\n";
echo "getting doc : \$doc = \$client->getDoc('some_doc')\n";
try {
    $doc = $client->getDoc('some_doc');
} catch (Exception $e) {
    if ($e->code() == 404) {
        echo "Document \"some_doc\" not found\n";
    } else {
        echo "Something weird happened: " . $e->getMessage() . " (errcode=" . $e->getCode() . ")\n";
    }
    exit(1);
}
echo "Document retrieved: " . print_r($doc, true) . "\n";
/**
* Finally, deleting a document is achieved using deleteDoc
*
*
*
*/
コード例 #7
0
ファイル: locum-covers.php プロジェクト: aadl/locum
 /**
  * Clear an erroneous cover image from the cache
  */
 public function clear_covercache($bnum)
 {
     //$db = MDB2::connect($this->dsn);
     //$db->query("UPDATE locum_bib_items SET cover_img = '' WHERE bnum = " . $bnum);
     $couch = new couchClient($this->couchserver, $this->couchdatabase);
     try {
         $doc = $couch->getDoc((string) $bnum);
     } catch (Exception $e) {
         return FALSE;
     }
     unset($doc->cover_img);
     $couch->storeDoc($doc);
 }
コード例 #8
0
ファイル: couchAdmin.php プロジェクト: ntulip/PHP-on-Couch
 /**
  * returns the document of a user
  *
  * @param string $login login of the user to fetch
  * @return stdClass CouchDB document
  */
 public function getUser($login)
 {
     if (strlen($login) < 1) {
         throw new InvalidArgumentException("Login can't be empty");
     }
     $client = new couchClient($this->client->dsn(), $this->userdb, $this->client->options());
     return $client->getDoc("org.couchdb.user:" . $login);
 }
コード例 #9
0
ファイル: convert_const.php プロジェクト: nrjacker4/crm-php
    try {
        $couchdb->deleteDocs($obj);
    } catch (Exception $e) {
        echo "Something weird happened: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
        exit(1);
    }

    print "Effacement en cours";
    exit;
}

$obj = new stdClass();
$obj->_id="const";

try{
	$obj = $couchdb->getDoc("const");
}catch(Exception $e) {}


$obj->class="system";
$obj->values=$conf->global;

//print_r($obj);
//exit;

try {
    print_r($couchdb->storeDoc($obj));
    } catch (Exception $e) {
        $error = "Something weird happened: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
		dol_print_error("", $error);
        exit(1);
コード例 #10
0
ファイル: couchdb.php プロジェクト: aadl/locum
#!/usr/bin/php
<?php 
/**
 * @file
 *   Initialize the sphinx view.
 */
chdir('..');
require_once 'locum.php';
$locum = new locum();
$client = new couchClient($locum->couchserver, $locum->couchdatabase);
// Create the view.
try {
    $doc = $client->getDoc('_design/sphinx');
} catch (Exception $e) {
    if ($e->getCode() == 404) {
        // document doesn't exist. create a new one
        $doc = new stdClass();
        $doc->_id = '_design/sphinx';
    } else {
        var_dump($e);
        exit;
    }
}
$doc->views = new stdClass();
$doc->views->by_sphinxid = new stdClass();
$doc->views->by_sphinxid->map = "function(doc) { if (doc.bnum) { emit(doc.bnum, null); } }";
// Save view.
$client->storeDoc($doc);
コード例 #11
0
ファイル: etape2.php プロジェクト: nrjacker4/crm-php
			$dir = "couchdb/json/";

			// Create views and documents
			$handle = @opendir($dir);   // Dir may not exists
			if (is_resource($handle)) {
				while (($file = readdir($handle)) !== false) {
					if (preg_match('/\.json$/i', $file)) {
						$fp = fopen($dir . $file, "r");
						if ($fp) {
							$json = fread($fp, filesize($dir . $file));
							$obj = json_decode($json);
							
							// Test if exist document in database : upgrade
							try {
								$result = $couchdb->getDoc($obj->_id);
								$obj->_rev = $result->_rev;
							} catch (Exception $e) {
								
							}

							$couchdb->storeDoc($obj);

							fclose($fp);
						}	
					}
				}
				closedir($handle);
			}
			
			// Enable module User
コード例 #12
0
$couchUrl = 'http://127.0.0.1:5984';
///error_reporting(E_ERROR);
include "lib/couch.php";
include "lib/couchClient.php";
include "lib/couchDocument.php";
if (isset($argv[2])) {
    //Display all available args
    //print_r($argv);
    $faci_ID = $argv[3];
    $status = $argv[2];
    $statusType = $argv[1];
    $carrentStatus = new stdClass();
    $carrentStatus->systemtime = date('Y-m-d H:i:s');
    $carrentStatus->status = $status;
    $system = new couchClient($couchUrl, "system");
    $doc = $system->getDoc($faci_ID);
    // get data from form and save it to couch
    $doc->kind = "Server_Status_Log";
    $doc->lastUpdate = date('y-m-d');
    if (!isset($doc->{$statusType})) {
        $doc->{$statusType} = array();
        array_push($doc->{$statusType}, $carrentStatus);
    } else {
        if ($doc->{$statusType} != null) {
            array_push($doc->{$statusType}, $carrentStatus);
        } else {
            $doc->{$statusType} = array();
            array_push($doc->{$statusType}, $carrentStatus);
        }
    }
    // save doc to couch and for responce->id
コード例 #13
0
ファイル: locum-server.php プロジェクト: aadl/locum
 /**
  * Does the actual import of bib records.  Called by the harvester.
  * It uses start and end parameters because this function can potentially be called by a
  * child process.
  *
  * @param int $start Bib number to start with
  * @param int $end Bib number to end with
  * @return array Array of information about the bibs imported
  */
 public function import_bibs($start, $end, $force = TRUE)
 {
     if (is_callable(array(__CLASS__ . '_hook', __FUNCTION__))) {
         eval('$hook = new ' . __CLASS__ . '_hook;');
         return $hook->{__FUNCTION__}($start, $end);
     }
     $db =& MDB2::connect($this->dsn);
     $couch = new couchClient($this->couchserver, $this->couchdatabase);
     $process_report['skipped'] = 0;
     $process_report['imported'] = 0;
     $utf = "SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'";
     $utfprep = $db->query($utf);
     for ($i = $start; $i <= $end; $i++) {
         $sql = "SELECT * FROM locum_bib_items WHERE bnum = {$i}";
         $init_result = $db->query($sql);
         $init_bib_arr = $init_result->fetchAll(MDB2_FETCHMODE_ASSOC);
         try {
             $doc = $couch->getDoc((string) $i);
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 // document doesn't exist. create a new one
                 $doc = new stdClass();
                 $doc->_id = (string) $i;
             } else {
                 // something probably wrong with the server. dump out
                 $this->putlog("Problem with CouchDB server for record {$i}. " . $e->getCode());
                 exit(1);
             }
         }
         if ($doc->protected != 1) {
             $bib = $this->locum_cntl->scrape_bib($i, $this->locum_config['api_config']['skip_covers']);
             if ($bib == FALSE || $bib == 'skip' || $bib['suppress'] == 1) {
                 if ($init_bib_arr) {
                     $sql_prep =& $db->prepare('UPDATE locum_bib_items SET active = ? WHERE bnum = ?', array('text', 'integer'));
                     $sql_prep->execute(array('0', $i));
                 }
                 if ($doc->active) {
                     $doc->active = 0;
                     $couch->storeDoc($doc);
                     require_once $this->locum_config['sphinx_config']['api_path'] . '/sphinxapi.php';
                     $cl = new SphinxClient();
                     $cl->SetServer($this->locum_config['sphinx_config']['server_addr'], (int) $this->locum_config['sphinx_config']['server_port']);
                     $cl->UpdateAttributes("bib_items_keyword,bib_items_author,bib_items_title,bib_items_subject,bib_items_callnum,bib_items_tags,bib_items_reviews", array("active"), array($i => array(0)));
                     $this->putlog("suppressed {$i}");
                 }
                 $process_report['skipped']++;
             } else {
                 if ($force || $doc->bib_lastupdate != $bib['bib_lastupdate']) {
                     $subj = $bib['subjects'];
                     $valid_vals = array('bib_created', 'bib_lastupdate', 'bib_prevupdate', 'bib_revs', 'lang', 'loc_code', 'mat_code', 'author', 'addl_author', 'title', 'title_medium', 'addl_title', 'edition', 'series', 'callnum', 'pub_info', 'pub_year', 'stdnum', 'upc', 'lccn', 'descr', 'notes', 'bnum', 'cover_img', 'non_romanized_title', 'non_romanized_author', 'genres', 'non_romanized_notes');
                     foreach ($bib as $bkey => $bval) {
                         if (in_array($bkey, $valid_vals)) {
                             if ($bval) {
                                 $doc->{$bkey} = $bval;
                             }
                             if (is_array($bval)) {
                                 if (count($bval) == 1) {
                                     $bval = $bval[0];
                                 } else {
                                     $bval = serialize($bval);
                                 }
                             }
                             $bib_values[$bkey] = $bval;
                         }
                     }
                     // unset items that are in couch but not mysql for now
                     unset($bib_values['non_romanized_title']);
                     unset($bib_values['non_romanized_author']);
                     unset($bib_values['non_romanized_notes']);
                     unset($bib_values['genres']);
                     if ($init_bib_arr) {
                         $bib_values['cover_img'] = $init_bib_arr[0]['cover_img'];
                     }
                     $bib_values['subjects_ser'] = serialize($subj);
                     $types = array('date', 'date', 'date', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'text');
                     $sql_prep = $db->prepare('REPLACE INTO locum_bib_items VALUES (:bnum, :author, :addl_author, :title, :addl_title, :title_medium, :edition, :series, :callnum, :pub_info, :pub_year, :stdnum, :upc, :lccn, :descr, :notes, :subjects_ser, :lang, :loc_code, :mat_code, :cover_img, NOW(), :bib_created, :bib_lastupdate, :bib_prevupdate, :bib_revs, \'1\')');
                     $affrows = $sql_prep->execute($bib_values);
                     $doc->subjects = $subj;
                     $doc->active = 1;
                     if ($doc->upc == '000000000000') {
                         unset($doc->upc);
                     }
                     if (!$bib['pub_year']) {
                         unset($doc->pub_year);
                     }
                     $couch->storeDoc($doc);
                     $this->putlog("Importing bib # {$i} - {$bib['title']}");
                     $sql_prep->free();
                     /*
                               if (is_array($subj) && count($subj)) {
                                 foreach ($subj as $subj_heading) {
                                   $insert_data = array($bib['bnum'], $subj_heading);
                                   $types = array('integer', 'text');
                                   $sql_prep = $db->prepare('INSERT INTO locum_bib_items_subject VALUES (?, ?)', $types, MDB2_PREPARE_MANIP);
                                   $affrows = $sql_prep->execute($insert_data);
                                   $sql_prep->free();
                                 }
                               }
                     */
                     $process_report['imported']++;
                 } else {
                     $process_report['skipped']++;
                     $this->putlog("Skipping unchanged bib # {$i} - {$bib['title']}");
                 }
             }
         }
     }
     $db->disconnect();
     return $process_report;
 }
コード例 #14
0
ファイル: viewResource.php プロジェクト: T-TEL/TelBel
<?php

session_start();
include "../secure/talk2db.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<?php 
if (isset($_GET['resid'])) {
    global $couchUrl;
    global $facilityId;
    $resources = new couchClient($couchUrl, $_GET['database']);
    $doc = $resources->getDoc($_GET['resid']);
    $docAttachment = $doc->_attachments;
    $arrayFiles = array();
    foreach ($docAttachment as $key => $value) {
        array_push($arrayFiles, $key);
    }
    //echo $arrayImage[0];
    if ($ext = pathinfo(urlencode($arrayFiles[0]), PATHINFO_EXTENSION) == "mp4") {
        if (isset($_GET['download'])) {
            $mystring = "http://" . $_SERVER['SERVER_NAME'] . ":5984/" . $_GET['database'] . "/" . $_GET['resid'] . "/" . urlencode($arrayFiles[0]) . "";
            die('<META HTTP-EQUIV=Refresh CONTENT="0; URL=' . $mystring . '">');
        } else {
            /////$mystring = "http://".$_SERVER['SERVER_NAME'].":5984/".$_GET['database']."/".$_GET['resid']."/".urlencode($arrayFiles[0])."";
            header("Location:player/index.php?resid=" . $_GET['resid']);
            die;
        }
コード例 #15
0
<?php

include '../secure/talk2db.php';
global $couchUrl;
$systems = new couchClient($couchUrl, "systems");
foreach ($inst_id as $schoolID) {
    try {
        $doc = $systems->getDoc($schoolID);
        $data = end($doc->internet_source);
        //echo $data->systemtime;
        //echo $data->status;
        $getSQLdata = mysql_query("SELECT MAX(REC_DATE) as recordDate FROM `log_internet_source` where INST_ID = '" . $schoolID . "' ") or die(mysql_error());
        $rowData = mysql_fetch_row($getSQLdata);
        if (strtotime($data->systemtime) > strtotime($rowData['0'])) {
            mysql_query("INSERT INTO `log_internet_source` (`COL_NUM`, `INST_ID`, `STATUS`, `REC_DATE`) VALUES (NULL, '" . $schoolID . "', '" . $data->status . "', '" . $data->systemtime . "' )") or die(mysql_error());
        } else {
        }
    } catch (Exception $errs) {
    }
    //////  internet_status ///
    try {
        $doc = $systems->getDoc($schoolID);
        $data = end($doc->internet_status);
        //echo $data->systemtime;
        //echo $data->status;
        $getSQLdata = mysql_query("SELECT MAX(REC_DATE) as recordDate FROM `log_internet` where INST_ID = '" . $schoolID . "' ") or die(mysql_error());
        $rowData = mysql_fetch_row($getSQLdata);
        if (strtotime($data->systemtime) > strtotime($rowData['0'])) {
            mysql_query("INSERT INTO `log_internet` (`COL_NUM`, `INST_ID`, `STATUS`, `REC_DATE`) VALUES (NULL, '" . $schoolID . "', '" . $data->status . "', '" . $data->systemtime . "' )") or die(mysql_error());
        } else {
        }
コード例 #16
0
$from_cache_date = $mem->get($key_date);
// result cache;
$results = [];
$dates = '-';
try {
    $table = null;
    $head_title = null;
    $options = array('include_docs' => true, 'limit' => 99999, 'descending' => true);
    $response = $client->setQueryParameters($options);
    $get_posts = $response->getView('get_blog_posts', 'by_date');
    $query_string = isset($_GET['action']) ? $_GET['action'] : null;
    switch ($query_string) {
        case 'edit':
            // update doc
            if (isset($_POST['update'])) {
                $get_doc = $client->getDoc($_GET['docid']);
                $get_doc->title = $_POST['title'];
                $get_doc->body = $_POST['body'];
                $get_doc->category = $_POST['category'];
                $d_res = (object) $get_doc;
                $client->storeDoc($d_res);
                header('Location:index.php');
            }
            $doc = $client->getDoc($_GET['docid']);
            $head_title .= 'Edit';
            $is_selected_hot = $doc->category === 'hot' ? 'selected="selected"' : '';
            $is_selected_news = $doc->category === 'news' ? 'selected="selected"' : '';
            $is_selected_tech = $doc->category === 'tech' ? 'selected="selected"' : '';
            $table .= <<<table
\t\t\t<form method="post">
\t\t\t<table border=1>