public function updateIdealo()
 {
     $tools = new tools();
     $tools->AllNeeded();
     $communication = new Communication($this->login);
     $count = count($this->update);
     $update = 0;
     $interval = $this->login['pagesize'];
     if ($count < $this->login['pagesize']) {
         $interval = $count;
     }
     while ($count > 0) {
         $tools->getXMLBegin($this->login['testmode']);
         for ($i = $update; $i < $update + $interval; $i++) {
             if ($this->update[$i]['event'] == 'DELETE') {
                 $tools->deleteProductAtIdealo($this->update[$i]['product']);
             } else {
                 $tools->getXML($this->update[$i]['product']);
             }
         }
         @$communication->sendRequest($tools->xml->saveXML());
         $count = $count - $this->login['pagesize'];
         $update = $update + $this->login['pagesize'];
     }
 }
Ejemplo n.º 2
0
 public function validate($value)
 {
     if (is_array($value) && isset($value['path']) && isset($value['dataURL'])) {
         $fileName = str_replace('..', '', $value['path']);
         /* secure relative path */
         /* find an unused name */
         $fileInfo = pathinfo($fileName);
         $base = $fileInfo['filename'];
         $ext = $fileInfo['extension'];
         $dir = empty($fileInfo['dirname']) ? '' : $fileInfo['dirname'] . '/';
         /*  $fileInfo['dirname'] in case that filename contains a part of dirname */
         $path = PROFILE_PATH . $this->entity->getModule() . '/' . $this->path . '/';
         $nbn = 0;
         while (is_file($path . $fileName)) {
             $fileName = $dir . $base . '_' . $nbn . '.' . $ext;
             $nbn++;
         }
         if (!is_dir($path . $dir)) {
             \tools::createDirectory($path . $fileInfo['dirname'] . '/');
         }
         /* decode dataURL */
         $cut = explode(',', $value['dataURL']);
         $dataURL = $cut[1];
         $dataURL = base64_decode(str_replace(' ', '+', $dataURL));
         /* save and check image */
         if (file_put_contents($path . $fileName, $dataURL)) {
             return $fileName;
         } else {
             return FALSE;
             /* can't write image */
         }
     } else {
         return parent::validate($value);
     }
 }
Ejemplo n.º 3
0
 public function onMove($typeProgress, $module, $name, $copy = FALSE)
 {
     $imgs = $this->getConfig('img');
     foreach ($imgs as $img) {
         $oldPath = $img['name'];
         $imagePath = substr(strstr($oldPath, '/files/'), 7);
         $newPath = $module . '/files/' . $imagePath;
         if ($oldPath !== $newPath) {
             if (stream_resolve_include_path($newPath) !== FALSE) {
                 /* check if an image with this path already exists in profile */
                 $fileInfo = pathinfo($imagePath);
                 $extension = strtolower($fileInfo['extension']);
                 $filename = $fileInfo['filename'];
                 /* allow to not overload filename with name_0_3_2_0 ... */
                 $generatedPart = strrchr($filename, '_');
                 if ($generatedPart !== FALSE && is_numeric(substr($generatedPart, 1))) {
                     $filename = substr($fileInfo['filename'], 0, -strlen($generatedPart));
                 }
                 $nbn = 0;
                 while (stream_resolve_include_path($newPath)) {
                     $imagePath = $filename . '_' . $nbn . '.' . $extension;
                     $newPath = $module . '/files/' . $imagePath;
                     $nbn++;
                 }
             }
             $this->setConfig('imgPath', $newPath);
             \tools::file_put_contents(PROFILE_PATH . $newPath, file_get_contents($oldPath, FILE_USE_INCLUDE_PATH));
         }
     }
 }
Ejemplo n.º 4
0
 public static function findAndAdd($title, $classify, $logid)
 {
     $title = zmf::filterInput($title, 't', 1);
     if (!$title) {
         return false;
     }
     $info = Tags::model()->find('title=:title AND classify=:classify', array(':title' => $title, ':classify' => $classify));
     if (!$info) {
         if (Yii::app()->session['checkHasBadword'] == 'yes') {
             $status = Posts::STATUS_STAYCHECK;
         } else {
             $status = Posts::STATUS_PASSED;
         }
         unset(Yii::app()->session['checkHasBadword']);
         $_data = array('title' => $title, 'name' => tools::pinyin($title), 'classify' => $classify, 'status' => $status, 'cTime' => time(), 'length' => mb_strlen($title, 'GBK'));
         $modelB = new Tags();
         $modelB->attributes = $_data;
         if ($modelB->save()) {
             $tagid = $modelB->id;
         }
     } else {
         $tagid = $info['id'];
     }
     if ($tagid && $logid) {
         $_info = TagRelation::model()->find('tagid=:tagid AND logid=:logid AND classify=:classify', array(':tagid' => $tagid, ':logid' => $logid, ':classify' => $classify));
         if (!$_info) {
             $_tagre = array('tagid' => $tagid, 'logid' => $logid, 'classify' => $classify, 'cTime' => zmf::now());
             $modelC = new TagRelation();
             $modelC->attributes = $_tagre;
             $modelC->save();
         }
     }
     return $tagid;
 }
Ejemplo n.º 5
0
 public function validate($value)
 {
     $length = strlen($value);
     if ($length >= $this->characters_min && $length <= $this->characters_max) {
         if (empty($value)) {
             $title = $this->entity->getField($this->entity->getBehaviorTitle());
             if (!$this->required) {
                 return '';
             } elseif (!empty($title->value)) {
                 return \tools::sanitizeString($title->value);
             } else {
                 return FALSE;
             }
         } else {
             $args = func_get_args();
             if ($this->unique && isset($args[1])) {
                 if ($args[1] === 'insert') {
                     $args[1] = FALSE;
                 }
                 if ($this->checkUniqueAction($value, $args[1]) === FALSE) {
                     return FALSE;
                 }
             }
             return filter_var($value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '#' . $this->regex . '#')));
         }
     }
     return FALSE;
 }
Ejemplo n.º 6
0
 /**
  * 获取汇率
  * 雅虎YQL https://developer.yahoo.com/yql/console/
  * 请求语句 select * from yahoo.finance.xchange where pair="CNYUSD,CNYHKD"
  * 示例 https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22CNYUSD%2CCNYHKD%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=
  */
 public function actionExrates()
 {
     $units = tools::getUnits();
     unset($units['CNY']);
     $arr = array();
     foreach ($units as $k => $v) {
         $arr[] = 'CNY' . $k;
     }
     $str = join(',', $arr);
     $url = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%3D%22{$str}%22%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=";
     $output = zmf::curlget($url);
     if (!$output) {
         exit('Failed');
     }
     $rateArr = CJSON::decode($output);
     $rateArr = $rateArr['query']['results']['rate'];
     foreach ($rateArr as $val) {
         $_key = str_replace('CNY', '', $val['id']);
         $rates[$_key] = array('rate' => $val['Rate'], 'title' => tools::getUnits($_key));
     }
     $detailDir = Yii::app()->basePath . '/runtime/rates/';
     zmf::createUploadDir($detailDir);
     $dir = $detailDir . 'detail.log';
     file_put_contents($dir, CJSON::encode($rates));
     exit('well done');
 }
Ejemplo n.º 7
0
     private static function getData($serverData, $lang){
	  try{
               $stops = array();
               $html = str_get_html($serverData);
               $nodes = $html->find("tr.rowHeightTraject");
               $i = 0;
               foreach ($nodes as $node) {
                    $row_delay = str_replace("'",'',str_replace('+','',trim($node->children(3)->first_child()->plaintext)));
                    if (isset($row_delay)) {
                         $arr= array();
                         $arr = explode(":",$row_delay);
                         if(isset($arr[1])){
                              $delay = (60*$arr[0] + $arr[1])*60;
                         }else{
                              $delay = $row_delay * 60;
                         }
                    } else {
                         $delay = 0;
                    }
                    $stops[$i] = new Stop();
                    $stops[$i]->station = stations::getStationFromRTName($node->children(1)->first_child()->plaintext,$lang);
                    $stops[$i]->delay = $delay;
                    $stops[$i]->time = tools::transformTime("00d" . $node->children(2)->first_child()->plaintext . ":00", date("Ymd"));
                    $i++;
               }
	       return $stops;
	  }
	  catch(Exception $e){
	       throw new Exception($e->getMessage(), 500);
	  }
     }
Ejemplo n.º 8
0
 /**
  * Constructor. Set DB Object and set {@link $return_statements return_statements}.
  *
  * @param \phpbb\db\driver\driver_interface	$db					Database connection
  * @param bool		$return_statements	True if only statements should be returned and no SQL being executed
  */
 public function __construct(\phpbb\db\driver\driver_interface $db, $return_statements = false)
 {
     parent::__construct($db, $return_statements);
     // Determine mapping database type
     $this->sql_layer = 'postgres';
     $this->dbms_type_map = self::get_dbms_type_map();
 }
Ejemplo n.º 9
0
function selectTrain()
{
    $conn = tools::connectDatabase();
    $data = array();
    $ID = array();
    $employeeCount = array();
    $result = mysqli_query($conn, "SELECT * FROM Training");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
        array_push($ID, $row[0]);
    }
    for ($x = 0; $x < count($ID); $x++) {
        $newID = $ID[$x];
        $employeeCount[$newID] = 0;
    }
    $newResult = mysqli_query($conn, "SELECT * FROM EmployeeTraining");
    while ($newRow = mysqli_fetch_array($newResult)) {
        for ($i = 0; $i < count($ID); $i++) {
            if ($ID[$i] == $newRow['TrainingID']) {
                $newID = $ID[$i];
                $employeeCount[$newID]++;
            }
        }
    }
    for ($z = 0; $z < count($data); $z++) {
        $tempID = $data[$z]['TrainingID'];
        $data[$z]['count'] = $employeeCount[$tempID];
    }
    echo json_encode($data);
}
Ejemplo n.º 10
0
function addRole($roleName, $roleAuthority)
{
    $conn = tools::connectDatabase();
    $roleID = tools::getMaxRoleID() + 1;
    mysqli_query($conn, "INSERT INTO Roles(RoleID,RoleName,Auth_Authority,Auth_Info,Auth_Job,Auth_Attendance,Auth_Training,Auth_Evaluation,Auth_RP,Auth_Role,Auth_Encrypt) VALUES ('{$roleID}','{$roleName}','{$roleAuthority['0']}','{$roleAuthority['1']}','{$roleAuthority['2']}','{$roleAuthority['3']}','{$roleAuthority['4']}','{$roleAuthority['5']}','{$roleAuthority['6']}','{$roleAuthority['7']}','{$roleAuthority['8']}')");
    echo "success";
}
Ejemplo n.º 11
0
 /**
  *  HELPER METHODS
  */
 public static function _element($class = null, $content = null, $args = array())
 {
     if (is_null($content)) {
         $content = isset($args['content']) ? $args['content'] : '';
     }
     return tools::load('html', 'elements/base', array('class' => self::_class($class, $args), 'id' => isset($args['id']) ? $args['id'] : '', 'title' => isset($args['title']) ? $args['title'] : '', 'icon' => isset($args['icon']) ? $args['icon'] : false, 'label' => isset($args['label']) ? $args['label'] : false, 'mobile' => isset($args['mobile']) ? $args['mobile'] : 'icon', 'compact' => isset($args['compact']) ? $args['compact'] : false, 'url' => isset($args['url']) ? $args['url'] : false, 'content' => $content));
 }
Ejemplo n.º 12
0
function selectAuthority($authority)
{
    $conn = tools::connectDatabase();
    $allData = array();
    $employeeID = array();
    $result = mysqli_query($conn, "SELECT RoleID,RoleName FROM Roles WHERE {$authority}='1' ");
    while ($row = mysqli_fetch_array($result)) {
        array_push($allData, array('roleID' => $row['RoleID'], 'roleName' => $row['RoleName']));
    }
    for ($i = 0; $i < count($allData); $i++) {
        $roleID = $allData[$i]["roleID"];
        $result = mysqli_query($conn, "SELECT EmployeeID FROM UserRole WHERE RoleID='{$roleID}'");
        while ($row = mysqli_fetch_array($result)) {
            array_push($employeeID, $row['EmployeeID']);
        }
    }
    $employee = array();
    for ($i = 0; $i < count($employeeID); $i++) {
        $id = $employeeID[$i];
        $result = mysqli_query($conn, "SELECT EmployeeID,EmployeeName,DepartmentID,Title From Employees WHERE EmployeeID='{$id}'");
        while ($row = mysqli_fetch_array($result)) {
            array_push($employee, $row);
        }
    }
    array_push($allData, $employee);
    echo json_encode($allData);
}
Ejemplo n.º 13
0
 /**
  *  FONTS
  */
 private function fontPaths($css)
 {
     $fonts = array(array('{{FA}}', tools::font('fontawesome-webfont.woff?v=4.2', false)), array('{{SSP400}}', tools::font('sourcesanspro-400.woff')), array('{{SSP600}}', tools::font('sourcesanspro-600.woff')), array('{{SSPitalic}}', tools::font('sourcesanspro-400-italic.woff')));
     foreach ($fonts as $font) {
         $css = str_ireplace($font[0], $font[1], $css);
     }
     return $css;
 }
Ejemplo n.º 14
0
 public function setContent($html)
 {
     if (\app::getClass('user')->VerifyConnexion() && $_SESSION['permissions'] & 128) {
         /* perm 128 = configure blocks */
         return \tools::file_put_contents(PROFILE_PATH . $this->getConfig('viewPath'), \tools::sanitize($html));
     }
     return FALSE;
 }
Ejemplo n.º 15
0
 public static function load_configs()
 {
     global $config;
     $files = tools::find_files(CONFIG_PATH, "*.php");
     foreach ($files as $file) {
         include_once $file;
     }
 }
function getEmployeeInformation($userID)
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM Employees WHERE EmployeeID='{$userID}'");
    while ($row = mysqli_fetch_array($result)) {
        echo json_encode($row);
    }
}
Ejemplo n.º 17
0
 function admin_delete($id)
 {
     if ($this->advert->delete((int) $id)) {
         tools::setFlash($this->l('Request processed'), 'success');
     } else {
         tools::setFlash($this->l('An error has occurred'), 'error');
     }
     tools::redirect('/admin/advert');
 }
Ejemplo n.º 18
0
Archivo: T.php Proyecto: ph7pal/mei
 public function init()
 {
     if (zmf::config('mobile')) {
         if (tools::checkmobile($this->platform)) {
             Yii::app()->theme = 'mobile';
             $this->isMobile = 'yes';
         }
     }
 }
Ejemplo n.º 19
0
function setDeleteEmployee($userID)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "DELETE FROM Employees WHERE EmployeeID={$userID}");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
Ejemplo n.º 20
0
function setModifyEmployee($userID, $employeeName, $sex, $phone, $birthDay, $degreeID, $departmentID, $title, $salary, $employeeTypeID, $hireDate)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "UPDATE Employees SET EmployeeName='{$employeeName}',SEX='{$sex}',Phone='{$phone}',BirthDay='{$birthDay}',DegreeID='{$degreeID}',DepartmentID='{$departmentID}',Title='{$title}',Salary='{$salary}',EmployeeTypeID='{$employeeTypeID}',HireDate='{$hireDate}' WHERE EmployeeID='{$userID}' ");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
Ejemplo n.º 21
0
Archivo: T.php Proyecto: ph7pal/naodong
 public function init()
 {
     //zh_tw\en_us
     Yii::app()->language = 'zh_cn';
     if (zmf::config('mobile')) {
         if (tools::checkmobile($this->platform)) {
             $this->isMobile = 'yes';
         }
     }
 }
Ejemplo n.º 22
0
function editTrain($trainingID, $startDate, $endDate, $trainType, $trainDescription)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "UPDATE Training SET BeginDate='{$startDate}',EndDate='{$endDate}',TrainingType='{$trainType}',Description='{$trainDescription}' WHERE TrainingID='{$trainingID}' ");
    } catch (Exception $e) {
        $e->getMessage();
    }
    echo "success";
}
Ejemplo n.º 23
0
function selectEmployee($sql)
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, $sql);
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 24
0
/**
 * Created by PhpStorm.
 * User: lenovo
 * Date: 2015/11/17
 * Time: 11:57
 */
function getModifyEmployee()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT EmployeeID,EmployeeName From Employees");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 25
0
function addEvaluation($ID, $name)
{
    $conn = tools::connectDatabase();
    try {
        mysqli_query($conn, "INSERT INTO EvaluationProjects(RP_ID,ProjectName) VALUES({$ID},{$name})");
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    echo "success";
}
Ejemplo n.º 26
0
function getEditReward()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM RewardsAndPunishments");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 27
0
function getSelectRole()
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, "SELECT RoleID,RoleName FROM Roles");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 28
0
function checkModifyEmployee($userID)
{
    $conn = tools::connectDatabase();
    $data = array();
    $result = mysqli_query($conn, "SELECT * FROM Employees WHERE EmployeeID='{$userID}' ");
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 29
0
function getEditEvaluation()
{
    $conn = tools::connectDatabase();
    $result = mysqli_query($conn, "SELECT * FROM EvaluationProjects");
    $data = array();
    while ($row = mysqli_fetch_array($result)) {
        array_push($data, $row);
    }
    echo json_encode($data);
}
Ejemplo n.º 30
0
 public function load_module($mname)
 {
     if (!is_array($this->modules)) {
         $this->modules = array();
     }
     tools::load_module_class($mname, $this->module_root . $mname . "/");
     if (!isset($this->modules[$mname])) {
         $this->modules[$mname] = new $mname($this->app, $this);
     }
 }