Пример #1
0
 /**
  *  Class Constructor
  *
  *  @access public
  *  @return void
  *
  */
 public function __construct(Connection $dbal, $sequenceTableName)
 {
     $this->dbal = $dbal;
     if (empty($sequenceTableName)) {
         throw new LedgerException(sprinf("The sequence table name is empty string"));
     }
     $this->sequenceTableName = $sequenceTableName;
 }
Пример #2
0
 /**
  * Verifies and returns the configuration.
  *
  * @return array
  *
  * @throws \RuntimeException
  */
 protected function getConfig()
 {
     if (false === isset($this->config['pike']['datatable'])) {
         throw new \RuntimeException('No [pike][datatable] section configured');
     }
     if (false === isset($this->config['pike']['datatable'][$this->getName()])) {
         throw new \RuntimeException(sprinf('No datatable configuration found for %s', $this->getName()));
     }
     return $this->config['pike']['datatable'][$this->getName()];
 }
 public function before(Request $request, Application $app)
 {
     if (!$request->headers->get('X-Authentication-Token')) {
         $app->abort(401, 'Not authenticated. Header X-Authentication-Token missing.');
     }
     $token = $request->headers->get('X-Authentication-Token');
     if (!$this->isAuthorized($token, $app)) {
         $msg = sprinf('Not authenticated. X-Authentication-Token %s is not authorized.', $token);
         $app->abort(401, $msg);
     }
 }
Пример #4
0
 public function set(Base $record, $name, $value)
 {
     if ($value !== null && !$value instanceof Base) {
         if (is_object($value)) {
             $message = sprintf("Must pass instance of Rails\\ActiveRecord\\Base as value, instance of %s passed", get_class($value));
         } else {
             $message = sprintf("Must pass either null or instance of Rails\\ActiveRecord\\Base as value, %s passed", gettype($value));
         }
         throw new Exception\InvalidArgumentException($message);
     }
     $options = $record->getAssociations()->get($name);
     switch ($options['type']) {
         case 'belongsTo':
             if ($value) {
                 $this->matchClass($value, $options['className']);
                 $value = $value->id();
             }
             $record->setAttribute($options['foreignKey'], $value);
             break;
         case 'hasOne':
             $foreignKey = $options['foreignKey'];
             if ($value) {
                 $this->matchClass($value, $options['className']);
                 $value->setAttribute($foreignKey, $record->id());
             }
             if ($record->isNewRecord()) {
                 return;
             }
             $oldValue = $record->getAssociation($name);
             if ($value && $oldValue && $value->getAttribute($foreignKey) == $oldValue->getAttribute($foreignKey)) {
                 return;
             }
             if ($oldValue) {
                 $oldValue->setAttribute($foreignKey, null);
             }
             if (!static::transaction(function () use($name, $value, $oldValue) {
                 if ($value) {
                     if (!$value->save()) {
                         return false;
                     }
                 }
                 if ($oldValue) {
                     if (!$oldValue->save()) {
                         return false;
                     }
                 }
             })) {
                 throw new RecordNotSavedException(sprinf("Failed to save new associated %s", strtolower($record::getService('inflector')->underscore($name)->humanize())));
             }
             break;
     }
     return true;
 }
Пример #5
0
 public function subclassDeleteAction(Request $request)
 {
     /** @var $em EntityManager */
     $em = $this->get('doctrine.orm.entity_manager');
     $subclass = $em->getRepository('WealthbotAdminBundle:Subclass')->find($request->get('id'));
     if (!$subclass) {
         throw $this->createNotFoundException(sprinf('Subclass with ID %s does not exist.', $request->get('id')));
     }
     $em->remove($subclass);
     $em->flush();
     return $this->getJsonResponse(array('status' => 'success'));
 }
Пример #6
0
 public function watched_episode()
 {
     if (!isset($_POST['episode_id'])) {
         wp_send_json_error(__('No episode ID provided.', 'life-control'));
     }
     $episode = get_post($_POST['episode_id']);
     if (!$episode || 'episode' != $episode->post_type) {
         wp_send_json_error(__("Provided ID isn't a episode.", 'life-control'));
     }
     $watched = get_post_meta($episode->ID, 'user_' . get_current_user_id() . '_watched', true);
     if ($watched) {
         wp_send_json_error(sprinf(__('You already watched %s', 'life-control'), $episode->post_title));
     }
     update_post_meta($episode->ID, 'user_' . get_current_user_id() . '_watched', time());
     wp_send_json_success(__('You mark this episode as watched.', 'life-control'));
 }
 /**
  *  Gets the URL that the user should generally be sent back to after payment completion offiste
  *  Adds the reg_url_link in order to remember which session we were in the middle of processing
  * @param EE_Registration or int, current registration we want to link back to in the return url.
  * @param boolean $urlencode whether or not to url-encode the url (if true, you probably intend to pass
  * this string as a URL parameter itself, or maybe a post parameter)
  *  @return string URL on the current site of the thank_you page, with parameters added on to know which registration was just 
  * processed in order to correctly display the payment status. And it gets URL-encoded by default
  */
 protected function _get_notify_url($registration, $urlencode = false)
 {
     //if $registration is an ID instead of an EE_Registration, make it an EE_Registration
     if (!$registration instanceof EE_Registration) {
         $registration = $this->_REG->get_one_by_ID($registration);
     }
     if (empty($registration)) {
         $msg[0] = __("Cannot get Notify URL for gateway. Invalid registration", 'event_espresso');
         $msg[1] = sprinf(__("Registration being used is %s.", 'event_espresso'), print_r($registration, true));
         EE_Error::add_error(implode("||", $msg), __FILE__, __FUNCTION__, __LINE__);
         return '';
     }
     //get a registration that's currently getting processed
     /*@var $registration EE_Registration */
     $url = add_query_arg(array('e_reg_url_link' => $registration->reg_url_link(), 'ee_gateway' => $this->_gateway_name), get_permalink(EE_Registry::instance()->CFG->core->txn_page_id));
     if ($urlencode) {
         $url = urlencode($url);
     }
     return $url;
 }
Пример #8
0
 public static function number_to_human_size($size, $precision = 1)
 {
     $size = float($size);
     $return = null;
     if ($size == 1) {
         $return = "1 Byte";
     } elseif ($size < 1024) {
         $return = sprintf("%d Bytes", $size);
     } elseif ($size < 1024 * 1024) {
         $return = sprintf("%.{$precision}f KB", $size / (1024 * 1024));
     } elseif ($size < 1024 * 1024 * 1024) {
         $return = sprinf("%.{$precision}f MB", $size / (1024 * 1024 * 1024));
     } elseif ($size < 1024 * 1024 * 1024 * 1024) {
         $return = sprinf("%.{$precision}f GB", $size / (1024 * 1024 * 1024 * 1024));
     } else {
         $return = sprintf("%.{$precision}f TB", $size / (1024 * 1024 * 1024 * 1024 * 1024));
     }
     return str_replace(".0", "", $return);
 }
 /**
  * This method is used to wright translation for mails.
  * This wrights subject translation files
  * (in root/mails/lang_choosen/lang.php or root/_PS_THEMES_DIR_/mails/lang_choosen/lang.php)
  * and mails files.
  */
 protected function submitTranslationsMails()
 {
     $arr_mail_content = array();
     $arr_mail_path = array();
     if (Tools::getValue('core_mail')) {
         $arr_mail_content['core_mail'] = Tools::getValue('core_mail');
         // Get path of directory for find a good path of translation file
         if ($this->theme_selected != self::DEFAULT_THEME_NAME) {
             $arr_mail_path['core_mail'] = $this->translations_informations[$this->type_selected]['override']['dir'];
         } else {
             $arr_mail_path['core_mail'] = $this->translations_informations[$this->type_selected]['dir'];
         }
     }
     if (Tools::getValue('module_mail')) {
         $arr_mail_content['module_mail'] = Tools::getValue('module_mail');
         // Get path of directory for find a good path of translation file
         if ($this->theme_selected != self::DEFAULT_THEME_NAME) {
             $arr_mail_path['module_mail'] = $this->translations_informations['modules']['override']['dir'] . '{module}/mails/' . $this->lang_selected->iso_code . '/';
         } else {
             $arr_mail_path['module_mail'] = $this->translations_informations['modules']['dir'] . '{module}/mails/' . $this->lang_selected->iso_code . '/';
         }
     }
     // Save each mail content
     foreach ($arr_mail_content as $group_name => $all_content) {
         foreach ($all_content as $type_content => $mails) {
             foreach ($mails as $mail_name => $content) {
                 $module_name = false;
                 $module_name_pipe_pos = stripos($mail_name, '|');
                 if ($module_name_pipe_pos) {
                     $module_name = substr($mail_name, 0, $module_name_pipe_pos);
                     if (!Validate::isModuleName($module_name)) {
                         throw new PrestaShopException(sprinf(Tools::displayError('Invalid module name "%s"'), $module_name));
                     }
                     $mail_name = substr($mail_name, $module_name_pipe_pos + 1);
                     if (!Validate::isTplName($mail_name)) {
                         throw new PrestaShopException(sprintf(Tools::displayError('Invalid mail name "%s"'), $mail_name));
                     }
                 }
                 if ($type_content == 'html') {
                     $content = Tools::htmlentitiesUTF8($content);
                     $content = htmlspecialchars_decode($content);
                     // replace correct end of line
                     $content = str_replace("\r\n", PHP_EOL, $content);
                     $title = '';
                     if (Tools::getValue('title_' . $group_name . '_' . $mail_name)) {
                         $title = Tools::getValue('title_' . $group_name . '_' . $mail_name);
                     }
                     $string_mail = $this->getMailPattern();
                     $content = str_replace(array('#title', '#content'), array($title, $content), $string_mail);
                     // Magic Quotes shall... not.. PASS!
                     if (_PS_MAGIC_QUOTES_GPC_) {
                         $content = stripslashes($content);
                     }
                 }
                 if (Validate::isCleanHTML($content)) {
                     $path = $arr_mail_path[$group_name];
                     if ($module_name) {
                         $path = str_replace('{module}', $module_name, $path);
                     }
                     file_put_contents($path . $mail_name . '.' . $type_content, $content);
                 } else {
                     throw new PrestaShopException(Tools::displayError('HTML e-mail templates cannot contain JavaScript code.'));
                 }
             }
         }
     }
     // Update subjects
     $array_subjects = array();
     if (($subjects = Tools::getValue('subject')) && is_array($subjects)) {
         $array_subjects['core_and_modules'] = array('translations' => array(), 'path' => $arr_mail_path['core_mail'] . 'lang.php');
         foreach ($subjects as $subject_translation) {
             $array_subjects['core_and_modules']['translations'] = array_merge($array_subjects['core_and_modules']['translations'], $subject_translation);
         }
     }
     if (!empty($array_subjects)) {
         foreach ($array_subjects as $infos) {
             $this->writeSubjectTranslationFile($infos['translations'], $infos['path']);
         }
     }
     if (Tools::isSubmit('submitTranslationsMailsAndStay')) {
         $this->redirect(true);
     } else {
         $this->redirect();
     }
 }
Пример #10
0
    function rotateTable($sourceTable,$month,$action) {
        // create a new table tableYYYYMM and copy data from the main table into it
        // if no month is supplied, the default is the previous month

        if (!$month) $month=date('Ym', mktime(0, 0, 0, date("m")-1, "01", date("Y")));

        if (!$sourceTable) $sourceTable=$this->table;

        if (preg_match("/^(\w+)\d{6}$/",$sourceTable,$m)) {
            $destinationTable=$m[1].$month;
        } else {
            $destinationTable=$sourceTable.$month;
        }

        print("rotateTable($sourceTable,$month,$destinationTable)\n");

        if ($sourceTable == $destinationTable) {
            $log=sprintf("Error: cannot copy records to the same table %s.\n",$destinationTable);
            syslog(LOG_NOTICE,$log);
            print $log;
            return 0;;
        }

        $createTableFile=$this->CDRTool['Path'].$this->createTableFile;

        if (!$this->createTableFile || !is_readable($createTableFile)) {
            $log=sprintf("Error: cannot locate mysql creation file\n");
            syslog(LOG_NOTICE,$log);
            print $log;
            return 0;;
        }

        $lockFile="/var/lock/CDRTool_".$this->cdr_source."_rotateTable.lock";

        $f=fopen($lockFile,"w");
        if (flock($f, LOCK_EX + LOCK_NB, $w)) {
            if ($w) {
                $log=sprintf("Another CDRTool rotate table is in progress. Aborting.\n");
                syslog(LOG_NOTICE,$log);
                print $log;
                return 0;;
            }
        } else {
            $log=sprintf("Another CDRTool rotate table is in progress. Aborting.\n");
            syslog(LOG_NOTICE,$log);
            print $log;
            return 0;;
        }

        $b=time();

        if (!preg_match("/^(\d{4})(\d{2})$/",$month,$m)) {
            print "Error: Month $month must be in YYYYMM format\n";
            return 0;
        } else {
            if ($m[2] > 12) {
                print "Error: Month must be in YYYYMM format\n";
                return 0;
            }

            $lastMonth=$month;
            $startSQL=$m[1]."-".$m[2]."-01";
            $stopSQL =date('Y-m-01', mktime(0, 0, 0, $m[2]+1, "01", $m[1]));
        }

        $query=sprintf("select count(*) as c from %s where %s >='%s' and %s < '%s'\n",
                    addslashes($sourceTable),
                    addslashes($this->CDRFields['startTime']),
                    addslashes($startSQL),
                    addslashes($this->CDRFields['startTime']),
                    addslashes($stopSQL)
                    );


        if ($this->CDRdb->query($query)) {
            $this->CDRdb->next_record();
            $rowsSourceTable=$this->CDRdb->f('c');
            $log=sprintf ("Source table %s has %d records in month %s\n",$sourceTable,$rowsSourceTable,$month);
            syslog(LOG_NOTICE,$log);
            print $log;
            if (!$rowsSourceTable) return 1;

        } else {
            $log=sprintf ("Error: %s (%s)\n",$this->table,$this->CDRdb->Error);
            syslog(LOG_NOTICE,$log);
            print $log;
            return 0;
        }

        $query=sprintf("select count(*) as c from %s\n", addslashes($destinationTable));

        if ($this->CDRdb->query($query)) {
            $this->CDRdb->next_record();
            $rowsDestinationTable = $this->CDRdb->f('c');
            $log=sprintf ("Destination table %s has %d records\n",$destinationTable,$rowsDestinationTable);
            syslog(LOG_NOTICE,$log);
            print $log;

            if ($rowsDestinationTable != $rowsSourceTable) {
                $log=sprintf ("Error: source table has %d records and destination table has %d records\n",$rowsSourceTable,$rowsDestinationTable);
                syslog(LOG_NOTICE,$log);
                print $log;
            } else {
                $log=sprintf ("Tables are in sync\n");
                syslog(LOG_NOTICE,$log);
                print $log;
            }

        } else {
            $log=sprintf ("%s (%s)\n",$this->CDRdb->Error,$this->CDRdb->Errno);
            syslog(LOG_NOTICE,$log);
            print $log;

            if ($this->CDRdb->Errno==1146) {

                $destinationTableTmp=$destinationTable."_tmp";
                $query=sprintf("drop table if exists %s",addslashes($destinationTableTmp));
                print($query);
                $this->CDRdb->query($query);

                if ($query=file_get_contents($createTableFile)) {
                    $query=preg_replace("/CREATE TABLE.*/","CREATE TABLE $destinationTableTmp (",$query);
                    if (!$this->CDRdb->query($query)) {
                        $log=sprintf ("Error creating table %s: %s, %s\n",$destinationTableTmp,$this->CDRdb->Error,$query);
                        syslog(LOG_NOTICE,$log);
                        print $log;
                        return 0;
                    }
                } else {
                    $log=sprintf ("Cannot read file %s\n",$createTableFile);
                    syslog(LOG_NOTICE,$log);
                    print $log;
                    return 0;
                }

                // if we reached this point we start to copy records
                $query=sprintf("insert into %s select * from %s where %s >='%s' and %s < '%s'",
                addslashes($destinationTableTmp),
                addslashes($sourceTable),
                addslashes($this->CDRFields['startTime']),
                addslashes($startSQL),
                addslashes($this->CDRFields['startTime']),
                addslashes($stopSQL)
                );

                return ;

                if ($this->CDRdb->query($query)) {
                    $e=time();
                    $d=$e-$b;
                    $rps=0;
                    if ($this->CDRdb->affected_rows() && $d) $rps=$this->CDRdb->affected_rows()/$d;

                    $log=printf ("Copied %d CDRs into table %s in %d s @ %.0f rps\n",$this->CDRdb->affected_rows(),$destinationTableTmp,$d,$rps);
                    syslog(LOG_NOTICE,$log);
                    print $log;

                    $query=sprinf("rename table %s to %s", addslashes($destinationTableTmp),addslashes($destinationTableTmp));

                    if (!$this->CDRdb->query($query)) {
                        printf ("Error renaming table %s to %s: %s\n",$destinationTableTmp,$destinationTable,$this->CDRdb->Error);
                        return 0;
                    }
                } else {
                    printf ("Error copying records in table %s: %s\n",$destinationTable,$this->CDRdb->Error);
                    return 0;
                }
            }
        }
    }
Пример #11
0
/**
 * Create a jquery.ui icon
 * @param string $icon the icon ID. Ex: ('lightbulb, plusthick, ...')
 * @param string $properties Html properties
 */
function ui_create_icon($icon = 'notice', $properties = '')
{
    if (is_array($properties)) {
        $class = sprinf(' ui-icon ui-icon-%s ', $icon);
        $properties['class'] = isset($properties['class']) ? $class . $properties['class'] : $class;
        $properties = arrayToString($properties);
        $pattern = '<span %s></span>';
    } else {
        $properties = $properties === '' ? 'style="z-index:2000"' : $properties;
        $pattern = '<span class="ui-icon ui-icon-%s ui-datepicker-prev" %s></span>';
    }
    return sprintf($pattern, $icon, $properties);
}
Пример #12
0
 /**
  *
  * @param mixed $handler_id The ID of the handler.
  * @param array &$data The local request data.
  */
 public function _show_generator($handler_id, array &$data)
 {
     // Builtin style prefix
     if (preg_match('/^builtin:(.+)/', $this->_request_data['query_data']['style'], $matches)) {
         $bpr = '-' . $matches[1];
         debug_add('Recognized builtin report, style prefix: ' . $bpr);
     } else {
         debug_add("'{$this->_request_data['query_data']['style']}' not recognized as builtin style");
         $bpr = '';
     }
     //Mangling if report wants to do it (done here to have style context, otherwise MidCOM will not like us.
     debug_print_r("query data before mangle:", $this->_request_data['query_data']);
     debug_add("calling midcom_show_style('report{$bpr}-mangle-query') to mangle the query data as necessary");
     midcom_show_style("projects_report{$bpr}-mangle-query");
     debug_print_r("query data after mangle:", $this->_request_data['query_data']);
     //Handle grouping
     debug_add('checking grouping');
     if (array_key_exists('grouping', $this->_request_data['query_data']) && !empty($this->_request_data['query_data']['grouping'])) {
         debug_add("checking validity of grouping value '{$this->_request_data['query_data']['grouping']}'");
         if (array_key_exists($this->_request_data['query_data']['grouping'], $this->_valid_groupings)) {
             debug_add('Setting grouping to: ' . $this->_request_data['query_data']['grouping']);
             $this->_grouping =& $this->_request_data['query_data']['grouping'];
         } else {
             debug_add(sprinf("\"%s\" is not a valid grouping, keeping default", $this->_request_data['query_data']['grouping']), MIDCOM_LOG_WARN);
         }
     }
     // Put grouping to request data
     $this->_request_data['grouping'] =& $this->_grouping;
     //Get our results
     $results_hr = $this->_get_hour_reports();
     //For debugging and sensible passing of data
     $this->_request_data['raw_results'] = array();
     $this->_request_data['raw_results']['hr'] = $results_hr;
     //TODO: Mileages, expenses
     $this->_request_data['report'] = array();
     $this->_request_data['report']['rows'] = array();
     $this->_request_data['report']['total_hours'] = 0;
     $this->_analyze_raw_hours();
     $this->_sort_rows_recursive($this->_request_data['report']['rows']);
     //TODO: add other report types when supported
     if (!is_array($this->_request_data['raw_results']['hr']) || count($this->_request_data['raw_results']['hr']) == 0) {
         midcom_show_style("projects_report{$bpr}-noresults");
         return;
     }
     //Start actual display
     //Indented to make style flow clearer
     midcom_show_style("projects_report{$bpr}-start");
     midcom_show_style("projects_report{$bpr}-header");
     $this->_show_generator_group($this->_request_data['report']['rows'], $bpr);
     midcom_show_style("projects_report{$bpr}-totals");
     midcom_show_style("projects_report{$bpr}-footer");
     midcom_show_style("projects_report{$bpr}-end");
 }
Пример #13
0
 /**
  *  Sets the Processing Mode
  *
  *  @access public
  *  @return void
  *
  */
 public function setMode($mode)
 {
     if ($mode !== self::PROCESS_MODE_COMPLETE || $mode !== self::PROCESS_MODE_DELAYED || $mode !== self::PROCESS_MODE_PROCESS) {
         throw new LedgerException(sprinf('Mode set to %s is not a valid option', $mode));
     }
     $this->mode = $mode;
 }
Пример #14
0
 public function set(DocumentInterface $record, $name, $value)
 {
     if ($value !== null && !is_array($value) && !$value instanceof DocumentInterface) {
         if (is_object($value)) {
             $message = sprintf("Must pass instance of Rails\\ActiveRecord\\Mongo\\Base as value, instance of %s passed", get_class($value));
         } else {
             $message = sprintf("Must pass either null, array or instance of Rails\\ActiveRecord\\Mongo\\Base as value, %s passed", gettype($value));
         }
         throw new Exception\InvalidArgumentException($message);
     }
     $options = $record->getAssociations()->get($name);
     switch ($options['type']) {
         case 'belongsTo':
             if ($value) {
                 if (is_object($value)) {
                     $this->matchClass($value, $options['className']);
                     $dbref = MongoDBRef::create($value->collectionName(), $value->id(), $value->connection()->databaseName());
                 } elseif (is_array($value)) {
                     if (!MongoDBRef::isRef($value)) {
                         throw new Exception\InvalidArgumentException(sprintf("Array passed to %s::%s association is not a reference", get_class($record), $name));
                     }
                     $dbref = $value;
                 } else {
                     throw new Exception\InvalidArgumentException(sprintf("Value passed to %s::%s association must be either object or array, %s passed", gettype($value)));
                 }
             } else {
                 $dbref = null;
             }
             $record->setAttribute($options['reference'], $dbref);
             break;
         case 'hasOne':
             $refAttr = $options['reference'];
             if ($value) {
                 $this->matchClass($value, $options['className']);
                 $dbref = MongoDBRef::create($record->collectionName(), $record->id(), $record->connection()->databaseName());
                 $value->setAttribute($refAttr, $dbref);
             }
             if ($record->isNewRecord()) {
                 return;
             }
             $oldValue = $record->getAssociation($name);
             if ($value && $oldValue && (string) $value->getAttribute($refAttr) == (string) $oldValue->getAttribute($refAttr)) {
                 return;
             }
             if ($oldValue) {
                 $oldValue->setAttribute($refAttr, null);
             }
             if ($value && $oldValue) {
                 $saved = $value->isValid() && $oldValue->isValid();
             } else {
                 $saved = true;
             }
             if ($saved && $value) {
                 if (!$value->save()) {
                     $saved = false;
                 }
             }
             if ($saved && $oldValue) {
                 if (!$oldValue->save()) {
                     $saved = false;
                 }
             }
             if (!$saved) {
                 throw new RecordNotSavedException(sprinf("Failed to save new associated %s", strtolower($record::getService('inflector')->underscore($name)->humanize())));
             }
             break;
         case 'hasMany':
             if ($value instanceof Collection) {
                 $value = $value->toArray();
             } elseif (!is_array($value)) {
                 throw new Exception\InvalidArgumentException(sprintf("HasMany association accepts either array or instance of Mongo\\Collection, %s passed", gettype($value)));
             }
             if (!empty($options['embedded'])) {
                 $record->{$name}()->set($value);
                 break;
             }
             break;
         default:
             throw new Exception\InvalidArgumentException(sprintf("Can't set unsupported association type %s", $options['type']));
     }
     return true;
 }
Пример #15
0
    /**
     * Output the HTML markup for the dialog box.
     * @access public
     * @since  5.5.6
     * @return void
     */
    public function output_dialog_markup()
    {
        $woo_framework_url = $this->framework_url();
        $woo_framework_version = get_option('woo_framework_version');
        $MIN_VERSION = '2.9';
        $meetsMinVersion = version_compare($woo_framework_version, $MIN_VERSION) >= 0;
        $isWooTheme = true;
        ?>
<div id="woo-dialog" style="display: none;">

<?php 
        if ($meetsMinVersion && $isWooTheme) {
            ?>
<div id="woo-options-buttons" class="clear">
	<div class="alignleft">

	    <input type="button" id="woo-btn-cancel" class="button" name="cancel" value="Cancel" accesskey="C" />

	</div>
	<div class="alignright">
	    <input type="button" id="woo-btn-insert" class="button-primary" name="insert" value="Insert" accesskey="I" />
	</div>
	<div class="clear"></div><!--/.clear-->
</div><!--/#woo-options-buttons .clear-->

<div id="woo-options" class="alignleft">
    <h3><?php 
            echo __('Customize the Shortcode', 'woothemes');
            ?>
</h3>

	<table id="woo-options-table">
	</table>

</div>
<div class="clear"></div>


<script type="text/javascript" src="<?php 
            echo esc_url($woo_framework_url . 'js/shortcode-generator/js/column-control.js');
            ?>
"></script>
<script type="text/javascript" src="<?php 
            echo esc_url($woo_framework_url . 'js/shortcode-generator/js/tab-control.js');
            ?>
"></script>
<?php 
        } else {
            ?>

<div id="woo-options-error">

    <h3><?php 
            echo __('Ninja Trouble', 'woothemes');
            ?>
</h3>

    <?php 
            if ($isWooTheme && !$meetsMinVersion) {
                ?>
    <p><?php 
                echo sprinf(__('Your version of the WooFramework (%s) does not yet support shortcodes. Shortcodes were introduced with version %s of the framework.', 'woothemes'), $woo_framework_version, $MIN_VERSION);
                ?>
</p>

    <h4><?php 
                echo __('What to do now?', 'woothemes');
                ?>
</h4>

    <p><?php 
                echo __('Upgrading your theme, or rather the WooFramework portion of it, will do the trick.', 'woothemes');
                ?>
</p>

	<p><?php 
                echo sprintf(__('The framework is a collection of functionality that all WooThemes have in common. In most cases you can update the framework even if you have modified your theme, because the framework resides in a separate location (under %s).', 'woothemes'), '<code>/functions/</code>');
                ?>
</p>

	<p><?php 
                echo sprintf(__('There\'s a tutorial on how to do this on WooThemes.com: %sHow to upgradeyour theme%s.', 'woothemes'), '<a title="WooThemes Tutorial" target="_blank" href="http://www.woothemes.com/2009/08/how-to-upgrade-your-theme/">', '</a>');
                ?>
</p>

	<p><?php 
                echo __('<strong>Remember:</strong> Every Ninja has a backup plan. Safe or not, always backup your theme before you update it or make changes to it.', 'woothemes');
                ?>
</p>

<?php 
            } else {
                ?>

    <p><?php 
                echo __('Looks like your active theme is not from WooThemes. The shortcode generator only works with themes from WooThemes.', 'woothemes');
                ?>
</p>

    <h4><?php 
                echo __('What to do now?', 'woothemes');
                ?>
</h4>

	<p><?php 
                echo __('Pick a fight: (1) If you already have a theme from WooThemes, install and activate it or (2) if you don\'t yet have one of the awesome WooThemes head over to the <a href="http://www.woothemes.com/themes/" target="_blank" title="WooThemes Gallery">WooThemes Gallery</a> and get one.', 'woothemes');
                ?>
</p>

<?php 
            }
            ?>

<div style="float: right"><input type="button" id="woo-btn-cancel"
	class="button" name="cancel" value="Cancel" accesskey="C" /></div>
</div>

<?php 
        }
        ?>

<script type="text/javascript" src="<?php 
        echo esc_url($woo_framework_url . 'js/shortcode-generator/js/dialog-js.php');
        ?>
"></script>
</div>
<?php 
    }
Пример #16
0
 /**
  * Process a Voided Payment IPN
  */
 function paymentVoided()
 {
     if ($this->paymentDBO == null) {
         fatal_error("PSIPNPage::paymentVoided()", sprinf("Received a Paypal Denied / Expired / Failed / Voided IPN for a payment that does not exist! TXN=%s, Customer=%s, Amount=%s, Status=%s", $_POST['txn_id'], $_POST['payer_email'], $_POST['mc_gross'], $_POST['payment_status']));
     }
     $this->deletePayment();
 }
Пример #17
0
  <title>WordPress &rsaquo; Error</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="{$admin_dir}css/install.css" type="text/css" />
</head>
<body>
  <h1 id="logo"><img alt="WordPress" src="{$admin_dir}images/wordpress-logo.png" /></h1>
  <p>{$message}</p>
  <p>{$data}</p>
</body>
<html>

HTML
);
}
if (version_compare(PHP_VERSION, '5.2.4', '<')) {
    pdo_log_error('PHP version on this server is too old.', sprinf("Your server is running PHP version %d but this version of WordPress requires at least 5.2.4", phpversion()));
}
if (!extension_loaded('pdo')) {
    pdo_log_error('PHP PDO Extension is not loaded.', 'Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress.');
}
if (!extension_loaded('pdo_sqlite')) {
    pdo_log_error('PDO Driver for SQLite is missing.', 'Your PHP installtion appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.');
}
/*
 * Notice:
 * Your scripts have the permission to create directories or files on your server.
 * If you write in your wp-config.php like below, we take these definitions.
 * define('DB_DIR', '/full_path_to_the_database_directory/');
 * define('DB_FILE', 'database_file_name');
 */
/*
Пример #18
0
    if (empty($p_group)) {
        $okt->error->set(__('m_users_must_select_at_least_one_group'));
    } else {
        foreach ($p_group as $gid) {
            if (!array_key_exists($gid, $aGroups)) {
                $okt->error->set(sprintf(__('m_users_group_%s_not_exportable'), $gid));
            }
        }
    }
    # we need at least one field
    if (empty($p_field)) {
        $okt->error->set(__('m_users_must_select_at_least_one_data_type'));
    } else {
        foreach ($p_field as $field) {
            if (!array_key_exists($field, $aAllowedFields)) {
                $okt->error->set(sprinf(__('m_users_data_type_%s_not_exportable'), html::escapeHTML($field)));
            }
        }
    }
    # we need a format
    if (empty($p_format)) {
        $okt->error->set(__('m_users_must_select_valid_format'));
    }
    # do export
    if ($okt->error->isEmpty()) {
        $okt->users->export($p_format, $p_field, $p_group);
        $okt->redirect('module.php?m=users&action=export&done=1');
    }
}
/* Affichage
----------------------------------------------------------*/
Пример #19
0
 /**
  * Handles new block insertion request.
  */
 public function insertBlockAction()
 {
     $this->isPostRequest();
     $this->checkLock();
     $pageRequest = $this->createPageRequest();
     $blockComponentName = $this->getRequestParameter('type');
     // Generate block according the page localization type provided
     $block = Block::factory($this->getPageLocalization());
     $block->setComponentName($blockComponentName);
     $class = $block->getComponentClass();
     $blockConfiguration = $this->getBlockCollection()->getConfiguration($class);
     // logic/code issue
     if (!$blockConfiguration->isInsertable()) {
         throw new CmsException(null, 'This block cannot be added.');
     }
     // deny adding if block is defined as unique
     // and page block set already contains it.
     if ($blockConfiguration->isUnique()) {
         foreach ($pageRequest->getBlockSet() as $existingBlock) {
             if ($existingBlock->getComponentClass() === $class) {
                 throw new CmsException(null, sprinf('Only one instance of "%s" block can be added on the page.', $blockConfiguration->getTitle()));
             }
         }
     }
     $placeHolderName = $this->getRequestParameter('placeholder_id');
     $placeHolder = $pageRequest->getPlaceHolderSet()->getFinalPlaceHolders()->offsetGet($placeHolderName);
     if ($placeHolder === null) {
         throw new \InvalidArgumentException(sprintf('Missing placeholder [%s] in place holder set.', $placeHolderName));
     }
     $insertBeforeTargetId = $this->getRequestInput()->get('reference_id');
     if (!empty($insertBeforeTargetId)) {
         $insertBeforeTarget = null;
         foreach ($placeHolder->getBlocks() as $existingBlock) {
             if ($existingBlock->getId() === $insertBeforeTargetId) {
                 $insertBeforeTarget = $existingBlock;
                 break;
             }
         }
         if ($insertBeforeTarget === null) {
             throw new \InvalidArgumentException(sprintf('Blocks collection item [%s] not found.', $insertBeforeTargetId));
         }
         $placeHolder->addBlockBefore($insertBeforeTarget, $block);
     } else {
         $placeHolder->addBlockLast($block);
     }
     $entityManager = $this->getEntityManager();
     $entityManager->persist($block);
     $entityManager->flush();
     return new SupraJsonResponse($this->getBlockData($block, true));
 }
Пример #20
0
<?php 
} else {
    ?>

<div id="wpz-options-error">

    <h3><?php 
    echo __('Error', 'wpzoom');
    ?>
</h3>
    
    <?php 
    if ($iswpzTheme) {
        ?>
	<p><?php 
        echo sprinf(__('Your version of theme does not yet support shortcodes.', 'wpzoom'), $wpzoom_framework_version, $MIN_VERSION);
        ?>
</p>

<?php 
    } else {
        ?>

    <p><?php 
        echo __('Looks like your active theme is not from WPZOOM. The shortcode generator only works with themes from WPZOOM.', 'wpzoom');
        ?>
</p>
 
<?php 
    }
    ?>
Пример #21
0
     $type = 0;
 } else {
     $type = (int) $_REQUEST['type'];
 }
 discern_type($type);
 $materials_array = array($cw['fighters'], $cw['colonists'], $cw['metals'], $cw['fuels'], $cw['electronics']);
 $materials_array[$type] = "<b class='b1'>" . $materials_array[$type] . "</b>";
 //select all ships in the system that are the users.
 $select_ships_sql = "select ship_name, class_name_abbr, fighters ,max_fighters, shields, max_shields, armour, max_armour, cargo_bays, metal, fuel, elect, colon, fleet_id, config, ship_id, location from {$db_name}_ships where login_id = '{$user['login_id']}' && location = '{$user['location']}' order by {$tech_mat} desc";
 $table_head_array = array($cw['ship_name'], $cw['ship_class'], $cw['fighters'], $cw['shields'], $cw['armour'], $cw['cargo_bays'], $st[1650], $cw['config'], $cw['select'], $st[1651]);
 $ship_listing = checkbox_ship_list($select_ships_sql, 2);
 if ($ship_listing == -1) {
     $output_str .= $st[1645];
 } elseif (conditions($user, $planet)) {
     //ensure user is allowed to play with this sort of stuff.
     $output_str .= sprinf($st[1646], $GAME_VARS[min_before_transfer]);
 } else {
     //list all the ships, and
     $out = $rs . "<br />";
     if (!empty($pre_processed_txt)) {
         $out .= $pre_processed_txt . "<br />";
     } else {
         $out .= sprintf($st[1647], $text_mat, $text_mat);
     }
     $out .= "<p />" . $st[1648] . ":<br />{$materials_array['0']}: <b>{$planet['fighters']}</b><br />{$materials_array['1']}: <b>{$planet['colon']}</b><br />{$materials_array['2']}: <b>{$planet['metal']}</b><br />{$materials_array['3']}: <b>{$planet['fuel']}</b><br />{$materials_array['4']}: <b>{$planet['elect']}</b><p />";
     //list the resources this page can trade
     $out .= sprintf($st[1649], $materials_array[$type]);
     foreach ($materials_array as $key => $material) {
         if ($key != $type) {
             $out .= "<a href='{$_SERVER['PHP_SELF']}?planet_id={$planet_id}&type={$key}&single_ship_deal=1'>{$material}</a> - ";
         } else {
Пример #22
0
<?php 
} else {
    ?>

<div id="woo-options-error">

    <h3><?php 
    echo __('Ninja Trouble', 'woothemes');
    ?>
</h3>
    
    <?php 
    if ($isWooTheme && !$meetsMinVersion) {
        ?>
    <p><?php 
        echo sprinf(__('Your version of the WooFramework (%s) does not yet support shortcodes. Shortcodes were introduced with version %s of the framework.', 'woothemes'), $woo_framework_version, $MIN_VERSION);
        ?>
</p>
    
    <h4><?php 
        echo __('What to do now?', 'woothemes');
        ?>
</h4>
    
    <p><?php 
        echo __('Upgrading your theme, or rather the WooFramework portion of it, will do the trick.', 'woothemes');
        ?>
</p>

	<p><?php 
        echo sprintf(__('The framework is a collection of functionality that all WooThemes have in common. In most cases you can update the framework even if you have modified your theme, because the framework resides in a separate location (under %s).', 'woothemes'), '<code>/functions/</code>');
Пример #23
0
 /**
  * Cleans up and saves the container.
  */
 public function close()
 {
     foreach ($this->_content as $content) {
         $content->close();
         if ($this->_container->addFile($content->getResource(), $content->getName()) === false) {
             $msg = 'Unable to add content in "%1$s" to file "%2$s"';
             throw new MW_Content_Exception(sprinf($msg, $content->getResource(), $this->_container->filename));
         }
     }
     if ($this->_container->close() === false) {
         throw new MW_Container_Exception(sprintf('Unable to close zip file "%1$s"', $this->_container->filename));
     }
     foreach ($this->_content as $content) {
         unlink($content->getResource());
     }
 }
Пример #24
0
 /**
  * Save the current configuration to file.
  * @throws RuntimeException
  */
 public function save()
 {
     if (!file_put_contents($this->file, json_encode($this->vars))) {
         throw new RuntimeException(sprinf('The configuration file could not be saved in %s', $this->file));
     }
 }
Пример #25
0
    ?>


<div id="tmnf-options-error">

    <h3><?php 
    echo __('Ninja Trouble', 'Themnific');
    ?>
</h3>
    
    <?php 
    if ($isThemnificTheme && !$meetsMinVersion) {
        ?>

    <p><?php 
        echo sprinf(__('Your version of the framework (%s) does not yet support shortcodes. Shortcodes were introduced with version %s of the framework.', 'Themnific'), $tmnf_framework_version, $MIN_VERSION);
        ?>
</p>
    
    <h4><?php 
        echo __('What to do now?', 'Themnific');
        ?>
</h4>
    
    <p><?php 
        echo __('Upgrading your theme, or rather the framework portion of it, will do the trick.', 'Themnific');
        ?>
</p>

	<p><?php 
        echo sprintf(__('The framework is a collection of functionality that all Themnific have in common. In most cases you can update the framework even if you have modified your theme, because the framework resides in a separate location (under %s).', 'Themnific'), '<code>/functions/</code>');
Пример #26
0
 /**
  * Returns the source of the boundary.
  * @public
  * @returns string
  */
 function GetSource($bLineEnding = true)
 {
     $ret = array();
     $mime[] = sprintf("--%s%s", $this->ID, $this->LE);
     $mime[] = sprintf("Content-Type: %s; charset = \"%s\"%s", $this->ContentType, $this->CharSet, $this->LE);
     //$mime[] = sprintf("Content-Transfer-Encoding: %s%s", $this->Encoding,
     //                  $this->LE);
     if (strlen($this->Disposition) > 0) {
         $mime[] = sprintf("Content-Disposition: %s;");
         if (strlen($this->FileName) > 0) {
             $mime[] = sprinf("filename=\"%s\"", $this->{$this}->FileName);
         }
     }
     if ($bLineEnding) {
         $mime[] = $this->LE;
     }
     return join("", $mime);
 }
Пример #27
0
 public function selectDb($dbname)
 {
     return $this->query(sprinf('USE `%s`', $dbname));
 }
Пример #28
0
 /**
  * Set the billing cycle.
  *
  * @param string $cycle
  *
  * @throws BillingCycleNotSupported
  * @throws PlanPropertyDoesNotExist
  */
 private function setBillingCycle($cycle)
 {
     if (!in_array($cycle, static::$cycles)) {
         throw new BillingCycleNotSupported(sprinf('The billing cycle "%s" is not supported', $cycle));
     }
     $this->setProperty('billing_cycle', $cycle);
 }
 public function fill_in_data()
 {
     global $woocsv_import;
     do_action('woocsv_product_before_fill_in_data');
     $id = false;
     //check if the product already exists by checking it's ID
     if (in_array('ID', $this->header)) {
         $tempID = $this->raw_data[array_search('ID', $this->header)];
         if ($tempID) {
             //use get_post instead of get_posts
             $test = new WC_Product($tempID);
             if ($test->post) {
                 $this->log[] = sprintf(__('Product found (ID), ID is: %s', 'woocsv'), $tempID);
                 $this->new = false;
                 // @ since 3.0.5 add ID else merging will not work using ID's
                 $id = $tempID;
             } else {
                 /* set the ID to null */
                 $this->raw_data[array_search('ID', $this->header)] = '';
                 $this->body['ID'] = '';
                 $this->log[] = sprinf(__('ID : %s not found!', 'woocsv'), $tempID);
             }
         }
     }
     //check if the product already exists by checking it's sku
     if (empty($id) && in_array('sku', $this->header) && $woocsv_import->get_match_by() == 'sku') {
         $sku = $this->raw_data[array_search('sku', $this->header)];
         if (!empty($sku)) {
             $id = $this->get_product_by_id($sku);
             if (!empty($id)) {
                 $this->new = false;
                 $this->log[] = sprintf(__('Product found (SKU), ID is: %s', 'woocsv'), $id);
             } else {
                 $this->log[] = __('New product', 'woocsv');
             }
         }
     }
     //check if the product already exists by checking it's post title
     if (empty($id) && in_array('post_title', $this->header) && $woocsv_import->get_match_by() == 'title') {
         $post_title = $this->raw_data[array_search('post_title', $this->header)];
         if ($post_title) {
             $testID = get_page_by_title($post_title, ARRAY_A, 'product');
             if ($testID) {
                 $this->log[] = sprintf(__('Product found (TITLE), ID is: %s', 'woocsv'), $testID['ID']);
                 $id = $testID['ID'];
                 $this->new = false;
             } else {
                 $this->log[] = sprintf(__('ID : %s not found!', 'woocsv'), $testID['ID']);
             }
         }
     }
     //check for if we need to merge the product
     if ($id && $woocsv_import->get_merge_products() == 1) {
         $this->merge_product($id);
     }
     //fill in the product body
     foreach ($this->body as $key => $value) {
         if (in_array($key, $this->header)) {
             $this->body[$key] = $this->raw_data[array_search($key, $this->header)];
         }
     }
     // get the author
     if (isset($this->body['post_author'])) {
         $user = get_user_by($woocsv_import->get_match_author_by() ? $woocsv_import->get_match_author_by() : 'login', $this->body['post_author']);
         if ($user) {
             $this->body['post_author'] = $user->ID;
             $this->log[] = __('user found', 'woocsv');
         } else {
             $this->body['post_author'] = '';
             $this->log[] = __('user not found', 'woocsv');
         }
     }
     //fill in the ID if the product already exists
     if ($id) {
         $this->body['ID'] = $id;
     }
     //fill in the meta data
     // @ since 3.0.5
     // trim meta values to loose spaces
     foreach ($this->meta as $key => $value) {
         if (in_array(substr($key, 1), $this->header)) {
             $this->meta[$key] = trim($this->raw_data[array_search(substr($key, 1), $this->header)]);
         }
     }
     // @ since 3.0.5
     // if the product is new add total_sales to show it in the front end
     // some themes needed total_sales for popularity sorting
     if (!empty($this->body['ID'])) {
         $this->meta['total_sales'] = 0;
     }
     //check if there are tags
     if (in_array('tags', $this->header)) {
         foreach ($this->header as $key => $value) {
             if ($value == 'tags') {
                 $this->tags[] = $this->raw_data[$key];
             }
         }
     }
     //check if there is a shipping
     if (in_array('shipping_class', $this->header)) {
         $key = array_search('shipping_class', $this->header);
         $this->shipping_class = trim($this->raw_data[$key]);
     }
     //check if there are categories
     if (in_array('category', $this->header)) {
         foreach ($this->header as $key => $value) {
             if ($value == 'category') {
                 $this->categories[] = $this->raw_data[$key];
             }
         }
     }
     /* change_stock */
     if (in_array('change_stock', $this->header)) {
         $key = array_search('change_stock', $this->header);
         $change_stock = $this->raw_data[$key];
         //get the stock
         $stock = get_post_meta($this->body['ID'], '_stock', true);
         //if the stock is empty set it to 0
         if (!$stock) {
             $stock = 0;
         }
         //calculate the new stock level
         $new_stock = $stock + $change_stock;
         //set new stock in the meta
         $this->meta['_stock'] = $new_stock;
         //set log
         $this->log[] = sprintf(__('Change stock modus: stock changed from %s to %s', 'woocsv'), $stock, $new_stock);
     }
     //check if there is a featured image
     if (in_array('featured_image', $this->header)) {
         $key = array_search('featured_image', $this->header);
         $this->featured_image = $this->raw_data[$key];
     }
     //check if there is a product gallery
     if (in_array('product_gallery', $this->header)) {
         $key = array_search('product_gallery', $this->header);
         $this->product_gallery = $this->raw_data[$key];
     }
     do_action('woocsv_product_after_fill_in_data');
 }