static function factory($paysys_id, DbSimple_Interface $db)
 {
     $class = 'InvoiceCreator_' . ucfirst(toCamelCase($paysys_id));
     if (class_exists($class, false)) {
         return new $class($paysys_id, $db);
     } else {
         throw new Exception(sprintf('Unknown Payment System [%s]', $paysys_id));
     }
 }
Exemple #2
0
 public function __invoke(Request $request)
 {
     $this->setRequest($request);
     $methodName = toCamelCase($this->getAction()) . 'Action';
     if (method_exists($this, $methodName)) {
         $this->{$methodName}();
     } else {
         throw new NotFoundHttpException();
     }
     return $this->getResponse();
 }
Exemple #3
0
 /**
  * Store the filename (sans extension) & full path of all ".php" files found
  */
 public static function registerDirectory($dirName)
 {
     $di = new DirectoryIterator($dirName);
     foreach ($di as $file) {
         if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
             // recurse into directories other than a few special ones
             self::registerDirectory($file->getPathname());
         } elseif (substr($file->getFilename(), -4) === '.php') {
             // save the class name / path of a .php file found
             $className = toCamelCase(substr($file->getFilename(), 0, -4));
             AutoLoader::registerClass($className, $file->getPathname());
         }
     }
 }
 function clearAction()
 {
     check_demo();
     $form = $this->getForm();
     if (!$form->validate()) {
         return $this->indexAction();
     }
     $vars = $form->getValue();
     if ($vars['dat'] >= $this->getDi()->sqlDate) {
         throw new Am_Exception_InputError(___("Please select date before today"), 0);
     }
     $tt = array();
     foreach ($this->getItems() as $id => $item) {
         if (!$vars[$id]) {
             continue;
         }
         $tt[] = $item['title'];
         $table = $this->getDi()->getService(lcfirst(toCamelCase($item['table'])));
         $table->clearOld($vars['dat']);
     }
     $this->getDi()->adminLogTable->log("Cleaned up old records to {$vars['dat']} (" . join(',', $tt) . ")");
     $this->view->content = $this->view->title = ___("Records Deleted Sucessfully");
     $this->view->display('admin/layout.phtml');
 }
Exemple #5
0
<?php

/**
 * [toCamelCase переводит строку вида test_var в строку testVar]
 * @param  string $str строка
 * @return string      новая строка в camelCase
 */
function toCamelCase($str)
{
    $camelcase = "";
    $arStr = explode('_', $str);
    foreach ($arStr as $val) {
        $camelcase .= ucfirst($val);
    }
    $camelcase = lcfirst($camelcase);
    return $camelcase;
}
assert(toCamelCase('str_val_first') == 'strValFirst');
assert(toCamelCase('class_number_random') == 'classNumberRandom');
Exemple #6
0
 /**
  * @param array $brickConfig - must have keys: 'id', 'class', may have 'hide', 'config'
  *
  * @return Am_Form_Brick */
 static function createFromRecord(array $brickConfig)
 {
     if (empty($brickConfig['class'])) {
         throw new Am_Exception_InternalError("Error in " . __METHOD__ . " - cannot create record without [class]");
     }
     if (empty($brickConfig['id'])) {
         throw new Am_Exception_InternalError("Error in " . __METHOD__ . " - cannot create record without [id]");
     }
     $className = 'Am_Form_Brick_' . ucfirst(toCamelCase($brickConfig['class']));
     if (!class_exists($className, true)) {
         Am_Di::getInstance()->errorLogTable->log("Missing form brick: [{$className}] - not defined");
         return;
     }
     $b = new $className($brickConfig['id'], empty($brickConfig['config']) ? array() : $brickConfig['config']);
     if (array_key_exists(self::HIDE, $brickConfig)) {
         $b->hideIfLoggedIn = (bool) @$brickConfig[self::HIDE];
     }
     if (!empty($brickConfig['labels'])) {
         $b->setCustomLabels($brickConfig['labels']);
     }
     return $b;
 }
Exemple #7
0
 /**
  * Get Class name of plugin;
  * @param string plugin name
  * @return string class name;
  */
 public function getPluginClassName($id)
 {
     return sprintf($this->classNameTemplate, ucfirst(toCamelCase($id)));
 }
Exemple #8
0
function main()
{
    $arguments = getopt("f:wvche:t:", array("vv", "rpc::", "service", "model", "mapper"));
    $file = isset($arguments['f']) ? $arguments['f'] : false;
    if (!$file) {
        echo "ERROR Option file -f \n";
        return;
    }
    $help = isset($arguments['h']) ? true : false;
    $Sservice = isset($arguments['service']) ? true : false;
    $Smodel = isset($arguments['model']) ? true : false;
    $Smapper = isset($arguments['mapper']) ? true : false;
    $Sall = $Sservice + $Smodel + $Smapper;
    $Sall = $Sall == 3 || $Sall == 0 ? true : false;
    $write = isset($arguments['w']) ? true : false;
    $clean = isset($arguments['c']) ? true : false;
    $exclus = isset($arguments['e']) ? $arguments['e'] : array();
    $Otable = isset($arguments['t']) ? $arguments['t'] : array();
    if (!is_array($exclus) || is_array($exclus) && count($exclus) == 1) {
        $exclus = array($exclus);
    }
    if (!is_array($Otable) || is_array($Otable) && count($Otable) == 1) {
        $Otable = array($Otable);
    }
    $verbose = isset($arguments['v']) ? true : false;
    $vverbose = isset($arguments['vv']) ? true : false;
    $rpc = isset($arguments['rpc']) ? is_bool($arguments['rpc']) ? true : $arguments['rpc'] : false;
    if ($help) {
        echo "-w                  : write\n";
        echo "-e [NameTable]      : exclus table\n";
        echo "-t [NameTable]      : filtre la table\n";
        echo "--service           : génerer service\n";
        echo "--mapper            : génerer mapper\n";
        echo "--model             : génerer model\n";
        echo "-v                  : verbose\n";
        echo "--vv                : verbose++\n";
        echo "-f                  : file *.mwb (file mysql workbench)\n";
        echo "--rpc[=NameTable]   : ATTENTION! si NameTable n'est pas present tous les JsonRpc des tables seront créés, sinon seule la table JSON-RPC NameTable sera créé \n";
        return 0;
    }
    $pathDal = "../module/Application/src/Application/";
    $pathJsonRpcServer = "../module/JsonRpcServer/src/JsonRpcServer/";
    $pathConf = "../module/Dal/Module.php";
    $pathConfRpc = "../module/JsonRpcServer/config/module.config.php";
    $result = parseMwb($file, $vverbose);
    $handle = opendir($pathDal . '/Model');
    $TableExistante = array();
    while (false !== ($entry = readdir($handle))) {
        if ($entry != "." && $entry != ".." && strpos($entry, 'Abstract') !== 0 && strpos($entry, '.php') !== false && $entry != "ModelInterface.php") {
            $TableExistante[] = substr(toNoCamelCase(substr($entry, 0, -4)), 1);
        }
    }
    foreach ($result as $nameTable => $body) {
        if (!empty($Otable) && in_array($nameTable, $Otable) || empty($Otable)) {
            $columCamel = array();
            foreach ($body['column'] as $colum => $opt) {
                $columCamel[$opt['name']] = toCamelCase($opt['name']);
            }
            if (in_array($nameTable, $TableExistante)) {
                $val = array_search($nameTable, $TableExistante);
                if ($val !== false) {
                    unset($TableExistante[$val]);
                }
            }
            if (!in_array($nameTable, $exclus) && $nameTable != "" && $body['type'] == "table") {
                if ($Sall || $Smodel) {
                    createModel($nameTable, $columCamel, $pathDal, $write, $verbose);
                }
                if ($Sall || $Smapper) {
                    createMapper($nameTable, $pathDal, $write, $verbose);
                }
                if ($Sall || $Sservice) {
                    createService($nameTable, $pathDal, $write, $verbose);
                }
            }
            if ($rpc && !is_string($rpc) || $rpc === $nameTable) {
                createServiceRpc($nameTable, $pathJsonRpcServer, $pathConfRpc, $write, $verbose);
            }
        }
    }
    foreach ($TableExistante as $nameTable) {
        if ($Otable && $Otable == $nameTable || !$Otable) {
            removeModel($nameTable, $pathDal, $write, $verbose);
        }
    }
}
 /**
  * Return allowed resources as objects
  * @return array of ResourceAbstract
  * @see self::selectAllowedResources
  */
 function getAllowedResources(User $user, $types = null, $groupByType = true)
 {
     $ret = array();
     if ($types === ResourceAccess::USER_VISIBLE_TYPES) {
         $types = array(ResourceAccess::FOLDER, ResourceAccess::FILE, ResourceAccess::PAGE, ResourceAccess::LINK, ResourceAccess::VIDEO);
     } elseif ($types === ResourceAccess::USER_VISIBLE_PAGES) {
         $types = array(ResourceAccess::FOLDER, ResourceAccess::PAGE, ResourceAccess::LINK);
     }
     $res = $this->selectAllowedResources($user, $types);
     usort($res, array($this, '_sortByResourceType'));
     foreach ($res as $r) {
         $o = $this->getDi()->getService(lcfirst(toCamelCase($r['resource_type'])) . 'Table')->load($r['resource_id'], false);
         if ($o) {
             $ret[] = $o;
         }
     }
     /** @todo - optimize: load resources by same type with one query */
     return $ret;
 }
 function handleDoctrine2PHPBody($db, $table, $crlf)
 {
     global $YAML_dataTypes;
     $lines = array();
     /*
      * Doctrine offers the ability to specify schema in an abbreviated syntax.
      *
      * If verbose is set to false, a lot of the schema parameters have values they default to,
      * this allows us to abbreviate the syntax and let Doctrine just use its defaults.
      *
      * If verbose is set to true ALL schema parameters will be included. This is recomended!
      */
     $useVerboseSyntax = cgGetOption('verbose');
     /*
      * Show Table relations in header
      */
     $showIndexes = cgGetOption('index');
     // create schema
     $YAML_dataTypes = createYAML_dataTypeSchema();
     // get table info
     $sqlQuery = "SELECT * FROM information_schema.columns WHERE TABLE_SCHEMA = '{$db}' AND TABLE_NAME = '{$table}'";
     $result = PMA_DBI_query($sqlQuery);
     // get table relations
     $sqlQuery = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '{$db}' AND TABLE_NAME = '{$table}'";
     $result_rel = PMA_DBI_query($sqlQuery);
     $tableRelations = array();
     while ($row = PMA_DBI_fetch_assoc($result_rel)) {
         $tableRelations[] = $row;
         $referencedTable = $row["REFERENCED_TABLE_NAME"];
         $referencedTableClass = toCamelCase($referencedTable, true);
     }
     // build header
     if (!$useVerboseSyntax) {
         //   $lines[] = "detect_relations: true\n";
     }
     // build body
     if ($result) {
         $tableProperties = array();
         while ($row = PMA_DBI_fetch_assoc($result)) {
             $tableProperties[] = new TableProperty($row);
             //$lines[] = print_r($row);
         }
         // insert table Class Headers
         $lines[] = "<?php\n";
         $lines[] = "namespace models;";
         $str = "\n/**\n * @Entity\n * @Table(name=\"" . $table . "\"";
         // insert table indexes
         if ($showIndexes) {
             $tableIndexes = new TableIndexes($db, $table);
             $indexes = $tableIndexes->getIndexes(true);
             if (count($indexes) > 0) {
                 $indexCount = 0;
                 $indexDeliminator = '';
                 $str .= ", indexes={";
                 foreach ($indexes as $index) {
                     $columnsCount = 0;
                     $columnDeliminator = '';
                     if ($indexCount > 0) {
                         $indexDeliminator = ', ';
                     }
                     $str .= $indexDeliminator . "@index(name=\"" . $index->name->schemaVal . "\", columns={";
                     foreach ($index->columns->schemaVal as $col) {
                         if ($columnsCount > 0) {
                             $columnDeliminator = ', ';
                         }
                         $str .= $columnDeliminator . "\"" . $col . "\"";
                         $columnsCount++;
                     }
                     $str .= "})";
                     $indexCount++;
                 }
                 $str .= "}";
             }
         }
         $str .= ")\n */\n";
         $lines[] = $str;
         // insert class name
         $lines[] = "class " . toCamelCase($table, true) . " {\n\n\n";
         foreach ($tableProperties as $tablePropertie) {
             //insert metadata
             $lines[] = "    " . $tablePropertie->insertMetadata($useVerboseSyntax);
             //insert property
             $propName = toCamelCase($tablePropertie->fields->name->schemaVal);
             $lines[] = "\tprivate \$" . $propName . ";\n";
         }
         // insert relations
         $sqlQuery = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '{$db}' AND TABLE_NAME = '{$table}'";
         $result2 = PMA_DBI_query($sqlQuery);
         while ($row = PMA_DBI_fetch_assoc($result2)) {
             $referencedTable = $row["REFERENCED_TABLE_NAME"];
             $referencedTableClass = toCamelCase($referencedTable, true);
             if ($referencedTable) {
                 $lines[] = "\t/**";
                 $lines[] = "\t * @OneToOne(targetEntity=\"" . $referencedTableClass . "\")";
                 $lines[] = "\t */";
                 $lines[] = "\tprivate \$" . $referencedTable . ";\n";
             }
         }
         // insert getters / setters
         $lines[] = "\n";
         foreach ($tableProperties as $tablePropertie) {
             $functname = toCamelCase($tablePropertie->fields->name->schemaVal, true);
             $propName = toCamelCase($tablePropertie->fields->name->schemaVal);
             $lines[] = "\tpublic function get" . $functname . "() \n\t{\n\t\treturn \$this->" . $propName . ";\n\t} \n";
             $lines[] = "\tpublic function set" . $functname . "(\$" . $propName . ") \n\t{\n\t\t\$this->" . $propName . " = \$" . $propName . ";\n\t} \n";
         }
         $lines[] = "}\n?>\n\n";
         PMA_DBI_free_result($result);
     }
     return implode("\n", $lines);
 }
 function handleDoctrineBody($db, $table, $crlf)
 {
     global $YAML_dataTypes;
     $lines = array();
     /*
      * Doctrine offers the ability to specify schema in an abbreviated syntax.
      *
      * If verbose is set to false, a lot of the schema parameters have values they default to,
      * this allows us to abbreviate the syntax and let Doctrine just use its defaults.
      *
      * If verbose is set to true ALL schema parameters will be included. This is recomended!
      */
     $useVerboseSyntax = true;
     // create schema
     $YAML_dataTypes = createYAML_dataTypeSchema();
     // build header
     if (!$useVerboseSyntax) {
         //   $lines[] = "detect_relations: true\n";
     }
     // build body
     $sqlQuery = "SELECT * FROM information_schema.columns WHERE TABLE_SCHEMA = '{$db}' AND TABLE_NAME = '{$table}'";
     $result = PMA_DBI_query($sqlQuery);
     if ($result) {
         $tableProperties = array();
         while ($rowObj = PMA_DBI_fetch_assoc($result)) {
             $tableProperties[] = new TableProperty($rowObj);
             // $lines[] = print_r($rowObj);
         }
         // insert table Class name
         $tableClass = toCamelCase($table, true);
         $lines[] = $tableClass . ":";
         // insert table name
         $lines[] = "  tableName: " . $table;
         //insert columns
         $lines[] = "  options:\n  type: INNODB\n";
         // insert columns
         $lines[] = "  columns:";
         foreach ($tableProperties as $tablePropertie) {
             // $lines[] = print_r($tablePropertie);
             $lines[] = "    " . $tablePropertie->insertColumn($useVerboseSyntax);
         }
         $lines[] = "\n";
         if ($useVerboseSyntax) {
             // DO relations here
         }
         PMA_DBI_free_result($result);
     }
     return implode("\n", $lines);
 }
Exemple #12
0
    } else {
        $com = Request::get('com');
        if (!is_dir(ADMIN_ROOT . '/components/' . $com)) {
            Router::set404();
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/config.php')) {
            require_once ADMIN_ROOT . '/components/' . $com . '/config.php';
        }
        if (is_file(ADMIN_ROOT . '/components/' . $com . '/SectionController.php')) {
            Load::controller(ADMIN_ROOT . '/components/' . $com . '/SectionController.php', Request::get('section', false));
        } else {
            $com_dirs = FileSys::getDirs(ADMIN_ROOT . '/components/' . $com);
            $forbidden_dir = ['client'];
            $section = Request::get('section');
            if (in_array($section, $com_dirs) && !in_array($section, $forbidden_dir)) {
                Load::manager(ADMIN_ROOT . '/components/' . $com . '/' . $section . '/' . toCamelCase($section) . 'Manager.php');
            } else {
                Router::set404();
            }
        }
    }
} catch (SystemException $e) {
    header('HTTP/1.0 500 Internal Server Error');
    echo $e->getError();
} catch (ValidatorException $e) {
    header('HTTP/1.0 400 Bad Request');
    echo $e->getError();
} catch (AccessException $e) {
    header('HTTP/1.0 403 Forbidden');
    echo $e->getError();
}
Exemple #13
0
 /**
  * Return allowed resources as objects
  * @return array of ResourceAbstract
  * @see self::selectAllowedResources
  */
 function getAllowedResources(User $user, $types = null, $groupByType = true)
 {
     $ret = array();
     $res = $this->selectAllowedResources($user, $types = $this->getResourceTypes($types));
     $ids = array();
     $order = array();
     $i = 0;
     foreach ($res as $k => $r) {
         //            $ids[$r['resource_type']][$r['resource_id']] = $k;
         $ids[$r['resource_type']][$r['resource_id']] = array('fn' => $r['fn'], 'id' => $r['fn_id']);
         $order[$r['resource_type'] . '_' . $r['resource_id']] = $i++;
     }
     $ret = array();
     foreach ($ids as $resource_type => &$container) {
         $table = $this->getDi()->getService(lcfirst(toCamelCase($resource_type)) . 'Table');
         /* @var $table Am_Table */
         foreach ($table->loadIds(array_keys($container)) as $rec) {
             $id = $rec->pk();
             if (isset($container[$id])) {
                 $k = $order[$resource_type . '_' . $id];
                 // get position in result
                 $rec->fn_id = $container[$id];
                 // assign product_title to email template
                 $ret[$k] = $rec;
             } else {
                 throw new Am_Exception_InternalError("->loadIds returned id[{$id}] not specified in request " . implode(",", array_keys($container)));
             }
         }
     }
     $event = new Am_Event(Am_Event::GET_ALLOWED_RESOURCES, array('user' => $user, 'types' => $types));
     $event->setReturn($ret);
     $this->getDi()->hook->call($event);
     $ret = $event->getReturn();
     ksort($ret);
     return $ret;
 }
Exemple #14
0
    protected function _afterInitSetupForm(Am_Form_Setup $form)
    {
        // insert title, description fields
        $form->setTitle(ucfirst(toCamelCase($this->getId())));
        $el = $form->addMagicSelect('reattempt', array('multiple' => 'multiple'));
        $options = array();
        for ($i = 1; $i < 60; $i++) {
            $options[$i] = ___("on %d-th day", $i);
        }
        $el->loadOptions($options);
        $el->setLabel(___("Retry On Failure\n" . "if the recurring billing has failed,\n" . "aMember can repeat it after several days,\n" . "and extend customer subscription for that period\n" . "enter number of days to repeat billing attempt"));
        if ($this->storesCcInfo() && !$this->_pciDssNotRequired) {
            $text = "<p><font color='red'>WARNING!</font> Every application processing e-check information, must be certified\n" . "as PA-DSS compliant, and every website processing credit cards must\n" . "be certified as PCI-DSS compliant.</p>";
            $text .= "<p>aMember Pro is not yet certified as PA-DSS compliant. We will start certification process\n" . "once we get 4.2.0 branch released and stable. This plugins is provided solely for TESTING purproses\n" . "Use it for anything else but testing at your own risk.</p>";
            $form->addProlog(<<<CUT
<div class="warning_box">
    {$text}
</div>   
CUT
);
        }
        $keyFile = defined('AM_KEYFILE') ? AM_KEYFILE : APPLICATION_PATH . '/configs/key.php';
        if (!is_readable($keyFile)) {
            $random = $this->getDi()->app->generateRandomString(78);
            $text = "<p>To use credit card plugins, you need to create a key file that contains unique\n";
            $text .= "encryption key for your website. It is necessary even if the plugin does not\n";
            $text .= "store sensitive information.</p>";
            $text .= "<p>In a text editor, create file with the following content (one-line, no spaces before opening &lt;?php):\n";
            $text .= "<br /><br /><pre style='background-color: #e0e0e0;'>&lt;?php return '{$random}';</pre>\n";
            $text .= "<br />save the file as <b>key.php</b>, and upload to <i>amember/application/configs/</i> folder.\n";
            $text .= "This warning will disappear once you do it correctly.</p>";
            $text .= "<p>KEEP A BACKUP COPY OF THE key.php FILE (!)</p>";
            $form->addProlog(<<<CUT
<div class="warning_box">
    {$text}
</div>
CUT
);
        }
        return parent::_afterInitSetupForm($form);
    }
 static function factory($paysys_id)
 {
     $class = 'InvoiceCreator_' . ucfirst(toCamelCase($paysys_id));
     if (class_exists($class, false)) {
         return new $class($paysys_id);
     } else {
         return new InvoiceCreator_Standard($paysys_id);
     }
 }
Exemple #16
0
$storeInfo = $BG->getStoreInfo();
// var_dump($storeInfo);
// echo '<br />';
// echo '<br />';
// echo '<br />';
// echo '<br />';
// echo '<br />';
$products = $BG->listProducts();
// var_dump($products);
$html = '<section class="content">';
foreach ($products as $product) {
    $name = str_replace('Mullins', '', $product->name);
    if (strpos(strtolower($name), 'shirt') !== false || strpos(strtolower($name), 'poster') !== false) {
    } else {
        $menu .= '<li class="menu-item"><a href="#' . toCamelCase($name) . '">' . $name . '</a></li>';
        $html .= '<section class="product" id="' . toCamelCase($name) . '">';
        $html .= '<h3 class="product-name">' . $name . '<a class="purchase-link" target="_blank" href="' . $storeInfo->url . '' . $product->url . '">$' . $product->default_price . ' <i class="fa fa-shopping-cart"></i></a></h3>';
        $html .= '<p class="product-description">' . utf8_decode($product->description) . '</p>';
        foreach ($product->images as $image) {
            $html .= '<img src="' . $image->url . '" />';
        }
        $html .= '</section>';
    }
}
$html .= '</section>';
$menu .= '<li class="after"><div class="inner"></div></li></ul>';
$menu .= '<span class="contact-info">Mullins Chain Drive<br/>401 1st Street #155</br>Richmond, California 94801</br></br><a href="mailto:info@mullinschaindrive.com">info@mullinschaindrive.com</a></span>';
$menu .= '<div class="social"><a href="http://facebook.com/mullinschaindrive" target="_blank"><i class="fa fa-facebook"></i></a><a href="http://instagram.com/mullinschaindrive" target="_blank"><i class="fa fa-instagram"></i></a>';
$menu .= '</div>';
echo $html;
?>
Exemple #17
0
    protected function _afterInitSetupForm(Am_Form_Setup $form)
    {
        // insert title, description fields
        $form->setTitle(ucfirst(toCamelCase($this->getId())));
        $el = $form->addMagicSelect('reattempt', array('multiple' => 'multiple'));
        $options = array();
        for ($i = 1; $i < 60; $i++) {
            $options[$i] = ___("on %d-th day", $i);
        }
        $el->loadOptions($options);
        $el->setLabel(___("Retry On Failure\n" . "if the recurring billing has failed,\n" . "aMember can repeat it after several days,\n" . "and extend customer subscription for that period\n" . "enter number of days to repeat billing attempt"));
        if ($this->canUseMaxmind()) {
            $form->addFieldset()->setLabel(___('MaxMind Credit Card Fraud Detection'));
            $form->addAdvCheckbox('use_maxmind')->setLabel(___('Use MaxMind Credit Card Fraud Detection'));
            $form->addText('maxmind_license_key')->setLabel(___("Maxmind License Key\n" . "%sObtain a Free or Premium license key%s", '<a href="http://www.maxmind.com/app/minfraud" target="_blank">', '</a>'));
            $form->addSelect('maxmind_requested_type')->setLabel(___("Requested Type\n" . "To be used if you have multiple plans in one account\n" . "and wish to select type of query you wish to make.\n" . "By default the service uses the highest level available"))->loadOptions(array("" => 'Default', "free" => 'Free', "city" => 'City (standard paid service)', "premium" => 'Premium (premium paid service)'));
            $form->addText('maxmind_risk_score')->setLabel(___("Risk Score\n" . "Overall %sRisk Score%s (decimal from 0 to 10)\n" . "For orders that return a fraud score of 2.5 and above,\n" . " it is recommended to hold for review,\n" . " or require the validation with the Telephone Verification service\n", '<a href="http://www.maxmind.com/app/web_services_score2" target="_blank">', '</a>'));
            $form->setDefault('maxmind_risk_score', '2.5');
            /*$form->addAdvCheckbox('maxmind_use_telephone_verification')->setLabel(
              ___("Telephone Verification\n" .
                      "Enable %sTelephone Verification%s service"
                      , '<a href="http://www.maxmind.com/app/telephone_overview" target="_blank">', '</a>'));*/
            $form->addAdvCheckbox('maxmind_use_number_identification')->setLabel(___("Number Identification\n" . "Enable %sTelephone Number Identification (TNI)%s service", '<a href="http://www.maxmind.com/app/phone_id" target="_blank">', '</a>'));
            $form->addMagicSelect('maxmind_tni_phone_types')->setLabel(___("Allowed Phone Types\n" . "The TNI service is able to categorize customer inputted US and Canadian\n" . "phone numbers into %seight different phone types%s\n" . "such as fixed land line, mobile, VoIP, and invalid phone numbers", '<a href="http://www.maxmind.com/app/phone_id_codes" target="_blank">', '</a>'))->loadOptions(array('0' => 'Undetermined (Medium Risk Level)', '1' => 'Fixed Line (Low Risk Level)', '2' => 'Mobile (Low-Medium Risk Level)', '3' => 'PrePaid Mobile (Medium-High Risk Level)', '4' => 'Toll-Free (High Risk Level)', '5' => 'Non-Fixed VoIP (High Risk Level)', '8' => 'Invalid Number (High Risk Level)', '9' => 'Restricted Number (High Risk Level)'));
            $form->addAdvCheckbox('maxmind_allow_country_not_matched')->setLabel(___("Allow payment if country not matched\n" . "Whether country of IP address matches billing address country\n" . "(mismatch = higher risk)"));
            $form->addAdvCheckbox('maxmind_allow_high_risk_country')->setLabel(___("Allow payment if high risk countries\n" . "Whether IP address or billing address country is in\n" . "Egypt, Ghana, Indonesia, Lebanon, Macedonia, Morocco, Nigeria,\n" . "Pakistan, Romania, Serbia and Montenegro, Ukraine, or Vietnam"));
            $form->addAdvCheckbox('maxmind_allow_anonymous_proxy')->setLabel(___("Allow payment if anonymous proxy\n" . "Whether IP address is %sAnonymous Proxy%s\n" . "(anonymous proxy = very high risk)", '<a href="http://www.maxmind.com/app/proxy#anon" target="_blank">', '</a>'));
            $form->addAdvCheckbox('maxmind_allow_free_mail')->setLabel(___("Allow payment if free e-mail\n" . "Whether e-mail is from free e-mail provider\n" . "(free e-mail = higher risk)"));
            $form->addElement('script')->setScript(<<<CUT
function showHideMaxmind()
{
    var el = \$("[id^=use_maxmind-]");    
    \$("[id^=maxmind_]").closest(".row").toggle(el.prop('checked'));
    if(el.prop('checked'))
        /*showHideNumberidentification();*/
        showHidePhonetypes();
}
/*function showHideNumberidentification()
{
    var el = \$("[id^=maxmind_use_telephone_verification-]");    
    \$("[id^=maxmind_tni_phone_types-]").closest(".row").toggle(el.prop('checked'));
    \$("[id^=maxmind_use_number_identification-]").closest(".row").toggle(el.prop('checked'));
    if(el.prop('checked'))
        showHidePhonetypes();
}*/
function showHidePhonetypes()
{
    \$("[id^=maxmind_tni_phone_types-]").closest(".row").toggle(\$("[id^=maxmind_use_number_identification-]").prop('checked'));
}
\$(function(){
    \$("[id^=use_maxmind-]").click(function(){
        showHideMaxmind();
    });
    /*\$("[id^=maxmind_use_telephone_verification-]").click(function(){
        showHideNumberidentification();
    });*/
    \$("[id^=maxmind_use_number_identification-]").click(function(){
        showHidePhonetypes();
    });
    showHideMaxmind();
});
CUT
);
        }
        if ($this->storesCcInfo() && !$this->_pciDssNotRequired) {
            $text = "<p><font color='red'>WARNING!</font> Every application processing credit card information, must be certified\n" . "as PA-DSS compliant, and every website processing credit cards must\n" . "be certified as PCI-DSS compliant.</p>";
            $text .= "<p>aMember Pro is not yet certified as PA-DSS compliant. " . "This plugins is provided solely for TESTING purproses\n" . "Use it for anything else but testing at your own risk.</p>";
            $form->addProlog(<<<CUT
<div class="warning_box">
    {$text}
</div>   
CUT
);
        }
        $keyFile = defined('AM_KEYFILE') ? AM_KEYFILE : APPLICATION_PATH . '/configs/key.php';
        if (!is_readable($keyFile)) {
            $random = $this->getDi()->app->generateRandomString(78);
            $text = "<p>To use credit card plugins, you need to create a key file that contains unique\n";
            $text .= "encryption key for your website. It is necessary even if the plugin does not\n";
            $text .= "store sensitive information.</p>";
            $text .= "<p>In a text editor, create file with the following content (one-line, no spaces before opening &lt;?php):\n";
            $text .= "<br /><br /><pre style='background-color: #e0e0e0;'>&lt;?php return '{$random}';</pre>\n";
            $text .= "<br />save the file as <b>key.php</b>, and upload to <i>amember/application/configs/</i> folder.\n";
            $text .= "This warning will disappear once you do it correctly.</p>";
            $text .= "<p>KEEP A BACKUP COPY OF THE key.php FILE (!)</p>";
            $form->addProlog(<<<CUT
<div class="warning_box">
    {$text}
</div>
CUT
);
        }
        return parent::_afterInitSetupForm($form);
    }
 function tryConnect(array &$info)
 {
     $class = 'Am_FileConnector_' . ucfirst(toCamelCase($info['method']));
     $connector = new $class($info);
     if (!$connector->connect()) {
         return "Connection failed: " . $connector->getError();
     }
     // create temp file locally
     $fn = tempnam(DATA_DIR, 'test-ftp-');
     $f = fopen($fn, 'w');
     fclose($f);
     $cwd = $connector->cwd();
     $root = $this->guessChrootedAmemberPath($cwd, array_keys($connector->ls('.')), ROOT_DIR);
     $root_path = null;
     foreach (array($root, ROOT_DIR) as $path) {
         $ls = $connector->ls($path . '/data');
         if (array_key_exists(basename($fn), $ls)) {
             $root_path = $path;
             break;
         }
     }
     @unlink($fn);
     if (is_null($root_path)) {
         return "Connection succesful, but upgrade script was unable to locate test file on remote server";
     }
     $info['root'] = $root_path;
 }
Exemple #19
0
/**
 * Checks if the given name is found in the array, either in camelCased or
 * un_camel_cased form.
 * @param string $name: The name to check, both CC'd and unCC'd
 * @param Array $array: Array to check
 * @return mixed: matched name form, or boolean false
 */
function cciInArray($name, $array) {
  if (!$array || !$name) {
    return false;
  }
  $ucc_name = unCamelCase($name);
  $ccName = toCamelCase($name);
  if (in_array($ucc_name, $array, true)) {
    return $ucc_name;
  }
  if (in_array($ccName, $array, true)) {
    return $ccName;
  }
  return false;
}