2 define( 'YOURLS_ADMIN', true );
\r
3 require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );
\r
4 yourls_maybe_require_auth();
\r
6 // Handle activation/deactivation of plugins
\r
7 if( isset( $_GET['action'] ) ) {
\r
10 if( !isset( $_GET['nonce'] ) or !yourls_verify_nonce( $_GET['nonce'], 'manage_plugins' ) )
\r
11 yourls_die( 'Unauthorized action or expired link', 'Error', 403 );
\r
13 // Check plugin file is valid
\r
14 if( isset( $_GET['plugin'] ) && yourls_validate_plugin_file( YOURLS_PLUGINDIR.'/'.$_GET['plugin'].'/plugin.php') ) {
\r
17 // Activate / Deactive
\r
18 switch( $_GET['action'] ) {
\r
20 $result = yourls_activate_plugin( $_GET['plugin'].'/plugin.php' );
\r
21 if( $result === true )
\r
22 yourls_redirect( yourls_admin_url( 'plugins.php?success=activated' ) );
\r
27 $result = yourls_deactivate_plugin( $_GET['plugin'].'/plugin.php' );
\r
28 if( $result === true )
\r
29 yourls_redirect( yourls_admin_url( 'plugins.php?success=deactivated' ) );
\r
34 $result = 'Unsupported action';
\r
38 $result = 'No plugin specified, or not a valid plugin';
\r
41 yourls_add_notice( $result );
\r
44 // Handle message upon succesfull (de)activation
\r
45 if( isset( $_GET['success'] ) ) {
\r
46 if( $_GET['success'] == 'activated' OR $_GET['success'] == 'deactivated' ) {
\r
47 yourls_add_notice( 'Plugin '.$_GET['success'] );
\r
51 yourls_html_head( 'plugins' );
\r
59 $plugins = (array)yourls_get_plugins();
\r
60 $count = count( $plugins );
\r
61 $count_active = yourls_has_active_plugins();
\r
64 <p>You currently have <strong><?php echo $count.' '.yourls_plural( 'plugin', $count ); ?></strong> installed, and <strong><?php echo $count_active; ?></strong> activated.</p>
\r
66 <table id="tblUrl" class="tblSorter" cellpadding="0" cellspacing="1">
\r
69 <th>Plugin Name</th>
\r
72 <th>Description</th>
\r
79 $nonce = yourls_create_nonce( 'manage_plugins' );
\r
81 foreach( $plugins as $file=>$plugin ) {
\r
83 // default fields to read from the plugin header
\r
85 'name' => 'Plugin Name',
\r
86 'uri' => 'Plugin URI',
\r
87 'desc' => 'Description',
\r
88 'version' => 'Version',
\r
89 'author' => 'Author',
\r
90 'author_uri' => 'Author URI'
\r
93 // Loop through all default fields, get value if any and reset it
\r
94 foreach( $fields as $field=>$value ) {
\r
95 if( $plugin[ $value ] ) {
\r
96 $data[ $field ] = $plugin[ $value ];
\r
98 $data[ $field ] = '(no info)';
\r
100 unset( $plugin[$value] );
\r
103 $plugindir = trim( dirname( $file ), '/' );
\r
104 $action = yourls_is_active_plugin( $file ) ?
\r
105 "<a href='?action=deactivate&plugin=$plugindir&nonce=$nonce'>Deactivate</a>" :
\r
106 "<a href='?action=activate&plugin=$plugindir&nonce=$nonce'>Activate</a>" ;
\r
108 // Other "Fields: Value" in the header? Get them too
\r
110 foreach( $plugin as $extra_field=>$extra_value ) {
\r
111 $data['desc'] .= "<br/>\n<em>$extra_field</em>: $extra_value";
\r
112 unset( $plugin[$extra_value] );
\r
116 $data['desc'] .= "<br/><small>plugin location: $file</small>";
\r
118 printf( "<tr><td><a href='%s'>%s</a></td><td>%s</td><td>%s</td><td><a href='%s'>%s</a></td><td>%s</td></tr>",
\r
119 $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author'], $action
\r
127 <script type="text/javascript">
\r
128 yourls_defaultsort = 0;
\r
129 yourls_defaultorder = 0;
\r
132 <p>If something goes wrong after you activate a plugin and you cannot use YOURLS or access this page, simply rename or delete its directory, or rename the plugin file to something different than <code>plugin.php</code>.</p>
\r
135 <?php yourls_html_footer(); ?>