Пример #1
0
    if ($shub_account_id && $envato->get('shub_account_id') == $shub_account_id) {
        /* @var $groups shub_item[] */
        $groups = $envato->get('groups');
        //print_r($groups);
        ?>
	    <form action="" method="post" enctype="multipart/form-data">
		    <input type="hidden" name="_process" value="send_envato_message">
			<?php 
        wp_nonce_field('send-envato' . (int) $envato->get('shub_account_id'));
        ?>
		    <?php 
        $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Compose message'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('item' => array('title' => __('envato Group', 'support_hub'), 'fields' => array()), 'message' => array('title' => __('message', 'support_hub'), 'field' => array('type' => 'textarea', 'name' => 'message', 'id' => 'envato_compose_message', 'value' => '')), 'type' => array('title' => __('Type', 'support_hub'), 'fields' => array('<input type="radio" name="post_type" id="post_type_wall" value="wall" checked> ', '<label for="post_type_wall">', __('Wall Post', 'support_hub'), '</label>', '<input type="radio" name="post_type" id="post_type_link" value="link"> ', '<label for="post_type_link">', __('Link Post', 'support_hub'), '</label>', '<input type="radio" name="post_type" id="post_type_picture" value="picture"> ', '<label for="post_type_picture">', __('Picture Post', 'support_hub'), '</label>')), 'link' => array('title' => __('Link', 'support_hub'), 'fields' => array(array('type' => 'text', 'name' => 'link', 'id' => 'message_link_url', 'value' => ''), '<div id="envato_link_loading_message"></div>', '<span class="envato-type-link envato-type-option"></span>')), 'link_picture' => array('title' => __('Link Picture', 'support_hub'), 'fields' => array(array('type' => 'text', 'name' => 'link_picture', 'value' => ''), 'Full URL (eg: http://) to the picture to use for this link preview', '<span class="envato-type-link envato-type-option"></span>')), 'link_name' => array('title' => __('Link Title', 'support_hub'), 'fields' => array(array('type' => 'text', 'name' => 'link_name', 'value' => ''), 'Title to use instead of the automatically generated one from the Link page', '<span class="envato-type-link envato-type-option"></span>')), 'link_caption' => array('title' => __('Link Caption', 'support_hub'), 'fields' => array(array('type' => 'text', 'name' => 'link_caption', 'value' => ''), 'Caption to use instead of the automatically generated one from the Link page', '<span class="envato-type-link envato-type-option"></span>')), 'link_description' => array('title' => __('Link Description', 'support_hub'), 'fields' => array(array('type' => 'text', 'name' => 'link_description', 'value' => ''), 'Description to use instead of the automatically generated one from the Link page', '<span class="envato-type-link envato-type-option"></span>')), 'picture' => array('title' => __('Picture', 'support_hub'), 'fields' => array('<input type="file" name="picture" value="">', '<span class="envato-type-picture envato-type-option"></span>')), 'schedule' => array('title' => __('Schedule', 'support_hub'), 'fields' => array(array('type' => 'date', 'name' => 'schedule_date', 'value' => ''), array('type' => 'time', 'name' => 'schedule_time', 'value' => ''), ' ', sprintf(__('Currently: %s', 'support_hub'), date('c')), ' (Leave blank to send now, or pick a date in the future.)')), 'debug' => array('title' => __('Debug', 'support_hub'), 'field' => array('type' => 'check', 'name' => 'debug', 'value' => '1', 'checked' => false, 'help' => 'Show debug output while posting the message'))));
        foreach ($groups as $item_id => $group) {
            $fieldset_data['elements']['item']['fields'][] = '<div id="envato_compose_group_select">' . '<input type="checkbox" name="compose_group_id[' . $item_id . ']" value="1" checked> ' . '<img src="//graph.envato.com/' . $item_id . '/picture"> ' . htmlspecialchars($group->get('item_name')) . '</div>';
        }
        echo shub_module_form::generate_fieldset($fieldset_data);
        ?>
	    </form>

	    <script type="text/javascript">
		    function change_post_type(){
			    var currenttype = jQuery('[name=post_type]:checked').val();
			    jQuery('.envato-type-option').each(function(){
				    jQuery(this).parents('tr').first().hide();
			    });
			    jQuery('.envato-type-'+currenttype).each(function(){
				    jQuery(this).parents('tr').first().show();
			    });

		    }
		    jQuery(function(){
Пример #2
0
                                                    <input type="hidden" name="item_name[<?php 
                        echo $product_id;
                        ?>
]" value="<?php 
                        echo esc_attr($product_data['name']);
                        ?>
">
												</td>
												<td>
													<?php 
                        echo htmlspecialchars($product_data['name']);
                        ?>
												</td>
												<td>
													<?php 
                        shub_module_form::generate_form_element(array('name' => 'item_product[' . $product_id . ']', 'type' => 'select', 'blank' => __('- None -', 'support_hub'), 'value' => $shub_ucm_account->is_item_active($product_id) ? $ucm_products[$product_id]->get('shub_product_id') : (isset($product_data['shub_product_id']) ? $product_data['shub_product_id'] : 0), 'options' => $products, 'options_array_id' => 'product_name', 'class' => 'shub_product_dropdown'));
                        ?>
												</td>
												<td>
													<?php 
                        echo $shub_ucm_account->is_item_active($product_id) && $ucm_products[$product_id]->get('last_checked') ? shub_print_date($ucm_products[$product_id]->get('last_checked'), true) : 'N/A';
                        ?>
												</td>
												<td>
													<?php 
                        if ($shub_ucm_account->is_item_active($product_id)) {
                            echo '<a href="' . $ucm_products[$product_id]->link_refresh() . '" target="_blank">re-load product tickets</a>';
                        }
                        ?>
												</td>
											</tr>
Пример #3
0
    public static function generate_form_element($setting)
    {
        if (isset($setting['ignore']) && $setting['ignore']) {
            return;
        }
        // type defaults
        if ($setting['type'] == 'currency') {
            $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'currency';
        }
        if ($setting['type'] == 'date') {
            $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'date_field';
            $setting['type'] = 'text';
        }
        if ($setting['type'] == 'time') {
            $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'time_field';
            $setting['type'] = 'text';
        }
        if ($setting['type'] == 'encrypted' && !get_option('shub_encrypt_public_key', '')) {
            $setting['type'] = 'text';
        }
        if ($setting['type'] == 'encrypted' && (!isset($setting['id']) || !$setting['id'])) {
            $setting['id'] = md5($setting['name']);
        }
        if ($setting['type'] == 'select' || $setting['type'] == 'wysiwyg') {
            if (!isset($setting['id']) || !$setting['id']) {
                $setting['id'] = $setting['name'];
            }
        }
        if ($setting['type'] == 'save_button') {
            $setting['type'] = 'submit';
            $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'submit_button save_button';
        }
        if ($setting['type'] == 'delete_button') {
            $setting['type'] = 'submit';
            $setting['class'] = (isset($setting['class']) ? $setting['class'] . ' ' : '') . 'submit_button delete_button';
        }
        if (isset($setting['label']) && (!isset($setting['id']) || !$setting['id'])) {
            // labels need ids
            $setting['id'] = md5($setting['name']);
        }
        $attributes = '';
        foreach (array('size', 'style', 'autocomplete', 'placeholder', 'class', 'id', 'onclick') as $attr) {
            if (isset($setting[$attr])) {
                $attributes .= ' ' . $attr . '="' . $setting[$attr] . '"';
            }
        }
        if (isset($setting['data']) && is_array($setting['data'])) {
            foreach ($setting['data'] as $key => $val) {
                $attributes .= ' data-' . $key . '="' . $val . '"';
            }
        }
        if (!isset($setting['value'])) {
            $setting['value'] = '';
        }
        ob_start();
        // handle multiple options
        $loop_count = 1;
        if (isset($setting['multiple']) && $setting['multiple']) {
            // has to have at least 1 value
            if ($setting['multiple'] === true) {
                // create our wrapper id.
                $multiple_id = md5(serialize($setting));
                echo '<div id="' . $multiple_id . '">';
            } else {
                $multiple_id = $setting['multiple'];
            }
            if (!isset($setting['values'])) {
                $setting['values'] = array($setting['value']);
            }
            $loop_count = count($setting['values']);
        }
        for ($x = 0; $x < $loop_count; $x++) {
            if (isset($setting['multiple']) && $setting['multiple']) {
                $setting['value'] = isset($setting['values'][$x]) ? $setting['values'][$x] : false;
                echo '<div class="dynamic_block">';
            }
            switch ($setting['type']) {
                case 'currency':
                    echo currency('<input type="text" name="' . $setting['name'] . '" value="' . htmlspecialchars($setting['value']) . '"' . $attributes . '>', true, isset($setting['currency_id']) ? $setting['currency_id'] : false);
                    break;
                case 'number':
                    ?>
                    <input type="text" name="<?php 
                    echo $setting['name'];
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'encrypted':
                    if (!self::$done_encrypt_scripts) {
                        self::$done_encrypt_scripts = true;
                        ?>
 
					
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/json2.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/jsbn.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/jsbn2.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/prng4.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/rng.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/rsa.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/rsa2.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script language="JavaScript" type="text/javascript" src="<?php 
                        echo plugins_url('assets/js/sjcl.js', _DTBAKER_SUPPORT_HUB_CORE_FILE_);
                        ?>
"></script>
						<script type="text/javascript">
						    var rsa2 = {
						        e: '010001', // 010001 (65537 was the old value, this was bad!)
						        bits: 1024,
						        public_key: '<?php 
                        echo get_option('shub_encrypt_public_key', '');
                        ?>
',
						        private_key: {},
						        private_encrypted: '<?php 
                        ?>
', // this is what we get from our server.
						        generate: function(passphrase){
						            // we generate a brand new key when creating a new encryption.
						            var rsakey = new RSAKey();
						            var dr = document.rsatest;
						            rsakey.generate(parseInt(this.bits),this.e);
						            this.public_key = rsakey.n.toString(16);
						            //console.debug(this.public_key);
						            this.private_key.d = rsakey.d.toString(16);
						            this.private_key.p = rsakey.p.toString(16);
						            this.private_key.q = rsakey.q.toString(16);
						            this.private_key.dmp1 = rsakey.dmp1.toString(16);
						            this.private_key.dmq1 = rsakey.dmq1.toString(16);
						            this.private_key.coeff = rsakey.coeff.toString(16);
						            var private_string = JSON.stringify(this.private_key);
						            this.private_key = {};
						            // encrypt this private key with our password?
						            this.private_encrypted = sjcl.encrypt(passphrase,private_string);
						            //console.debug(this.private_encrypted);
						        },
						        decrypt_private_key: function(passphrase){
						            try{
						                var p = sjcl.decrypt(passphrase,this.private_encrypted);
						                if(p){
						                    var j = JSON.parse(p);
						                    if(j){
						                        this.private_key = j;
						                        //console.debug(this.private_key);
						                        return true;
						                    }
						                }
						            }catch(e){}
						            return false;
						        },
						        encrypt: function(value){
						            var rsakey = new RSAKey();
						            rsakey.setPublic(this.public_key, this.e);
						            return rsakey.encrypt(value);
						        },
						        decrypt: function(ciphertext){
						            var rsakey = new RSAKey();
						            //console.log(this.public_key);
						            //console.log(this.e);
						            //console.log(this.private_key.d);
						            //console.log(this.private_key.p);
						            //console.log(this.private_key.q);
						            //console.log(this.private_key.dmp1);
						            //console.log(this.private_key.dmq1);
						            //console.log(this.private_key.coeff);
						            rsakey.setPrivateEx(this.public_key, this.e, this.private_key.d, this.private_key.p, this.private_key.q, this.private_key.dmp1, this.private_key.dmq1, this.private_key.coeff);
						            return rsakey.decrypt(ciphertext);
						        }
						    };
						    function do_save(){
						        var enc = rsa2.encrypt($('#decrypted_value').val());
						        if(enc){

						        }
						    }
                            jQuery(function(){
                                jQuery('#<?php 
                        echo $setting['id'];
                        ?>
').change(function(){
                                    jQuery('#encrypted_<?php 
                        echo $setting['id'];
                        ?>
').val(rsa2.encrypt(jQuery(this).val()));
                                });
                            });
						
						</script>
					<?php 
                    }
                    ?>
                    <input type="text" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                    <input type="hidden" name="<?php 
                    echo $setting['name'];
                    ?>
" value="" id="encrypted_<?php 
                    echo $setting['id'];
                    ?>
">
					[encrypted] <a href="#" onclick="jQuery(this).parent().find('.encrypted_learn_more').show(); jQuery(this).hide(); return false;">(learn more)</a>
					<div class="encrypted_learn_more" style="display: none">
						This field is encrypted using industry standard PGP cryptography in JavaScript before getting sent to the server. This provides an extremely high level of security as the raw value is never transmitted with the request and can only be decrypted by a single person here in the office.
					</div>
                    <?php 
                    break;
                case 'text':
                    ?>
                    <input type="text" name="<?php 
                    echo $setting['name'];
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'password':
                    ?>
                    <input type="password" name="<?php 
                    echo $setting['name'];
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'hidden':
                    ?>
                    <input type="hidden" name="<?php 
                    echo $setting['name'];
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'textarea':
                    ?>
                    <textarea name="<?php 
                    echo $setting['name'];
                    ?>
" rows="6" cols="50"<?php 
                    echo $attributes;
                    ?>
><?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
</textarea>
                    <?php 
                    break;
                case 'select':
                    // copied from print_select_box()
                    if (isset($setting['allow_new']) && $setting['allow_new']) {
                        $attributes .= ' onchange="dynamic_select_box(this);"';
                    }
                    ?>
                    <select name="<?php 
                    echo $setting['name'];
                    ?>
"<?php 
                    echo $attributes;
                    ?>
>
                        <?php 
                    if (!isset($setting['blank']) || $setting['blank']) {
                        ?>
                        <option value=""><?php 
                        echo !isset($setting['blank']) || $setting['blank'] === true ? __('- Select -') : htmlspecialchars($setting['blank']);
                        ?>
</option>
                        <?php 
                    }
                    $found_selected = false;
                    $current_val = 'Enter new value here';
                    $sel = '';
                    foreach ($setting['options'] as $key => $val) {
                        if (is_array($val)) {
                            if (!$setting['options_array_id']) {
                                if (isset($val[$setting['id']])) {
                                    $setting['options_array_id'] = $setting['id'];
                                } else {
                                    $setting['options_array_id'] = key($val);
                                }
                            }
                            $printval = $val[$setting['options_array_id']];
                        } else {
                            $printval = $val;
                        }
                        if (strlen($printval) == 0) {
                            continue;
                        }
                        $sel .= '<option value="' . htmlspecialchars($key) . '"';
                        // to handle 0 elements:
                        if ($setting['value'] !== false && $setting['value'] != '' && $key == $setting['value']) {
                            $current_val = $printval;
                            $sel .= ' selected';
                            $found_selected = true;
                        }
                        $sel .= '>' . htmlspecialchars($printval) . '</option>';
                    }
                    if ($setting['value'] && !$found_selected) {
                        $sel .= '<option value="' . htmlspecialchars($setting['value']) . '" selected>' . htmlspecialchars($setting['value']) . '</option>';
                    }
                    /*if(isset($setting['allow_new']) && $setting['allow_new'] && get_display_mode() != 'mobile'){
                          $sel .= '<option value="create_new_item">'._l(' - Create New - ') .'</option>';
                      }
                      if(isset($setting['allow_new']) && $setting['allow_new']){
                          //$sel .= '<input type="text" name="new_'.$id.'" style="display:none;" value="'.$current_val.'">';
                      }*/
                    echo $sel;
                    ?>
                        <?php 
                    /*foreach($setting['options'] as $key=>$val){ ?>
                      <option value="<?php echo $key;?>"<?php echo $setting['value'] == $key ? ' selected':'' ?>><?php echo htmlspecialchars($val);?></option>
                      <?php }*/
                    ?>
                    </select>
                    <?php 
                    break;
                case 'checkbox':
                    ?>
                    <input type="hidden" name="default_<?php 
                    echo $setting['name'];
                    ?>
" value="1">
                    <input type="checkbox" name="<?php 
                    echo $setting['name'];
                    ?>
" value="1" <?php 
                    if ($setting['value']) {
                        echo ' checked';
                    }
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'check':
                    ?>
                    <input type="checkbox" name="<?php 
                    echo $setting['name'];
                    ?>
" value="<?php 
                    echo $setting['value'];
                    ?>
" <?php 
                    if ($setting['checked']) {
                        echo ' checked';
                    }
                    echo $attributes;
                    ?>
>
                    <?php 
                    break;
                case 'submit':
                    ?>
                    <input type="submit" name="<?php 
                    echo htmlspecialchars($setting['name']);
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
" <?php 
                    echo $attributes;
                    ?>
/>
                    <?php 
                    break;
                case 'button':
                    ?>
                    <input type="button" name="<?php 
                    echo htmlspecialchars($setting['name']);
                    ?>
" value="<?php 
                    echo htmlspecialchars($setting['value']);
                    ?>
" <?php 
                    echo $attributes;
                    ?>
/>
                    <?php 
                    break;
            }
            if (isset($setting['multiple']) && $setting['multiple']) {
                echo '<a href="#" class="add_addit" onclick="return seladd(this);">+</a> <a href="#" class="remove_addit" onclick="return selrem(this);">-</a>';
                echo '</div>';
            }
        }
        if (isset($setting['multiple']) && $setting['multiple']) {
            if ($setting['multiple'] === true) {
                echo '</div>';
            }
            echo '<script type="text/javascript"> set_add_del("' . $multiple_id . '"); </script>';
        }
        $html = ob_get_clean();
        /*if(isset($setting['encrypt']) && $setting['encrypt'] && class_exists('module_encrypt',false)){
              $html = module_encrypt::parse_html_input($setting['page_name'],$html);
          }*/
        echo $html;
        if (isset($setting['label']) && strlen($setting['label'])) {
            echo '<label for="' . htmlspecialchars($setting['id']) . '">' . __($setting['label']) . '</label>';
        }
        /*if(isset($setting['help']) && (count($setting['help']) || strlen($setting['help']))){
              _h($setting['help']);
          }*/
    }
 public function reply_actions()
 {
     $user_data = $this->account->get('account_data');
     if (isset($user_data['reply_options']) && is_array($user_data['reply_options'])) {
         foreach ($user_data['reply_options'] as $reply_option) {
             if (isset($reply_option['title'])) {
                 echo '<div>';
                 echo '<label for="">' . htmlspecialchars($reply_option['title']) . '</label>';
                 if (isset($reply_option['field']) && is_array($reply_option['field'])) {
                     $reply_option['field']['name'] = 'extra-' . $reply_option['field']['name'];
                     $reply_option['field']['data'] = array('reply' => 'yes');
                     shub_module_form::generate_form_element($reply_option['field']);
                 }
                 echo '</div>';
             }
         }
     }
 }
Пример #5
0
                            <textarea name="extra_description"><?php 
    echo esc_attr($shub_extra->get('extra_description'));
    ?>
</textarea>
	                        (e.g. Enter your Website Address so we can see the problem)
                        </td>
                    </tr>
                    <tr>
                        <th>
                            <?php 
    _e('Field Type', 'support_hub');
    ?>
                        </th>
                        <td class="">
                            <?php 
    shub_module_form::generate_form_element(array('type' => 'select', 'options' => array('text' => 'Text Field', 'encrypted' => 'Encrypted Field'), 'value' => $shub_extra->get('field_type'), 'name' => 'field_type'));
    ?>
                        </td>
                    </tr>
					</tbody>
				</table>

				<p class="submit">
					<?php 
    if ($shub_extra->get('shub_extra_id')) {
        ?>
						<input name="butt_save" type="submit" class="button-primary"
						       value="<?php 
        echo esc_attr(__('Save', 'support_hub'));
        ?>
"/>
        ?>
			<div>
				<label for="extra_<?php 
        echo $extra->get('shub_extra_id');
        ?>
"><?php 
        echo htmlspecialchars($extra->get('extra_name'));
        ?>
:</label>
				<?php 
        shub_module_form::generate_form_element(array('type' => $extra->get('field_type') ? $extra->get('field_type') : 'text', 'name' => 'extra[' . $extra->get('shub_extra_id') . ']', 'value' => isset($extra_previous_data[$extra->get('shub_extra_id')]) ? $extra_previous_data[$extra->get('shub_extra_id')] : ''));
        ?>
			</div>
			<?php 
    }
    ?>
	</fieldset>
	<fieldset class="shub_extra_notes">
		<legend>Any more information? (optional)</legend>
		<div>
			<label for="extra_notes">Message:</label>
			<?php 
    shub_module_form::generate_form_element(array('type' => 'textarea', 'name' => 'extra_notes', 'value' => isset($extra_previous_notes) ? $extra_previous_notes : ''));
    ?>
		</div>
	</fieldset>
	<div><button type="submit" id="submit-go">Submit Private Message</button></div>
	<?php 
}
?>
</form>