示例#1
0
function configSetting($cf, $setting, $value)
{
    if ($value === '') {
        return $cf;
    }
    // Empty
    $empty = is_bool($value) ? '(true|false)' : "''";
    $val = is_bool($value) ? $value ? 'true' : 'false' : "'" . preg_replace("/([\\'])/", '\\\\$1', $value) . "'";
    // First check if the directive exists in the config file.
    $directiveHead = "'" . preg_quote($setting, '/') . "'(\\s*)=>";
    $exists = preg_match('/' . $directiveHead . '/', $cf);
    if ($exists) {
        // If it exists, simply add the value instead of an empty one
        return preg_replace('/' . $directiveHead . '(\\s*)' . $empty . '/', "'" . $setting . "'\$1=>\$2" . $val, $cf);
    } else {
        // If it does not exist, let's add it to the end of the literal array in the file.
        return str_lreplace(');', "'" . $setting . "' => " . $val . ",\n);", $cf);
    }
}
示例#2
0
 public function convertAction()
 {
     if (!isset($_POST["tek"])) {
         echo 'this file cannot be called this way';
         exit;
     }
     $render = $_POST["tek"];
     //$render = str_replace("\n", " \n\\newline\n", $render);
     $render = str_replace('<br>', "\n//\n", $render);
     $render = str_replace('<br />', "\n//\n", $render);
     $render = str_replace('<title>', '\\title{', $render);
     $render = str_replace('</title>', "}", $render);
     $render = preg_replace('/\\<paragraph\\>/', '\\begin{letter}{', $render, 1);
     $render = preg_replace('/\\<\\/paragraph\\>/', "}\n\\pagestyle{plain}\n", $render, 1);
     $render = preg_replace('/\\<paragraph\\>/', '\\name{', $render, 1);
     $render = preg_replace('/\\<\\/paragraph\\>/', "}\n", $render, 1);
     $render = preg_replace('/\\<paragraph\\>/', '\\opening{', $render, 1);
     $render = preg_replace('/\\<\\/paragraph\\>/', "}\n", $render, 1);
     $render = str_lreplace('<paragraph>', '\\closing{', $render);
     $render = str_lreplace('</paragraph>', '}', $render);
     $render = str_replace('<paragraph>', '', $render);
     $render = str_replace('</paragraph>', '', $render);
     $render = str_replace('<item>', '\\item ', $render);
     $render = str_replace('</item>', "\n", $render);
     $render = str_replace('<bullets>', "\\begin{itemize}\n", $render);
     $render = str_replace('</bullets>', "\nnd{itemize}\n", $render);
     $render = str_replace('<xml>', '', $render);
     $render = str_replace('</xml>', '', $render);
     //$render = html_entity_decode(html_entity_decode($render));
     $render = str_replace('&amp;', '\\&', $render);
     $render = str_replace('&aacute;', '\\acute{a}', $render);
     $render = str_replace('&agrave;', '\\grave{a}', $render);
     $render = str_replace('&eacute;', '\\acute{e}', $render);
     $render = str_replace('&egrave;', '\\grave{e}', $render);
     $render = str_replace('<b>', '\\textbf{', $render);
     $render = str_replace('</b>', '}', $render);
     $render = str_replace('<u>', '\\underline{', $render);
     $render = str_replace('</u>', '}', $render);
     $render = str_replace('<i>', '\\textit{', $render);
     $render = str_replace('</i>', '}', $render);
     $this->template->data = $render;
     $this->template->setView("raw");
 }
示例#3
0
 function saveFile($user_id, $name, $value)
 {
     //setup some vars
     $file = $_FILES[$name];
     $user = get_userdata($user_id);
     //no file?
     if (empty($file['name'])) {
         return;
     }
     //check extension against allowed extensions
     $filetype = wp_check_filetype_and_ext($file['tmp_name'], $file['name']);
     if ((!$filetype['type'] || !$filetype['ext']) && !current_user_can('unfiltered_upload')) {
         //we throw an error earlier, but this just bails on the upload just in case
         return false;
     } else {
         //need to check this in case we are in class context or not
         if (!empty($this)) {
             if (!empty($this->ext)) {
                 $ext = $this->ext;
             } else {
                 $ext = false;
             }
         } else {
             global $pmprorh_registration_fields;
             foreach ($pmprorh_registration_fields as $checkout_box) {
                 foreach ($checkout_box as $field) {
                     if ($field->name == $name) {
                         if (!empty($field->ext)) {
                             $ext = $field->ext;
                         } else {
                             $ext = false;
                         }
                         break 2;
                     }
                 }
             }
         }
         //check for specific extensions anyway
         if (!empty($ext) && !in_array($filetype['ext'], $ext)) {
             pmpro_setMessage(sprintf(__("Sorry, the file type for %s is not permitted for security reasons.", "pmpro"), $file['name']), "pmpro_error");
             return false;
         }
     }
     /*
     	save file in uploads
     */
     //check for a register helper directory in wp-content
     $upload_dir = wp_upload_dir();
     $pmprorh_dir = $upload_dir['basedir'] . "/pmpro-register-helper/" . $user->user_login . "/";
     //create the dir and subdir if needed
     if (!is_dir($pmprorh_dir)) {
         wp_mkdir_p($pmprorh_dir);
     }
     //if we already have a file for this field, delete it
     $old_file = get_user_meta($user->ID, $name, true);
     if (!empty($old_file) && !empty($old_file['fullpath']) && file_exists($old_file['fullpath'])) {
         unlink($old_file['fullpath']);
     }
     //figure out new filename
     $filename = $file['name'];
     $count = 0;
     while (file_exists($pmprorh_dir . $filename)) {
         if ($count) {
             $filename = str_lreplace("-" . $count . "." . $filetype['ext'], "-" . strval($count + 1) . "." . $filetype['ext'], $filename);
         } else {
             $filename = str_lreplace("." . $filetype['ext'], "-1." . $filetype['ext'], $filename);
         }
         $count++;
         //let's not expect more than 50 files with the same name
         if ($count > 50) {
             die("Error uploading file. Too many files with the same name.");
         }
     }
     //save file
     if (strpos($file['tmp_name'], $upload_dir['basedir']) !== false) {
         //was uploaded and saved to $_SESSION
         rename($file['tmp_name'], $pmprorh_dir . $filename);
     } else {
         //it was just uploaded
         move_uploaded_file($file['tmp_name'], $pmprorh_dir . $filename);
     }
     //save filename in usermeta
     update_user_meta($user_id, $name, array("original_filename" => $file['name'], "filename" => $filename, "fullpath" => $pmprorh_dir . $filename, "fullurl" => content_url("/uploads/pmpro-register-helper/" . $user->user_login . "/" . $filename), "size" => $file['size']));
 }
示例#4
0
文件: app.php 项目: pkdevbox/jsbin
     $revision = $action;
 } else {
     $code_id = $action;
     $revision = 1;
 }
 list($latest_revision, $html, $javascript) = getCode($code_id, $revision);
 list($html, $javascript) = formatCompletedCode($html, $javascript, $code_id, $revision);
 global $quiet;
 // using new str_lreplace to ensure only the *last* </body> is replaced.
 // FIXME there's still a bug here if </body> appears in the script and not in the
 // markup - but I'll fix that later
 if (!$quiet) {
     $html = str_lreplace('</body>', '<script src="../js/render/edit.js"></script>' . "\n</body>", $html);
 }
 if ($no_code_found == false) {
     $html = str_lreplace('</body>', googleAnalytics() . '</body>', $html);
 }
 if (false) {
     if (stripos($html, '<head>')) {
         $html = preg_replace('/<head>(.*)/', '<head><script>if (window.top != window.self) window.top.location.replace(window.location.href);</script>$1', $html);
     } else {
         // if we can't find a head element, brute force the framebusting in to the HTML
         $html = '<script>if (window.top != window.self) window.top.location.replace(window.location.href);</script>' . $html;
     }
 }
 if (!$html && !$ajax) {
     $javascript = "/*\n  Created using " . $host . ROOT . "\n  Source can be edit via " . $host . ROOT . "{$code_id}/edit\n*/\n\n" . $javascript;
 }
 if (!$html) {
     header("Content-type: text/javascript");
 }
示例#5
0
<?php 
$versions = array();
$file = file('changelog.txt');
$changelog = '';
$first = true;
foreach ($file as $line) {
    if (strpos($line, '*') !== 0) {
        $key = trim(str_replace('.', '-', str_replace(' ', '-', $line)));
        $version = ucfirst(trim($line));
        array_push($versions, $key);
        if (!$first) {
            add_buttons();
        }
        $changelog .= "<hr><div id='{$key}-fake'><h3>{$version}</h3></div>";
        $first = false;
        $href_version = trim(str_lreplace(' ', '-', $line));
    } else {
        $change = substr($line, 1);
        $changelog .= "<li>{$change}</li>";
    }
}
echo '<div class="btn-group"><button type="button" class="btn btn-material-lightgreen dropdown-toggle" data-toggle="dropdown">Version Index <span 
class="caret"></span></button><ul class="dropdown-menu">';
foreach ($versions as $version) {
    echo "<li class='hashlink'><a>{$version}</a></li>";
}
echo '</ul></div>';
add_buttons();
echo $changelog;
function add_buttons()
{
示例#6
0
文件: selects.php 项目: bafio89/qea-u
function qa_db_categoryslugs_favorite_sql_args($favoriteslugs, &$arguments)
{
    $output = '';
    if (count($favoriteslugs) == 1) {
        if (!is_array($categoryslugs)) {
            // accept old-style string arguments for one category deep
            $categoryslugs = strlen($categoryslugs) ? array($categoryslugs) : array();
        }
        $levels = count($categoryslugs);
        if ($levels > 0 && $levels <= QA_CATEGORY_DEPTH) {
            $arguments[] = qa_db_slugs_to_backpath($categoryslugs);
            return ($levels == QA_CATEGORY_DEPTH ? 'categoryid' : 'catidpath' . $levels) . '=(SELECT categoryid FROM ^categories WHERE backpath=$ LIMIT 1) AND ';
        }
        return '';
    } else {
        foreach ($favoriteslugs as $categoryslugs) {
            if (!is_array($categoryslugs)) {
                // accept old-style string arguments for one category deep
                $categoryslugs = strlen($categoryslugs) ? array($categoryslugs) : array();
            }
            $levels = count($categoryslugs);
            if ($levels > 0 && $levels <= QA_CATEGORY_DEPTH) {
                $arguments[] = qa_db_slugs_to_backpath($categoryslugs);
                $output = $output . ($levels == QA_CATEGORY_DEPTH ? 'categoryid' : 'catidpath' . $levels) . '=(SELECT categoryid FROM ^categories WHERE backpath=$ LIMIT 1) OR ';
            }
        }
        $output = str_lreplace('OR', '', $output);
        $output = $output . 'AND ';
        return $output;
    }
}
if ($year != null) {
    $sql .= " AND end>='{$year}' AND start<='{$year}'";
}
echo $sql;
$res = mysqli_query($con, $sql) or die("query error");
while ($row = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
    foreach ($row as &$r) {
        str_replace('flash', '/', $r);
    }
    $ru = $row['runways'];
    $ru = str_replace('fslash', '/', $ru);
    $ru = str_replace('-', '/', $ru);
    $ru = str_replace('...', '<br />Name: ', $ru);
    $ru = str_replace('..', ' Surface: ', $ru);
    $ru = str_replace('.', ' Length (m): ', $ru);
    $ru = str_lreplace('Name:', '', $ru);
    $row['terminals'] = str_replace('..', '<br />', $row['terminals']);
    $row['terminals'] = str_replace('.', ' Gates: ', $row['terminals']);
    ?>
			<div class="print">
	
			<h4>Manufacturer:</h4><h5> <?php 
    echo $row['manufacturer'];
    ?>
</h5>
			<h4>Name:</h4><h5> <?php 
    echo $row['name'];
    ?>
</h5>
			<h4>Price:</h4><h5 class="commas"> <?php 
    echo $row['price'];
示例#8
0
 /**
  * Handle the checkout process
  *
  * @access	public
  * @return	void
  *
  **/
 public function index()
 {
     if (!$this->_can_checkout()) {
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> you can\'t checkout right now: ' . $this->data['error']);
         redirect(app_setting('url', 'shop') . 'basket');
         return;
     }
     // --------------------------------------------------------------------------
     if ($this->user_model->is_logged_in() || $this->input->get('guest')) {
         //	Continue, user is logged in or is checking out as a guest
         if ($this->input->get('guest')) {
             $this->data['guest'] = TRUE;
         } else {
             $this->data['guest'] = FALSE;
         }
         // --------------------------------------------------------------------------
         //	Check the order to see if we need to take shipping information
         $this->data['requires_shipping'] = FALSE;
         foreach ($this->data['basket']->items as $item) {
             if ($item->type->requires_shipping) {
                 $this->data['requires_shipping'] = TRUE;
                 break;
             }
         }
         // --------------------------------------------------------------------------
         //	If there's no shipping and only one payment gateway then skip this page
         //	entirely - simples! Unless they are a guest, in which case we need to take
         //	some personal details
         if (!$this->data['guest'] && !$this->data['requires_shipping'] && (count($this->data['payment_gateways']) == 1 || $this->data['basket']->totals->grand == 0)) {
             //	Save payment gateway info to the session
             if ($this->data['basket']->totals->grand != 0) {
                 $this->shop_basket_model->add_payment_gateway($this->data['payment_gateways'][0]->id);
             } else {
                 $this->shop_basket_model->remove_payment_gateway();
             }
             //	... and redirect to confirm
             $_uri = app_setting('url', 'shop') . 'checkout/confirm';
             $_uri .= $this->data['guest'] ? '?guest=true' : '';
             redirect($_uri);
             return;
         }
         // --------------------------------------------------------------------------
         //	If there's post data, then deal with that. If shipping is required then verify shipping info
         //	If not then punt onto shop/checkout/confirm
         if ($this->input->post()) {
             //	Validate
             $this->load->library('form_validation');
             if ($this->data['guest']) {
                 $this->form_validation->set_rules('first_name', 'First Name', 'xss_clean|required');
                 $this->form_validation->set_rules('last_name', 'Surname', 'xss_clean|required');
                 $this->form_validation->set_rules('email', 'Email', 'xss_clean|required|valid_email');
             }
             // --------------------------------------------------------------------------
             if ($this->data['requires_shipping']) {
                 $this->form_validation->set_rules('addressee', 'Addressee', 'xss_clean|required');
                 $this->form_validation->set_rules('line_1', 'Line_1', 'xss_clean|required');
                 $this->form_validation->set_rules('line_2', 'Line_2', 'xss_clean|required');
                 $this->form_validation->set_rules('town', 'Town', 'xss_clean|required');
                 $this->form_validation->set_rules('postcode', 'Postcode', 'xss_clean|required');
                 $this->form_validation->set_rules('country', 'Country', 'xss_clean|required');
                 //	If country is USA then us_state is required
                 if ($this->input->post('country') == 'ID OF USA') {
                     $this->form_validation->set_rules('us_state', 'State', 'xss_clean|required');
                 } else {
                     $this->form_validation->set_rules('us_state', 'State', 'xss_clean');
                 }
                 //	If country is AUSTRALIA then aus_state is required
                 if ($this->input->post('country') == 'ID OF AUSTRALIA') {
                     $this->form_validation->set_rules('aus_state', 'State', 'xss_clean|required');
                 } else {
                     $this->form_validation->set_rules('aus_state', 'State', 'xss_clean');
                 }
             }
             // --------------------------------------------------------------------------
             //	Payment gateway
             if ($this->data['basket']->totals->grand > 0) {
                 $this->form_validation->set_rules('payment_gateway', 'Payment Gateway', 'xss_clean|required|is_natural');
             }
             // --------------------------------------------------------------------------
             //	Set messages
             $this->form_validation->set_message('required', lang('fv_required'));
             $this->form_validation->set_message('is_natural', lang('fv_required'));
             $this->form_validation->set_message('valid_email', lang('fv_valid_email'));
             if ($this->form_validation->run()) {
                 //	Save personal info to session
                 if ($this->data['guest']) {
                     $_details = new stdClass();
                     $_details->first_name = $this->input->post('first_name');
                     $_details->last_name = $this->input->post('last_name');
                     $_details->email = $this->input->post('email');
                     $this->shop_basket_model->add_personal_details($_details);
                 } else {
                     //	In case it's already there for some reason
                     $this->shop_basket_model->remove_personal_details();
                 }
                 // --------------------------------------------------------------------------
                 //	Save shipping info to the session
                 if ($this->data['requires_shipping']) {
                     $_details = new stdClass();
                     $_details->addressee = $this->input->post('addressee');
                     $_details->line_1 = $this->input->post('line_1');
                     $_details->line_2 = $this->input->post('line_2');
                     $_details->town = $this->input->post('town');
                     $_details->postcode = $this->input->post('postcode');
                     $_details->country = $this->input->post('country');
                     if ($this->input->post('country') == 'ID OF USA') {
                         $_details->state = $this->input->post('us_state');
                     } elseif ($this->input->post('country') == 'ID OF AUSTRALIA') {
                         $_details->state = $this->input->post('aus_state');
                     } else {
                         $_details->state = '';
                     }
                     $this->shop_basket_model->add_shipping_details($_details);
                 } else {
                     //	In case it's already there for some reason
                     $this->shop_basket_model->remove_shipping_details();
                 }
                 // --------------------------------------------------------------------------
                 //	Redirect to the appropriate payment gateway. If there's only one, then
                 //	bump straight along to that one
                 if ($this->data['basket']->totals->grand > 0 && count($this->data['payment_gateways']) == 1) {
                     //	Save payment gateway info to the session
                     $this->shop_basket_model->add_payment_gateway($this->data['payment_gateways'][0]->id);
                     //	... and confirm
                     $_uri = app_setting('url', 'shop') . 'checkout/confirm';
                     $_uri .= $this->data['guest'] ? '?guest=true' : '';
                     redirect($_uri);
                 } elseif ($this->data['basket']->totals->grand > 0 && count($this->data['payment_gateways']) >= 1) {
                     foreach ($this->data['payment_gateways'] as $pg) {
                         if ($pg->id == $this->input->post('payment_gateway')) {
                             //	Save payment gateway info to the session
                             $this->shop_basket_model->add_payment_gateway($pg->id);
                             //	... and confirm
                             $_uri = app_setting('url', 'shop') . 'checkout/confirm';
                             $_uri .= $this->data['guest'] ? '?guest=true' : '';
                             redirect($_uri);
                             break;
                         }
                     }
                 } elseif ($this->data['basket']->totals->grand == 0) {
                     //	Incase it's already there for some reason
                     $this->shop_basket_model->remove_payment_gateway();
                     // --------------------------------------------------------------------------
                     $_uri = app_setting('url', 'shop') . 'checkout/confirm';
                     $_uri .= $this->data['guest'] ? '?guest=true' : '';
                     redirect($_uri);
                 }
                 // --------------------------------------------------------------------------
                 here();
                 //	Something went wrong.
                 $this->data['error'] = '<strong>Sorry,</strong> we couldn\'t verify your payment option. Please try again.';
             } else {
                 $this->data['error'] = lang('fv_there_were_errors');
             }
         }
         // --------------------------------------------------------------------------
         //	Set appropriate title
         $_titles = array();
         if ($this->data['guest']) {
             $_titles[] = 'Personal Details';
         }
         if ($this->data['requires_shipping']) {
             $_titles[] = 'Shipping Details';
         }
         if (count($this->data['payment_gateways']) > 1) {
             $_titles[] = 'Payment Options';
         }
         $this->data['page']->title = 'Checkout &rsaquo; ' . str_lreplace(', ', ' &amp; ', implode(', ', $_titles));
         // --------------------------------------------------------------------------
         //	Load veiws
         $this->load->view('structure/header', $this->data);
         $this->load->view('shop/' . $this->_skin->dir . '/checkout/checkout', $this->data);
         $this->load->view('structure/footer', $this->data);
     } else {
         $this->data['page']->title = 'Checkout &rsaquo; Please Sign In';
         // --------------------------------------------------------------------------
         $this->lang->load('auth/auth');
         // --------------------------------------------------------------------------
         $this->load->view('structure/header', $this->data);
         $this->load->view('shop/' . $this->_skin->dir . '/checkout/signin', $this->data);
         $this->load->view('structure/footer', $this->data);
     }
 }
示例#9
0
 public function special_storage($prop_key, $prop_val)
 {
     global $APP;
     if (strpos($prop_key, "str_") !== FALSE) {
         if ($this->obj_debug) {
             echo "In Special_storage function() for prop: {$prop_key}<br/><br/>";
         }
         $content_mime_type = "text/plain";
         $content_extension = "txt";
         $original_content_extension = $content_extension;
         $sha1_string = sha1(microtime() . $prop_key . $prop_val . rand(3, 5));
         $keyname = $GLOBALS['settings'][$APP['fs']->kind]['paths']['strings']['@attributes']['value'] . "/" . $sha1_string . "." . $content_extension;
         $bucket_name = $GLOBALS['settings'][$APP['fs']->kind][$APP['fs']->bucket_syntax()]['@attributes']['value'];
         $content_detection_info = get_mime_and_extension($prop_val);
         // GIVES MIME TYPE, EXTENSION
         $content_mime_type = $content_detection_info[0];
         $content_extension = $content_detection_info[1];
         if (!stringEndsWith($keyname, $content_extension)) {
             $keyname = str_lreplace($original_content_extension, $content_extension, $keyname);
         }
         $APP['fs']->create_object(false, $bucket_name, $keyname, $prop_val, $content_mime_type);
         $string_url = $APP['fs']->key_url($bucket_name, $keyname);
         $sha1_string2 = sha1($prop_key . microtime() . $prop_val . rand(1, 20));
         $props_string = array();
         $props_string['id'] = $sha1_string2;
         $props_string['val'] = $string_url;
         $new_string = new strings();
         $new_string->create($props_string);
         $prop_val = $sha1_string2;
     }
     // end if
     return $prop_val;
 }
 /**
  * Process content of CSV file
  *
  * @since 0.1
  **/
 public static function process_csv()
 {
     if (isset($_POST['_wpnonce-is-iu-import-users-users-page_import'])) {
         check_admin_referer('is-iu-import-users-users-page_import', '_wpnonce-is-iu-import-users-users-page_import');
         if (isset($_FILES['users_csv']['tmp_name'])) {
             // Setup settings variables
             $filename = $_FILES['users_csv']['tmp_name'];
             $password_nag = isset($_POST['password_nag']) ? $_POST['password_nag'] : false;
             $users_update = isset($_POST['users_update']) ? $_POST['users_update'] : false;
             $new_user_notification = isset($_POST['new_user_notification']) ? $_POST['new_user_notification'] : false;
             //use AJAX?
             if (!empty($_POST['ajaximport'])) {
                 //check for a imports directory in wp-content
                 $upload_dir = wp_upload_dir();
                 $import_dir = $upload_dir['basedir'] . "/imports/";
                 //create the dir and subdir if needed
                 if (!is_dir($import_dir)) {
                     wp_mkdir_p($import_dir);
                 }
                 //figure out filename
                 $filename = $_FILES['users_csv']['name'];
                 $count = 0;
                 while (file_exists($import_dir . $filename)) {
                     if ($count) {
                         $filename = str_lreplace("-" . $count . "." . $filetype['ext'], "-" . strval($count + 1) . "." . $filetype['ext'], $filename);
                     } else {
                         $filename = str_lreplace("." . $filetype['ext'], "-1." . $filetype['ext'], $filename);
                     }
                     $count++;
                     //let's not expect more than 50 files with the same name
                     if ($count > 50) {
                         die("Error uploading file. Too many files with the same name. Clean out the " . $import_dir . " directory on your server.");
                     }
                 }
                 //save file
                 if (strpos($_FILES['users_csv']['tmp_name'], $upload_dir['basedir']) !== false) {
                     //was uploaded and saved to $_SESSION
                     rename($_FILES['users_csv']['tmp_name'], $import_dir . $filename);
                 } else {
                     //it was just uploaded
                     move_uploaded_file($_FILES['users_csv']['tmp_name'], $import_dir . $filename);
                 }
                 //redurect to the page to run AJAX
                 $url = admin_url('users.php?page=import-users-from-csv&import=resume&filename=' . $filename);
                 $url = add_query_arg(array('password_nag' => $password_nag, 'new_user_notification' => $new_user_notification, 'users_update' => $users_update), $url);
                 wp_redirect($url);
                 exit;
             } else {
                 $results = self::import_csv($filename, array('password_nag' => $password_nag, 'new_user_notification' => $new_user_notification, 'users_update' => $users_update));
                 // No users imported?
                 if (!$results['user_ids']) {
                     wp_redirect(add_query_arg('import', 'fail', wp_get_referer()));
                 } elseif ($results['errors']) {
                     wp_redirect(add_query_arg('import', 'errors', wp_get_referer()));
                 } else {
                     wp_redirect(add_query_arg('import', 'success', wp_get_referer()));
                 }
                 exit;
             }
         }
         wp_redirect(add_query_arg('import', 'file', wp_get_referer()));
         exit;
     }
 }
示例#11
0
function addJSCSS($final)
{
    $res = CSSJS();
    $css = $res['css'];
    $js = $res['js'];
    $final = str_lreplace('</head>', $css . '</head>', $final);
    $final = str_lreplace('</body>', $js . '</body>', $final);
    return $final;
}
function avc_get_filter_relationships($filter_values)
{
    $ret = array();
    global $wpdb;
    global $TABLES;
    global $FILTERS;
    // Transform filter_values into an array
    $filters = explode(',', $filter_values);
    // Determine which filter is used, and connect with the underlying database table
    $split = explode(':', $filters[0]);
    // anvelope-latime
    $name = explode('-', $split[0]);
    // anvelope
    $index = array_search($name[0], $TABLES);
    // 0
    $filter_column_names = $FILTERS[$index];
    // ['anvelope-latime', .... 'amvelope-brand']
    $table = $wpdb->prefix . 'filter_' . $name[0];
    // wp_filter_anvelope
    // 0. Initialize the return arrays
    // - each array will contain all elements by default
    // - later these will be intersected when looping through the filters
    foreach ($filter_column_names as $index => $filter_column_name) {
        $column = avc_remove_filter_prefix($filter_column_name);
        $query = $wpdb->get_results("SELECT {$column} FROM " . $table);
        $ret[$index] = array_unique(avc_prettify_single_relation($query));
    }
    // 1. Loop through all filters individually
    // - intersect the return arrays with relationships from the database
    foreach ($filters as $filter) {
        // Get filter name and value
        // returns: [0] => anvelope-latime, [1] => .33
        $split = explode(':', $filter);
        $filter_name = $split[0];
        // anvelope-latime
        if (isset($split[1])) {
            $filter_value = $split[1];
            // .33
            // Do the query
            $column = avc_remove_filter_prefix($filter_name);
            $value = explode('.', $filter_value);
            if (isset($value[1])) {
                foreach ($filter_column_names as $index => $filter_column_name) {
                    $column_name = avc_remove_filter_prefix($filter_column_name);
                    if ($column != $column_name) {
                        $relation = $wpdb->get_results("SELECT " . $column_name . " FROM " . $table . " WHERE " . $column . " ='" . $value[1] . "' ");
                        $ret[$index] = array_unique(array_intersect($ret[$index], avc_prettify_single_relation($relation)));
                    }
                }
            }
        }
    }
    // 2. When there are multiple filters active
    // Build the SQL query's WHERE clause
    $where = '';
    $multiple_filters = 0;
    foreach ($filters as $filter) {
        // Get filter name and value
        // returns: [0] => anvelope-latime, [1] => .33
        $split = explode(':', $filter);
        if (isset($split[1])) {
            $column = avc_remove_filter_prefix($split[0]);
            // Remove . from the value
            // returns .'33' => '33'
            $value = explode('.', $split[1]);
            if (isset($value[1])) {
                $where .= $column . " = '" . $value[1] . "' ";
                $where .= " AND ";
                $multiple_filters++;
            }
        }
    }
    if ($multiple_filters > 1) {
        $where = str_lreplace(" AND ", "", $where);
        // Execute the SQL
        $relations = $wpdb->get_results("SELECT * FROM " . $table . " WHERE " . $where);
        $relations = avc_prettify_relationships($relations);
        // intersect the results from 1.) with these new results
        foreach ($filter_column_names as $index => $filter_column_name) {
            $ret[$index] = array_unique(array_intersect($ret[$index], $relations[$index]));
        }
    }
    return $ret;
}
示例#13
0
        $commitRemoved = $commit->removed;
        // general Info
        $message .= '<div><strong>Branch: </strong>' . $branch . '</div>';
        $message .= '<div><strong>Commit: </strong><a href="' . $commitUrl . '" class="commit">' . $commitId . '</a></div>';
        $message .= '<div><strong>Date: </strong>' . $commitTimestamp . '</div>';
        $message .= '<div><strong>Message</strong><br/>' . nl2br(str_lreplace('\\n', '', $commitMessage)) . '</div>';
        $message .= '</div>';
        $message .= '<div style="margin-top: 10px;font-size: 15px;font-weight:bold; font-family: Arial, monospace;">Changed paths:</div>';
        $message .= '<div style="margin-top: 10px; border: 1px solid #d2e6ed;">';
        foreach ($commit->added as $commitAdded) {
            $message .= '<div style="background: #EAF2F5; color: #000; font-size: 12px; font-family: Arial, monospace; padding: 1px 4px; border-bottom: 1px solid #d2e6ed;">A   ' . $commitAdded . '</div>';
        }
        foreach ($commit->modified as $commitModified) {
            $message .= '<div style="background: #EAF2F5; color: #000; font-size: 12px; font-family: Arial, monospace; padding: 1px 4px; border-bottom: 1px solid #d2e6ed;">M   ' . $commitModified . '</div>';
        }
        foreach ($commit->removed as $commitRemoved) {
            $message .= '<div style="background: #EAF2F5; color: #000; font-size: 12px; font-family: Arial, monospace; padding: 1px 4px; border-bottom: 1px solid #d2e6ed;">D   ' . $commitRemoved . '</div>';
        }
        $message .= '</div>';
    }
    $mailMessage = str_replace('\\n', ' ', str_lreplace('\\n', ' ', $firstCommitMessage));
    $from = $commiterName . ' <' . $commiterEmail . '>';
}
$message .= '<div style="margin-top: 10px;font-size: 12px; font-family: Arial, monospace;">--<br/>You received this message because you are subscribed to Tirasa ' . $repoName . ' project.</div>';
$message .= '</body></html>';
$subject = '[' . $repoName . '] ' . $mailMessage;
$smtpconfig;
require_once "./email.class.php";
require "./smtp.config.php";
$smtp = new smtp($smtpconfig->server, $smtpconfig->port, true, $smtpconfig->user, $smtpconfig->pass);
$smtp->sendmail($to, $smtpconfig->from, $subject, $message, 'HTML');
示例#14
0
function STROM_loop_articles($ID, $i)
{
    $template = get_field('template', $ID);
    $continued = get_field('fortsat', $ID);
    $show_author = get_field('vis_forfatter', $ID);
    $author = get_field('forfatter', $ID);
    $img_text = get_field('img_text', $ID);
    $categories = get_the_terms($ID, 'category');
    $colorScheme = get_field('farvetema', $ID);
    if ($categories) {
        foreach ($categories as $value) {
            $category .= $value->name . ' & ';
        }
        $category = str_lreplace(' & ', '', $category);
    }
    switch ($template) {
        case 'split-page-left':
            $templateShort = 'split';
            break;
        case 'split-page-right':
            $templateShort = 'split';
            break;
        case '2-columns':
            $templateShort = 'col';
            break;
        case '4-columns':
            $templateShort = 'col';
            break;
        case 'img-fullscreen':
            $templateShort = 'img-full';
            break;
        case 'img-collage':
            $templateShort = 'img-col';
            break;
    }
    switch ($template) {
        case 'split-page-left':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            //Article image start
            $html .= '<aside class="split-left" style="background-image: url(' . get_field('img', $ID) . ');">';
            //Print image text
            if ($img_text !== '') {
                $html .= '<div class="img-text ' . $colorScheme . '"><p>' . strip_tags(get_field('img_text', $ID)) . '</p></div>';
            }
            //Article image end
            $html .= '</aside>';
            //Content area start
            $html .= '<article class="split-right ' . $colorScheme . '">';
            //Print header
            if ($continued == false) {
                $html .= '<header>';
                $html .= '<div class="type">' . $category . '</div>';
                $html .= '<h1>' . get_the_title($ID) . '</h1>';
                if ($show_author) {
                    $html .= '<p class="author">By ' . $author . '</p>';
                }
                $html .= '</header>';
            }
            //Print content
            $html .= get_field('content', $ID);
            //Content area end
            $html .= '</article>';
            $html .= '</div>';
            break;
        case 'split-page-right':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            //Content area start
            $html .= '<article class="split-left ' . $colorScheme . '">';
            //Print header
            if ($continued == false) {
                $html .= '<header>';
                $html .= '<div class="type">' . $category . '</div>';
                $html .= '<h1>' . get_the_title($ID) . '</h1>';
                if ($show_author) {
                    $html .= '<p class="author">By ' . $author . '</p>';
                }
                $html .= '</header>';
            }
            //Print content
            $html .= get_field('content', $ID);
            //Content area end
            $html .= '</article>';
            //Article image start
            $html .= '<aside class="split-right" style="background-image: url(' . get_field('img', $ID) . ');">';
            //Print image text
            if ($img_text !== '') {
                $html .= '<div class="img-text ' . $colorScheme . '"><p>' . strip_tags(get_field('img_text', $ID)) . '</p></div>';
            }
            //Article image end
            $html .= '</aside>';
            $html .= '</div>';
            break;
        case '2-columns':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            $html .= '<article class="' . $colorScheme . '">';
            //Print header
            if ($continued == false) {
                $html .= '<header>';
                $html .= '<div class="type">' . $category . '</div>';
                $html .= '<h1>' . get_the_title($ID) . '</h1>';
                if ($show_author) {
                    $html .= '<p class="author">By ' . $author . '</p>';
                }
                $html .= '</header>';
            }
            //Print content
            $html .= '<div class="col-inner col-2">';
            $html .= get_field('content', $ID);
            $html .= '</div>';
            //Content area end
            $html .= '</article>';
            $html .= '</div>';
            break;
        case '4-columns':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            $html .= '<article class="' . $colorScheme . '">';
            //Print header
            if ($continued == false) {
                $html .= '<header>';
                $html .= '<div class="type">' . $category . '</div>';
                $html .= '<h1>' . get_the_title($ID) . '</h1>';
                if ($show_author) {
                    $html .= '<p class="author">By ' . $author . '</p>';
                }
                $html .= '</header>';
            }
            //Print content
            $html .= '<div class="col-inner col-4">';
            $html .= get_field('content', $ID);
            $html .= '</div>';
            //Content area end
            $html .= '</article>';
            $html .= '</div>';
            break;
        case 'img-fullscreen':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            //Content area start
            $html .= '<div class="img-holder ' . $colorScheme . '">';
            //Print content
            $html .= '<div class="img-holder-inner" style="background-image: url(' . get_field('img', $ID) . ');">';
            //Print image text
            $img_text = get_field('img_text', $ID);
            if ($img_text !== '') {
                $html .= '<div class="img-text ' . $colorScheme . '"><p>' . strip_tags(get_field('img_text', $ID)) . '</p></div>';
            }
            $html .= '</div>';
            //Content area end
            $html .= '</div>';
            $html .= '</div>';
            break;
        case 'img-collage':
            $html .= '<div class="slide tmpl ' . $templateShort . '-tmpl ' . $colorScheme . '" data-anchor="slide' . $i . '">';
            //Print content
            $fields = get_field('img_array', $ID);
            if ($fields) {
                foreach ($fields as $field) {
                    $html .= '<div class="img-col-item" style="background-image: url(' . $field['img'] . ');"></div>';
                }
            }
            //Print image text
            $img_text = get_field('img_text', $ID);
            if ($img_text !== '') {
                $html .= '<div class="img-text ' . $colorScheme . '"><p>' . strip_tags(get_field('img_text', $ID)) . '</p></div>';
            }
            $html .= '</div>';
            break;
    }
    echo $html;
}
示例#15
0
function importAudios()
{
    $categories = array('assets', 'dialogs', 'music', 'other');
    $foldersToScan = array();
    $jsonData = array();
    // Create sounds and music folders if not exists
    $soundsFolder = dirname(__FILE__) . '/sounds';
    if (!file_exists($soundsFolder)) {
        mkdir($soundsFolder, 0777, true);
    }
    $musicFolder = dirname(__FILE__) . '/sounds/music';
    if (!file_exists($musicFolder)) {
        mkdir($musicFolder, 0777, true);
    }
    foreach ($categories as $category) {
        $jsonData[$category] = array();
        switch ($category) {
            case 'music':
                $foldersToScan = array($category . '/');
                break;
            default:
                $foldersToScan = array($category . '/general/', $category . '/audiosprites/');
                break;
        }
        for ($i = 0; $i < count($foldersToScan); $i++) {
            $filesToImport = scandir("import/sounds/" . $foldersToScan[$i]);
            $spritesToImport = array();
            $audiosprite = true;
            $pos = strrpos($foldersToScan[$i], "audiosprites");
            if ($pos === false) {
                $audiosprite = false;
            }
            // Add all JSON files to filesToImport
            foreach ($filesToImport as $fileName) {
                if ($fileName == "." || $fileName == "..") {
                    continue;
                }
                $ext = pathinfo($fileName, PATHINFO_EXTENSION);
                if ($audiosprite && $ext != "json" && $ext != "JSON") {
                    continue;
                }
                $spritesToImport[] = $fileName;
            }
            $importFolder = "import/sounds/" . $foldersToScan[$i];
            foreach ($spritesToImport as $spriteName) {
                $importFile = $importFolder . $spriteName;
                $targetFile = $soundsFolder . "/" . $spriteName;
                if (is_file($importFile)) {
                    if ($category === 'music') {
                        $targetFile = $soundsFolder . "/music/" . $spriteName;
                    }
                    copy($importFile, $targetFile);
                } else {
                    continue;
                }
                if ($audiosprite) {
                    $audioSpriteName = str_lreplace(".json", "", $spriteName);
                    if (!isset($jsonData[$category]['audiosprites'])) {
                        $jsonData[$category]['audiosprites'] = array();
                    }
                    // Read json file to php array
                    $jsonData[$category]['audiosprites'][$audioSpriteName] = json_decode(file_get_contents($importFile), true);
                    foreach ($jsonData[$category]['audiosprites'][$audioSpriteName]["resources"] as $soundFile) {
                        // Copy audiofiles
                        if (is_file($importFolder . $soundFile)) {
                            copy($importFolder . $soundFile, $soundsFolder . "/" . $soundFile);
                        }
                    }
                } else {
                    $audioName = str_lreplace(".mp3", "", $spriteName);
                    $audioName = str_lreplace(".ogg", "", $audioName);
                    $audioName = str_lreplace(".wav", "", $audioName);
                    if (!isset($jsonData[$category]['general'])) {
                        $jsonData[$category]['general'] = array();
                    }
                    if (!isset($jsonData[$category]['general'][$audioName])) {
                        $jsonData[$category]['general'][$audioName] = array($targetFile);
                    } else {
                        $jsonData[$category]['general'][$audioName][] = $targetFile;
                    }
                }
            }
        }
    }
    // Print response
    header('Cache-Control: no-cache, must-revalidate');
    // HTTP/1.1
    header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
    // Date in the past
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($jsonData);
    exit;
}
示例#16
0
 /**
  * Ask user if he wants to add it to router.
  * Ask for domains.
  * Alter router.
  */
 protected function addToRouter()
 {
     if ($this->option('skip-router')) {
         return $this->output('Skipping global router changes');
     }
     if ($hosts = $this->argument('hosts')) {
         $hosts = explode(',', $hosts);
     } else {
         $hosts = [];
         do {
             $host = $this->askQuestion('Enter hostname:');
         } while ($host && ($hosts[] = $host) || $host);
     }
     $this->output('Updating global router');
     /**
      * First we build array.
      */
     $append = '    \'' . $this->app . '\' => [
         \'host\' => [';
     foreach ($hosts as $host) {
         $append .= '
             \'' . $host . '\',';
     }
     if ($hosts) {
         $append .= '
         ';
     }
     $append .= '],
     ],
 ';
     /**
      * Read current router content.
      */
     $routerPath = BASE_PATH . 'config' . path('ds') . 'router.php';
     $router = file_get_contents($routerPath);
     /**
      * Build new router.
      */
     $newRouter = str_lreplace('],', $append . '],', $router);
     /**
      * Write new router.
      */
     file_put_contents($routerPath, $newRouter);
     $this->output('Global router has been updated.');
 }
示例#17
0
        // cycle through checkboxes and add to sql statement according to whats checked else do the other adding to sql statement
        if ($fieldname == "day") {
            $sql .= $fieldname . " REGEXP '";
            if (!empty($_POST['day'])) {
                foreach ($_POST['day'] as $day) {
                    $sql .= $day . "|";
                }
            }
            $sql = str_lreplace("|", "' AND ", $sql);
        } else {
            $wfieldname = preg_replace('!\\s+!', '%', $wfieldname);
            $sql .= $fieldname . " LIKE '%" . $wfieldname . "%' AND ";
        }
    }
}
$sql = str_lreplace("AND", "", $sql);
// remove trailing AND in sql statement
if ($_POST['start'] && $_POST['end']) {
    $sql .= "AND `start` BETWEEN '" . $_POST['start'] . ":00' AND '" . $_POST['end'] . ":00'  ";
} elseif ($_POST['start']) {
    $sql .= "AND `start` > '" . $start . ":00'";
} elseif ($_POST['end']) {
    $sql .= "AND `end` > '" . $end . ":00'";
}
//	echo $sql.'<br>';
$result = $db->query($sql);
if ($result->num_rows > 0) {
    print '<section id="schedule-section">
	<h4 class="section-heading">Search Result For ' . ucwords(str_replace("_", " ", $_POST['season'])) . '</h2>
	<a id="open-search-button" class="btn btn-default btn-xl">Search Again</a>
	<div class="component">