コード例 #1
0
ファイル: count.php プロジェクト: ArcherSys/ArcherSysOSCloud7
 * @file ajax/count.php
 * @brief Ajax method to retrieve a list of important sums, counts of the existing set of shortys
 * @return json: success/error state indicator
 * @return json: Associative array of counts
 * @author Christian Reiner
 */

// swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure
OC_Shorty_Tools::ob_control ( TRUE );

//no apps or filesystem
$RUNTIME_NOSETUPFS = TRUE;

// Sanity checks
OCP\JSON::callCheck ( );
OCP\JSON::checkLoggedIn ( );
OCP\JSON::checkAppEnabled ( 'shorty' );

try
{
	$countResult = OC_Shorty_Tools::countShortys ( );
	// swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure
	OC_Shorty_Tools::ob_control ( FALSE );
	OCP\Util::writeLog( 'shorty', sprintf("Counting shortys resulted in %s entries and %s clicks.",$countResult['sum_shortys'],$countResult['sum_clicks']), OCP\Util::DEBUG );
	OCP\JSON::success ( array (
		'data'    => $countResult,
		'level'   => 'info',
		'message' => OC_Shorty_L10n::t("Counted entries and clicks") ) );
} catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); }
?>
コード例 #2
0
	/**
	* @method import
	* @brief Imports all data from a given resource into this apps storage areas
	* @author Christian Reiner
	*/
	function import ( )
	{
		OCP\Util::writeLog ( 'shorty','Starting data migration import for Shorty', OCP\Util::INFO );
		switch( $this->appinfo->version )
		{
			default:
				$query  = $this->content->prepare( "SELECT * FROM shorty WHERE user LIKE ?" );
				$result = $query->execute( array( $this->olduid ) );
				if (is_array(is_array($result)))
				{
					while( $row = $result->fetchRow() )
					{
						$param = array (
							'id'       => $row['id'],
							'status'   => $row['status'],
							'title'    => $row['title'],
							'favicon'  => $row['favicon'],
							'source'   => $row['source'],
							'target'   => $row['target'],
							'user'     => $row['user'],
							'until'    => $row['until'],
							'created'  => $row['created'],
							'accessed' => $row['accessed'],
							'clicks'   => $row['clicks'],
							'notes'    => $row['notes'],
						);
						// import each shorty one by one, no special treatment required, since no autoincrement id is used
						$query = OCP\DB::prepare( sprintf ( "INSERT INTO *PREFIX*shorty(%s) VALUES (%s)",
															implode(',',array_keys($param)),
															implode(',',array_fill(0,count($param),'?')) ) );
						$query->execute( $param );
					} // while
				} // if
				break;
		} // switch
		// check for success by counting the generated entries
		$count = OC_Shorty_Tools::countShortys();
		if(   (is_array($result) && is_array($count))
		&& (count($result)==$count['sum_shortys']) )
			return true;
		else return false;
	} // function import