示例#1
0
 public static function load($in_type_name)
 {
     /* determine and sanitise the type and name */
     $parts = explode('/', str_replace('.', '', substr($in_type_name, 0, 1024)));
     if (count($parts) != 2) {
         CinsImpError::malformed('Plugin type-name must be of form: <type>/<name>');
     }
     $type = $parts[0] . 's';
     $name = $parts[1];
     unset($parts);
     /* load the main plugin definition file */
     global $config;
     $plugin_base = $config->base . 'plugins/' . $type . '/' . $name . '/';
     $plugin_file_path = $plugin_base . $name . '.js';
     if (!file_exists($plugin_file_path)) {
         CinsImpError::missing('Plugin', $plugin_file_path);
     }
     $plugin_file = file_get_contents($plugin_file_path);
     /* output the file to the requestor */
     Util::response_is_ajax_only();
     print $plugin_file;
 }
示例#2
0
 public function stack_load_card($card_id, $in_mark_state = null, $bkgnd_id = null, $in_current = null, $in_searchable = null)
 {
     $this->_check_access();
     $this->file_db->beginTransaction();
     /* used to ensure consistent reads */
     $card_id = $this->_card_ref_to_id($card_id, $in_mark_state, $bkgnd_id, $in_current, $in_searchable);
     $stmt = $this->file_db->prepare('SELECT id,bkgnd_id,seq,name,cant_delete,dont_search,marked,script,art,art_hidden FROM card WHERE id=?');
     $stmt->execute(array(intval($card_id)));
     $row = $stmt->fetch(PDO::FETCH_NUM);
     if ($row === false || count($row) == 0) {
         CinsImpError::missing('Card');
     }
     $card = array('id' => intval($row[0]), 'bkgnd_id' => intval($row[1]), 'seq' => intval($row[2]), 'name' => $row[3], 'cant_delete' => Stack::decode_bool($row[4]), 'dont_search' => Stack::decode_bool($row[5]), 'marked' => Stack::decode_bool($row[6]), 'script' => $row[7], 'art' => Stack::_evl($row[8]), 'art_hidden' => Stack::decode_bool($row[9]));
     /* make sure the card we've found actually complies with the filter requirements (if any) */
     if ($in_mark_state !== null && $card['marked'] != $in_mark_state) {
         CinsImpError::missing('Card');
     }
     if ($bkgnd_id !== null && $card['bkgnd_id'] != $bkgnd_id) {
         CinsImpError::missing('Card');
     }
     $content = array();
     $stmt = $this->file_db->prepare('SELECT bkgnd_object_id,content FROM card_data WHERE card_id=?');
     $stmt->execute(array($row[0]));
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $content[] = $row;
     }
     $card['content'] = $content;
     $card['objects'] = Stack::_layer_parts(-intval($card['id']));
     $this->file_db->commit();
     return $card;
 }