Exemplo n.º 1
7
function ote_accent($str)
{
    $str = str_replace("'", " ", $str);
    $str = utf8_decode($str);
    $ch = strtr($str, '����������������������������������������������������', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
    return utf8_encode($ch);
}
Exemplo n.º 2
5
Arquivo: Word.php Projeto: pumi11/aau
 /**
  * @throws \PhpOffice\PhpWord\Exception\Exception
  * Создание word для юр вопросов
  */
 public static function ur_questions($row)
 {
     $user = User::findOne(\Yii::$app->user->identity->id);
     $file = \Yii::$app->basePath . '/temp/ur_questions/' . $row['qid'] . '.docx';
     $template = \Yii::$app->basePath . '/temp/ur_questions/Template.docx';
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template);
     // Variables on different parts of document
     $row['question'] = str_replace("\n", "<w:br/>", $row['question']);
     //Для пробелов
     $templateProcessor->setValue('vopros', $row['question']);
     $templateProcessor->setValue('date', date("d.m.Y"));
     $templateProcessor->setValue('ur_name', $row['uname']);
     $templateProcessor->setValue('ur_ruk', $row['contact_face']);
     $templateProcessor->setValue('ur_phone', $row['contact_phone']);
     $templateProcessor->setValue('ur_mail', $row['contact_mail']);
     $templateProcessor->setValue('ur_region', $row['rname']);
     //$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
     $templateProcessor->saveAs($file);
     $qf = explode("|", $row['qfiles']);
     if (!isset($qf[0])) {
         $qf[0] = $qf;
     }
     $mail = \Yii::$app->mail->compose('ur_questions', ['uname' => $row['uname'], 'username' => $user['username'], 'mail' => $user['mail']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo(\Yii::$app->params['uristEmail'])->setSubject('Юридический вопрос')->attach($file);
     foreach ($qf as $q) {
         if ($q != "") {
             $mail->attach($q);
         }
     }
     $mail->send();
     // if($templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx')) {
     //      return true;
     //  }else{
     //    return false;
     // }
 }
Exemplo n.º 3
2
function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
Exemplo n.º 4
1
 public function collectData(array $param)
 {
     $html = $this->file_get_html('http://www.maliki.com/') or $this->returnError('Could not request Maliki.', 404);
     $count = 0;
     $latest = 1;
     $latest_title = "";
     $latest = $html->find('div.conteneur_page a', 1)->href;
     $latest_title = $html->find('div.conteneur_page img', 0)->title;
     function MalikiExtractContent($url)
     {
         $html2 = $this->file_get_html($url);
         $text = 'http://www.maliki.com/' . $html2->find('img', 0)->src;
         $text = '<img alt="" src="' . $text . '"/><br>' . $html2->find('div.imageetnews', 0)->plaintext;
         return $text;
     }
     $item = new \Item();
     $item->uri = 'http://www.maliki.com/' . $latest;
     $item->title = $latest_title;
     $item->timestamp = time();
     $item->content = MalikiExtractContent($item->uri);
     $this->items[] = $item;
     foreach ($html->find('div.boite_strip') as $element) {
         if (!empty($element->find('a', 0)->href) and $count < 3) {
             $item = new \Item();
             $item->uri = 'http://www.maliki.com/' . $element->find('a', 0)->href;
             $item->title = $element->find('img', 0)->title;
             $item->timestamp = strtotime(str_replace('/', '-', $element->find('span.stylepetit', 0)->innertext));
             $item->content = MalikiExtractContent($item->uri);
             $this->items[] = $item;
             $count++;
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function getEntityAlias($entityClass)
 {
     if ($this->configManager->hasConfig($entityClass)) {
         // check for enums
         $enumCode = $this->configManager->getProvider('enum')->getConfig($entityClass)->get('code');
         if ($enumCode) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias(str_replace('_', '', $enumCode));
         }
         // check for dictionaries
         $groups = $this->configManager->getProvider('grouping')->getConfig($entityClass)->get('groups');
         if (!empty($groups) && in_array(GroupingScope::GROUP_DICTIONARY, $groups, true)) {
             // delegate aliases generation to default provider
             return null;
         }
         // exclude hidden entities
         if ($this->configManager->isHiddenModel($entityClass)) {
             return false;
         }
         // check for custom entities
         if (ExtendHelper::isCustomEntity($entityClass)) {
             $entityAlias = $this->getEntityAliasFromConfig($entityClass);
             if (null !== $entityAlias) {
                 return $entityAlias;
             }
             return $this->createEntityAlias('Extend' . ExtendHelper::getShortClassName($entityClass));
         }
     }
     return null;
 }
Exemplo n.º 6
1
 /**
  * Get link definition defined in 'fields' metadata. In linkDefs can be used as value (e.g. "type": "hasChildren") and/or variables (e.g. "entityName":"{entity}"). Variables should be defined into fieldDefs (in 'entityDefs' metadata).
  *
  * @param  string $entityName
  * @param  array  $fieldDef
  * @param  array  $linkFieldDefsByType
  * @return array | null
  */
 public function getLinkDefsInFieldMeta($entityName, $fieldDef, array $linkFieldDefsByType = null)
 {
     if (!isset($fieldDefsByType)) {
         $fieldDefsByType = $this->getFieldDefsByType($fieldDef);
         if (!isset($fieldDefsByType['linkDefs'])) {
             return null;
         }
         $linkFieldDefsByType = $fieldDefsByType['linkDefs'];
     }
     foreach ($linkFieldDefsByType as $paramName => &$paramValue) {
         if (preg_match('/{(.*?)}/', $paramValue, $matches)) {
             if (in_array($matches[1], array_keys($fieldDef))) {
                 $value = $fieldDef[$matches[1]];
             } else {
                 if (strtolower($matches[1]) == 'entity') {
                     $value = $entityName;
                 }
             }
             if (isset($value)) {
                 $paramValue = str_replace('{' . $matches[1] . '}', $value, $paramValue);
             }
         }
     }
     return $linkFieldDefsByType;
 }
Exemplo n.º 7
1
 public function addFieldToModule($field)
 {
     global $log;
     $fileName = 'modules/Settings/Vtiger/models/CompanyDetails.php';
     $fileExists = file_exists($fileName);
     if ($fileExists) {
         require_once $fileName;
         $fileContent = file_get_contents($fileName);
         $placeToAdd = "'website' => 'text',";
         $newField = "'{$field}' => 'text',";
         if (self::parse_data($placeToAdd, $fileContent)) {
             $fileContent = str_replace($placeToAdd, $placeToAdd . PHP_EOL . '	' . $newField, $fileContent);
         } else {
             if (self::parse_data('?>', $fileContent)) {
                 $fileContent = str_replace('?>', '', $fileContent);
             }
             $fileContent = $fileContent . PHP_EOL . $placeToAdd . PHP_EOL . '	' . $newField . PHP_EOL . ');';
         }
         $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - add line to modules/Settings/Vtiger/models/CompanyDetails.php ');
     } else {
         $log->info('Settings_Vtiger_SaveCompanyField_Action::addFieldToModule - File does not exist');
         return FALSE;
     }
     $filePointer = fopen($fileName, 'w');
     fwrite($filePointer, $fileContent);
     fclose($filePointer);
     return TRUE;
 }
Exemplo n.º 8
1
 public static function apiUpdateOrder($order, $response)
 {
     if (!defined('ORDER_MANAGEMENT')) {
         define('ORDER_MANAGEMENT', true);
     }
     if (!empty($order['status'])) {
         $statuses = fn_get_statuses(STATUSES_ORDER, false, true);
         if (!isset($statuses[$order['status']])) {
             $response->addError('ERROR_OBJECT_UPDATE', str_replace('[object]', 'orders', __('twgadmin_wrong_api_object_data')));
         } else {
             fn_change_order_status($order['order_id'], $order['status']);
         }
     }
     $cart = array();
     fn_clear_cart($cart, true);
     $customer_auth = fn_fill_auth(array(), array(), false, 'C');
     fn_form_cart($order['order_id'], $cart, $customer_auth);
     $cart['order_id'] = $order['order_id'];
     // update only profile data
     $profile_data = fn_check_table_fields($order, 'user_profiles');
     $cart['user_data'] = fn_array_merge($cart['user_data'], $profile_data);
     $cart['user_data'] = fn_array_merge($cart['user_data'], $order);
     fn_calculate_cart_content($cart, $customer_auth, 'A', true, 'I');
     if (!empty($order['details'])) {
         db_query('UPDATE ?:orders SET details = ?s WHERE order_id = ?i', $order['details'], $order['order_id']);
     }
     if (!empty($order['notes'])) {
         $cart['notes'] = $order['notes'];
     }
     fn_update_payment_surcharge($cart, $customer_auth);
     list($order_id, $process_payment) = fn_place_order($cart, $customer_auth, 'save');
     return array($order_id, $process_payment);
 }
Exemplo n.º 9
1
 /**
  * Requests API data and returns aliases
  *
  * @return string
  */
 private function getAliases()
 {
     $request = new Request();
     $user = new User();
     $path = 'drush_aliases';
     $method = 'GET';
     $response = $request->request('users', Session::getValue('user_id'), $path, $method);
     eval(str_replace('<?php', '', $response['data']->drush_aliases));
     $formatted_aliases = substr($response['data']->drush_aliases, 0, -1);
     $sites_object = new Sites();
     $sites = $sites_object->all();
     foreach ($sites as $site) {
         $environments = $site->environments->all();
         foreach ($environments as $environment) {
             $key = $site->get('name') . '.' . $environment->get('id');
             if (isset($aliases[$key])) {
                 break;
             }
             try {
                 $formatted_aliases .= PHP_EOL . "  \$aliases['{$key}'] = ";
                 $formatted_aliases .= $this->constructAlias($environment);
             } catch (TerminusException $e) {
                 continue;
             }
         }
     }
     $formatted_aliases .= PHP_EOL;
     return $formatted_aliases;
 }
Exemplo n.º 10
0
 /**
  * Entry point for the script
  *
  * @return  void
  *
  * @since   1.0
  */
 public function doExecute()
 {
     jimport('joomla.filesystem.file');
     if (file_exists(JPATH_BASE . '/configuration.php') || file_exists(JPATH_BASE . '/config.php')) {
         $configfile = file_exists(JPATH_BASE . 'configuration.php') ? JPATH_BASE . '/config.php' : JPATH_BASE . '/configuration.php';
         if (is_writable($configfile)) {
             $config = file_get_contents($configfile);
             //Do a simple replace for the CMS and old school applications
             $newconfig = str_replace('public $offline = \'0\'', 'public $offline = \'1\'', $config);
             // Newer applications generally use JSON instead.
             if (!$newconfig) {
                 $newconfig = str_replace('"public $offline":"0"', '"public $offline":"1"', $config);
             }
             if (!$newconfig) {
                 $this->out('This application does not have an offline configuration setting.');
             } else {
                 JFile::Write($configfile, &$newconfig);
                 $this->out('Site is offline');
             }
         } else {
             $this->out('The file is not writable, you need to change the file permissions first.');
             $this->out();
         }
     } else {
         $this->out('This application does not have a configuration file');
     }
     $this->out();
 }
Exemplo n.º 11
0
/**
 * On modifie les URLS des images dans le corps de l'article
 */
function filtre_picture($content, $url, $id)
{
    $matches = array();
    $processing_pictures = array();
    // list of processing image to avoid processing the same pictures twice
    preg_match_all('#<\\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
    foreach ($matches as $i => $link) {
        $link[1] = trim($link[1]);
        if (!preg_match('#^(([a-z]+://)|(\\#))#', $link[1])) {
            $absolute_path = get_absolute_link($link[2], $url);
            $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
            $directory = create_assets_directory($id);
            $fullpath = $directory . '/' . $filename;
            if (in_array($absolute_path, $processing_pictures) === true) {
                // replace picture's URL only if processing is OK : already processing -> go to next picture
                continue;
            }
            if (download_pictures($absolute_path, $fullpath) === true) {
                $content = str_replace($matches[$i][2], $fullpath, $content);
            }
            $processing_pictures[] = $absolute_path;
        }
    }
    return $content;
}
Exemplo n.º 12
0
 function mdl_const($str_type)
 {
     if (!fn_token("chk")) {
         //令牌
         $this->obj_ajax->halt_alert("x030102");
     }
     $_arr_opt = fn_post("opt");
     $_str_content = "<?php" . PHP_EOL;
     foreach ($_arr_opt as $_key => $_value) {
         $_arr_optChk = validateStr($_value, 1, 900);
         $_str_optValue = $_arr_optChk["str"];
         if (is_numeric($_value)) {
             $_str_content .= "define(\"" . $_key . "\", " . $_str_optValue . ");" . PHP_EOL;
         } else {
             $_str_content .= "define(\"" . $_key . "\", \"" . str_replace(PHP_EOL, "|", $_str_optValue) . "\");" . PHP_EOL;
         }
     }
     if ($str_type == "base") {
         $_str_content .= "define(\"BG_SITE_SSIN\", \"" . fn_rand(6) . "\");" . PHP_EOL;
     } else {
         if ($str_type == "visit") {
             if ($_arr_opt["BG_VISIT_TYPE"] != "static") {
                 $_str_content .= "define(\"BG_VISIT_FILE\", \"html\");" . PHP_EOL;
             }
         }
     }
     $_str_content = str_replace("||", "", $_str_content);
     $_num_size = file_put_contents(BG_PATH_CONFIG . "opt_" . $str_type . ".inc.php", $_str_content);
     if ($_num_size > 0) {
         $_str_alert = "y060101";
     } else {
         $_str_alert = "x060101";
     }
     return array("alert" => $_str_alert);
 }
Exemplo n.º 13
0
function valida_valor($valor, $aceita_float)
{
    // valida valor
    if ($valor == null) {
        // informa que nao e um valor
        return false;
    }
    // remove a virgula se houver
    $valor = str_replace(",", ".", $valor);
    // remove espaco vazio no meio se houver
    $valor = str_replace(" ", null, $valor);
    // remove o espaco em branco
    $valor = trim($valor);
    // valida se e numero, e se e numero positivo
    if (is_numeric($valor) == false or $valor < 0) {
        // informa que nao e um numero
        return false;
    }
    // arredonda valor se nao aceitar float
    if ($aceita_float == false) {
        // arredonda
        $valor = round($valor, 0);
    }
    // se aceitar float, e for float entao arredonda
    if ($aceita_float == true) {
        // arredonda
        $valor = round($valor, 2);
    }
    // retorno
    return $valor;
}
Exemplo n.º 14
0
 function includePeer($path = "general")
 {
     $_path = _FM_HOME_DIR . DS . 'symbiosis' . DS . _FM_PEER . DS . str_replace('.', DS, $path) . '.php';
     if (file_exists($_path)) {
         require_once $_path;
     }
 }
Exemplo n.º 15
0
 /**
  * Load metadata about an HTML document using Aperture.
  *
  * @param string $htmlFile File on disk containing HTML.
  *
  * @return array
  */
 protected static function getApertureFields($htmlFile)
 {
     $xmlFile = tempnam('/tmp', 'apt');
     $cmd = static::getApertureCommand($htmlFile, $xmlFile, 'filecrawler');
     exec($cmd);
     // If we failed to process the file, give up now:
     if (!file_exists($xmlFile)) {
         throw new \Exception('Aperture failed.');
     }
     // Extract and decode the full text from the XML:
     $xml = str_replace(chr(0), ' ', file_get_contents($xmlFile));
     @unlink($xmlFile);
     preg_match('/<plainTextContent[^>]*>([^<]*)</ms', $xml, $matches);
     $final = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the title from the XML:
     preg_match('/<title[^>]*>([^<]*)</ms', $xml, $matches);
     $title = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Extract the keywords from the XML:
     preg_match_all('/<keyword[^>]*>([^<]*)</ms', $xml, $matches);
     $keywords = [];
     if (isset($matches[1])) {
         foreach ($matches[1] as $current) {
             $keywords[] = trim(html_entity_decode($current, ENT_QUOTES, 'UTF-8'));
         }
     }
     // Extract the description from the XML:
     preg_match('/<description[^>]*>([^<]*)</ms', $xml, $matches);
     $description = isset($matches[1]) ? trim(html_entity_decode($matches[1], ENT_QUOTES, 'UTF-8')) : '';
     // Send back the extracted fields:
     return ['title' => $title, 'keywords' => $keywords, 'description' => $description, 'fulltext' => $final];
 }
 /**
  * getUser
  *
  * read User by ID
  * id, int: id (required)
  * 
  * @return User
  */
 public function getUser($id)
 {
     // parse inputs
     $resourcePath = "/user_get_two_read1";
     $resourcePath = str_replace("{format}", "json", $resourcePath);
     $method = "GET";
     $queryParams = array();
     $headerParams = array();
     $formParams = array();
     $headerParams['Accept'] = '*/*';
     $headerParams['Content-Type'] = 'application/json';
     // query params
     if ($id !== null) {
         $queryParams['id'] = $this->apiClient->toQueryValue($id);
     }
     $body = $body ?: $formParams;
     if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) {
         $body = http_build_query($body);
     }
     // make the API Call
     $response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $body, $headerParams);
     if (!$response) {
         return null;
     }
     $responseObject = $this->apiClient->deserialize($response, 'User');
     return $responseObject;
 }
Exemplo n.º 17
0
Arquivo: sax.php Projeto: nursit/SPIP
function xml_debutElement($phraseur, $name, $attrs)
{
    $depth = $phraseur->depth;
    $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' ';
    // espace initial signifie: deja integree au resultat
    if ($t[0] != ' ') {
        $phraseur->res .= '<' . $t . '>';
        $phraseur->ouvrant[$depth] = ' ' . $t;
    }
    $t = $phraseur->contenu[$depth];
    // n'indenter que s'il y a un separateur avant
    $phraseur->res .= preg_replace("/[\n\t ]+\$/", "\n{$depth}", $t);
    $phraseur->contenu[$depth] = "";
    $att = '';
    $sep = ' ';
    foreach ($attrs as $k => $v) {
        $delim = strpos($v, "'") === false ? "'" : '"';
        $val = xml_entites_html($v);
        $att .= $sep . $k . "=" . $delim . ($delim !== '"' ? str_replace('&quot;', '"', $val) : $val) . $delim;
        $sep = "\n {$depth}";
    }
    $phraseur->depth .= '  ';
    $phraseur->contenu[$phraseur->depth] = "";
    $phraseur->ouvrant[$phraseur->depth] = $name . $att;
    $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax);
}
Exemplo n.º 18
0
 /**
  * Returns a string with the values as placeholders in a string to be used
  * for the SQL version of this expression
  *
  * @param \Cake\Database\ValueBinder $generator The value binder to convert expressions with.
  * @return string
  */
 protected function _stringifyValues($generator)
 {
     $values = [];
     $parts = $this->getValue();
     if ($parts instanceof ExpressionInterface) {
         return $parts->sql($generator);
     }
     foreach ($parts as $i => $value) {
         if ($value instanceof ExpressionInterface) {
             $values[] = $value->sql($generator);
             continue;
         }
         $type = $this->_type;
         $multiType = is_array($type);
         $isMulti = $this->isMulti();
         $type = $multiType ? $type : str_replace('[]', '', $type);
         $type = $type ?: null;
         if ($isMulti) {
             $bound = [];
             foreach ($value as $k => $val) {
                 $valType = $multiType ? $type[$k] : $type;
                 $bound[] = $this->_bindValue($generator, $val, $valType);
             }
             $values[] = sprintf('(%s)', implode(',', $bound));
             continue;
         }
         $valType = $multiType && isset($type[$i]) ? $type[$i] : $type;
         $values[] = $this->_bindValue($generator, $value, $valType);
     }
     return implode(', ', $values);
 }
Exemplo n.º 19
0
 private function underscore($name)
 {
     $name = preg_replace('/([A-Z]+)([A-Z][a-z])/', '\\1_\\2', $name);
     $name = preg_replace('/([a-z\\d])([A-Z])/', '\\1_\\2', $name);
     $name = str_replace(array('/', '\\'), array('.', '.'), $name);
     return $name;
 }
Exemplo n.º 20
0
 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     /**
      * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
      * because PHP has problems with including files that contain BOM character.
      * Having BOM character after <script> tag causes a javascript error.
      */
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKEditor'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
         echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         if (!$uploaded) {
             echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
         } else {
             echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
         }
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
 public function wp_hi_term_link($termlink, $term, $taxonomy)
 {
     foreach ($this->cpts_array as $hi_cpt) {
         $termlink = str_replace($hi_cpt['cpt_taxonomy'], $hi_cpt['cpt_slug'] . '/category', $termlink);
         return $termlink;
     }
 }
Exemplo n.º 22
0
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     $contents = $this->getKeyFile();
     $dbName = $this->argument('database');
     $dbUserName = $this->ask('What is your MySQL username?');
     $dbPassword = $this->secret('What is your MySQL password?');
     // Replace DB credentials taken from env.php file
     $keys = ['MYSQL_DATABASE', 'MYSQL_USERNAME', 'MYSQL_PASSWORD'];
     $search = ["'{$keys['0']}' => ''", "'{$keys['1']}' => ''", "'{$keys['2']}' => ''"];
     $replace = ["'{$keys['0']}' => '{$dbName}'", "'{$keys['1']}' => '{$dbUserName}'", "'{$keys['2']}' => '{$dbPassword}'"];
     $contents = str_replace($search, $replace, $contents, $count);
     if ($count != 3) {
         throw new Exception('Error while writing credentials to .env.php.');
     }
     // Set DB credentials to laravel config
     $this->laravel['config']['database.connections.mysql.database'] = $dbName;
     $this->laravel['config']['database.connections.mysql.username'] = $dbUserName;
     $this->laravel['config']['database.connections.mysql.password'] = $dbPassword;
     $this->error($this->laravel['config']['local.database.connections.mysql.database']);
     // Migrate DB
     if (!Schema::hasTable('migrations')) {
         $this->call('migrate');
         $this->call('db:seed');
     } else {
         $this->error('A migrations table was found in database [' . $dbName . '], no migrate and seed were done.');
     }
     // Write to .env.php
     $env = $this->laravel->environment();
     $newPath = $env == 'production' ? '.env.php' : '.env.' . $env . '.php';
     $this->files->put($newPath, $contents);
 }
Exemplo n.º 23
0
 public function get_mp3_url($id, $type)
 {
     $byte1[] = $this->getBytes(self::secret_bit_mask);
     //18
     $byte2[] = $this->getBytes($id);
     //16
     $magic = $byte1[0];
     $song_id = $byte2[0];
     $size = count($song_id);
     for ($i = 0; $i < $size; $i++) {
         $song_id[$i] ^= $magic[$i % count($magic)];
     }
     $result = base64_encode(md5($this->toStr($song_id), true));
     $result = str_replace(['/', '+'], ['_', '-'], $result);
     $sufix = $result . '/' . number_format($id, 0, '', '') . ".mp3";
     switch ($type) {
         case "hd":
             $url = self::mp3_hd_url . $sufix;
             break;
         case "sd":
             $url = self::mp3_sd_url . $sufix;
             break;
         default:
             $url = NULL;
             break;
     }
     return $url;
 }
Exemplo n.º 24
0
 function index()
 {
     $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS;
     $files = \GCore\Libs\Folder::getFiles($path, true);
     $strings = array();
     //function to prepare strings
     $prepare = function ($str) {
         /*$path = \GCore\C::get('GCORE_FRONT_PATH');
         		if(strpos($str, $path) !== false AND strpos($str, $path) == 0){
         			return '//'.str_replace($path, '', $str);
         		}*/
         $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : '';
         return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";';
     };
     foreach ($files as $file) {
         if (substr($file, -4, 4) == '.php') {
             // AND strpos($file, DS.'extensions'.DS) === TRUE){
             //$strings[] = $file;
             $file_code = file_get_contents($file);
             preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs);
             if (!empty($langs[2])) {
                 $strings = array_merge($strings, $langs[2]);
             }
         }
     }
     $strings = array_unique($strings);
     $strings = array_map($prepare, $strings);
     echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>';
 }
Exemplo n.º 25
0
 public function __construct($a = '')
 {
     parent::__construct();
     $this->a = $a;
     /* parse the before and after graphs if necessary*/
     foreach (array('before', 'after', 'before_rdfxml', 'after_rdfxml') as $rdf) {
         if (!empty($a[$rdf])) {
             if (is_string($a[$rdf])) {
                 /** @var \ARC2_RDFParser $parser */
                 $parser = \ARC2::getRDFParser();
                 $parser->parse(false, $a[$rdf]);
                 $a[$rdf] = $parser->getSimpleIndex(0);
             } else {
                 if (is_array($a[$rdf]) and isset($a[$rdf][0]) and isset($a[$rdf][0]['s'])) {
                     //triples array
                     /** @var \ARC2_RDFSerializer $ser */
                     $ser = \ARC2::getTurtleSerializer();
                     /** @var string $turtle */
                     $turtle = $ser->getSerializedTriples($a[$rdf]);
                     /** @var \ARC2_RDFParser $parser */
                     $parser = \ARC2::getTurtleParser();
                     $parser->parse(false, $turtle);
                     $a[$rdf] = $parser->getSimpleIndex(0);
                 }
             }
             $nrdf = str_replace('_rdfxml', '', $rdf);
             $this->{$nrdf} = $a[$rdf];
         }
     }
     $this->__init();
 }
Exemplo n.º 26
0
 public function renderPager()
 {
     // /controller/action -> #!controller/action
     $str = parent::renderPager();
     $str = str_replace('href="/', 'href="#!', $str);
     return $str;
 }
Exemplo n.º 27
0
 function CoolVideoGallery()
 {
     $this->plugin_url = trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)));
     $this->video_player_url = trailingslashit(WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/cvg-player');
     $this->video_player_path = trailingslashit(WP_CONTENT_DIR . '/plugins/' . dirname(plugin_basename(__FILE__)) . '/cvg-player/');
     $this->table_gallery = '';
     $this->table_videos = '';
     $this->video_id = '';
     if (function_exists('is_multisite') && is_multisite()) {
         $this->default_gallery_path = get_option('upload_path') . '/video-gallery/';
     } else {
         $this->default_gallery_path = 'wp-content/uploads/video-gallery/';
     }
     $this->winabspath = str_replace("\\", "/", ABSPATH);
     $this->load_video_files();
     //adds scripts and css stylesheets
     add_action('wp_print_scripts', array(&$this, 'gallery_script'));
     //adds admin menu options to manage
     add_action('admin_menu', array(&$this, 'admin_menu'));
     //adds contextual help for all menus of plugin
     add_action('admin_init', array(&$this, 'add_gallery_contextual_help'));
     //adds player options to head
     add_action('wp_head', array(&$this, 'addPlayerHeader'));
     add_action('admin_head', array(&$this, 'addPlayerHeader'));
     //adds filter for post/page content
     add_filter('the_content', array(&$this, 'CVGVideo_Parse'));
     add_filter('the_content', array(&$this, 'CVGGallery_Parse'));
     add_action('wp_dashboard_setup', array(&$this, 'cvg_custom_dashboard_widgets'));
 }
Exemplo n.º 28
0
 /**
  * Return book's short name
  *
  * @return string
  */
 public function getShortName()
 {
     if ($this->short_name === null) {
         $this->short_name = str_replace('_', '-', basename($this->path));
     }
     return $this->short_name;
 }
Exemplo n.º 29
0
 function plugin_skype_inline()
 {
     $options = $this->conf['options'];
     $args = func_get_args();
     $alias = array_pop($args);
     $this->fetch_options($options, $args, array('id'));
     if (!$options['id']) {
         return FALSE;
     } else {
         $id = $this->func->htmlspecialchars($options['id']);
     }
     if (!$alias) {
         $alias = $id;
     }
     foreach ($this->conf['modes'] as $mode) {
         if (!empty($options[$mode])) {
             break;
         }
     }
     if ($options['status']) {
         foreach ($this->conf['statuses'] as $status) {
             if ($options['status'] === $status) {
                 break;
             }
         }
     } else {
         $status = '';
     }
     $image = '';
     if ($status) {
         $image = '<img src="http://mystatus.skype.com/' . $status . '/' . $id . '" />';
     }
     $link = 'skype:' . $id . '?' . $mode;
     return str_replace(array('$image', '$link', '$alias'), array($image, $link, $alias), $this->conf['format']);
 }
Exemplo n.º 30
0
 function schema()
 {
     $this->column('id')->integer()->primary()->autoIncrement();
     $this->column('name')->typeConstraint()->required()->varchar(128);
     $this->column('description')->varchar(128);
     $this->column('category_id')->integer();
     $this->column('address')->varchar(64)->validator(function ($val, $args, $record) {
         if (preg_match('/f**k/', $val)) {
             return array(false, "Please don't");
         }
         return array(true, "Good");
     })->filter(function ($val, $args, $record) {
         return str_replace('John', 'XXXX', $val);
     })->default(function () {
         return 'Default Address';
     })->varchar(256);
     $this->column('country')->varchar(12)->required()->index()->validValues(array('Taiwan', 'Taipei', 'Tokyo'));
     $this->column('type')->varchar(24)->validValues(function () {
         return array('Type Name A' => 'type-a', 'Type Name B' => 'type-b', 'Type Name C' => 'type-c');
     });
     $this->column('confirmed')->boolean();
     $this->column('date')->date()->isa('DateTime')->deflator(function ($val) {
         if ($val instanceof \DateTime) {
             return $val->format('Y-m-d');
         } elseif (is_integer($val)) {
             return strftime('%Y-%m-%d', $val);
         }
         return $val;
     })->inflator(function ($val) {
         return new \DateTime($val);
     });
     $this->seeds('TestSeed');
 }