Gorilla.php
changeset 2 b6178b40aa09
parent 1 f2ceea4fabe8
child 3 6fe9c484bb26
equal deleted inserted replaced
1:f2ceea4fabe8 2:b6178b40aa09
   763   $now = time();
   763   $now = time();
   764   $q = $db->sql_query('DELETE FROM ' . table_prefix . "pastes WHERE paste_timestamp + paste_ttl < $now AND paste_ttl > 0;");
   764   $q = $db->sql_query('DELETE FROM ' . table_prefix . "pastes WHERE paste_timestamp + paste_ttl < $now AND paste_ttl > 0;");
   765 }
   765 }
   766 
   766 
   767 register_cron_task('gorilla_prune_expired', 1);
   767 register_cron_task('gorilla_prune_expired', 1);
       
   768 
       
   769 // Search handler
       
   770 $plugins->attachHook('session_started', 'gorilla_attach_search();');
       
   771 function gorilla_attach_search()
       
   772 {
       
   773   global $lang;
       
   774   register_search_handler(array(
       
   775     'table' => 'pastes',
       
   776     'titlecolumn' => 'paste_title',
       
   777     'datacolumn' => 'paste_text',
       
   778     'uniqueid' => 'ns=Paste;cid={paste_id}',
       
   779     'additionalcolumns' => array('paste_id', 'paste_language'),
       
   780     'resultnote' => $lang->get('gorilla_lbl_search_tag'),
       
   781     'linkformat' => array(
       
   782         'page_id' => '{paste_id}',
       
   783         'namespace' => 'Paste'
       
   784       ),
       
   785     'additionalwhere' => 'AND (paste_flags & ' . PASTE_PRIVATE . ') = 0',
       
   786   ));
       
   787 }
   768 
   788 
   769 /**!install dbms="mysql"; **
   789 /**!install dbms="mysql"; **
   770 CREATE TABLE {{TABLE_PREFIX}}pastes(
   790 CREATE TABLE {{TABLE_PREFIX}}pastes(
   771   paste_id int(18) NOT NULL auto_increment,
   791   paste_id int(18) NOT NULL auto_increment,
   772   paste_title text DEFAULT NULL,
   792   paste_title text DEFAULT NULL,
   848         template_ns_string: 'paste',
   868         template_ns_string: 'paste',
   849         
   869         
   850         msg_paste_deleted: 'Paste deleted.',
   870         msg_paste_deleted: 'Paste deleted.',
   851         msg_delete_confirm: 'Really delete this paste?',
   871         msg_delete_confirm: 'Really delete this paste?',
   852         btn_delete_confirm: 'Delete',
   872         btn_delete_confirm: 'Delete',
       
   873         
       
   874         lbl_search_tag: '[Paste]',
   853       }
   875       }
   854     }
   876     }
   855   }
   877   }
   856 }
   878 }
   857 </code>
   879 </code>