コード例 #1
0
function wufoo_cache_get($key, $expiration = 1800)
{
    global $wufoo_cache;
    if (preg_match('/forms/', $key)) {
        $expiration = time2seconds(get_option('WuPhooey-cache-forms', '30 minutes'));
    }
    if (preg_match('/entries/', $key) || preg_match('/fields/', $key)) {
        $expiration = time2seconds(get_option('WuPhooey-cache-entries', '30 minutes'));
    }
    return $wufoo_cache->get($key, $expiration);
}
コード例 #2
0
 * Copyright (c) 2010 rasenplanscher [ github.com/rasenplanscher ]
 */
/*
 * setup some variables that will be used in several places or within function while not in direct context
 */
# load the configuration
$_configuration = json_decode('{' . preg_replace('/#.*\\n/', '', file_get_contents('CONFIGURATION')) . '}', true);
# determine the uri the app was called with
$request_uri =& $_SERVER['REQUEST_URI'];
# determine the path to the application -- should ideally be '/'
$basepath = dirname($_SERVER['PHP_SELF']);
# determine how long a file stays valid
$file_ttl = time2seconds($_configuration['file ttl']);
# determine how long an expired file remains before it is deleted
$file_ttd = time2seconds($_configuration['file ttd']);
# identify the file to be downloaded if given as a hexadecimal number or the page to be shown, otherwise
$id = basename($request_uri);
# determine the valid length for file IDs
$id_length = $_configuration['ID length'];
# determine which locale to activate
$locale = $_configuration['locale'];
# setup conversion instructions for metadata types
$metadata_types = array('expire' => 'integer', 'size' => 'integer', 'virgin' => 'boolean');
# determine the maximum filesize accepted for uploads
$max_filesize = sscanf(ini_get('upload_max_filesize'), '%u%s');
$max_filesize = $max_filesize[0] * ($max_filesize[1] ? str_replace(array('k', 'm', 'g'), array(1024, 1024 * 1024, 1024 * 1024 * 1024), strtolower($max_filesize[1])) : 1);
# establish a mapping of possible error codes to their configuration labels
$post_errors = array(UPLOAD_ERR_OK => 'success', UPLOAD_ERR_INI_SIZE => 'size error, ini', UPLOAD_ERR_FORM_SIZE => 'size error, form', UPLOAD_ERR_PARTIAL => 'partial upload', UPLOAD_ERR_NO_FILE => 'no file', UPLOAD_ERR_NO_TMP_DIR => 'no tmp directory', UPLOAD_ERR_CANT_WRITE => 'can\'t write', UPLOAD_ERR_EXTENSION => 'extension error', 'FILE_TOO_LARGE' => 'web server abort', 'FILE_NOT_SAVED' => 'not saved', 'UNKNOWN_ERROR' => 'unknown error');
# determine how frequently to purge the uploaded files
$purge_interval = time2seconds($_configuration['purge interval']);
コード例 #3
0
ファイル: main.php プロジェクト: macconsultinggroup/WordPress
function wufoo_settings()
{
    wufoo_header('Settings', 'Your settings have been saved!');
    $forms = wufoo_cache_get('forms');
    if (!get_option('WuPhooey-cache-forms')) {
        add_option('WuPhooey-cache-forms', '30 minutes');
    }
    if (!get_option('WuPhooey-cache-entries')) {
        add_option('WuPhooey-cache-entries', '30 minutes');
    }
    // if( isset($_POST['WuPhooey-forms_to_count']) ) {
    //   update_option('WuPhooey-forms_to_count', serialize($_POST['WuPhooey-forms_to_count']));
    // }else {
    //   update_option('WuPhooey-forms_to_count', '');
    // }
    if (!empty($_POST)) {
        update_option('WuPhooey-username', $_POST['WuPhooey-username']);
        update_option('WuPhooey-api_key', $_POST['WuPhooey-api_key']);
        update_option('WuPhooey-cache-forms', $_POST['WuPhooey-cache-forms']);
        update_option('WuPhooey-cache-entries', $_POST['WuPhooey-cache-entries']);
        update_option('WuPhooey-forms_to_count', serialize($_POST['WuPhooey-forms_to_count']));
    }
    ?>
  
  <p>WuPhooey needs your Wufoo API-Key and subdomain to get your forms.</p>
  <p>If you need help finding your Wufoo API-Key please see the Wufoo Docs on <a target="_blank" href="http://wufoo.com/docs/api/v3/#key" title="Wufoo Docs &middot; Finding Your Key">Finding Your Key</a>.</p>
  
  <form method="post" action="<?php 
    echo wufoo_link('settings');
    ?>
&amp;updated=true">
    <?php 
    wp_nonce_field('update-options');
    ?>
    
    <table class="form-table wuphooey-form">
      
      <tr valign="top" class="form-field form-required">

        <th scope="row"><label for="username">Wufoo Subdomain</label></th>
        <td><input type="text" id="username" name="WuPhooey-username" class="regular-text large-font" value="<?php 
    echo get_option('WuPhooey-username');
    ?>
" /></td>

      </tr>
                  
      <tr valign="top" class="form-field form-required">
        
        <th scope="row"><label for="api-key">API Key</label></th>
        <td><input aria-required="true" type="text" id="api-key" name="WuPhooey-api_key" class="regular-text large-font" value="<?php 
    echo get_option('WuPhooey-api_key');
    ?>
" /></td>
        
      </tr>
                  
    </table>
        
    <a id="toggle-adv-opts" href="#">+ Advanced Options</a>
    <div id="adv-opts">
      
      <h3>Caching</h3>
      <table class="form-table wuphooey-form">
        
        <tr valign="top" class="form-field form-required">
          <th scope="row"><label for="caching-forms">Forms</label></th>
          <td>
            <input type="text" id="caching-forms" name="WuPhooey-cache-forms" class="regular-text" value="<?php 
    echo get_option('WuPhooey-cache-forms');
    ?>
" />
          </td>
        </tr>
        
        <tr valign="top" class="form-field form-required">
          <th scope="row"><label for="caching-entries">Entries*</label></th>
          <td>
            <input type="text" id="caching-entries" name="WuPhooey-cache-entries" class="regular-text" value="<?php 
    echo get_option('WuPhooey-cache-entries');
    ?>
" />
          </td>
        </tr>
        
        <?php 
    /* ?>
       <tr valign="top" class="form-field form-required">
         <th scope="row"><label for="caching-reports">Reports</label></th>
         <td>
           <input type="text" id="caching-reports" name="WuPhooey-cache-reports" class="regular-text" value="<?php echo get_option('WuPhooey-cache-reports') ?>" />
         </td>
       </tr>
       <?php */
    ?>
                
      </table> 
      
      <h3>Misc</h3>
      <table class="form-table wuphooey-form">
        
        <tr valign="top" class="form-field">
          <th scope="row" style="width: 20px;"></th>
          <td>
            <a class="button" href="<?php 
    echo plugins_url('/clear_cache.php', __FILE__);
    ?>
?url=<?php 
    echo urlencode($_SERVER['REQUEST_URI']);
    ?>
">Clear Cache</a>
            <p style="color: #fff; text-shadow: 0 1px 0 #000">This will empty the cache folder. Clearing used disk space.</p>
          </td>
        </tr>
        
        <?php 
    /*
    <tr valign="top" class="form-field">
      <th scope="row" style="width: 20px;"></th>
      <td>
        <input type="checkbox" style="display: inline; width: inherit;" id="WuPhooey-use-css" name="WuPhooey-use-css" <?php echo (get_option('WuPhooey-use-css')) ? 'checked="checked"' : '' ?> value="true" />
        <label for="WuPhooey-use-css">Use Generic CSS</label>
        <p style="color: #fff; text-shadow: 0 1px 0 #000; padding: 2px; margin: 0;">This will autoload a <a target="_blank" href="<?php echo plugins_url('/generic_form.css', __FILE__) ?>">generic stylesheet</a> for Wufoo Forms</p>
      </td>
    </tr>
    */
    ?>
        
      </table>
      
      <?php 
    if ($wrapper = wufoo_login($echo = false)) {
        ?>
        <h3>Count Today&#x27;s Entries</h3>
        <p>Choose the forms you would like to have counted.</p>
        <div id="forms-list">
          <ul>
            
            <?php 
        if (!($forms = wufoo_cache_get('forms-tec', time2seconds('10 minutes')))) {
            $forms = $wrapper->getForms();
            wufoo_cache_set('forms-tec', $forms);
        }
        $chosenForms = unserialize(get_option('WuPhooey-forms_to_count'));
        ?>
            
            <?php 
        foreach ($forms as $id => $form) {
            ?>
              <?php 
            $selected = isset($chosenForms['id-' . $id]) ? ' checked="checked"' : ' ';
            ?>
              <li>
                <input<?php 
            echo $selected;
            ?>
 type="checkbox" id="WuPhooey-forms_to_count[id-<?php 
            echo $id;
            ?>
]" name="WuPhooey-forms_to_count[id-<?php 
            echo $id;
            ?>
]" value="selected" />
                <label for="WuPhooey-forms_to_count[id-<?php 
            echo $id;
            ?>
]"><?php 
            echo $form->Name;
            ?>
</label>
              </li>
            <?php 
        }
        ?>
            
          </ul>
        </div>
      <?php 
    } else {
        ?>
        <h3 class="disabled">Count Today&#x27;s Entries</h3>
        <p>This feature will be enabled after you add your Wufoo Subdomain and API Key.</p>
      <?php 
    }
    ?>
      
    </div>
    
    <input type="hidden" name="WuPhooey-secret_key" value="<?php 
    echo time();
    ?>
" />
    <!-- <input type="hidden" name="action" value="update" /> -->
    <!-- <input type="hidden" name="page_options" value="WuPhooey-api_key,WuPhooey-username,WuPhooey-secret_key,WuPhooey-cache-forms,WuPhooey-cache-entries<?php 
    /* ,WuPhooey-cache-reports,WuPhooey-use-css */
    ?>
" /> -->
    
    <p class="submit">
      <input type="submit" class="button-primary" value="<?php 
    _e('Save Changes');
    ?>
" /> &#8212;
      <input type="button" id="wuphooey-test_info" class="button" value="<?php 
    _e('Test Info');
    ?>
" />
      <img id="spinner" style="position: relative; top: 3px" src="<?php 
    echo plugins_url('/images/ajax-loader-blue.gif', __FILE__);
    ?>
" />
      <span style="position: relative; left: -16px;" id="wuphooey-message" class="description">Make sure it's right</span>
    </p>
    
  </form>
  
  <p>* This will not apply when totaling "Count Today's Entries". Today's entries update every hour.</p>
  
  <script src="<?php 
    echo plugins_url('/js/jquery.cookie.js', __FILE__);
    ?>
"></script>
  <script>
    var $ = jQuery;
    var $test_btn = $('#wuphooey-test_info'),
        $message = $('#wuphooey-message'),
        $spinner = $('#spinner').css('opacity', 0),
        
        // Advanced options
         $link = $('#toggle-adv-opts'),
        advOpts_status = $.cookie('WuPhooey-Settings-adv_opts');
    
    if( !advOpts_status ) {
      $.cookie('WuPhooey-Settings-adv_opts', 'closed');
      advOpts_status = $.cookie('WuPhooey-Settings-adv_opts');
    }
    
    $test_btn.click(function() {
      
      $message.stop().animate({
        left: 0
      }, '', function() {
        $spinner.stop().animate({
          opacity: 1
        }, 250); 
      });
      
      $.post('<?php 
    echo plugins_url('test_info.php', __FILE__);
    ?>
', $('form').serialize(), function(data) {        
        if( data == 'Success!' )
          $message.text(data).removeClass('error').addClass('updated');
        else
          $message.text(data).removeClass('updated').addClass('error');
          
        $spinner.stop().css('opacity', 0);
        $message.stop().css('left', -16);
      });
      
    });
    
    if( advOpts_status == 'closed' )
      $('#adv-opts').hide();
    else
      $link.text('- Advanced Options');
    
      $link.click(function(e) {
      
      if( $('#adv-opts').is(':visible') ) {
        $('#adv-opts').slideUp();
        $link.text('+ Advanced Options');
        $.cookie('WuPhooey-Settings-adv_opts', 'closed');
      }else {
        $('#adv-opts').slideDown();
        $link.html('- Advanced Options');
        $.cookie('WuPhooey-Settings-adv_opts', 'opened');
      }
      
      e.preventDefault();
    });
  </script>

<?php 
    wufoo_footer();
}