src="<?php p(OCP\Util::imagePath('shorty', 'blank.png')); ?>"> <img id="mimicon" class="shorty-icon svg" width="16px" data="blank" src="<?php p(OCP\Util::imagePath('shorty', 'blank.png')); ?>"> </span> <span id="explanation" maxlength="80" class="shorty-value" data=""></span> </span> <br /> <label for="title"><?php p(OC_Shorty_L10n::t('Title').':'); ?></label> <input id="title" name="title" type="text" data="" class="" readonly="true" disabled /> <br /> <span class="label-line"> <label for="status"><?php p(OC_Shorty_L10n::t('Status').':'); ?></label> <input id="status" name="status" type="text" data="" class="" style="width:8em;" readonly="true" disabled /> <label for="until"><?php p(OC_Shorty_L10n::t('Expiration').':'); ?></label> <input id="until" name="until" type="text" data="" class="" style="width:12em;" readonly="true" disabled /> </span> <br /> <label for="notes"><?php p(OC_Shorty_L10n::t('Notes').':'); ?></label> <input id="notes" name="notes" data="" class="" readonly="true" disabled /> <br /> <span class="label-line"> <label for="clicks"><?php p(OC_Shorty_L10n::t('Clicks').':'); ?></label> <input id="clicks" name="clicks" data="" type="textarea" class="" style="width:3em;" readonly="true" disabled /> <label for="created"><?php p(OC_Shorty_L10n::t('Creation').':'); ?></label> <input id="created" name="created" type="text" data="" class="" style="width:7em;" readonly="true" disabled /> <label for="accessed"><?php p(OC_Shorty_L10n::t('Access').':'); ?></label> <input id="accessed" name="accessed" type="text" data="" class="" style="width:11em;" readonly="true" disabled /> </span> </fieldset> </form>
/** * @method OC_Shorty_HttpException::__construct * @brief: Constructs an exception based on a phrase and a set of parameters * @param integer status: Http status code * @access public * @author Christian Reiner */ public function __construct ( $status ) { if ( is_numeric($status) && array_key_exists($status,OC_Shorty_Type::$HTTPCODE) ) { $status = intval($status); $phrase = OC_Shorty_Type::$HTTPCODE[$status]; } else { $status = 400; $phrase = OC_Shorty_Type::$HTTPCODE[400]; // "Bad Request" } // else // return http status code to client (browser) if ( ! headers_sent() ) { header ( sprintf("HTTP/1.0 %s %s",$status,$phrase) ); } $tmpl = new OCP\Template("shorty", "tmpl_http_status", "guest"); $tmpl->assign("explanation", OC_Shorty_L10n::t($phrase)); $tmpl->printPage(); exit; } // function __construct
<fieldset id="backend-plugins" class="backend-supplement"> <legend><?php p(OC_Shorty_L10n::t("Plugins").":"); ?></legend> <?php foreach ( $_['shorty-plugins']['shorty'] as $plugin ) { ?> <div> <label for="shorty-plugin-<?php p(trim($plugin['id']));?>"> <?php p(trim($plugin['name']).":");?> </label> <span class="shorty-plugin-<?php p(trim($plugin['id']));?>" class="shorty-example"> <?php p(trim($plugin['abstract']));?> </span> </div> <?php } ?> <!-- list of suggested plugins --> <?php if ( ! OCP\App::isEnabled('shorty_tracking') ) { ?> <div> <span id="plugins" class="suggestion"> <?php print_unescaped( sprintf(OC_Shorty_L10n::t("The additional plugin '%%s' can track the usage of existing Shortys!"), '<strong>Shorty Tracking</strong>')); ?> <br/> <?php print_unescaped( sprintf(OC_Shorty_L10n::t('It has to be installed manually from the %%s.'), sprintf('<a href="%s" target="_blank">%s</a>', 'http://apps.owncloud.com/content/show.php/Shorty+Tracking?content=152473', OC_Shorty_L10n::t('OwnCloud App Store')))); ?> </span> </div> <?php } ?> </fieldset> </div>
// add url taked from the session vars to anything contained in the query string $_SERVER['QUERY_STRING'] = implode('&',array_merge(array('url'=>$_SESSION['shorty-referrer']),explode('&',$_SERVER['QUERY_STRING']))); } else { // simple desktop initialization, no special actions contained OCP\Util::addScript ( 'shorty', 'list' ); } $tmpl = new OCP\Template( 'shorty', 'tmpl_index', 'user' ); // any additional actions registered via hooks that should be offered ? $tmpl->assign ( 'shorty-actions', OC_Shorty_Hooks::requestActions() ); // the (remote) base url of the qrcode generator $tmpl->assign ( 'qrcode-ref', sprintf('%s?service=%s&id=', OCP\Util::linkToAbsolute('', 'public.php'), 'shorty_qrcode') ); // available status options (required for select filter in toolbox) $shorty_status['']=sprintf('- %s -',OC_Shorty_L10n::t('all')); foreach ( OC_Shorty_Type::$STATUS as $status ) $shorty_status[$status] = OC_Shorty_L10n::t($status); $tmpl->assign ( 'shorty-status', $shorty_status ); $tmpl->assign ( 'default-status', OCP\Config::getUserValue(OCP\User::getUser(),'shorty','default-status','private') ); // any referrer we want to hand over to the browser ? if ( array_key_exists('shorty-referrer',$_SESSION) ) $tmpl->assign ( 'shorty-referrer', $_SESSION['shorty-referrer'] ); // is sending sms enabled in the personal preferences ? $tmpl->assign ( 'sms-control', OCP\Config::getUserValue(OCP\User::getUser(),'shorty','sms-control','disabled') ); // clean up session var so that a browser reload does not trigger the same action again \OC::$session->remove('shorty-referrer'); $tmpl->printPage(); } catch ( OC_Shorty_Exception $e ) { OCP\JSON::error ( array ( 'message'=>$e->getTranslation(), 'level'=>'error', 'data'=>$result ) ); } } // switch ?>
<div class="usage-instruction"> <?php p(OC_Shorty_L10n::t("Click for embedding details")); ?>… </div> </div> </div> <div class='qrcode-ref' style="display:none;"> <div class="usage-explanation"> <?php p(OC_Shorty_L10n::t("This is the url referencing the QRCode shown before")); ?>. <br> <?php p(OC_Shorty_L10n::t("Embed the QRCode as an image into some web page using this url")); ?>. </div> <input class="payload" readonly="true"> <div class="usage-instruction"> <?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>:<span class="usage-token"><?php p(OC_Shorty_L10n::t("Ctrl-C")); ?></span> <br> <?php p(OC_Shorty_L10n::t("Paste to embed elsewhere")); ?>:<span class="usage-token"><?php p(OC_Shorty_L10n::t("Ctrl-V")); ?></span> </div> <hr> <div class="usage-explanation"> <?php p(OC_Shorty_L10n::t("Alternatively the image can be downloaded for printout or storage")); ?>. <?php p(OC_Shorty_L10n::t("That image can be used when writing documents or setting up web sites")); ?>: <br> <div style="text-align:center;"> <button id="download" style="margin:1.2em;" class="shorty-button">Download QRCode</button> </div> </div> </div> </fieldset> </div> <!-- end of qrcode dialog -->
src="<?php p(OCP\Util::imagePath('shorty','usage/qrcode.svg')); ?>" title="<?php p(OC_Shorty_L10n::t("Show as QRCode")); ?>" /> </td> <td> <img id="usage-email" name="usage-email" class="shorty-usage svg" alt="email" src="<?php p(OCP\Util::imagePath('shorty','usage/email.svg')); ?>" title="<?php p(OC_Shorty_L10n::t("Send by email")); ?>" /> </td> <?php if ('disabled'!=$_['sms-control']) { ?> <td> <img id="usage-sms" name="usage-sms" class="shorty-usage svg" alt="sms" src="<?php p(OCP\Util::imagePath('shorty','usage/sms.svg')); ?>" title="<?php p(OC_Shorty_L10n::t("Send by SMS")); ?>" /> </td> <?php } ?> <td> <img id="usage-clipboard" name="usage-clipboard" class="shorty-usage svg" alt="clipboard" src="<?php p(OCP\Util::imagePath('shorty','usage/clipboard.svg')); ?>" title="<?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>" /> </td> </tr> </table> </fieldset> </form> <!-- additional (hidden) popup dialogs for specific usage actions --> <?php require_once('tmpl_dlg_email.php'); ?> <?php require_once('tmpl_dlg_sms.php'); ?> <?php require_once('tmpl_dlg_clipboard.php'); ?> <?php require_once('tmpl_dlg_qrcode.php'); ?>
<!-- verbosity --> <label for="verbosity" class="shorty-aspect"><?php p(OC_Shorty_L10n::t("Feedback").":"); ?></label> <span id="verbosity" style="margin-right:1em;"> <select id="verbosity-control" name="verbosity-control" style="width:11em;"> <?php foreach (array('none','error','info','debug') as $verbosity) print_unescaped(sprintf('<option value="%1$s" %2$s>%3$s</option>'."\n", $verbosity, ($verbosity==$_['verbosity-control']?'selected':''), OC_Shorty_L10n::t($verbosity))); ?> </select> <em><?php p(OC_Shorty_L10n::t("The amount of feedback messages shown.")); ?></em> </span> <br /> <label for="timeout" class="shorty-aspect"></label> <span id="timeout" style="margin-right:1em;"> <select id="verbosity-timeout" name="verbosity-timeout" style="width:11em;"> <?php foreach (array('(never)'=>0, '2 seconds'=>2000, '5 seconds'=>5000, '12 seconds'=>120000, '1 minute'=>60000) as $key=>$timeout) print_unescaped(sprintf('<option value="%1$s" %2$s>%3$s</option>'."\n", $timeout, ($timeout==$_['verbosity-timeout']?'selected':''), OC_Shorty_L10n::t($key))); ?> </select> <em><?php p(OC_Shorty_L10n::t("The time span after which messages are hidden again automatically.")); ?></em> </span> </p> </div> </form> </fieldset>
<fieldset> <legend> <img class="shorty-status" src="<?php p(OCP\Util::imagePath('shorty','status/good.png')); ?>" alt="<?php OC_Shorty_L10n::t('Success') ?>" title="<?php OC_Shorty_L10n::t('Verification successful') ?>"> <span id="title" class="shorty-title"><strong><?php p(OC_Shorty_L10n::t("Verification successful")); ?>!</strong></span> </legend> <p><?php p(OC_Shorty_L10n::t("Great, your setup appears to be working fine!")); ?></p> <p><?php p(OC_Shorty_L10n::t("Requests to the configured base url are mapped to this ownClouds relay service.").' '); p(OC_Shorty_L10n::t("Usage of that static backend is fine and safe as long as this setup is not altered.")); ?></p> <p><?php p(OC_Shorty_L10n::t("This backend will now be offered as an additional backend alternative to all local users inside their personal preferences.")); ?></p> </fieldset> </div> <!-- failure --> <div id="failure"> <fieldset> <legend> <img class="shorty-status" src="<?php p(OCP\Util::imagePath('shorty','status/bad.png')); ?>" alt="<?php OC_Shorty_L10n::t('Success') ?>" title="<?php OC_Shorty_L10n::t('Verification successful') ?>"> <span id="title" class="shorty-title"><strong><?php p(OC_Shorty_L10n::t("Verification failed")); ?>!</strong></span> </legend> <p><?php p(OC_Shorty_L10n::t("Sorry, but your setup appears not to be working correctly yet!")); ?></p> <p><?php p(OC_Shorty_L10n::t("Please check your setup and make sure that the configured base url is indeed correct.").' '); p(OC_Shorty_L10n::t("Make sure that all requests to it are somehow mapped to Shortys relay service.")); ?></p> <p><?php p(OC_Shorty_L10n::t("Relay service")); ?>: <br> <a><?php p(OCP\Util::linkToAbsolute('','public.php?service=shorty_relay&id=')."<shorty-key>"); ?></a></p> </fieldset> </div> </div> </body> </html> <!-- end of verification dialog -->
* @file templates/tmpl_dlg_sms.php * Dialog popup to prepare sending a url via sms * @access public * @author Christian Reiner */ ?> <!-- begin of sms dialog --> <div id="dialog-sms" style="display:none;"> <fieldset class=""> <legend><?php p(OC_Shorty_L10n::t("Prepare to send as SMS")); ?>:</legend> <div class="usage-explanation"> <?php p(OC_Shorty_L10n::t("Clicking 'Ok' below will try to launch an sms composer")); ?>. <br> <?php p(OC_Shorty_L10n::t("Typically this only works on devices like smart phones")); ?>. <br> <?php p(OC_Shorty_L10n::t("Unfortunately the implementation of this scheme is limited")); ?>, <?php p(OC_Shorty_L10n::t("therefore the content must be copied manually")); ?>: </div> <textarea class="payload" readonly="true"></textarea> <div class="usage-instruction"> <?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>:<span class="usage-token"><?php p(OC_Shorty_L10n::t("Ctrl-C")); ?></span> <br> …<?php p(OC_Shorty_L10n::t("after the SMS has been launched")); ?>… <br> <?php p(OC_Shorty_L10n::t("then paste into message")); ?>:<span class="usage-token"><?php p(OC_Shorty_L10n::t("Ctrl-V")); ?></span> </div> </fieldset> </div> <!-- end of sms dialog -->
break; case OC_Shorty_Type::INTEGER: case OC_Shorty_Type::TIMESTAMP: settype ( $data[$key], 'integer' ); break; case OC_Shorty_Type::FLOAT: settype ( $data[$key], 'float' ); break; default: } // switch } } // foreach // 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("Setting '%s' saved",implode(',',array_keys($data))), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => $data, 'level' => 'debug', 'message' => OC_Shorty_L10n::t("Setting '%s' saved",implode(',',array_keys($data))) ) ); break; default: throw new OC_Shorty_Exception ( "unexpected request method '%s'", $_SERVER['REQUEST_METHOD'] ); } // switch } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
':notes' => $p_notes ? substr($p_notes, 0,4096) : '', ':until' => $p_until ? $p_until : null, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_INSERT ); $query->execute ( $param ); // read new entry for feedback $param = array ( ':user' => OCP\User::getUser(), ':id' => $p_id, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_VERIFY ); $entries = $query->execute($param)->FetchAll(); if ( (1==count($entries)) &&(isset($entries[0]['id'])) &&($p_id==$entries[0]['id']) ) $entries[0]['relay']=OC_Shorty_Tools::relayUrl ( $entries[0]['id'] ); else throw new OC_Shorty_Exception ( "failed to verify stored shorty with id '%1s'", array($p_id) ); // 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("Created Shorty '%s' for target url '%s'",$p_source,$p_target), OCP\Util::INFO ); OCP\JSON::success ( array ( 'data' => $entries[0], 'level' => 'info', 'message' => OC_Shorty_L10n::t("Url shortened to: %s",$p_source) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
<span id="controls-handle" class="shorty-handle shorty-handle-top"> <img class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('shorty','actions/shade.svg')); ?>" > </span> </span> <!-- controls: center area, some passive information --> <span class="shorty-controls-center"> <!-- display label: number of entries in list --> <span class="shorty-prompt"><?php p(OC_Shorty_L10n::t('Number of entries')); ?>:</span> <span id="sum_shortys" class="shorty-value"> <img src="<?php p(OCP\Util::imagePath('core', 'loading.gif')); ?>" alt="<?php p(OC_Shorty_L10n::t('Loading')); ?>…"/> </span> <!-- display label: total of clicks in list --> <span class="shorty-prompt"><?php p(OC_Shorty_L10n::t('Total of clicks')); ?>:</span> <span id="sum_clicks" class="shorty-value"> <img src="<?php p(OCP\Util::imagePath('core', 'loading.gif')); ?>" alt="<?php p(OC_Shorty_L10n::t('Loading')); ?>…" /> </span> </span> <!-- the dialogs, hidden by default --> <?php echo $this->inc('tmpl_url_add'); ?> <?php echo $this->inc('tmpl_url_edit'); ?> <?php echo $this->inc('tmpl_url_show'); ?> <?php echo $this->inc('tmpl_url_share'); ?> </div> <!-- the "desktop where the action takes place --> <div id="desktop" class="right-content shorty-desktop"> <?php echo $this->inc('tmpl_url_list'); ?> </div>
&&(isset($entries[0]['id'])) &&($p_id==$entries[0]['id']) ) $entries[0]['relay']=OC_Shorty_Tools::relayUrl ( $entries[0]['id'] ); else throw new OC_Shorty_Exception ( "failed to verify clicked shorty with id '%1s'", array($p_id) ); $details['shorty'] = $entries[0]; // now collect some info about the request $details['click'] = array ( 'address' => $_SERVER['REMOTE_ADDR'], 'host' => $_SERVER['REMOTE_HOST'], 'time' => $details['shorty']['accessed'], 'user' => OCP\User::getUser(), ); // and off we go (IF any hooks were registered OCP\Util::emitHook( "OC_Shorty", "post_clickShorty", $details ); // report result OCP\Util::writeLog( 'shorty', sprintf("Registered click of shorty with id '%s'.",$p_id), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => array('id'=>$p_id), 'level' => 'info', 'message' => OC_Shorty_L10n::t("Click registered") ) ); } else throw new OC_Shorty_Exception ( "request failed: missing mandatory argument 'id'" ); // swallow any accidential output generated by php notices and stuff to preserve a clean JSON reply structure OC_Shorty_Tools::ob_control ( FALSE ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
* @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); } ?>
</a> <?php } ?> <a id="shorty-action-show" title="<?php p(OC_Shorty_L10n::t('show')); ?>" class=""> <img alt="<?php p(OC_Shorty_L10n::t('show')); ?>" title="<?php p(OC_Shorty_L10n::t('Show details')); ?>" class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('shorty','actions/info.svg')); ?>" /> </a> <a id="shorty-action-edit" title="<?php p(OC_Shorty_L10n::t('edit')); ?>" class=""> <img alt="<?php p(OC_Shorty_L10n::t('modify')); ?>" title="<?php p(OC_Shorty_L10n::t('Modify shorty')); ?>" class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('core','actions/rename.svg')); ?>" /> </a> <a id="shorty-action-del" title="<?php p(OC_Shorty_L10n::t('delete')); ?>" class=""> <img alt="<?php p(OC_Shorty_L10n::t('delete')); ?>" title="<?php p(OC_Shorty_L10n::t('Delete shorty')); ?>" class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('core','actions/delete.svg')); ?>" /> </a> <a id="shorty-action-share" title="<?php p(OC_Shorty_L10n::t('share')); ?>" class=""> <img alt="<?php p(OC_Shorty_L10n::t('share')); ?>" title="<?php p(OC_Shorty_L10n::t('Share shorty')); ?>" class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('core','actions/share.svg')); ?>" /> </a> <a id="shorty-action-open" title="<?php p(OC_Shorty_L10n::t('open')); ?>" class=""> <img alt="<?php p(OC_Shorty_L10n::t('open')); ?>" title="<?php p(OC_Shorty_L10n::t('Open target')); ?>" class="shorty-icon svg" src="<?php p(OCP\Util::imagePath('shorty','actions/open.svg')); ?>" /> </a> </span> </td> </tr> </thead> <!-- the standard body for non-empty lists --> <tbody> </tbody> </table>
* */ ?> <?php /** * @file templates/tmpl_wdg_shortlet.php * Widget offering the 'Shortlet' as a drag'n'drop object * @access public * @author Christian Reiner */ ?> <!-- shortlet --> <label for="shortlet" class="shorty-aspect"><?php p(OC_Shorty_L10n::t("Shortlet").":"); ?></label> <span id="shortlet"> <a class="shortlet" href="javascript:(function(){url=encodeURIComponent(location.href);window.open('<?php p(OCP\Util::linkToAbsolute('shorty', 'index.php')); ?>?url='+url, 'owncloud-shorty')%20})()"> <?php p(OC_Shorty_L10n::t("Add page as 'Shorty' to ownCloud")); ?> </a> </span> <p> <span class="shorty-explain"> <em> <?php p(OC_Shorty_L10n::t("Drag this to your browser bookmarks.")); ?> <br> <?php p(OC_Shorty_L10n::t("Click it, for whatever site you want to create a Shorty.")); ?> </em> </span> </p>
* @return json: success/error state indicator * @return array: Associative array of meta data aspects * @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 { $target = OC_Shorty_Type::req_argument ( 'target', OC_Shorty_Type::URL, TRUE ); $meta = OC_Shorty_Meta::fetchMetaData(htmlspecialchars_decode($target)); // 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("Target meta data retrieved for url '%s'.",$target), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => $meta, 'level' => 'info', 'message' => OC_Shorty_L10n::t("Target url '%s' is valid", $meta['target']) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
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 { $p_id = OC_Shorty_Type::req_argument ( 'id', OC_Shorty_Type::ID, TRUE ); $param = array ( 'user' => OCP\User::getUser(), 'id' => $p_id, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_DELETE ); $query->execute($param); // 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("Deleted Shorty with id '%s'",$p_id), OCP\Util::INFO ); OCP\JSON::success ( array ( 'data' => array('id'=>$p_id), 'level' => 'info', 'message' => OC_Shorty_L10n::t("Shorty with id '%s' deleted",$p_id) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
//no apps or filesystem $RUNTIME_NOSETUPFS = true; // Sanity checks OCP\JSON::callCheck ( ); OCP\JSON::checkLoggedIn ( ); OCP\JSON::checkAppEnabled ( 'shorty' ); try { $p_id = OC_Shorty_Type::req_argument ( 'id', OC_Shorty_Type::ID, TRUE ); $p_status = OC_Shorty_Type::req_argument ( 'status', OC_Shorty_Type::STATUS, FALSE ); $param = array ( 'user' => OCP\User::getUser ( ), 'id' => $p_id, 'status' => $p_status, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_STATUS ); $query->execute ( $param ); // 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("Status change for shorty with id '%s' saved",$p_id), OCP\Util::INFO ); OCP\JSON::success ( array ( 'data' => array('id'=>$p_id), 'level' => 'info', 'message' => OC_Shorty_L10n::t("Status change for shorty with id '%s' saved",$p_id) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
':notes' => $p_notes ? substr($p_notes, 0,4096) : '', ':until' => $p_until ? $p_until : null, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_UPDATE ); $query->execute ( $param ); // read new entry for feedback $param = array ( 'user' => OCP\User::getUser(), 'id' => $p_id, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_VERIFY ); $entries = $query->execute($param)->FetchAll(); if ( (1==count($entries)) &&(isset($entries[0]['id'])) &&($p_id==$entries[0]['id']) ) $entries[0]['relay']=OC_Shorty_Tools::relayUrl ( $entries[0]['id'] ); else throw new OC_Shorty_Exception ( "failed to verify stored shorty with id '%1s'", array($p_id) ); // 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("Modifications for shorty with id '%s' saved.",$p_id), OCP\Util::INFO ); OCP\JSON::success ( array ( 'data' => $entries[0], 'level' => 'info', 'message' => OC_Shorty_L10n::t("Modifications for shorty with id '%s' saved",$p_id) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
case OC_Shorty_Type::URL: case OC_Shorty_Type::DATE: settype ( $data[$key], 'string' ); break; case OC_Shorty_Type::INTEGER: case OC_Shorty_Type::TIMESTAMP: settype ( $data[$key], 'integer' ); break; case OC_Shorty_Type::FLOAT: settype ( $data[$key], 'float' ); break; default: } // switch } } // foreach // 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("Preference '%s' retrieved",implode(',',array_keys($data))), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => $data, 'level' => 'debug', 'message' => OC_Shorty_L10n::t("Preference '%s' retrieved",implode(',',array_keys($data))) ) ); break; default: throw new OC_Shorty_Exception ( "unexpected request method '%s'", $_SERVER['REQUEST_METHOD'] ); } // switch } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
<input id="title" name="title" type="text" maxlength="80" data="" class="" placeholder=""/> <br /> <span class="label-line"> <label for="status"><?php p(OC_Shorty_L10n::t('Status').':'); ?></label> <select id="status" name="status" class="" data="<?php echo $_['default-status'];?>" value="<?php echo $_['default-status'];?>" > <?php foreach ( OC_Shorty_Type::$STATUS as $status ) if ( 'deleted'!=$status ) print_unescaped(sprintf("<option value=\"%s\" %s>%s</option>\n", $status, ($status==$_['default-status'])?'selected':'', OC_Shorty_L10n::t($status))); ?> </select> <span style="display:inline-block;"> <label for="until"><?php p(OC_Shorty_L10n::t('Expiration').':'); ?></label> <input id="until" name="until" type="text" maxlength="10" value="" data="" class="" style="width:8em;" placeholder="-<?php p(OC_Shorty_L10n::t('never')); ?>-" icon="<?php p(OCP\Util::imagePath('shorty', 'calendar.png')); ?>"/> </span> </span> <br /> <label for="notes"><?php p(OC_Shorty_L10n::t('Notes').':'); ?></label> <textarea id="notes" name="notes" maxlength="4096" data="" class="" placeholder="<?php p(OC_Shorty_L10n::t('Anything that appears helpful …')); ?>"></textarea> <br /> <label for="confirm"></label> <button id="confirm" class="shorty-button-submit"><?php p(OC_Shorty_L10n::t('Add as new')); ?></button> </fieldset> </form>
$param = array ( ':user' => OCP\User::getUser ( ), ':sort' => $p_sort, // ':offset' => $p_offset, // ':limit' => PAGE_SIZE, ); $query = OCP\DB::prepare ( OC_Shorty_Query::URL_LIST ); $result = $query->execute($param); $reply = $result->fetchAll(); foreach (array_keys($reply) as $key) { if (isset($reply[$key]['id'])) { // enhance all entries with the relay url $reply[$key]['relay']=OC_Shorty_Tools::relayUrl ( $reply[$key]['id'] ); // make sure there is _any_ favicon contained, otherwise layout in MS-IE browser is broken... if (empty($reply[$key]['favicon'])) $reply[$key]['favicon'] = OCP\Util::imagePath('shorty', 'blank.png'); } } // foreach // 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("Constructed list of defined shortys holding %s entries.",sizeof($reply)), OCP\Util::DEBUG ); OCP\JSON::success ( array ( 'data' => $reply, 'level' => 'debug', 'count' => sizeof($reply), 'message' => OC_Shorty_L10n::t("Number of entries: %s", count($reply)) ) ); } catch ( Exception $e ) { OC_Shorty_Exception::JSONerror($e); } ?>
static function enrichMetaDataCurl ( $url, &$meta ) { // to fetch meta data we rely on curl being installed if ( ! function_exists('curl_init') ) return; // try to retrieve the meta data $handle = curl_init ( ); curl_setopt ( $handle, CURLOPT_URL, OC_Shorty_Tools::idnToASCII($url) ); curl_setopt ( $handle, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $handle, CURLOPT_FOLLOWLOCATION, TRUE ); curl_setopt ( $handle, CURLOPT_MAXREDIRS, 10 ); if ( FALSE!==($page=curl_exec($handle)) ) { // try to extract title from page preg_match ( "/<head[^>]*>.*<title>(.*)<\/title>.*<\/head>/si", $page, $match ); // $meta['title'] = isset($match[1]) ? htmlspecialchars_decode ( trim($match[1]) ) : ''; $meta['title'] = isset($match[1]) ? html_entity_decode ( trim($match[1]), ENT_COMPAT, 'UTF-8' ) : ''; $meta['staticon'] = self::selectIcon ( 'state', TRUE ); // final url after a possible redirection $meta['final'] = curl_getinfo ( $handle, CURLINFO_EFFECTIVE_URL ); // try to extract favicon from page preg_match ( '/<[^>]*link[^>]*(rel=["\']icon["\']|rel=["\']shortcut icon["\']) .*href=["\']([^>]*)["\'].*>/iU', $page, $match ); if (1<sizeof($match)) { // the specified uri might be an url, an absolute or a relative path // we have to turn it into an url to be able to display it out of context $favicon = htmlspecialchars_decode ( $match[2] ); // test for an url if (parse_url($favicon,PHP_URL_SCHEME)) { $meta['favicon'] = $favicon; } // test for an absolute path elseif ( 0===strpos(parse_url($favicon,PHP_URL_PATH),'/') ) { $url_token = parse_url($meta['final']); $meta['favicon'] = sprintf( '%s://%s/%s', $url_token['scheme'], $url_token['host'], $favicon ); } // so it appears to be a relative path else { $url_token = parse_url($meta['final']); $meta['favicon'] = sprintf( '%s://%s%s%s', $url_token['scheme'], $url_token['host'], dirname($url_token['path']), $favicon ); } } $meta['mimetype'] = preg_replace ( '/^([^;]+);.*/i', '$1', curl_getinfo($handle,CURLINFO_CONTENT_TYPE) ); $meta['mimicon'] = self::selectIcon ( 'mimetype', $meta['mimetype'] ); $meta['code'] = curl_getinfo ( $handle, CURLINFO_HTTP_CODE ); $meta['status'] = OC_Shorty_L10n::t ( self::selectCode('status',$meta['code']) ); $meta['explanation'] = OC_Shorty_L10n::t ( self::selectCode('explanation',$meta['code']) ); } // if curl_close ( $handle ); // that's it ! } // function enrichMetaDataCurl
* You should have received a copy of the GNU Affero General Public * License along with this library. * If not, see <http://www.gnu.org/licenses/>. * */ ?> <?php /** * @file templates/tmpl_dlg_clipboard.php * Dialog popup to copy url for further usage * @access public * @author Christian Reiner */ ?> <!-- begin of clipboard dialog --> <div id="dialog-clipboard" style="display:none;"> <fieldset class=""> <legend><?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>:</legend> <div class="usage-explanation"> <?php p(OC_Shorty_L10n::t("The link below can be copied for further usage")); ?>: </div> <input class="payload" readonly="true"> <div class="usage-instruction"> <?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>:<span class="usage-token"><?php p(OC_Shorty_L10n::t("Ctrl-C")); ?></span> </div> </fieldset> </div> <!-- end of clipboard dialog -->
* @author Christian Reiner */ ?> <!-- begin of email dialog --> <div id="dialog-email" style="display:none;"> <fieldset class=""> <legend><?php p(OC_Shorty_L10n::t("Send link by email")); ?>:</legend> <div class="usage-explanation"> <span class="explanation"> <?php p(OC_Shorty_L10n::t("Clicking 'Ok' below will try to launch an email composer")); ?>. <br> <?php p(OC_Shorty_L10n::t("Alternatively the link can be copied into a message manually")); ?>: </span> </div> <textarea class="payload" readonly="true"></textarea> <div class="usage-instruction"> <?php p(OC_Shorty_L10n::t("Copy to clipboard")); ?>: <span class="usage-token"> <?php p(OC_Shorty_L10n::t("Ctrl-C")); ?> </span> <br> <?php p(OC_Shorty_L10n::t("then paste into message")); ?>: <span class="usage-token"> <?php p(OC_Shorty_L10n::t("Ctrl-V")); ?> </span> </div> </fieldset> </div> <!-- end of email dialog -->